summaryrefslogtreecommitdiff
path: root/vcl/source/gdi
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r--vcl/source/gdi/gdimtf.cxx768
-rw-r--r--vcl/source/gdi/gfxlink.cxx1
-rw-r--r--vcl/source/gdi/graph.cxx28
-rw-r--r--vcl/source/gdi/impgraph.cxx54
-rwxr-xr-xvcl/source/gdi/makefile.mk94
-rw-r--r--vcl/source/gdi/metaact.cxx90
-rw-r--r--vcl/source/gdi/outdev6.cxx29
-rw-r--r--vcl/source/gdi/pdfwriter_impl2.cxx12
-rw-r--r--vcl/source/gdi/print2.cxx30
-rw-r--r--vcl/source/gdi/rendergraphic.cxx240
-rw-r--r--vcl/source/gdi/rendergraphicrasterizer.cxx400
-rw-r--r--vcl/source/gdi/svgread.cxx131
12 files changed, 1524 insertions, 353 deletions
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 23da138d23a2..1e99c5c3c04f 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -1449,6 +1449,15 @@ void GDIMetaFile::Rotate( long nAngle10 )
}
break;
+ case( META_RENDERGRAPHIC_ACTION ):
+ {
+ OSL_TRACE( "Rotate not supported for RenderGraphic MetaActions yet" );
+
+ pAction->Duplicate();
+ aMtf.AddAction( pAction );
+ }
+ break;
+
default:
{
pAction->Execute( &aMapVDev );
@@ -1513,363 +1522,371 @@ Rectangle GDIMetaFile::GetBoundRect( OutputDevice& i_rReference )
switch( nActionType )
{
case( META_PIXEL_ACTION ):
- {
- MetaPixelAction* pAct = (MetaPixelAction*) pAction;
- ImplActionBounds( aBound,
- Rectangle( aMapVDev.LogicToLogic( pAct->GetPoint(), aMapVDev.GetMapMode(), GetPrefMapMode() ),
- aMapVDev.PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ),
- aClipStack );
- }
- break;
+ {
+ MetaPixelAction* pAct = (MetaPixelAction*) pAction;
+ ImplActionBounds( aBound,
+ Rectangle( aMapVDev.LogicToLogic( pAct->GetPoint(), aMapVDev.GetMapMode(), GetPrefMapMode() ),
+ aMapVDev.PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ),
+ aClipStack );
+ }
+ break;
case( META_POINT_ACTION ):
- {
- MetaPointAction* pAct = (MetaPointAction*) pAction;
- ImplActionBounds( aBound,
- Rectangle( aMapVDev.LogicToLogic( pAct->GetPoint(), aMapVDev.GetMapMode(), GetPrefMapMode() ),
- aMapVDev.PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ),
- aClipStack );
- }
- break;
+ {
+ MetaPointAction* pAct = (MetaPointAction*) pAction;
+ ImplActionBounds( aBound,
+ Rectangle( aMapVDev.LogicToLogic( pAct->GetPoint(), aMapVDev.GetMapMode(), GetPrefMapMode() ),
+ aMapVDev.PixelToLogic( Size( 1, 1 ), GetPrefMapMode() ) ),
+ aClipStack );
+ }
+ break;
case( META_LINE_ACTION ):
- {
- MetaLineAction* pAct = (MetaLineAction*) pAction;
- Point aP1( pAct->GetStartPoint() ), aP2( pAct->GetEndPoint() );
- Rectangle aRect( aP1, aP2 );
- aRect.Justify();
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaLineAction* pAct = (MetaLineAction*) pAction;
+ Point aP1( pAct->GetStartPoint() ), aP2( pAct->GetEndPoint() );
+ Rectangle aRect( aP1, aP2 );
+ aRect.Justify();
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_RECT_ACTION ):
- {
- MetaRectAction* pAct = (MetaRectAction*) pAction;
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaRectAction* pAct = (MetaRectAction*) pAction;
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_ROUNDRECT_ACTION ):
- {
- MetaRoundRectAction* pAct = (MetaRoundRectAction*) pAction;
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaRoundRectAction* pAct = (MetaRoundRectAction*) pAction;
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_ELLIPSE_ACTION ):
- {
- MetaEllipseAction* pAct = (MetaEllipseAction*) pAction;
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaEllipseAction* pAct = (MetaEllipseAction*) pAction;
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_ARC_ACTION ):
- {
- MetaArcAction* pAct = (MetaArcAction*) pAction;
- // FIXME: this is imprecise
- // e.g. for small arcs the whole rectangle is WAY too large
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaArcAction* pAct = (MetaArcAction*) pAction;
+ // FIXME: this is imprecise
+ // e.g. for small arcs the whole rectangle is WAY too large
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_PIE_ACTION ):
- {
- MetaPieAction* pAct = (MetaPieAction*) pAction;
- // FIXME: this is imprecise
- // e.g. for small arcs the whole rectangle is WAY too large
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaPieAction* pAct = (MetaPieAction*) pAction;
+ // FIXME: this is imprecise
+ // e.g. for small arcs the whole rectangle is WAY too large
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_CHORD_ACTION ):
- {
- MetaChordAction* pAct = (MetaChordAction*) pAction;
- // FIXME: this is imprecise
- // e.g. for small arcs the whole rectangle is WAY too large
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaChordAction* pAct = (MetaChordAction*) pAction;
+ // FIXME: this is imprecise
+ // e.g. for small arcs the whole rectangle is WAY too large
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_POLYLINE_ACTION ):
- {
- MetaPolyLineAction* pAct = (MetaPolyLineAction*) pAction;
- Rectangle aRect( pAct->GetPolygon().GetBoundRect() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaPolyLineAction* pAct = (MetaPolyLineAction*) pAction;
+ Rectangle aRect( pAct->GetPolygon().GetBoundRect() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_POLYGON_ACTION ):
- {
- MetaPolygonAction* pAct = (MetaPolygonAction*) pAction;
- Rectangle aRect( pAct->GetPolygon().GetBoundRect() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaPolygonAction* pAct = (MetaPolygonAction*) pAction;
+ Rectangle aRect( pAct->GetPolygon().GetBoundRect() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_POLYPOLYGON_ACTION ):
- {
- MetaPolyPolygonAction* pAct = (MetaPolyPolygonAction*) pAction;
- Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaPolyPolygonAction* pAct = (MetaPolyPolygonAction*) pAction;
+ Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_TEXT_ACTION ):
- {
- MetaTextAction* pAct = (MetaTextAction*) pAction;
- Rectangle aRect;
- // hdu said base = index
- aMapVDev.GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen() );
- Point aPt( pAct->GetPoint() );
- aRect.Move( aPt.X(), aPt.Y() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaTextAction* pAct = (MetaTextAction*) pAction;
+ Rectangle aRect;
+ // hdu said base = index
+ aMapVDev.GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen() );
+ Point aPt( pAct->GetPoint() );
+ aRect.Move( aPt.X(), aPt.Y() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_TEXTARRAY_ACTION ):
- {
- MetaTextArrayAction* pAct = (MetaTextArrayAction*) pAction;
- Rectangle aRect;
- // hdu said base = index
- aMapVDev.GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(),
- 0, pAct->GetDXArray() );
- Point aPt( pAct->GetPoint() );
- aRect.Move( aPt.X(), aPt.Y() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaTextArrayAction* pAct = (MetaTextArrayAction*) pAction;
+ Rectangle aRect;
+ // hdu said base = index
+ aMapVDev.GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(),
+ 0, pAct->GetDXArray() );
+ Point aPt( pAct->GetPoint() );
+ aRect.Move( aPt.X(), aPt.Y() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_STRETCHTEXT_ACTION ):
- {
- MetaStretchTextAction* pAct = (MetaStretchTextAction*) pAction;
- Rectangle aRect;
- // hdu said base = index
- aMapVDev.GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(),
- pAct->GetWidth(), NULL );
- Point aPt( pAct->GetPoint() );
- aRect.Move( aPt.X(), aPt.Y() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaStretchTextAction* pAct = (MetaStretchTextAction*) pAction;
+ Rectangle aRect;
+ // hdu said base = index
+ aMapVDev.GetTextBoundRect( aRect, pAct->GetText(), pAct->GetIndex(), pAct->GetIndex(), pAct->GetLen(),
+ pAct->GetWidth(), NULL );
+ Point aPt( pAct->GetPoint() );
+ aRect.Move( aPt.X(), aPt.Y() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_TEXTLINE_ACTION ):
- {
- MetaTextLineAction* pAct = (MetaTextLineAction*) pAction;
- // measure a test string to get ascend and descent right
- static const sal_Unicode pStr[] = { 0xc4, 0x67, 0 };
- String aStr( pStr );
-
- Rectangle aRect;
- aMapVDev.GetTextBoundRect( aRect, aStr, 0, 0, aStr.Len(), 0, NULL );
- Point aPt( pAct->GetStartPoint() );
- aRect.Move( aPt.X(), aPt.Y() );
- aRect.Right() = aRect.Left() + pAct->GetWidth();
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaTextLineAction* pAct = (MetaTextLineAction*) pAction;
+ // measure a test string to get ascend and descent right
+ static const sal_Unicode pStr[] = { 0xc4, 0x67, 0 };
+ String aStr( pStr );
+
+ Rectangle aRect;
+ aMapVDev.GetTextBoundRect( aRect, aStr, 0, 0, aStr.Len(), 0, NULL );
+ Point aPt( pAct->GetStartPoint() );
+ aRect.Move( aPt.X(), aPt.Y() );
+ aRect.Right() = aRect.Left() + pAct->GetWidth();
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_BMPSCALE_ACTION ):
- {
- MetaBmpScaleAction* pAct = (MetaBmpScaleAction*) pAction;
- Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaBmpScaleAction* pAct = (MetaBmpScaleAction*) pAction;
+ Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_BMPSCALEPART_ACTION ):
- {
- MetaBmpScalePartAction* pAct = (MetaBmpScalePartAction*) pAction;
- Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaBmpScalePartAction* pAct = (MetaBmpScalePartAction*) pAction;
+ Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_BMPEXSCALE_ACTION ):
- {
- MetaBmpExScaleAction* pAct = (MetaBmpExScaleAction*) pAction;
- Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaBmpExScaleAction* pAct = (MetaBmpExScaleAction*) pAction;
+ Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_BMPEXSCALEPART_ACTION ):
- {
- MetaBmpExScalePartAction* pAct = (MetaBmpExScalePartAction*) pAction;
- Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaBmpExScalePartAction* pAct = (MetaBmpExScalePartAction*) pAction;
+ Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_GRADIENT_ACTION ):
- {
- MetaGradientAction* pAct = (MetaGradientAction*) pAction;
- Rectangle aRect( pAct->GetRect() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaGradientAction* pAct = (MetaGradientAction*) pAction;
+ Rectangle aRect( pAct->GetRect() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_GRADIENTEX_ACTION ):
- {
- MetaGradientExAction* pAct = (MetaGradientExAction*) pAction;
- Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaGradientExAction* pAct = (MetaGradientExAction*) pAction;
+ Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_COMMENT_ACTION ):
- {
- // nothing to do
- };
- break;
+ {
+ // nothing to do
+ };
+ break;
case( META_HATCH_ACTION ):
- {
- MetaHatchAction* pAct = (MetaHatchAction*) pAction;
- Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaHatchAction* pAct = (MetaHatchAction*) pAction;
+ Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_TRANSPARENT_ACTION ):
- {
- MetaTransparentAction* pAct = (MetaTransparentAction*) pAction;
- Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaTransparentAction* pAct = (MetaTransparentAction*) pAction;
+ Rectangle aRect( pAct->GetPolyPolygon().GetBoundRect() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_FLOATTRANSPARENT_ACTION ):
- {
- MetaFloatTransparentAction* pAct = (MetaFloatTransparentAction*) pAction;
- GDIMetaFile aTransMtf( pAct->GetGDIMetaFile() );
- // get the bound rect of the contained metafile
- Rectangle aRect( aTransMtf.GetBoundRect( i_rReference ) );
- // scale the rect now on the assumption that the correct top left of the metafile
- // (not its bounds !) is (0,0)
- Size aPSize( aTransMtf.GetPrefSize() );
- aPSize = aMapVDev.LogicToLogic( aPSize, aTransMtf.GetPrefMapMode(), aMapVDev.GetMapMode() );
- Size aActSize( pAct->GetSize() );
- double fX = double(aActSize.Width())/double(aPSize.Width());
- double fY = double(aActSize.Height())/double(aPSize.Height());
- aRect.Left() = long(double(aRect.Left())*fX);
- aRect.Right() = long(double(aRect.Right())*fX);
- aRect.Top() = long(double(aRect.Top())*fY);
- aRect.Bottom() = long(double(aRect.Bottom())*fY);
-
- // transform the rect to current VDev state
- aRect = aMapVDev.LogicToLogic( aRect, aTransMtf.GetPrefMapMode(), aMapVDev.GetMapMode() );
-
- ImplActionBounds( aBound, aRect, aClipStack );
- }
- break;
+ {
+ MetaFloatTransparentAction* pAct = (MetaFloatTransparentAction*) pAction;
+ GDIMetaFile aTransMtf( pAct->GetGDIMetaFile() );
+ // get the bound rect of the contained metafile
+ Rectangle aRect( aTransMtf.GetBoundRect( i_rReference ) );
+ // scale the rect now on the assumption that the correct top left of the metafile
+ // (not its bounds !) is (0,0)
+ Size aPSize( aTransMtf.GetPrefSize() );
+ aPSize = aMapVDev.LogicToLogic( aPSize, aTransMtf.GetPrefMapMode(), aMapVDev.GetMapMode() );
+ Size aActSize( pAct->GetSize() );
+ double fX = double(aActSize.Width())/double(aPSize.Width());
+ double fY = double(aActSize.Height())/double(aPSize.Height());
+ aRect.Left() = long(double(aRect.Left())*fX);
+ aRect.Right() = long(double(aRect.Right())*fX);
+ aRect.Top() = long(double(aRect.Top())*fY);
+ aRect.Bottom() = long(double(aRect.Bottom())*fY);
+
+ // transform the rect to current VDev state
+ aRect = aMapVDev.LogicToLogic( aRect, aTransMtf.GetPrefMapMode(), aMapVDev.GetMapMode() );
+
+ ImplActionBounds( aBound, aRect, aClipStack );
+ }
+ break;
case( META_EPS_ACTION ):
- {
- MetaEPSAction* pAct = (MetaEPSAction*) pAction;
- Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaEPSAction* pAct = (MetaEPSAction*) pAction;
+ Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_CLIPREGION_ACTION ):
- {
- MetaClipRegionAction* pAct = (MetaClipRegionAction*) pAction;
- if( pAct->IsClipping() )
- aClipStack.back() = aMapVDev.LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev.GetMapMode(), GetPrefMapMode() );
- else
- aClipStack.back() = Rectangle();
- }
- break;
+ {
+ MetaClipRegionAction* pAct = (MetaClipRegionAction*) pAction;
+ if( pAct->IsClipping() )
+ aClipStack.back() = aMapVDev.LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev.GetMapMode(), GetPrefMapMode() );
+ else
+ aClipStack.back() = Rectangle();
+ }
+ break;
case( META_ISECTRECTCLIPREGION_ACTION ):
- {
- MetaISectRectClipRegionAction* pAct = (MetaISectRectClipRegionAction*) pAction;
- Rectangle aRect( aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ) );
- if( aClipStack.back().IsEmpty() )
- aClipStack.back() = aRect;
- else
- aClipStack.back().Intersection( aRect );
- }
- break;
+ {
+ MetaISectRectClipRegionAction* pAct = (MetaISectRectClipRegionAction*) pAction;
+ Rectangle aRect( aMapVDev.LogicToLogic( pAct->GetRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ) );
+ if( aClipStack.back().IsEmpty() )
+ aClipStack.back() = aRect;
+ else
+ aClipStack.back().Intersection( aRect );
+ }
+ break;
case( META_ISECTREGIONCLIPREGION_ACTION ):
- {
- MetaISectRegionClipRegionAction* pAct = (MetaISectRegionClipRegionAction*) pAction;
- Rectangle aRect( aMapVDev.LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ) );
- if( aClipStack.back().IsEmpty() )
- aClipStack.back() = aRect;
- else
- aClipStack.back().Intersection( aRect );
- }
- break;
+ {
+ MetaISectRegionClipRegionAction* pAct = (MetaISectRegionClipRegionAction*) pAction;
+ Rectangle aRect( aMapVDev.LogicToLogic( pAct->GetRegion().GetBoundRect(), aMapVDev.GetMapMode(), GetPrefMapMode() ) );
+ if( aClipStack.back().IsEmpty() )
+ aClipStack.back() = aRect;
+ else
+ aClipStack.back().Intersection( aRect );
+ }
+ break;
case( META_BMP_ACTION ):
- {
- MetaBmpAction* pAct = (MetaBmpAction*) pAction;
- Rectangle aRect( pAct->GetPoint(), aMapVDev.PixelToLogic( pAct->GetBitmap().GetSizePixel() ) );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaBmpAction* pAct = (MetaBmpAction*) pAction;
+ Rectangle aRect( pAct->GetPoint(), aMapVDev.PixelToLogic( pAct->GetBitmap().GetSizePixel() ) );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_BMPEX_ACTION ):
- {
- MetaBmpExAction* pAct = (MetaBmpExAction*) pAction;
- Rectangle aRect( pAct->GetPoint(), aMapVDev.PixelToLogic( pAct->GetBitmapEx().GetSizePixel() ) );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaBmpExAction* pAct = (MetaBmpExAction*) pAction;
+ Rectangle aRect( pAct->GetPoint(), aMapVDev.PixelToLogic( pAct->GetBitmapEx().GetSizePixel() ) );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_MASK_ACTION ):
- {
- MetaMaskAction* pAct = (MetaMaskAction*) pAction;
- Rectangle aRect( pAct->GetPoint(), aMapVDev.PixelToLogic( pAct->GetBitmap().GetSizePixel() ) );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaMaskAction* pAct = (MetaMaskAction*) pAction;
+ Rectangle aRect( pAct->GetPoint(), aMapVDev.PixelToLogic( pAct->GetBitmap().GetSizePixel() ) );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_MASKSCALE_ACTION ):
- {
- MetaMaskScalePartAction* pAct = (MetaMaskScalePartAction*) pAction;
- Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaMaskScalePartAction* pAct = (MetaMaskScalePartAction*) pAction;
+ Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_MASKSCALEPART_ACTION ):
- {
- MetaMaskScalePartAction* pAct = (MetaMaskScalePartAction*) pAction;
- Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaMaskScalePartAction* pAct = (MetaMaskScalePartAction*) pAction;
+ Rectangle aRect( pAct->GetDestPoint(), pAct->GetDestSize() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_WALLPAPER_ACTION ):
- {
- MetaWallpaperAction* pAct = (MetaWallpaperAction*) pAction;
- Rectangle aRect( pAct->GetRect() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaWallpaperAction* pAct = (MetaWallpaperAction*) pAction;
+ Rectangle aRect( pAct->GetRect() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_TEXTRECT_ACTION ):
- {
- MetaTextRectAction* pAct = (MetaTextRectAction*) pAction;
- Rectangle aRect( pAct->GetRect() );
- ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
- }
- break;
+ {
+ MetaTextRectAction* pAct = (MetaTextRectAction*) pAction;
+ Rectangle aRect( pAct->GetRect() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
case( META_MOVECLIPREGION_ACTION ):
+ {
+ MetaMoveClipRegionAction* pAct = (MetaMoveClipRegionAction*) pAction;
+ if( ! aClipStack.back().IsEmpty() )
{
- MetaMoveClipRegionAction* pAct = (MetaMoveClipRegionAction*) pAction;
- if( ! aClipStack.back().IsEmpty() )
- {
- Size aDelta( pAct->GetHorzMove(), pAct->GetVertMove() );
- aDelta = aMapVDev.LogicToLogic( aDelta, aMapVDev.GetMapMode(), GetPrefMapMode() );
- aClipStack.back().Move( aDelta.Width(), aDelta.Width() );
- }
+ Size aDelta( pAct->GetHorzMove(), pAct->GetVertMove() );
+ aDelta = aMapVDev.LogicToLogic( aDelta, aMapVDev.GetMapMode(), GetPrefMapMode() );
+ aClipStack.back().Move( aDelta.Width(), aDelta.Width() );
}
- break;
+ }
+ break;
+
+ case( META_RENDERGRAPHIC_ACTION ):
+ {
+ MetaRenderGraphicAction* pAct = (MetaRenderGraphicAction*) pAction;
+ Rectangle aRect( pAct->GetPoint(), pAct->GetSize() );
+ ImplActionBounds( aBound, aMapVDev.LogicToLogic( aRect, aMapVDev.GetMapMode(), GetPrefMapMode() ), aClipStack );
+ }
+ break;
default:
{
@@ -2269,6 +2286,15 @@ void GDIMetaFile::ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pCol
}
break;
+ case( META_RENDERGRAPHIC_ACTION ):
+ {
+ OSL_TRACE( "ExchangeColors not supported for RenderGraphic MetaActions yet" );
+
+ pAction->Duplicate();
+ aMtf.Insert( pAction, LIST_APPEND );
+ }
+ break;
+
default:
{
pAction->Duplicate();
@@ -2454,11 +2480,13 @@ sal_uLong GDIMetaFile::GetChecksum() const
{
GDIMetaFile aMtf;
SvMemoryStream aMemStm( 65535, 65535 );
- ImplMetaWriteData aWriteData; aWriteData.meActualCharSet = aMemStm.GetStreamCharSet();
+ ImplMetaWriteData aWriteData;
SVBT16 aBT16;
SVBT32 aBT32;
sal_uLong nCrc = 0;
+ aWriteData.meActualCharSet = aMemStm.GetStreamCharSet();
+
for( sal_uLong i = 0, nObjCount = GetActionCount(); i < nObjCount; i++ )
{
MetaAction* pAction = GetAction( i );
@@ -2715,6 +2743,30 @@ sal_uLong GDIMetaFile::GetChecksum() const
}
break;
+ case( META_RENDERGRAPHIC_ACTION ):
+ {
+ MetaRenderGraphicAction* pAct = (MetaRenderGraphicAction*) pAction;
+ const ::vcl::RenderGraphic& rRenderGraphic = pAct->GetRenderGraphic();
+
+ ShortToSVBT16( pAct->GetType(), aBT16 );
+ nCrc = rtl_crc32( nCrc, aBT16, 2 );
+
+ nCrc = rtl_crc32( nCrc, rRenderGraphic.GetGraphicData().get(), rRenderGraphic.GetGraphicDataLength() );
+
+ UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
+ nCrc = rtl_crc32( nCrc, aBT32, 4 );
+
+ UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
+ nCrc = rtl_crc32( nCrc, aBT32, 4 );
+
+ UInt32ToSVBT32( pAct->GetSize().Width(), aBT32 );
+ nCrc = rtl_crc32( nCrc, aBT32, 4 );
+
+ UInt32ToSVBT32( pAct->GetSize().Height(), aBT32 );
+ nCrc = rtl_crc32( nCrc, aBT32, 4 );
+ }
+ break;
+
default:
{
pAction->Write( aMemStm, &aWriteData );
@@ -2781,8 +2833,7 @@ sal_uLong GDIMetaFile::GetSizeBytes() const
}
break;
- default:
- break;
+ case( META_RENDERGRAPHIC_ACTION ): nSizeBytes += ( ( (MetaRenderGraphicAction*) pAction )->GetRenderGraphic() ).GetGraphicDataLength(); break;
}
}
@@ -2810,27 +2861,63 @@ SvStream& operator>>( SvStream& rIStm, GDIMetaFile& rGDIMetaFile )
// new format
VersionCompat* pCompat;
MetaAction* pAction;
- sal_uInt32 nStmCompressMode = 0;
- sal_uInt32 nCount = 0;
+ sal_uInt32 nStmCompressMode = 0;
+ sal_uInt32 nCount = 0;
+ sal_uInt8 bRenderGraphicReplacements = 0;
pCompat = new VersionCompat( rIStm, STREAM_READ );
+ {
+ // version 1
+ rIStm >> nStmCompressMode;
+ rIStm >> rGDIMetaFile.aPrefMapMode;
+ rIStm >> rGDIMetaFile.aPrefSize;
+ rIStm >> nCount;
- rIStm >> nStmCompressMode;
- rIStm >> rGDIMetaFile.aPrefMapMode;
- rIStm >> rGDIMetaFile.aPrefSize;
- rIStm >> nCount;
+ if( pCompat->GetVersion() >= 2 )
+ {
+ // version 2
+ // =========
+ // contains an additional flag to indicate that RenderGraphic
+ // actions are immediately followed by a replacement image, that
+ // needs to be skipped in case the flag is set (KA 01/2011)
+ rIStm >> bRenderGraphicReplacements;
+ }
+ }
delete pCompat;
ImplMetaReadData aReadData;
aReadData.meActualCharSet = rIStm.GetStreamCharSet();
- for( sal_uInt32 nAction = 0UL; ( nAction < nCount ) && !rIStm.IsEof(); nAction++ )
+ for( sal_uInt32 nAction = 0UL; ( nAction < nCount ) && !rIStm.IsEof(); ++nAction )
{
pAction = MetaAction::ReadMetaAction( rIStm, &aReadData );
if( pAction )
+ {
rGDIMetaFile.AddAction( pAction );
+
+ // if the MetaFile was written in RenderGraphics replacement mode
+ // and we just read a RenderGraphic action, skip the following
+ // META_BMPEXSCALE_ACTION, since this is the replacement image,
+ // just needed for old implementations; don't forget to increment
+ // the action read counter! (KA 01/2011)
+ if( bRenderGraphicReplacements &&
+ ( META_RENDERGRAPHIC_ACTION == pAction->GetType() ) &&
+ ( ++nAction < nCount ) && !rIStm.IsEof() )
+ {
+ sal_uInt16 nFollowingType;
+
+ // dummy read of the next following META_BMPEXSCALE_ACTION
+ // RenderGraphic replacement action (KA 01/2011)
+ rIStm >> nFollowingType;
+ delete ( new VersionCompat( rIStm, STREAM_READ ) );
+
+ OSL_ENSURE( META_BMPEXSCALE_ACTION == nFollowingType, \
+"META_RENDERGRAPHIC_ACTION read in RenderGraphic replacement mode \
+without following META_BMPEXSCALE_ACTION replacement" );
+ }
+ }
}
}
else
@@ -2859,10 +2946,27 @@ SvStream& operator<<( SvStream& rOStm, const GDIMetaFile& rGDIMetaFile )
{
if( !rOStm.GetError() )
{
- if( rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50 )
- ((GDIMetaFile&) rGDIMetaFile ).Write( rOStm );
+ static const char* pEnableSVM1 = getenv( "SAL_ENABLE_SVM1" );
+ static const bool bNoSVM1 = (NULL == pEnableSVM1 ) || ( '0' == *pEnableSVM1 );
+
+ if( bNoSVM1 || rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50 )
+ {
+ const_cast< GDIMetaFile& >( rGDIMetaFile ).Write( rOStm );
+ }
else
- delete( new SVMConverter( rOStm, (GDIMetaFile&) rGDIMetaFile, CONVERT_TO_SVM1 ) );
+ {
+ delete( new SVMConverter( rOStm, const_cast< GDIMetaFile& >( rGDIMetaFile ), CONVERT_TO_SVM1 ) );
+ }
+
+#ifdef DEBUG
+ if( !bNoSVM1 && rOStm.GetVersion() < SOFFICE_FILEFORMAT_50 )
+ {
+OSL_TRACE( \
+"GDIMetaFile would normally be written in old SVM1 format by this call. \
+The current implementation always writes in VCLMTF format. \
+Please set environment variable SAL_ENABLE_SVM1 to '1' to reenable old behavior" );
+ }
+#endif // DEBUG
}
return rOStm;
@@ -2880,32 +2984,90 @@ SvStream& GDIMetaFile::Read( SvStream& rIStm )
// ------------------------------------------------------------------------
-SvStream& GDIMetaFile::Write( SvStream& rOStm )
+SvStream& GDIMetaFile::Write( SvStream& rOStm, GDIMetaFileWriteFlags nWriteFlags )
{
VersionCompat* pCompat;
const sal_uInt32 nStmCompressMode = rOStm.GetCompressMode();
sal_uInt16 nOldFormat = rOStm.GetNumberFormatInt();
+ const sal_uInt8 bRenderGraphicReplacements =
+ ( ( ( GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC & nWriteFlags ) != 0 ) ? 1 : 0 );
+
+ // With the introduction of the META_RENDERGRAPHIC_ACTION, it is neccessary
+ // to provide some kind of document backward compatibility:
+ //
+ // If the flag GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC is set in
+ // parameter nWriteFlags, each META_RENDERGRAPHIC_ACTION is followed by
+ // an additional META_BMPEXSCALE_ACTION, that contains a replacement
+ // image for the new RenderGraphic action.
+ //
+ // Old implementations, not knowing anything about META_RENDERGRAPHIC_ACTION,
+ // will skip this new action and read the META_BMPEXSCALE_ACTION instead
+ //
+ // Since the current implementation is able to handle the new action, the
+ // then following image replacement action needs to be skipped by this
+ // implementation, if the metafile was written in the RenderGraphic
+ // replacement mode.
+ //
+ // To be able to detect this compatibility mode, the header needs to
+ // be extended by a corresponding flag, resulting in version 2 of
+ // the header. The surrounding VersionCompat of the header
+ // allows to add such new data without any problems (KA 01/2011)
rOStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
rOStm.Write( "VCLMTF", 6 );
- pCompat = new VersionCompat( rOStm, STREAM_WRITE, 1 );
+ pCompat = new VersionCompat( rOStm, STREAM_WRITE, 2 );
- rOStm << nStmCompressMode;
- rOStm << aPrefMapMode;
- rOStm << aPrefSize;
- rOStm << (sal_uInt32) GetActionCount();
+ {
+ // version 1
+ sal_uInt32 nActionCount = 0;
+
+ // calculate correct action count and watch for
+ // additional RenderGraphic replacement actions, if the
+ // GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC is set
+ // and META_RENDERGRAPHIC_ACTION are encountered (KA 01/2011)
+ for( MetaAction* pAct = static_cast< MetaAction* >( First() ); pAct; pAct = static_cast< MetaAction* >( Next() ) )
+ {
+ nActionCount += ( bRenderGraphicReplacements && ( META_RENDERGRAPHIC_ACTION == pAct->GetType() ) ? 2 : 1 );
+ }
+
+ rOStm << nStmCompressMode << aPrefMapMode << aPrefSize << nActionCount;
+
+ {
+ // version 2
+ // =========
+ // since version 2, a GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC flag
+ // is written, to indicate that each META_BMPEXSCALE_ACTION following
+ // a META_RENDERGRAPHIC_ACTION needs to be skipped, in case the flag is
+ // set (KA 01/2011)
+ rOStm << bRenderGraphicReplacements;
+ }
+ }
delete pCompat;
ImplMetaWriteData aWriteData;
+
aWriteData.meActualCharSet = rOStm.GetStreamCharSet();
+ aWriteData.mnWriteFlags = nWriteFlags;
- MetaAction* pAct = (MetaAction*)First();
- while ( pAct )
+ for( MetaAction* pAct = static_cast< MetaAction* >( First() ); pAct; pAct = static_cast< MetaAction* >( Next() ) )
{
pAct->Write( rOStm, &aWriteData );
- pAct = (MetaAction*)Next();
+
+ // write the RenderGraphic replacement image, if the
+ // GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC flag is set
+ // and if a META_RENDERGRAPHIC_ACTION is encountered (KA 01/2011)
+ if( bRenderGraphicReplacements && ( META_RENDERGRAPHIC_ACTION == pAct->GetType() ) )
+ {
+ MetaRenderGraphicAction* pRenderAction = static_cast< MetaRenderGraphicAction* >( pAct );
+ MetaBmpExScaleAction* pBmpExScaleAction = new MetaBmpExScaleAction(
+ pRenderAction->GetPoint(), pRenderAction->GetSize(),
+ pRenderAction->GetRenderGraphic().GetReplacement() );
+
+ pBmpExScaleAction->Write( rOStm, &aWriteData );
+ pBmpExScaleAction->Delete();
+ }
}
rOStm.SetNumberFormatInt( nOldFormat );
diff --git a/vcl/source/gdi/gfxlink.cxx b/vcl/source/gdi/gfxlink.cxx
index 1a476f1b5420..c9c997b568e2 100644
--- a/vcl/source/gdi/gfxlink.cxx
+++ b/vcl/source/gdi/gfxlink.cxx
@@ -258,6 +258,7 @@ sal_Bool GfxLink::LoadNative( Graphic& rGraphic )
case( GFX_LINK_TYPE_NATIVE_WMF ): nCvtType = CVT_WMF; break;
case( GFX_LINK_TYPE_NATIVE_MET ): nCvtType = CVT_MET; break;
case( GFX_LINK_TYPE_NATIVE_PCT ): nCvtType = CVT_PCT; break;
+ case( GFX_LINK_TYPE_NATIVE_SVG ): nCvtType = CVT_SVG; break;
default: nCvtType = CVT_UNKNOWN; break;
}
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index 1a8201706212..99f82c5d092b 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -427,6 +427,27 @@ sal_Bool Graphic::IsAnimated() const
// ------------------------------------------------------------------------
+sal_Bool Graphic::IsEPS() const
+{
+ return mpImpGraphic->ImplIsEPS();
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool Graphic::IsRenderGraphic() const
+{
+ return mpImpGraphic->ImplIsRenderGraphic();
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool Graphic::HasRenderGraphic() const
+{
+ return mpImpGraphic->ImplHasRenderGraphic();
+}
+
+// ------------------------------------------------------------------------
+
Bitmap Graphic::GetBitmap(const GraphicConversionParameters& rParameters) const
{
return mpImpGraphic->ImplGetBitmap(rParameters);
@@ -455,6 +476,13 @@ const GDIMetaFile& Graphic::GetGDIMetaFile() const
// ------------------------------------------------------------------------
+::vcl::RenderGraphic Graphic::GetRenderGraphic() const
+{
+ return mpImpGraphic->ImplGetRenderGraphic();
+}
+
+// ------------------------------------------------------------------------
+
uno::Reference< graphic::XGraphic > Graphic::GetXGraphic() const
{
uno::Reference< graphic::XGraphic > xRet;
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 500ba9549b9e..b4af43cf3556 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -480,6 +480,48 @@ sal_Bool ImpGraphic::ImplIsAnimated() const
// ------------------------------------------------------------------------
+sal_Bool ImpGraphic::ImplIsEPS() const
+{
+ return( ( meType == GRAPHIC_GDIMETAFILE ) &&
+ ( maMetaFile.GetActionCount() > 0 ) &&
+ ( maMetaFile.GetAction( 0 )->GetType() == META_EPS_ACTION ) );
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool ImpGraphic::ImplIsRenderGraphic() const
+{
+ return( ( GRAPHIC_GDIMETAFILE == meType ) &&
+ ( 1 == maMetaFile.GetActionCount() ) &&
+ ( META_RENDERGRAPHIC_ACTION == maMetaFile.GetAction( 0 )->GetType() ) );
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool ImpGraphic::ImplHasRenderGraphic() const
+{
+ sal_Bool bRet = sal_False;
+
+ if( GRAPHIC_GDIMETAFILE == meType )
+ {
+ GDIMetaFile& rMtf = const_cast< ImpGraphic* >( this )->maMetaFile;
+
+ for( MetaAction* pAct = rMtf.FirstAction(); pAct && !bRet; pAct = rMtf.NextAction() )
+ {
+ if( META_RENDERGRAPHIC_ACTION == pAct->GetType() )
+ {
+ bRet = sal_True;
+ }
+ }
+
+ rMtf.WindStart();
+ }
+
+ return( bRet );
+}
+
+// ------------------------------------------------------------------------
+
Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters) const
{
Bitmap aRetBmp;
@@ -592,6 +634,18 @@ Animation ImpGraphic::ImplGetAnimation() const
// ------------------------------------------------------------------------
+::vcl::RenderGraphic ImpGraphic::ImplGetRenderGraphic() const
+{
+ ::vcl::RenderGraphic aRet;
+
+ if( ImplIsRenderGraphic() )
+ aRet = static_cast< MetaRenderGraphicAction* >( maMetaFile.GetAction( 0 ) )->GetRenderGraphic();
+
+ return( aRet );
+}
+
+// ------------------------------------------------------------------------
+
const GDIMetaFile& ImpGraphic::ImplGetGDIMetaFile() const
{
return maMetaFile;
diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk
index ac2e586a41cb..ec664cf648a6 100755
--- a/vcl/source/gdi/makefile.mk
+++ b/vcl/source/gdi/makefile.mk
@@ -47,75 +47,77 @@ CDEFS+=-DENABLE_GRAPHITE
# --- Files --------------------------------------------------------
-EXCEPTIONSFILES= $(SLO)$/salmisc.obj \
- $(SLO)$/outdev.obj \
- $(SLO)$/outdev3.obj \
- $(SLO)$/outdevnative.obj \
- $(SLO)$/gfxlink.obj \
- $(SLO)$/print.obj \
- $(SLO)$/print2.obj \
- $(SLO)$/print3.obj \
- $(SLO)$/oldprintadaptor.obj \
- $(SLO)$/configsettings.obj \
- $(SLO)$/sallayout.obj \
- $(SLO)$/image.obj \
- $(SLO)$/impimage.obj \
- $(SLO)$/impgraph.obj \
- $(SLO)$/metric.obj \
- $(SLO)$/pdfwriter_impl.obj \
- $(SLO)$/pdfwriter_impl2.obj \
- $(SLO)$/pdffontcache.obj\
- $(SLO)$/bmpconv.obj \
- $(SLO)$/pdfextoutdevdata.obj \
- $(SLO)$/jobset.obj \
- $(SLO)$/impimagetree.obj \
- $(SLO)$/pngread.obj \
- $(SLO)$/pngwrite.obj \
- $(SLO)$/virdev.obj \
- $(SLO)$/gdimtf.obj \
- $(SLO)$/graphictools.obj \
- $(SLO)$/textlayout.obj \
- $(SLO)$/lineinfo.obj
+EXCEPTIONSFILES= $(SLO)$/salmisc.obj \
+ $(SLO)$/outdev.obj \
+ $(SLO)$/outdev3.obj \
+ $(SLO)$/outdevnative.obj \
+ $(SLO)$/gfxlink.obj \
+ $(SLO)$/print.obj \
+ $(SLO)$/print2.obj \
+ $(SLO)$/print3.obj \
+ $(SLO)$/oldprintadaptor.obj \
+ $(SLO)$/configsettings.obj \
+ $(SLO)$/sallayout.obj \
+ $(SLO)$/image.obj \
+ $(SLO)$/impimage.obj \
+ $(SLO)$/impgraph.obj \
+ $(SLO)$/metric.obj \
+ $(SLO)$/pdfwriter_impl.obj \
+ $(SLO)$/pdfwriter_impl2.obj \
+ $(SLO)$/pdffontcache.obj \
+ $(SLO)$/bmpconv.obj \
+ $(SLO)$/pdfextoutdevdata.obj \
+ $(SLO)$/jobset.obj \
+ $(SLO)$/impimagetree.obj \
+ $(SLO)$/pngread.obj \
+ $(SLO)$/pngwrite.obj \
+ $(SLO)$/virdev.obj \
+ $(SLO)$/gdimtf.obj \
+ $(SLO)$/graphictools.obj \
+ $(SLO)$/textlayout.obj \
+ $(SLO)$/lineinfo.obj \
+ $(SLO)$/svgread.obj \
+ $(SLO)$/rendergraphic.obj \
+ $(SLO)$/rendergraphicrasterizer.obj
-SLOFILES= $(EXCEPTIONSFILES) \
+SLOFILES= $(EXCEPTIONSFILES) \
$(SLO)$/animate.obj \
$(SLO)$/impanmvw.obj \
- $(SLO)$/bitmap.obj \
+ $(SLO)$/bitmap.obj \
$(SLO)$/bitmap2.obj \
$(SLO)$/bitmap3.obj \
$(SLO)$/bitmap4.obj \
- $(SLO)$/alpha.obj \
+ $(SLO)$/alpha.obj \
$(SLO)$/bitmapex.obj \
$(SLO)$/bmpacc.obj \
$(SLO)$/bmpacc2.obj \
$(SLO)$/bmpacc3.obj \
$(SLO)$/bmpfast.obj \
- $(SLO)$/cvtsvm.obj \
- $(SLO)$/cvtgrf.obj \
- $(SLO)$/font.obj \
+ $(SLO)$/cvtsvm.obj \
+ $(SLO)$/cvtgrf.obj \
+ $(SLO)$/font.obj \
$(SLO)$/gradient.obj \
- $(SLO)$/hatch.obj \
- $(SLO)$/graph.obj \
- $(SLO)$/impbmp.obj \
+ $(SLO)$/hatch.obj \
+ $(SLO)$/graph.obj \
+ $(SLO)$/impbmp.obj \
$(SLO)$/imagerepository.obj \
$(SLO)$/impvect.obj \
- $(SLO)$/mapmod.obj \
+ $(SLO)$/mapmod.obj \
$(SLO)$/metaact.obj \
- $(SLO)$/octree.obj \
- $(SLO)$/outmap.obj \
+ $(SLO)$/octree.obj \
+ $(SLO)$/outmap.obj \
$(SLO)$/outdev2.obj \
$(SLO)$/outdev4.obj \
$(SLO)$/outdev5.obj \
$(SLO)$/outdev6.obj \
$(SLO)$/regband.obj \
- $(SLO)$/region.obj \
- $(SLO)$/wall.obj \
- $(SLO)$/base14.obj \
+ $(SLO)$/region.obj \
+ $(SLO)$/wall.obj \
+ $(SLO)$/base14.obj \
$(SLO)$/pdfwriter.obj \
$(SLO)$/salgdilayout.obj \
$(SLO)$/extoutdevdata.obj \
- $(SLO)$/salnativewidgets-none.obj
-
+ $(SLO)$/salnativewidgets-none.obj
# --- Targets ------------------------------------------------------
diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx
index eab6af8444e5..ad0c9c9d5f95 100644
--- a/vcl/source/gdi/metaact.cxx
+++ b/vcl/source/gdi/metaact.cxx
@@ -38,6 +38,7 @@
#include <vcl/salbtype.hxx>
#include <vcl/metaact.hxx>
#include <vcl/graphictools.hxx>
+#include <vcl/rendergraphicrasterizer.hxx>
// ========================================================================
@@ -235,6 +236,7 @@ MetaAction* MetaAction::ReadMetaAction( SvStream& rIStm, ImplMetaReadData* pData
case( META_COMMENT_ACTION ): pAction = new MetaCommentAction; break;
case( META_LAYOUTMODE_ACTION ): pAction = new MetaLayoutModeAction; break;
case( META_TEXTLANGUAGE_ACTION ): pAction = new MetaTextLanguageAction; break;
+ case( META_RENDERGRAPHIC_ACTION ): pAction = new MetaRenderGraphicAction; break;
default:
{
@@ -2565,7 +2567,10 @@ MetaGradientExAction::~MetaGradientExAction()
void MetaGradientExAction::Execute( OutputDevice* pOut )
{
if( pOut->GetConnectMetaFile() )
- pOut->GetConnectMetaFile()->AddAction( Clone() );
+ {
+ Duplicate();
+ pOut->GetConnectMetaFile()->AddAction( this );
+ }
}
// ------------------------------------------------------------------------
@@ -4059,7 +4064,10 @@ void MetaCommentAction::ImplInitDynamicData( const sal_uInt8* pData, sal_uInt32
void MetaCommentAction::Execute( OutputDevice* pOut )
{
if ( pOut->GetConnectMetaFile() )
- pOut->GetConnectMetaFile()->AddAction( Clone() );
+ {
+ Duplicate();
+ pOut->GetConnectMetaFile()->AddAction( this );
+ }
}
// ------------------------------------------------------------------------
@@ -4294,3 +4302,81 @@ void MetaTextLanguageAction::Read( SvStream& rIStm, ImplMetaReadData* )
}
// ========================================================================
+
+IMPL_META_ACTION( RenderGraphic, META_RENDERGRAPHIC_ACTION )
+
+// ------------------------------------------------------------------------
+
+MetaRenderGraphicAction::MetaRenderGraphicAction( const Point& rPoint, const Size& rSize,
+ const vcl::RenderGraphic& rRenderGraphic,
+ double fRotateAngle, double fShearAngleX, double fShearAngleY ) :
+ MetaAction( META_RENDERGRAPHIC_ACTION ),
+ maRenderGraphic( rRenderGraphic ),
+ maPoint( rPoint ),
+ maSize( rSize ),
+ mfRotateAngle( fRotateAngle ),
+ mfShearAngleX( fShearAngleX ),
+ mfShearAngleY( fShearAngleY )
+{
+}
+
+// ------------------------------------------------------------------------
+
+void MetaRenderGraphicAction::Execute( OutputDevice* pOut )
+{
+ pOut->DrawRenderGraphic( maPoint, maSize, maRenderGraphic );
+}
+
+// ------------------------------------------------------------------------
+
+MetaAction* MetaRenderGraphicAction::Clone()
+{
+ MetaAction* pClone = (MetaAction*) new MetaRenderGraphicAction( *this );
+ pClone->ResetRefCount();
+ return pClone;
+}
+
+// ------------------------------------------------------------------------
+
+void MetaRenderGraphicAction::Move( long nHorzMove, long nVertMove )
+{
+ maPoint.Move( nHorzMove, nVertMove );
+}
+
+// ------------------------------------------------------------------------
+
+void MetaRenderGraphicAction::Scale( double fScaleX, double fScaleY )
+{
+ Rectangle aRectangle( maPoint, maSize );
+ ImplScaleRect( aRectangle, fScaleX, fScaleY );
+ maPoint = aRectangle.TopLeft();
+ maSize = aRectangle.GetSize();
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool MetaRenderGraphicAction::Compare( const MetaAction& rMetaAction ) const
+{
+ return ( maRenderGraphic.IsEqual( ( (MetaRenderGraphicAction&) rMetaAction).maRenderGraphic ) &&
+ ( maPoint == ( (MetaRenderGraphicAction&) rMetaAction).maPoint ) &&
+ ( maSize == ( (MetaRenderGraphicAction&) rMetaAction).maSize ) &&
+ ( mfRotateAngle == ( (MetaRenderGraphicAction&) rMetaAction).mfRotateAngle ) &&
+ ( mfShearAngleX == ( (MetaRenderGraphicAction&) rMetaAction).mfShearAngleX ) &&
+ ( mfShearAngleY == ( (MetaRenderGraphicAction&) rMetaAction).mfShearAngleY ) );
+}
+
+// ------------------------------------------------------------------------
+
+void MetaRenderGraphicAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
+{
+ WRITE_BASE_COMPAT( rOStm, 1, pData );
+ rOStm << maRenderGraphic << maPoint << maSize << mfRotateAngle << mfShearAngleX << mfShearAngleY;
+}
+
+// ------------------------------------------------------------------------
+
+void MetaRenderGraphicAction::Read( SvStream& rIStm, ImplMetaReadData* )
+{
+ COMPAT( rIStm );
+ rIStm >> maRenderGraphic >> maPoint >> maSize >> mfRotateAngle >> mfShearAngleX >> mfShearAngleY;
+}
diff --git a/vcl/source/gdi/outdev6.cxx b/vcl/source/gdi/outdev6.cxx
index eb4b76fb4b41..6f481237ab53 100644
--- a/vcl/source/gdi/outdev6.cxx
+++ b/vcl/source/gdi/outdev6.cxx
@@ -43,6 +43,7 @@
#include <vcl/wrkwin.hxx>
#include <vcl/graph.hxx>
#include <vcl/wall2.hxx>
+#include <vcl/rendergraphicrasterizer.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <basegfx/vector/b2dvector.hxx>
@@ -1143,6 +1144,7 @@ void OutputDevice::Erase()
return;
sal_Bool bNativeOK = sal_False;
+
if( meOutDevType == OUTDEV_WINDOW )
{
Window* pWindow = static_cast<Window*>(this);
@@ -1193,6 +1195,8 @@ void OutputDevice::ImplDraw2ColorFrame( const Rectangle& rRect,
bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
const GfxLink& rGfxLink, GDIMetaFile* pSubst )
{
+ DBG_TRACE( "OutputDevice::DrawEPS()" );
+
bool bDrawn(true);
if ( mpMetaFile )
@@ -1211,7 +1215,7 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
if( mbOutputClipped )
return bDrawn;
- Rectangle aRect( ImplLogicToDevicePixel( Rectangle( rPoint, rSize ) ) );
+ Rectangle aRect( ImplLogicToDevicePixel( Rectangle( rPoint, rSize ) ) );
if( !aRect.IsEmpty() )
{
@@ -1245,3 +1249,26 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
return bDrawn;
}
+
+// ------------------------------------------------------------------
+
+void OutputDevice::DrawRenderGraphic( const Point& rPoint, const Size& rSize,
+ const ::vcl::RenderGraphic& rRenderGraphic )
+{
+ DBG_TRACE( "OutputDevice::DrawRenderGraphic()" );
+
+ if( mpMetaFile )
+ mpMetaFile->AddAction( new MetaRenderGraphicAction( rPoint, rSize, rRenderGraphic ) );
+
+ if( !rRenderGraphic.IsEmpty() )
+ {
+ ::vcl::RenderGraphicRasterizer aRasterizer( rRenderGraphic );
+ BitmapEx aBmpEx;
+ const Size aSizePixel( LogicToPixel( rSize ) );
+ GDIMetaFile* pOldMetaFile = mpMetaFile;
+
+ mpMetaFile = NULL;
+ DrawBitmapEx( rPoint, rSize, aRasterizer.Rasterize( aSizePixel ) );
+ mpMetaFile = pOldMetaFile;
+ }
+}
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index 143c55a83ab1..996f320357c8 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -36,6 +36,7 @@
#include "vcl/bmpacc.hxx"
#include "vcl/graph.hxx"
#include "vcl/svdata.hxx"
+#include "vcl/rendergraphicrasterizer.hxx"
#include "unotools/streamwrap.hxx"
#include "unotools/processfactory.hxx"
#include "comphelper/processfactory.hxx"
@@ -1044,6 +1045,17 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa
}
break;
+ case( META_RENDERGRAPHIC_ACTION ):
+ {
+ const MetaRenderGraphicAction* pA = static_cast< const MetaRenderGraphicAction* >( pAction );
+ const ::vcl::RenderGraphicRasterizer aRasterizer( pA->GetRenderGraphic() );
+
+ implWriteBitmapEx( pA->GetPoint(), pA->GetSize(),
+ aRasterizer.Rasterize( pDummyVDev->LogicToPixel( pA->GetSize() ) ),
+ pDummyVDev, i_rContext );
+ }
+ break;
+
default:
// #i24604# Made assertion fire only once per
// metafile. The asserted actions here are all
diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx
index d86df6e2816b..28fa8670b8e8 100644
--- a/vcl/source/gdi/print2.cxx
+++ b/vcl/source/gdi/print2.cxx
@@ -45,6 +45,7 @@
#include <vcl/svapp.hxx>
#include <vcl/sallayout.hxx>
#include <vcl/bmpacc.hxx>
+#include <vcl/rendergraphicrasterizer.hxx>
#include "pdfwriter_impl.hxx"
@@ -111,6 +112,9 @@ static bool ImplIsActionSpecial( const MetaAction& rAct )
case META_BMPEXSCALEPART_ACTION:
return static_cast<const MetaBmpExScalePartAction&>(rAct).GetBitmapEx().IsTransparent();
+ case META_RENDERGRAPHIC_ACTION:
+ return true;
+
default:
return false;
}
@@ -198,6 +202,16 @@ static void ImplConvertTransparentAction( GDIMetaFile& o_rMtf,
aBmpEx = static_cast<const MetaBmpExScaleAction&>(rAct).GetBitmapEx();
break;
+ case META_RENDERGRAPHIC_ACTION:
+ {
+ const ::vcl::RenderGraphicRasterizer aRasterizer( static_cast<const MetaRenderGraphicAction&>(rAct).
+ GetRenderGraphic() );
+
+ aBmpEx = aRasterizer.Rasterize( rStateOutDev.LogicToPixel(
+ static_cast<const MetaRenderGraphicAction&>(rAct).GetSize() ) );
+ break;
+ }
+
case META_TRANSPARENT_ACTION:
default:
@@ -265,6 +279,11 @@ static void ImplConvertTransparentAction( GDIMetaFile& o_rMtf,
static_cast<const MetaBmpExScalePartAction&>(rAct).GetSrcSize(),
aBmp ));
break;
+ case META_RENDERGRAPHIC_ACTION:
+ o_rMtf.AddAction( new MetaBmpScaleAction(
+ static_cast<const MetaRenderGraphicAction&>(rAct).GetPoint(),
+ static_cast<const MetaRenderGraphicAction&>(rAct).GetSize(),
+ aBmp ));
default:
DBG_ERROR("Unexpected case");
break;
@@ -377,6 +396,7 @@ static bool ImplIsNotTransparent( const MetaAction& rAct, const OutputDevice& rO
case META_TEXTRECT_ACTION:
case META_STRETCHTEXT_ACTION:
case META_TEXTLINE_ACTION:
+ case META_RENDERGRAPHIC_ACTION:
// all other actions: generate non-transparent output
bRet = true;
break;
@@ -629,7 +649,14 @@ static Rectangle ImplCalcActionBounds( const MetaAction& rAct, const OutputDevic
case META_TEXTLINE_ACTION:
DBG_ERROR("META_TEXTLINE_ACTION not supported");
- break;
+ break;
+
+ case( META_RENDERGRAPHIC_ACTION ):
+ {
+ const MetaRenderGraphicAction& rRenderAct = static_cast<const MetaRenderGraphicAction&>(rAct);
+ aActionBounds = Rectangle( rRenderAct.GetPoint(), rRenderAct.GetSize() );
+ }
+ break;
default:
break;
@@ -656,6 +683,7 @@ static bool ImplIsActionHandlingTransparency( const MetaAction& rAct )
case META_BMPEX_ACTION:
case META_BMPEXSCALE_ACTION:
case META_BMPEXSCALEPART_ACTION:
+ case META_RENDERGRAPHIC_ACTION:
return true;
default:
diff --git a/vcl/source/gdi/rendergraphic.cxx b/vcl/source/gdi/rendergraphic.cxx
new file mode 100644
index 000000000000..10b6064cc57c
--- /dev/null
+++ b/vcl/source/gdi/rendergraphic.cxx
@@ -0,0 +1,240 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <vcl/rendergraphic.hxx>
+#include <vcl/rendergraphicrasterizer.hxx>
+#include <vcl/mapmod.hxx>
+#include <tools/stream.hxx>
+#include <tools/vcompat.hxx>
+
+#include <cstring>
+#include <cstdio>
+
+namespace vcl
+{
+
+// -----------------
+// - RenderGraphic -
+// -----------------
+RenderGraphic::RenderGraphic( ) :
+ mnGraphicDataLength( 0 )
+{
+}
+
+// -------------------------------------------------------------------------
+
+RenderGraphic::RenderGraphic( const RenderGraphic& rRenderGraphic ) :
+ maGraphicData( rRenderGraphic.maGraphicData ),
+ mnGraphicDataLength( rRenderGraphic.mnGraphicDataLength ),
+ maGraphicDataMimeType( rRenderGraphic.maGraphicDataMimeType ),
+ mapPrefMapMode( rRenderGraphic.mapPrefMapMode.get() ? new MapMode( *rRenderGraphic.mapPrefMapMode ) : NULL ),
+ mapPrefSize( rRenderGraphic.mapPrefSize.get() ? new Size( *rRenderGraphic.mapPrefSize ) : NULL )
+{
+}
+
+// -------------------------------------------------------------------------
+
+RenderGraphic::RenderGraphic( const GraphicData& rGraphicData,
+ sal_uInt32 nGraphicDataLength,
+ const rtl::OUString& rGraphicDataMimeType ) :
+ maGraphicData( rGraphicData ),
+ mnGraphicDataLength( nGraphicDataLength ),
+ maGraphicDataMimeType( rGraphicDataMimeType )
+{
+ ImplCheckData( );
+}
+
+// -------------------------------------------------------------------------
+
+RenderGraphic::RenderGraphic( const rtl::OUString& rGraphicDataMimeType,
+ sal_uInt32 nGraphicDataLength,
+ const sal_uInt8* pGraphicData ) :
+ maGraphicData(),
+ mnGraphicDataLength( nGraphicDataLength ),
+ maGraphicDataMimeType( rGraphicDataMimeType )
+{
+ if( rGraphicDataMimeType.getLength( ) && nGraphicDataLength )
+ {
+ maGraphicData.reset( new sal_uInt8[ nGraphicDataLength ] );
+
+ if( pGraphicData )
+ {
+ memcpy( maGraphicData.get(), pGraphicData, nGraphicDataLength );
+ }
+ }
+ else
+ {
+ ImplCheckData( );
+ }
+}
+
+// -------------------------------------------------------------------------
+
+RenderGraphic::~RenderGraphic( )
+{
+}
+
+// -------------------------------------------------------------------------
+
+RenderGraphic& RenderGraphic::operator=(const RenderGraphic& rRenderGraphic )
+{
+ maGraphicData = rRenderGraphic.maGraphicData;
+ mnGraphicDataLength = rRenderGraphic.mnGraphicDataLength;
+ maGraphicDataMimeType = rRenderGraphic.maGraphicDataMimeType;
+ mapPrefMapMode.reset( rRenderGraphic.mapPrefMapMode.get() ? new MapMode( *rRenderGraphic.mapPrefMapMode ) : NULL );
+ mapPrefSize.reset( rRenderGraphic.mapPrefSize.get() ? new Size( *rRenderGraphic.mapPrefSize ) : NULL );
+
+ return( *this );
+}
+
+// -------------------------------------------------------------------------
+
+bool RenderGraphic::operator==(const RenderGraphic& rRenderGraphic ) const
+{
+ return( ( rRenderGraphic.mnGraphicDataLength == mnGraphicDataLength ) &&
+ ( rRenderGraphic.maGraphicData == maGraphicData ) &&
+ ( rRenderGraphic.maGraphicDataMimeType.equalsIgnoreAsciiCase( maGraphicDataMimeType ) ) );
+}
+
+// -------------------------------------------------------------------------
+
+bool RenderGraphic::operator!() const
+{
+ return( ( 0 == maGraphicDataMimeType.getLength( ) ) ||
+ ( 0 == mnGraphicDataLength ) ||
+ !maGraphicData.get( ) );
+}
+
+// -------------------------------------------------------------------------
+
+bool RenderGraphic::IsEqual( const RenderGraphic& rRenderGraphic ) const
+{
+ bool bRet = ( rRenderGraphic.mnGraphicDataLength == mnGraphicDataLength ) &&
+ ( rRenderGraphic.maGraphicDataMimeType.equalsIgnoreAsciiCase( maGraphicDataMimeType ) );
+
+ if( bRet && mnGraphicDataLength && ( rRenderGraphic.maGraphicData != maGraphicData ) )
+ {
+ bRet = ( 0 == memcmp( rRenderGraphic.maGraphicData.get( ),
+ maGraphicData.get( ),
+ mnGraphicDataLength ) );
+ }
+
+ return( bRet );
+}
+
+// -------------------------------------------------------------------------
+
+const MapMode& RenderGraphic::GetPrefMapMode() const
+{
+ ImplGetDefaults();
+ return( *mapPrefMapMode );
+}
+
+// -------------------------------------------------------------------------
+
+const Size& RenderGraphic::GetPrefSize() const
+{
+ ImplGetDefaults();
+ return( *mapPrefSize );
+}
+
+// -------------------------------------------------------------------------
+
+BitmapEx RenderGraphic::GetReplacement() const
+{
+ const RenderGraphicRasterizer aRasterizer( *this );
+
+ return( aRasterizer.GetReplacement() );
+}
+
+// -------------------------------------------------------------------------
+
+void RenderGraphic::ImplCheckData( )
+{
+ if( !( *this ) )
+ {
+ maGraphicData.reset( );
+ mnGraphicDataLength = 0;
+ maGraphicDataMimeType = ::rtl::OUString();
+ mapPrefMapMode.reset();
+ mapPrefSize.reset();
+ }
+}
+
+// -------------------------------------------------------------------------
+
+void RenderGraphic::ImplGetDefaults() const
+{
+ if( !mapPrefMapMode.get() || !mapPrefSize.get() )
+ {
+ const RenderGraphicRasterizer aRasterizer( *this );
+
+ mapPrefMapMode.reset( new MapMode( aRasterizer.GetPrefMapMode() ) );
+ mapPrefSize.reset( new Size( aRasterizer.GetPrefSize() ) );
+ }
+}
+
+// -------------------------------------------------------------------------
+
+::SvStream& operator>>( ::SvStream& rIStm, RenderGraphic& rRenderGraphic )
+{
+ ::VersionCompat aVCompat( rIStm, STREAM_READ );
+ String aGraphicDataMimeType;
+ sal_uInt32 nGraphicDataLength = 0;
+
+ rIStm.ReadByteString( aGraphicDataMimeType, RTL_TEXTENCODING_ASCII_US );
+ rIStm >> nGraphicDataLength;
+
+ rRenderGraphic = RenderGraphic( aGraphicDataMimeType, nGraphicDataLength );
+
+ if( !rRenderGraphic.IsEmpty() )
+ {
+ rIStm.Read( rRenderGraphic.GetGraphicData().get(), nGraphicDataLength );
+ }
+
+ return rIStm;
+}
+
+// ------------------------------------------------------------------
+
+::SvStream& operator<<( ::SvStream& rOStm, const RenderGraphic& rRenderGraphic )
+{
+ ::VersionCompat aVCompat( rOStm, STREAM_WRITE, 1 );
+ const sal_uInt32 nGraphicDataLength = rRenderGraphic.GetGraphicDataLength();
+
+ rOStm.WriteByteString( rRenderGraphic.GetGraphicDataMimeType(), RTL_TEXTENCODING_ASCII_US );
+ rOStm << nGraphicDataLength;
+
+ if( nGraphicDataLength )
+ {
+ rOStm.Write( rRenderGraphic.GetGraphicData().get(), nGraphicDataLength );
+ }
+
+ return rOStm;
+}
+
+} // VCL
diff --git a/vcl/source/gdi/rendergraphicrasterizer.cxx b/vcl/source/gdi/rendergraphicrasterizer.cxx
new file mode 100644
index 000000000000..29c9863335b3
--- /dev/null
+++ b/vcl/source/gdi/rendergraphicrasterizer.cxx
@@ -0,0 +1,400 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <vcl/rendergraphicrasterizer.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/unohelp.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/graph.hxx>
+#include <tools/stream.hxx>
+#include <comphelper/processfactory.hxx>
+#include <unotools/streamwrap.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#define VCL_SERVICENAME_RASTERIZER_SVG "com.sun.star.graphic.GraphicRasterizer_RSVG"
+
+using namespace com::sun::star;
+
+namespace vcl
+{
+// ---------------------------------------------------------
+// - maximum extent in pixel for graphics to be rasterized -
+// ---------------------------------------------------------
+
+static const sal_uInt32 nRasterizerDefaultExtent = 4096;
+
+// ---------------------------
+// - RenderGraphicRasterizer -
+// ---------------------------
+
+RenderGraphicRasterizer::RenderGraphicRasterizer( const RenderGraphic& rRenderGraphic ) :
+ maRenderGraphic( rRenderGraphic ),
+ mfRotateAngle( 0.0 ),
+ mfShearAngleX( 0.0 ),
+ mfShearAngleY( 0.0 )
+{
+}
+
+// -------------------------------------------------------------------------
+
+RenderGraphicRasterizer::RenderGraphicRasterizer( const RenderGraphicRasterizer& rRenderGraphicRasterizer ) :
+ maRenderGraphic( rRenderGraphicRasterizer.maRenderGraphic ),
+ mxRasterizer( rRenderGraphicRasterizer.mxRasterizer ),
+ maBitmapEx( rRenderGraphicRasterizer.maBitmapEx ),
+ maDefaultSizePixel( rRenderGraphicRasterizer.maDefaultSizePixel ),
+ mfRotateAngle( rRenderGraphicRasterizer.mfRotateAngle ),
+ mfShearAngleX( rRenderGraphicRasterizer.mfShearAngleX ),
+ mfShearAngleY( rRenderGraphicRasterizer.mfShearAngleY )
+{
+}
+
+// -------------------------------------------------------------------------
+
+RenderGraphicRasterizer::~RenderGraphicRasterizer()
+{
+}
+
+// -------------------------------------------------------------------------
+
+RenderGraphicRasterizer& RenderGraphicRasterizer::operator=(
+ const RenderGraphicRasterizer& rRenderGraphicRasterizer )
+{
+ maRenderGraphic = rRenderGraphicRasterizer.maRenderGraphic;
+ maBitmapEx = rRenderGraphicRasterizer.maBitmapEx;
+ maDefaultSizePixel = rRenderGraphicRasterizer.maDefaultSizePixel;
+ mfRotateAngle = rRenderGraphicRasterizer.mfRotateAngle;
+ mfShearAngleX = rRenderGraphicRasterizer.mfShearAngleX;
+ mfShearAngleY = rRenderGraphicRasterizer.mfShearAngleY;
+ mxRasterizer = rRenderGraphicRasterizer.mxRasterizer;
+
+ return( *this );
+}
+
+// -------------------------------------------------------------------------
+
+const Size& RenderGraphicRasterizer::GetDefaultSizePixel() const
+{
+ const_cast< RenderGraphicRasterizer* >( this )->InitializeRasterizer();
+
+ return( maDefaultSizePixel );
+}
+
+// -------------------------------------------------------------------------
+
+BitmapEx RenderGraphicRasterizer::GetReplacement() const
+{
+ BitmapEx aRet( Rasterize( GetDefaultSizePixel() ) );
+
+ aRet.SetPrefSize( GetPrefSize() );
+ aRet.SetPrefMapMode( GetPrefMapMode() );
+
+ return( aRet );
+}
+
+// -------------------------------------------------------------------------
+
+Size RenderGraphicRasterizer::GetPrefSize() const
+{
+ const Size aSizePixel( GetDefaultSizePixel() );
+ std::auto_ptr< VirtualDevice > apCompVDev;
+ OutputDevice* pCompDev = NULL;
+
+#ifndef NO_GETAPPWINDOW
+ pCompDev = Application::GetAppWindow();
+#endif
+
+ if( !pCompDev )
+ {
+ apCompVDev.reset( new VirtualDevice );
+ pCompDev = apCompVDev.get();
+ }
+
+ return( pCompDev->PixelToLogic( aSizePixel, GetPrefMapMode() ) );
+}
+
+// -------------------------------------------------------------------------
+
+MapMode RenderGraphicRasterizer::GetPrefMapMode() const
+{
+ return( MapMode( MAP_100TH_MM ) );
+}
+
+// -------------------------------------------------------------------------
+
+const BitmapEx& RenderGraphicRasterizer::Rasterize( const Size& rSizePixel,
+ double fRotateAngle,
+ double fShearAngleX,
+ double fShearAngleY,
+ sal_uInt32 nMaxExtent ) const
+{
+ const bool bRasterize = !maRenderGraphic.IsEmpty() &&
+ rSizePixel.Width() && rSizePixel.Height() &&
+ ( maBitmapEx.IsEmpty() ||
+ ( rSizePixel != maBitmapEx.GetSizePixel() ) ||
+ ( fRotateAngle != mfRotateAngle ) ||
+ ( fShearAngleX != mfShearAngleX ) ||
+ ( fShearAngleY != mfShearAngleY ) );
+
+ if( bRasterize )
+ {
+ const_cast< RenderGraphicRasterizer* >( this )->InitializeRasterizer();
+
+ if( mxRasterizer.is() )
+ {
+ sal_uInt32 nWidth = labs( rSizePixel.Width() );
+ sal_uInt32 nHeight = labs( rSizePixel.Height() );
+
+ // limiting the extent of the rastered bitmap
+ if( VCL_RASTERIZER_UNLIMITED_EXTENT != nMaxExtent )
+ {
+ if( VCL_RASTERIZER_DEFAULT_EXTENT == nMaxExtent )
+ {
+ nMaxExtent = nRasterizerDefaultExtent;
+ }
+
+ if( ( nWidth > nMaxExtent ) || ( nHeight > nMaxExtent ) )
+ {
+ const double fScale = static_cast< double >( nMaxExtent ) / ::std::max( nWidth, nHeight );
+
+ nWidth = FRound( nWidth * fScale );
+ nHeight = FRound( nHeight * fScale );
+ }
+ }
+
+ if( !ImplRasterizeFromCache( const_cast< RenderGraphicRasterizer& >( *this ),
+ Size( nWidth, nHeight ), fRotateAngle, fShearAngleX, fShearAngleY ) )
+ {
+ try
+ {
+ const uno::Sequence< beans::PropertyValue > aPropertySeq;
+ const Graphic aRasteredGraphic( mxRasterizer->rasterize( nWidth,
+ nHeight,
+ fRotateAngle,
+ fShearAngleX,
+ fShearAngleY,
+ aPropertySeq ) );
+
+ maBitmapEx = aRasteredGraphic.GetBitmapEx();
+ mfRotateAngle = fRotateAngle;
+ mfShearAngleX = fShearAngleX;
+ mfShearAngleY = fShearAngleY;
+
+ ImplUpdateCache( *this );
+
+// OSL_TRACE( "Wanted: %d x %d / Got: %d x %d", rSizePixel.Width(), rSizePixel.Height(), maBitmapEx.GetSizePixel().Width(), maBitmapEx.GetSizePixel().Height() );
+ }
+ catch( ... )
+ {
+ OSL_TRACE( "caught exception during rasterization" );
+ }
+ }
+ }
+ }
+
+ return( maBitmapEx );
+}
+
+// -------------------------------------------------------------------------
+
+void RenderGraphicRasterizer::InitializeRasterizer()
+{
+ if( !mxRasterizer.is() && !ImplInitializeFromCache( *this ) )
+ {
+ uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
+
+ maDefaultSizePixel.Width() = maDefaultSizePixel.Height() = 0;
+
+ if( !maRenderGraphic.IsEmpty() )
+ {
+ rtl::OUString aServiceName;
+
+ if( 0 == maRenderGraphic.GetGraphicDataMimeType().compareToAscii( "image/svg+xml" ) )
+ {
+ aServiceName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VCL_SERVICENAME_RASTERIZER_SVG ) );
+ }
+
+ if( aServiceName.getLength() )
+ {
+ mxRasterizer.set( xFactory->createInstance( aServiceName ), uno::UNO_QUERY );
+
+ if( mxRasterizer.is() )
+ {
+ std::auto_ptr< VirtualDevice > apCompVDev;
+ OutputDevice* pCompDev = NULL;
+
+#ifndef NO_GETAPPWINDOW
+ pCompDev = Application::GetAppWindow();
+#endif
+
+ if( !pCompDev )
+ {
+ apCompVDev.reset( new VirtualDevice );
+ pCompDev = apCompVDev.get();
+ }
+
+ const Size aDPI( pCompDev->LogicToPixel( Size( 1, 1 ), MAP_INCH ) );
+ awt::Size aSizePixel;
+ SvMemoryStream aMemStm( maRenderGraphic.GetGraphicData().get(),
+ maRenderGraphic.GetGraphicDataLength(),
+ STREAM_READ );
+
+ uno::Reference< io::XInputStream > xIStm( new utl::OSeekableInputStreamWrapper( aMemStm ) );
+
+ try
+ {
+ if( !xIStm.is() || !mxRasterizer->initializeData( xIStm, aDPI.Width(), aDPI.Height(), aSizePixel ) )
+ {
+ mxRasterizer.clear();
+ }
+ else
+ {
+ maDefaultSizePixel.Width() = aSizePixel.Width;
+ maDefaultSizePixel.Height() = aSizePixel.Height;
+ }
+ }
+ catch( ... )
+ {
+ OSL_TRACE( "caught exception during initialization of SVG rasterizer component" );
+ mxRasterizer.clear();
+ }
+ }
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+RenderGraphicRasterizer::RenderGraphicRasterizerCache& RenderGraphicRasterizer::ImplGetCache()
+{
+ static RenderGraphicRasterizerCache* pCache = NULL;
+
+ if( !pCache )
+ {
+ pCache = new RenderGraphicRasterizerCache;
+ }
+
+ return( *pCache );
+}
+
+// ------------------------------------------------------------------------------
+
+bool RenderGraphicRasterizer::ImplInitializeFromCache( RenderGraphicRasterizer& rRasterizer )
+{
+ RenderGraphicRasterizerCache& rCache = ImplGetCache();
+ bool bRet = false;
+
+ for( sal_uInt32 i = 0; i < rCache.size(); ++i )
+ {
+ const RenderGraphicRasterizer* pCheck = &rCache[ i ];
+
+ if( pCheck && pCheck->mxRasterizer.is() && ( pCheck->maRenderGraphic == rRasterizer.maRenderGraphic ) )
+ {
+// OSL_TRACE( "Hit RenderGraphicRasterizer cache for initialization" );
+
+ rRasterizer.mxRasterizer = pCheck->mxRasterizer;
+ rRasterizer.maDefaultSizePixel = pCheck->maDefaultSizePixel;
+
+ // put found Rasterizer at begin of deque
+ const RenderGraphicRasterizer aFound( rCache[ i ] );
+
+ rCache.erase( rCache.begin() + i );
+ rCache.push_front( aFound );
+
+
+ bRet = true;
+ }
+ }
+
+ return( bRet );
+}
+
+// ------------------------------------------------------------------------------
+
+bool RenderGraphicRasterizer::ImplRasterizeFromCache( RenderGraphicRasterizer& rRasterizer,
+ const Size& rSizePixel,
+ double fRotateAngle,
+ double fShearAngleX,
+ double fShearAngleY )
+{
+ RenderGraphicRasterizerCache& rCache = ImplGetCache();
+ bool bRet = false;
+
+ for( sal_uInt32 i = 0; i < rCache.size(); ++i )
+ {
+ const RenderGraphicRasterizer& rCheck = rCache[ i ];
+
+ if( rCheck.mxRasterizer.is() && rRasterizer.mxRasterizer.is() &&
+ ( ( rCheck.mxRasterizer == rRasterizer.mxRasterizer ) ||
+ ( rRasterizer.maRenderGraphic == rCheck.maRenderGraphic ) ) &&
+ ( rCheck.maBitmapEx.GetSizePixel() == rSizePixel ) &&
+ ( rCheck.mfRotateAngle == fRotateAngle ) &&
+ ( rCheck.mfShearAngleX == fShearAngleX ) &&
+ ( rCheck.mfShearAngleY == fShearAngleY ) )
+ {
+// OSL_TRACE( "Hit RenderGraphicRasterizer cache for rasterizing" );
+
+ rRasterizer.maBitmapEx = rCheck.maBitmapEx;
+ rRasterizer.mfRotateAngle = fRotateAngle;
+ rRasterizer.mfShearAngleX = fShearAngleX;
+ rRasterizer.mfShearAngleY = fShearAngleY;
+
+ // put found Rasterizer at begin of deque
+ const RenderGraphicRasterizer aFound( rCache[ i ] );
+
+ rCache.erase( rCache.begin() + i );
+ rCache.push_front( aFound );
+
+ bRet = true;
+ }
+ }
+
+ return( bRet );
+}
+
+// ------------------------------------------------------------------------------
+
+void RenderGraphicRasterizer::ImplUpdateCache( const RenderGraphicRasterizer& rRasterizer )
+{
+ RenderGraphicRasterizerCache& rCache = ImplGetCache();
+ const sal_uInt32 nMaxCacheSize = 8;
+
+ if( rCache.size() < nMaxCacheSize )
+ {
+ rCache.push_front( rRasterizer );
+ }
+ else
+ {
+ rCache.pop_back();
+ rCache.push_front( rRasterizer );
+ }
+}
+
+} // VCL
diff --git a/vcl/source/gdi/svgread.cxx b/vcl/source/gdi/svgread.cxx
new file mode 100644
index 000000000000..47ef39c37f20
--- /dev/null
+++ b/vcl/source/gdi/svgread.cxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include <tools/stream.hxx>
+#include <vcl/svgread.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/metaact.hxx>
+#include <vcl/rendergraphicrasterizer.hxx>
+
+// -----------
+// - Defines -
+// -----------
+
+namespace vcl
+{
+ // -----------------
+ // - SVGReaderImpl -
+ // -----------------
+
+ class SVGReaderImpl
+ {
+ public:
+
+ SVGReaderImpl( SvStream& rStm );
+ ~SVGReaderImpl();
+
+ GDIMetaFile& ImplRead( GDIMetaFile& rSVGMtf );
+
+ private:
+
+ SvStream& mrStm;
+ };
+
+ // ------------------------------------------------------------------------------
+
+ SVGReaderImpl::SVGReaderImpl( SvStream& rStm ) :
+ mrStm( rStm )
+ {
+ }
+
+ // ------------------------------------------------------------------------
+
+ SVGReaderImpl::~SVGReaderImpl()
+ {
+ }
+
+ // ------------------------------------------------------------------------
+
+ GDIMetaFile& SVGReaderImpl::ImplRead( GDIMetaFile& rSVGMtf )
+ {
+ const sal_uInt32 nStmPos = mrStm.Tell();
+ const sal_uInt32 nStmLen = mrStm.Seek( STREAM_SEEK_TO_END ) - nStmPos;
+
+ if( nStmLen )
+ {
+ const vcl::RenderGraphic aSVGGraphic( ::rtl::OUString::createFromAscii( "image/svg+xml" ), nStmLen );
+
+ mrStm.Seek( nStmPos );
+ mrStm.Read( aSVGGraphic.GetGraphicData().get(), nStmLen );
+
+ if( !mrStm.GetError() )
+ {
+ const vcl::RenderGraphicRasterizer aRasterizer( aSVGGraphic );
+ const Size aDefaultSizePixel( aRasterizer.GetDefaultSizePixel() );
+
+ if( aDefaultSizePixel.Width() && aDefaultSizePixel.Height() )
+ {
+ const Point aPos;
+ const Size aPrefSize( aRasterizer.GetPrefSize() );
+
+ rSVGMtf.SetPrefMapMode( aRasterizer.GetPrefMapMode() );
+ rSVGMtf.SetPrefSize( aPrefSize );
+ rSVGMtf.AddAction( new MetaRenderGraphicAction( aPos, aPrefSize, aSVGGraphic ) );
+ rSVGMtf.WindStart();
+ }
+ }
+ }
+
+ return( rSVGMtf );
+ }
+
+ // -------------
+ // - SVGReader -
+ // -------------
+
+ SVGReader::SVGReader( SvStream& rIStm ) :
+ mapImpl( new ::vcl::SVGReaderImpl( rIStm ) )
+ {
+ }
+
+ // ------------------------------------------------------------------------
+
+ SVGReader::~SVGReader()
+ {
+ }
+
+ // ------------------------------------------------------------------------
+
+ GDIMetaFile& SVGReader::Read( GDIMetaFile& rSVGMtf )
+ {
+ rSVGMtf = GDIMetaFile();
+
+ return( mapImpl.get() ? mapImpl->ImplRead( rSVGMtf ) : rSVGMtf );
+ }
+
+} // namespace vcl