diff options
Diffstat (limited to 'vcl/source/gdi')
54 files changed, 1834 insertions, 957 deletions
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx index a0b48f4ee124..e2ab338e66b0 100644 --- a/vcl/source/gdi/bitmap.cxx +++ b/vcl/source/gdi/bitmap.cxx @@ -28,20 +28,22 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" + #include <rtl/crc.h> -#include <vcl/salbtype.hxx> #include <tools/stream.hxx> -#include <vcl/bmpacc.hxx> #include <tools/poly.hxx> -#include <vcl/outdev.hxx> -#include <vcl/impbmp.hxx> -#include <vcl/salbmp.hxx> #include <tools/rc.h> +#include <vcl/salbtype.hxx> +#include <vcl/bmpacc.hxx> +#include <vcl/outdev.hxx> #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/svapp.hxx> #include <vcl/image.hxx> +#include <impbmp.hxx> +#include <salbmp.hxx> + // ---------- // - Bitmap - // ---------- diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index c2d929ea4fa0..0ae8e63d2519 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -30,13 +30,15 @@ #include "precompiled_vcl.hxx" #include <stdlib.h> + #include <vcl/bmpacc.hxx> -#include <vcl/impoct.hxx> #include <vcl/octree.hxx> -#include <impvect.hxx> #include <vcl/bitmapex.hxx> #include <vcl/bitmap.hxx> +#include <impoct.hxx> +#include <impvect.hxx> + // ----------- // - Defines - // ----------- diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index d1f130d9d1cc..2e77b666f8c8 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -28,22 +28,27 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" + #include <ctype.h> + #include <rtl/crc.h> -#include <vcl/salbtype.hxx> + #include <tools/stream.hxx> #include <tools/debug.hxx> +#include <tools/rc.h> + +#include <vcl/salbtype.hxx> #include <vcl/outdev.hxx> #include <vcl/alpha.hxx> -#include <vcl/image.h> #include <vcl/bitmapex.hxx> #include <vcl/pngread.hxx> -#include <vcl/impimagetree.hxx> -#include <tools/rc.h> #include <vcl/svapp.hxx> #include <vcl/bmpacc.hxx> #include <vcl/virdev.hxx> +#include <image.h> +#include <impimagetree.hxx> + // ------------ // - BitmapEx - // ------------ diff --git a/vcl/source/gdi/bmpacc.cxx b/vcl/source/gdi/bmpacc.cxx index 0762821c3267..03b29fcbc965 100644 --- a/vcl/source/gdi/bmpacc.cxx +++ b/vcl/source/gdi/bmpacc.cxx @@ -28,10 +28,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" + #include <vcl/salbtype.hxx> -#include <vcl/impbmp.hxx> #include <vcl/bitmap.hxx> #include <vcl/bmpacc.hxx> + +#include <impbmp.hxx> + #include <string.h> // -------------------- diff --git a/vcl/source/gdi/bmpacc3.cxx b/vcl/source/gdi/bmpacc3.cxx index 5e87d680e9c0..39d57a05cb84 100644 --- a/vcl/source/gdi/bmpacc3.cxx +++ b/vcl/source/gdi/bmpacc3.cxx @@ -28,12 +28,15 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" + +#include <tools/poly.hxx> + #include <vcl/salbtype.hxx> #include <vcl/bitmap.hxx> -#include <tools/poly.hxx> #include <vcl/region.hxx> #include <vcl/bmpacc.hxx> -#include <vcl/bmpfast.hxx> + +#include <bmpfast.hxx> // --------------------- // - BitmapWriteAccess - diff --git a/vcl/source/gdi/bmpfast.cxx b/vcl/source/gdi/bmpfast.cxx index 8fc5188c9204..e410e0ee25e8 100644 --- a/vcl/source/gdi/bmpfast.cxx +++ b/vcl/source/gdi/bmpfast.cxx @@ -29,7 +29,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <vcl/bmpfast.hxx> +#include <bmpfast.hxx> #ifndef NO_OPTIMIZED_BITMAP_ACCESS diff --git a/vcl/source/gdi/configsettings.cxx b/vcl/source/gdi/configsettings.cxx index ff701ab640fa..1ddc801c8329 100644 --- a/vcl/source/gdi/configsettings.cxx +++ b/vcl/source/gdi/configsettings.cxx @@ -30,7 +30,9 @@ #include "precompiled_vcl.hxx" #include <vcl/configsettings.hxx> -#include <vcl/svdata.hxx> + +#include <svdata.hxx> + #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/beans/PropertyValue.hpp> diff --git a/vcl/source/gdi/cvtgrf.cxx b/vcl/source/gdi/cvtgrf.cxx index 261781ebcf50..6d3b60777120 100644 --- a/vcl/source/gdi/cvtgrf.cxx +++ b/vcl/source/gdi/cvtgrf.cxx @@ -29,12 +29,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <svsys.h> #include <vcl/metaact.hxx> -#include <vcl/salinst.hxx> -#include <vcl/svdata.hxx> #include <vcl/cvtgrf.hxx> +#include <salinst.hxx> +#include <svdata.hxx> + // -------------- // - Callback - // -------------- diff --git a/vcl/source/gdi/font.cxx b/vcl/source/gdi/font.cxx index 03708f865c96..8ed39ea10fed 100644 --- a/vcl/source/gdi/font.cxx +++ b/vcl/source/gdi/font.cxx @@ -29,15 +29,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include "sft.hxx" +#include "unotools/fontcfg.hxx" #include "tools/stream.hxx" #include "tools/vcompat.hxx" #include "tools/debug.hxx" + #include "vcl/font.hxx" -#include "vcl/impfont.hxx" -#include "vcl/outfont.hxx" -#include "unotools/fontcfg.hxx" + +#include "impfont.hxx" +#include "outfont.hxx" +#include "sft.hxx" + #include <sal/macros.h> #include <algorithm> @@ -876,9 +879,6 @@ namespace bool identifyTrueTypeFont( const void* i_pBuffer, sal_uInt32 i_nSize, Font& o_rResult ) { bool bResult = false; -// FIXME: This is HACK. We do not build psprint's part on aqua... -// How to solve this? -#ifndef QUARTZ TrueTypeFont* pTTF = NULL; if( OpenTTFontBuffer( const_cast<void*>(i_pBuffer), i_nSize, 0, &pTTF ) == SF_OK ) { @@ -952,7 +952,6 @@ namespace // success bResult = true; } -#endif return bResult; } diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 20f0731f19d2..984386028cdc 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -37,18 +37,20 @@ #include <vcl/window.hxx> #include <vcl/cvtsvm.hxx> #include <vcl/virdev.hxx> -#include <vcl/salbmp.hxx> #include <vcl/svapp.hxx> -#include <vcl/svdata.hxx> -#include <vcl/salinst.hxx> #include <vcl/gdimtf.hxx> #include <vcl/graphictools.hxx> #include <vcl/canvastools.hxx> #include <vcl/unohelp.hxx> +#include <salbmp.hxx> +#include <salinst.hxx> +#include <svdata.hxx> + #include <com/sun/star/beans/XFastPropertySet.hpp> -#include <com/sun/star/rendering/XCanvas.hpp> #include <com/sun/star/rendering/MtfRenderer.hpp> +#include <com/sun/star/rendering/XBitmapCanvas.hpp> +#include <com/sun/star/rendering/XCanvas.hpp> #include <comphelper/processfactory.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XInitialization.hpp> @@ -1745,6 +1747,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 ); @@ -1809,363 +1820,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: { @@ -2564,6 +2583,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.push_back( pAction ); + } + break; + default: { pAction->Duplicate(); @@ -2749,11 +2777,12 @@ 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( size_t i = 0, nObjCount = GetActionSize(); i < nObjCount; i++ ) { MetaAction* pAction = GetAction( i ); @@ -3010,6 +3039,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 ); @@ -3076,8 +3129,7 @@ sal_uLong GDIMetaFile::GetSizeBytes() const } break; - default: - break; + case( META_RENDERGRAPHIC_ACTION ): nSizeBytes += ( ( (MetaRenderGraphicAction*) pAction )->GetRenderGraphic() ).GetGraphicDataLength(); break; } } @@ -3105,27 +3157,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 @@ -3154,10 +3242,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; @@ -3175,32 +3280,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) GetActionSize(); + { + // 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 = FirstAction(); pAct; pAct = NextAction() ) + { + 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 = FirstAction(); - while ( pAct ) + for( MetaAction* pAct = FirstAction(); pAct; pAct = NextAction() ) { pAct->Write( rOStm, &aWriteData ); - pAct = NextAction(); + + // 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 29b6a62253a6..745c4f765398 100644 --- a/vcl/source/gdi/gfxlink.cxx +++ b/vcl/source/gdi/gfxlink.cxx @@ -259,6 +259,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 f61bbf8dc041..eb22d31937df 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -28,11 +28,15 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <vcl/impgraph.hxx> + #include <vcl/outdev.hxx> #include <vcl/svapp.hxx> #include <vcl/graph.hxx> + +#include <impgraph.hxx> + #include <comphelper/processfactory.hxx> + #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> @@ -428,6 +432,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); @@ -456,6 +481,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/image.cxx b/vcl/source/gdi/image.cxx index 24c86c326910..18f927e5b0ff 100644 --- a/vcl/source/gdi/image.cxx +++ b/vcl/source/gdi/image.cxx @@ -32,6 +32,7 @@ #include <boost/scoped_array.hpp> #include <rtl/logfile.hxx> + #include <tools/debug.hxx> #include <tools/stream.hxx> #include <tools/rc.h> @@ -41,10 +42,10 @@ #include <vcl/outdev.hxx> #include <vcl/graph.hxx> #include <vcl/svapp.hxx> -#include <vcl/impimagetree.hxx> -#include <vcl/image.h> #include <vcl/image.hxx> #include <vcl/imagerepository.hxx> +#include <impimagetree.hxx> +#include <image.h> #if OSL_DEBUG_LEVEL > 0 #include <rtl/strbuf.hxx> diff --git a/vcl/source/gdi/imagerepository.cxx b/vcl/source/gdi/imagerepository.cxx index ea5b5f5d87a4..6fda85735b01 100644 --- a/vcl/source/gdi/imagerepository.cxx +++ b/vcl/source/gdi/imagerepository.cxx @@ -28,10 +28,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" + #include <vcl/bitmapex.hxx> #include <vcl/imagerepository.hxx> #include <vcl/svapp.hxx> -#include "vcl/impimagetree.hxx" +#include "impimagetree.hxx" //........................................................................ namespace vcl diff --git a/vcl/source/gdi/impbmp.cxx b/vcl/source/gdi/impbmp.cxx index 6957e32b3e25..579515f67e9c 100644 --- a/vcl/source/gdi/impbmp.cxx +++ b/vcl/source/gdi/impbmp.cxx @@ -29,13 +29,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <svsys.h> -#include <vcl/salbmp.hxx> #include <tools/debug.hxx> -#include <vcl/impbmp.hxx> + #include <vcl/bitmap.hxx> -#include <vcl/svdata.hxx> -#include <vcl/salinst.hxx> + +#include <svdata.hxx> +#include <salinst.hxx> +#include <salbmp.hxx> +#include <impbmp.hxx> // -------------- // - ImpBitmap - diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index bf99364a0f64..9d995f361329 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -28,22 +28,26 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" + #include <tools/vcompat.hxx> #include <tools/urlobj.hxx> #include <tools/debug.hxx> +#include <tools/stream.hxx> + #include <ucbhelper/content.hxx> + #include <unotools/ucbstreamhelper.hxx> #include <unotools/tempfile.hxx> #include <vcl/outdev.hxx> #include <vcl/virdev.hxx> -#include <tools/debug.hxx> -#include <tools/stream.hxx> -#include <vcl/impgraph.hxx> #include <vcl/gfxlink.hxx> #include <vcl/cvtgrf.hxx> #include <vcl/salbtype.hxx> #include <vcl/graph.hxx> #include <vcl/metaact.hxx> + +#include <impgraph.hxx> + #include <com/sun/star/ucb/CommandAbortedException.hpp> // ----------- @@ -479,6 +483,48 @@ sal_Bool ImpGraphic::ImplIsAnimated() const // ------------------------------------------------------------------------ +sal_Bool ImpGraphic::ImplIsEPS() const +{ + return( ( meType == GRAPHIC_GDIMETAFILE ) && + ( maMetaFile.GetActionSize() > 0 ) && + ( maMetaFile.GetAction( 0 )->GetType() == META_EPS_ACTION ) ); +} + +// ------------------------------------------------------------------------ + +sal_Bool ImpGraphic::ImplIsRenderGraphic() const +{ + return( ( GRAPHIC_GDIMETAFILE == meType ) && + ( 1 == maMetaFile.GetActionSize() ) && + ( 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; @@ -591,6 +637,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/impimage.cxx b/vcl/source/gdi/impimage.cxx index d2e479e1edb5..2246058fb10f 100644 --- a/vcl/source/gdi/impimage.cxx +++ b/vcl/source/gdi/impimage.cxx @@ -28,15 +28,17 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" + #include <vcl/outdev.hxx> #include <vcl/bitmapex.hxx> #include <vcl/alpha.hxx> #include <vcl/window.hxx> #include <vcl/bmpacc.hxx> #include <vcl/virdev.hxx> -#include <vcl/image.h> #include <vcl/image.hxx> +#include <image.h> + // ----------- // - Defines - // ----------- diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx index 88b465c89f7d..b43611e34b04 100644 --- a/vcl/source/gdi/impimagetree.cxx +++ b/vcl/source/gdi/impimagetree.cxx @@ -27,13 +27,13 @@ ***********************************************************************/ #include "precompiled_vcl.hxx" + #include "sal/config.h" #include <list> #include <memory> #include <utility> #include <vector> - #include <boost/unordered_map.hpp> #include "com/sun/star/container/XNameAccess.hpp" @@ -44,24 +44,31 @@ #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/uno/Sequence.hxx" + #include "comphelper/processfactory.hxx" + #include "osl/file.hxx" #include "osl/diagnose.h" + #include "rtl/bootstrap.hxx" #include "rtl/string.h" #include "rtl/textenc.h" #include "rtl/ustrbuf.hxx" #include "rtl/ustring.h" #include "rtl/ustring.hxx" + #include "sal/types.h" + #include "tools/stream.hxx" #include "tools/urlobj.hxx" + #include "vcl/bitmapex.hxx" -#include "vcl/impimagetree.hxx" #include "vcl/pngread.hxx" #include "vcl/settings.hxx" #include "vcl/svapp.hxx" +#include "impimagetree.hxx" + namespace { namespace css = com::sun::star; diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx index bcf7986c70b2..d06e16dcf0cb 100644 --- a/vcl/source/gdi/jobset.cxx +++ b/vcl/source/gdi/jobset.cxx @@ -28,11 +28,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" + #include <tools/debug.hxx> #include <tools/stream.hxx> #include <rtl/alloc.h> #include <vcl/jobset.hxx> -#include <vcl/jobset.h> + +#include <jobset.h> // ======================================================================= diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index d01c46a77ca0..e124dc343eba 100755 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -50,7 +50,7 @@ CDEFS+=-DGR2_STATIC # --- Files -------------------------------------------------------- -EXCEPTIONSFILES= $(SLO)$/salmisc.obj \ +EXCEPTIONSFILES= $(SLO)$/salmisc.obj \ $(SLO)$/animate.obj \ $(SLO)$/base14.obj \ $(SLO)$/bitmap.obj \ @@ -90,36 +90,38 @@ EXCEPTIONSFILES= $(SLO)$/salmisc.obj \ $(SLO)$/pdfwriter_impl.obj \ $(SLO)$/pdfwriter_impl2.obj \ $(SLO)$/pngread.obj \ - $(SLO)$/pngwrite.obj \ + $(SLO)$/pngwrite.obj \ $(SLO)$/print.obj \ $(SLO)$/print2.obj \ $(SLO)$/print3.obj \ + $(SLO)$/rendergraphic.obj \ + $(SLO)$/rendergraphicrasterizer.obj \ $(SLO)$/salgdilayout.obj \ $(SLO)$/sallayout.obj \ $(SLO)$/salnativewidgets-none.obj \ + $(SLO)$/svgread.obj \ $(SLO)$/textlayout.obj \ $(SLO)$/virdev.obj \ $(SLO)$/wall.obj -SLOFILES= $(EXCEPTIONSFILES) \ +SLOFILES= $(EXCEPTIONSFILES) \ $(SLO)$/bitmap3.obj \ $(SLO)$/bitmap4.obj \ - $(SLO)$/alpha.obj \ + $(SLO)$/alpha.obj \ $(SLO)$/bmpacc.obj \ $(SLO)$/bmpacc2.obj \ $(SLO)$/bmpacc3.obj \ $(SLO)$/bmpfast.obj \ - $(SLO)$/font.obj \ + $(SLO)$/font.obj \ $(SLO)$/gradient.obj \ - $(SLO)$/hatch.obj \ - $(SLO)$/impbmp.obj \ - $(SLO)$/mapmod.obj \ - $(SLO)$/octree.obj \ + $(SLO)$/hatch.obj \ + $(SLO)$/impbmp.obj \ + $(SLO)$/mapmod.obj \ + $(SLO)$/octree.obj \ $(SLO)$/regband.obj \ - $(SLO)$/region.obj \ + $(SLO)$/region.obj \ $(SLO)$/extoutdevdata.obj - # --- Targets ------------------------------------------------------ .INCLUDE : target.mk diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index feba437c7c2f..2ffa3c68e4f7 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -39,6 +39,7 @@ #include <vcl/salbtype.hxx> #include <vcl/metaact.hxx> #include <vcl/graphictools.hxx> +#include <vcl/rendergraphicrasterizer.hxx> // ======================================================================== @@ -236,6 +237,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: { @@ -2566,7 +2568,10 @@ MetaGradientExAction::~MetaGradientExAction() void MetaGradientExAction::Execute( OutputDevice* pOut ) { if( pOut->GetConnectMetaFile() ) - pOut->GetConnectMetaFile()->AddAction( Clone() ); + { + Duplicate(); + pOut->GetConnectMetaFile()->AddAction( this ); + } } // ------------------------------------------------------------------------ @@ -4060,7 +4065,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 ); + } } // ------------------------------------------------------------------------ @@ -4323,4 +4331,82 @@ void MetaTextLanguageAction::Read( SvStream& rIStm, ImplMetaReadData* ) // ======================================================================== -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +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; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/vcl/source/gdi/metric.cxx b/vcl/source/gdi/metric.cxx index 4814d6e3114e..e8a8a2cb3a63 100644 --- a/vcl/source/gdi/metric.cxx +++ b/vcl/source/gdi/metric.cxx @@ -29,7 +29,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <vcl/impfont.hxx> +#include <impfont.hxx> #include <vcl/metric.hxx> #include <vector> diff --git a/vcl/source/gdi/octree.cxx b/vcl/source/gdi/octree.cxx index c2f0d92f03c3..56c46f421695 100644 --- a/vcl/source/gdi/octree.cxx +++ b/vcl/source/gdi/octree.cxx @@ -28,11 +28,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" + #include <limits.h> + #include <vcl/bmpacc.hxx> -#include <vcl/impoct.hxx> #include <vcl/octree.hxx> +#include <impoct.hxx> + // --------- // - pMask - // --------- diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx index 99a93432652f..3e5e05904e57 100644 --- a/vcl/source/gdi/outdev.cxx +++ b/vcl/source/gdi/outdev.cxx @@ -30,31 +30,34 @@ #include "precompiled_vcl.hxx" #include <tools/ref.hxx> -#include <svsys.h> -#include <vcl/salgdi.hxx> -#include <vcl/sallayout.hxx> -#include <vcl/salframe.hxx> -#include <vcl/salvd.hxx> -#include <vcl/salprn.hxx> #include <tools/debug.hxx> -#include <vcl/svdata.hxx> +#include <tools/poly.hxx> + #include <vcl/svapp.hxx> #include <vcl/ctrl.hxx> -#include <tools/poly.hxx> #include <vcl/region.hxx> -#include <vcl/region.h> #include <vcl/virdev.hxx> -#include <vcl/window.h> #include <vcl/window.hxx> #include <vcl/metaact.hxx> #include <vcl/gdimtf.hxx> -#include <vcl/outdata.hxx> #include <vcl/print.hxx> -#include <vcl/outdev.h> #include <vcl/outdev.hxx> #include <vcl/unowrap.hxx> +// declare system types in sysdata.hxx +#include <svsys.h> #include <vcl/sysdata.hxx> +#include <salgdi.hxx> +#include <sallayout.hxx> +#include <salframe.hxx> +#include <salvd.hxx> +#include <salprn.hxx> +#include <svdata.hxx> +#include <window.h> +#include <outdev.h> +#include <region.h> +#include <outdata.hxx> + #include <basegfx/point/b2dpoint.hxx> #include <basegfx/vector/b2dvector.hxx> #include <basegfx/polygon/b2dpolygon.hxx> diff --git a/vcl/source/gdi/outdev2.cxx b/vcl/source/gdi/outdev2.cxx index 356542952360..d1a76a9f085b 100644 --- a/vcl/source/gdi/outdev2.cxx +++ b/vcl/source/gdi/outdev2.cxx @@ -29,28 +29,29 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <svsys.h> -#include <vcl/salbmp.hxx> -#include <vcl/salgdi.hxx> -#include <vcl/impbmp.hxx> #include <tools/debug.hxx> + #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/window.hxx> #include <vcl/metaact.hxx> #include <vcl/gdimtf.hxx> #include <vcl/virdev.hxx> -#include <vcl/outdata.hxx> -#include <vcl/outdev.h> #include <vcl/bmpacc.hxx> -#include <vcl/region.h> #include <vcl/outdev.hxx> #include <vcl/window.hxx> -#include <vcl/window.h> -#include <vcl/sallayout.hxx> -#include <vcl/image.h> #include <vcl/image.hxx> -#include <vcl/bmpfast.hxx> + +#include <bmpfast.hxx> +#include <salbmp.hxx> +#include <salgdi.hxx> +#include <impbmp.hxx> +#include <sallayout.hxx> +#include <image.h> +#include <outdev.h> +#include <window.h> +#include <region.h> +#include <outdata.hxx> #define BAND_MAX_SIZE 512000 diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 59242e24a473..31ef2c5a8250 100644..100755 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -31,49 +31,57 @@ #include "i18npool/mslangid.hxx" -#include "svsys.h" -#include "vcl/salgdi.hxx" -#include "vcl/sallayout.hxx" #include "rtl/tencinfo.h" +#include "rtl/logfile.hxx" + #include "tools/debug.hxx" -#include "vcl/svdata.hxx" -#include "vcl/metric.hxx" -#include "vcl/impfont.hxx" -#include "vcl/metaact.hxx" -#include "vcl/gdimtf.hxx" -#include "vcl/outdata.hxx" -#include "vcl/outfont.hxx" +#include "tools/poly.hxx" + #include "basegfx/polygon/b2dpolygon.hxx" #include "basegfx/polygon/b2dpolypolygon.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" -#include "tools/poly.hxx" -#include "vcl/outdev.h" + +#include "vcl/metric.hxx" +#include "vcl/metaact.hxx" +#include "vcl/gdimtf.hxx" #include "vcl/virdev.hxx" #include "vcl/print.hxx" #include "vcl/event.hxx" -#include "vcl/window.h" #include "vcl/window.hxx" #include "vcl/svapp.hxx" #include "vcl/bmpacc.hxx" -#include "unotools/fontcvt.hxx" #include "vcl/outdev.hxx" #include "vcl/edit.hxx" -#include "unotools/fontcfg.hxx" +// declare system types in sysdata.hxx +#include <svsys.h> #include "vcl/sysdata.hxx" -#include "vcl/textlayout.hxx" -#include "vcl/svids.hrc" +#include "vcl/unohelp.hxx" +#include "vcl/controllayout.hxx" + +#include "salgdi.hxx" +#include "sallayout.hxx" +#include "svdata.hxx" +#include "impfont.hxx" +#include "outdata.hxx" +#include "outfont.hxx" +#include "outdev.h" +#include "textlayout.hxx" +#include "svids.hrc" +#include "window.h" + +#include "unotools/fontcvt.hxx" +#include "unotools/fontcfg.hxx" + #include "osl/file.h" + #ifdef ENABLE_GRAPHITE -#include "vcl/graphite_features.hxx" +#include "graphite_features.hxx" #endif #ifdef USE_BUILTIN_RASTERIZER -#include "vcl/glyphcache.hxx" +#include "glyphcache.hxx" #endif -#include "vcl/unohelp.hxx" #include "pdfwriter_impl.hxx" -#include "vcl/controllayout.hxx" -#include "rtl/logfile.hxx" #include "com/sun/star/beans/PropertyValues.hpp" #include "com/sun/star/i18n/XBreakIterator.hpp" diff --git a/vcl/source/gdi/outdev4.cxx b/vcl/source/gdi/outdev4.cxx index 94226e863de5..f3828761bd6f 100644 --- a/vcl/source/gdi/outdev4.cxx +++ b/vcl/source/gdi/outdev4.cxx @@ -29,25 +29,26 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <svsys.h> -#include <vcl/salgdi.hxx> #include <tools/debug.hxx> -#include <vcl/svdata.hxx> +#include <tools/line.hxx> +#include <tools/poly.hxx> + #include <vcl/gradient.hxx> #include <vcl/metaact.hxx> #include <vcl/gdimtf.hxx> -#include <vcl/outdata.hxx> -#include <tools/poly.hxx> #include <vcl/salbtype.hxx> -#include <tools/line.hxx> #include <vcl/hatch.hxx> #include <vcl/window.hxx> #include <vcl/virdev.hxx> #include <vcl/outdev.hxx> #include "pdfwriter_impl.hxx" -#include "vcl/window.h" -#include "vcl/salframe.hxx" + +#include "window.h" +#include "salframe.hxx" +#include "salgdi.hxx" +#include "svdata.hxx" +#include "outdata.hxx" #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> diff --git a/vcl/source/gdi/outdev5.cxx b/vcl/source/gdi/outdev5.cxx index 2df0ff86dc3e..fcf32aff87e6 100644 --- a/vcl/source/gdi/outdev5.cxx +++ b/vcl/source/gdi/outdev5.cxx @@ -30,18 +30,19 @@ #include "precompiled_vcl.hxx" #include <tools/ref.hxx> -#include <svsys.h> -#include <vcl/salgdi.hxx> #include <tools/debug.hxx> -#include <vcl/svdata.hxx> #include <tools/poly.hxx> + #include <vcl/metaact.hxx> #include <vcl/gdimtf.hxx> -#include <vcl/outdata.hxx> -#include <vcl/outdev.h> #include <vcl/outdev.hxx> #include <vcl/virdev.hxx> +#include <salgdi.hxx> +#include <svdata.hxx> +#include <outdata.hxx> +#include <outdev.h> + // ======================================================================= DBG_NAMEEX( OutputDevice ) diff --git a/vcl/source/gdi/outdev6.cxx b/vcl/source/gdi/outdev6.cxx index 92898ebfdf3a..dd2d30642d25 100644 --- a/vcl/source/gdi/outdev6.cxx +++ b/vcl/source/gdi/outdev6.cxx @@ -29,10 +29,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <svsys.h> -#include <vcl/salgdi.hxx> #include <tools/debug.hxx> -#include <vcl/outdev.h> #include <vcl/outdev.hxx> #include <vcl/virdev.hxx> #include <vcl/bmpacc.hxx> @@ -41,16 +38,22 @@ #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> #include <vcl/graph.hxx> -#include <vcl/wall2.hxx> +#include <vcl/rendergraphicrasterizer.hxx> + +#include <wall2.hxx> +#include <salgdi.hxx> +#include <window.h> +#include <svdata.hxx> +#include <outdev.h> + #include <com/sun/star/uno/Sequence.hxx> #include <basegfx/vector/b2dvector.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> + #include <math.h> -#include <vcl/window.h> -#include <vcl/svdata.hxx> // ======================================================================== @@ -1135,6 +1138,7 @@ void OutputDevice::Erase() return; sal_Bool bNativeOK = sal_False; + if( meOutDevType == OUTDEV_WINDOW ) { Window* pWindow = static_cast<Window*>(this); @@ -1185,6 +1189,8 @@ void OutputDevice::ImplDraw2ColorFrame( const Rectangle& rRect, bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, const GfxLink& rGfxLink, GDIMetaFile* pSubst ) { + OSL_TRACE( "OutputDevice::DrawEPS()" ); + bool bDrawn(true); if ( mpMetaFile ) @@ -1203,7 +1209,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() ) { @@ -1238,4 +1244,27 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, return bDrawn; } +// ------------------------------------------------------------------ + +void OutputDevice::DrawRenderGraphic( const Point& rPoint, const Size& rSize, + const ::vcl::RenderGraphic& rRenderGraphic ) +{ + OSL_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; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/outdevnative.cxx b/vcl/source/gdi/outdevnative.cxx index 8449828eb48a..52500a53e24f 100644 --- a/vcl/source/gdi/outdevnative.cxx +++ b/vcl/source/gdi/outdevnative.cxx @@ -31,10 +31,11 @@ #include "vcl/outdev.hxx" #include "vcl/window.hxx" -#include "vcl/salgdi.hxx" #include "vcl/salnativewidgets.hxx" #include "vcl/pdfextoutdevdata.hxx" +#include "salgdi.hxx" + // ----------------------------------------------------------------------- static bool lcl_enableNativeWidget( const OutputDevice& i_rDevice ) diff --git a/vcl/source/gdi/outmap.cxx b/vcl/source/gdi/outmap.cxx index 40c42a071025..a7e138361200 100644 --- a/vcl/source/gdi/outmap.cxx +++ b/vcl/source/gdi/outmap.cxx @@ -31,23 +31,25 @@ #include <limits.h> -#include <svsys.h> #include <tools/bigint.hxx> #include <tools/debug.hxx> -#include <vcl/virdev.hxx> -#include <vcl/svdata.hxx> #include <tools/poly.hxx> + +#include <vcl/virdev.hxx> #include <vcl/region.hxx> -#include <vcl/region.h> -#include <vcl/window.h> #include <vcl/wrkwin.hxx> #include <vcl/cursor.hxx> #include <vcl/metaact.hxx> #include <vcl/gdimtf.hxx> #include <vcl/lineinfo.hxx> #include <vcl/outdev.hxx> -#include <vcl/outdev.h> -#include <vcl/salgdi.hxx> + +#include <svdata.hxx> +#include <region.h> +#include <window.h> +#include <outdev.h> +#include <salgdi.hxx> + #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx index a626bacd9589..868163d5ded8 100644 --- a/vcl/source/gdi/pdfextoutdevdata.cxx +++ b/vcl/source/gdi/pdfextoutdevdata.cxx @@ -32,22 +32,25 @@ #include "vcl/graph.hxx" #include "vcl/outdev.hxx" #include "vcl/gfxlink.hxx" +#include "vcl/dllapi.h" #include "basegfx/polygon/b2dpolygon.hxx" #include "basegfx/polygon/b2dpolygontools.hxx" #include <boost/shared_ptr.hpp> #include <set> +#include <map> namespace vcl { -struct PDFExtOutDevDataSync +struct SAL_DLLPRIVATE PDFExtOutDevDataSync { enum Action{ CreateNamedDest, CreateDest, CreateLink, SetLinkDest, SetLinkURL, + RegisterDest, CreateOutlineItem, SetOutlineItemParent, SetOutlineItemText, @@ -74,7 +77,15 @@ struct PDFExtOutDevDataSync Action eAct; }; -struct GlobalSyncData +struct SAL_DLLPRIVATE PDFLinkDestination +{ + Rectangle mRect; + MapMode mMapMode; + sal_Int32 mPageNr; + PDFWriter::DestAreaType mAreaType; +}; + +struct SAL_DLLPRIVATE GlobalSyncData { std::deque< PDFExtOutDevDataSync::Action > mActions; std::deque< MapMode > mParaMapModes; @@ -85,6 +96,7 @@ struct GlobalSyncData std::deque< PDFWriter::DestAreaType > mParaDestAreaTypes; std::deque< PDFNote > mParaPDFNotes; std::deque< PDFWriter::PageTransition > mParaPageTransitions; + ::std::map< sal_Int32, PDFLinkDestination > mFutureDestinations; sal_Int32 GetMappedId(); sal_Int32 GetMappedStructId( sal_Int32 ); @@ -146,7 +158,7 @@ void GlobalSyncData::PlayGlobalActions( PDFWriter& rWriter ) { switch( *aIter ) { - case PDFExtOutDevDataSync::CreateNamedDest : //i56629 + case PDFExtOutDevDataSync::CreateNamedDest : //i56629 { rWriter.Push( PUSH_MAPMODE ); rWriter.SetMapMode( mParaMapModes.front() ); @@ -198,6 +210,21 @@ void GlobalSyncData::PlayGlobalActions( PDFWriter& rWriter ) mParaOUStrings.pop_front(); } break; + case PDFExtOutDevDataSync::RegisterDest : + { + const sal_Int32 nDestId = mParaInts.front(); + mParaInts.pop_front(); + OSL_ENSURE( mFutureDestinations.find( nDestId ) != mFutureDestinations.end(), + "GlobalSyncData::PlayGlobalActions: DescribeRegisteredRequest has not been called for that destination!" ); + + PDFLinkDestination& rDest = mFutureDestinations[ nDestId ]; + + rWriter.Push( PUSH_MAPMODE ); + rWriter.SetMapMode( rDest.mMapMode ); + mParaIds.push_back( rWriter.RegisterDestReference( nDestId, rDest.mRect, rDest.mPageNr, rDest.mAreaType ) ); + rWriter.Pop(); + } + break; case PDFExtOutDevDataSync::CreateOutlineItem : { sal_Int32 nParent = GetMappedId(); @@ -458,6 +485,7 @@ sal_Bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIM case PDFExtOutDevDataSync::CreateLink: case PDFExtOutDevDataSync::SetLinkDest: case PDFExtOutDevDataSync::SetLinkURL: + case PDFExtOutDevDataSync::RegisterDest: case PDFExtOutDevDataSync::CreateOutlineItem: case PDFExtOutDevDataSync::SetOutlineItemParent: case PDFExtOutDevDataSync::SetOutlineItemText: @@ -616,9 +644,28 @@ sal_Int32 PDFExtOutDevData::CreateNamedDest(const String& sDestName, const Rect mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() ); mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr ); mpGlobalSyncData->mParaDestAreaTypes.push_back( eType ); + return mpGlobalSyncData->mCurId++; } //<---i56629 +sal_Int32 PDFExtOutDevData::RegisterDest() +{ + const sal_Int32 nLinkDestID = mpGlobalSyncData->mCurId++; + mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::RegisterDest ); + mpGlobalSyncData->mParaInts.push_back( nLinkDestID ); + + return nLinkDestID; +} +void PDFExtOutDevData::DescribeRegisteredDest( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType ) +{ + OSL_PRECOND( nDestId != -1, "PDFExtOutDevData::DescribeRegisteredDest: invalid destination Id!" ); + PDFLinkDestination aLinkDestination; + aLinkDestination.mRect = rRect; + aLinkDestination.mMapMode = mrOutDev.GetMapMode(); + aLinkDestination.mPageNr = nPageNr == -1 ? mnPage : nPageNr; + aLinkDestination.mAreaType = eType; + mpGlobalSyncData->mFutureDestinations[ nDestId ] = aLinkDestination; +} sal_Int32 PDFExtOutDevData::CreateDest( const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType ) { mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateDest ); diff --git a/vcl/source/gdi/pdffontcache.cxx b/vcl/source/gdi/pdffontcache.cxx index 2b5944377eac..61499fdc24d8 100644 --- a/vcl/source/gdi/pdffontcache.cxx +++ b/vcl/source/gdi/pdffontcache.cxx @@ -29,9 +29,9 @@ #include "precompiled_vcl.hxx" #include "pdffontcache.hxx" -#include <vcl/salgdi.hxx> -#include <vcl/outfont.hxx> -#include <vcl/sallayout.hxx> +#include <salgdi.hxx> +#include <outfont.hxx> +#include <sallayout.hxx> using namespace vcl; diff --git a/vcl/source/gdi/pdffontcache.hxx b/vcl/source/gdi/pdffontcache.hxx index 30d075d23e42..f607f100c52c 100644 --- a/vcl/source/gdi/pdffontcache.hxx +++ b/vcl/source/gdi/pdffontcache.hxx @@ -31,8 +31,8 @@ #include <sal/types.h> -#include <vcl/sallayout.hxx> -#include <vcl/salgdi.hxx> +#include <sallayout.hxx> +#include <salgdi.hxx> namespace vcl { diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx index 4f56caf6e822..481ad2be3aa4 100644 --- a/vcl/source/gdi/pdfwriter.cxx +++ b/vcl/source/gdi/pdfwriter.cxx @@ -421,6 +421,10 @@ sal_Int32 PDFWriter::CreateLink( const Rectangle& rRect, sal_Int32 nPageNr ) { return ((PDFWriterImpl*)pImplementation)->createLink( rRect, nPageNr ); } +sal_Int32 PDFWriter::RegisterDestReference( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr, DestAreaType eType ) +{ + return ((PDFWriterImpl*)pImplementation)->registerDestReference( nDestId, rRect, nPageNr, eType ); +} //--->i56629 sal_Int32 PDFWriter::CreateNamedDest( const rtl::OUString& sDestName, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType ) { diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index b9d76cd4faa5..91aec0e83ba5 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -34,42 +34,53 @@ #include <algorithm> #include <tools/urlobj.hxx> + #include <pdfwriter_impl.hxx> + #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dpolypolygoncutter.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> + +#include <osl/thread.h> +#include <osl/file.h> + +#include <rtl/crc.h> +#include <rtl/digest.h> #include <rtl/ustrbuf.hxx> + #include <tools/debug.hxx> #include <tools/zcodec.hxx> #include <tools/stream.hxx> + #include <i18npool/mslangid.hxx> + #include <vcl/virdev.hxx> #include <vcl/bmpacc.hxx> #include <vcl/bitmapex.hxx> #include <vcl/image.hxx> -#include <vcl/outdev.h> -#include <vcl/sallayout.hxx> #include <vcl/metric.hxx> -#include <vcl/fontsubset.hxx> -#include <vcl/textlayout.hxx> -#include <vcl/cvtgrf.hxx> -#include <svsys.h> -#include <vcl/salgdi.hxx> #include <vcl/svapp.hxx> -#include <osl/thread.h> -#include <osl/file.h> -#include <rtl/crc.h> -#include <rtl/digest.h> +#include <vcl/lineinfo.hxx> +#include "vcl/cvtgrf.hxx" +#include "vcl/strhelper.hxx" + +#include <fontsubset.hxx> +#include <outdev.h> +#include <sallayout.hxx> +#include <textlayout.hxx> +#include <salgdi.hxx> + +#include <icc/sRGB-IEC61966-2.1.hxx> + #include <comphelper/processfactory.hxx> + #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/util/URL.hpp> + #include "cppuhelper/implbase1.hxx" -#include <icc/sRGB-IEC61966-2.1.hxx> -#include <vcl/lineinfo.hxx> -#include "vcl/strhelper.hxx" using namespace vcl; @@ -5582,7 +5593,7 @@ bool PDFWriterImpl::emitWidgetAnnotations() if(!m_bIsPDF_A1) { OStringBuffer aDest; - if( rWidget.m_nDest != -1 && appendDest( rWidget.m_nDest, aDest ) ) + if( rWidget.m_nDest != -1 && appendDest( m_aDestinationIdTranslation[ rWidget.m_nDest ], aDest ) ) { aLine.append( "/AA<</D<</Type/Action/S/GoTo/D " ); aLine.append( aDest.makeStringAndClear() ); @@ -10819,6 +10830,11 @@ sal_Int32 PDFWriterImpl::createDest( const Rectangle& rRect, sal_Int32 nPageNr, return nRet; } +sal_Int32 PDFWriterImpl::registerDestReference( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType ) +{ + return m_aDestinationIdTranslation[ nDestId ] = createDest( rRect, nPageNr, eType ); +} + sal_Int32 PDFWriterImpl::setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId ) { if( nLinkId < 0 || nLinkId >= (sal_Int32)m_aLinks.size() ) diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index a8ae5164d385..8649beff6ceb 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -38,7 +38,7 @@ #include "vcl/gradient.hxx" #include "vcl/hatch.hxx" #include "vcl/wall.hxx" -#include "vcl/outdata.hxx" +#include "outdata.hxx" #include "rtl/strbuf.hxx" #include "rtl/cipher.h" #include "rtl/digest.h" @@ -46,7 +46,7 @@ #include "com/sun/star/lang/Locale.hpp" #include <sal/macros.h> -#include <vcl/sallayout.hxx> +#include <sallayout.hxx> #include "pdffontcache.hxx" #include <vector> @@ -613,6 +613,9 @@ private: dest id is always the dest's position in this vector */ std::vector<PDFDest> m_aDests; + /** contains destinations accessible via a public Id, instead of being linked to by an ordinary link + */ + ::std::map< sal_Int32, sal_Int32 > m_aDestinationIdTranslation; /* contains all links ever set during PDF creation, link id is always the link's position in this vector */ @@ -1279,6 +1282,7 @@ public: // links sal_Int32 createLink( const Rectangle& rRect, sal_Int32 nPageNr = -1 ); sal_Int32 createDest( const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ ); + sal_Int32 registerDestReference( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ ); sal_Int32 setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId ); sal_Int32 setLinkURL( sal_Int32 nLinkId, const rtl::OUString& rURL ); void setLinkPropertyId( sal_Int32 nLinkId, sal_Int32 nPropertyId ); diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index caa19380394c..17b684e6a675 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -35,9 +35,13 @@ #include "vcl/metaact.hxx" #include "vcl/bmpacc.hxx" #include "vcl/graph.hxx" -#include "vcl/svdata.hxx" +#include "vcl/rendergraphicrasterizer.hxx" + +#include "svdata.hxx" + #include "unotools/streamwrap.hxx" #include "unotools/processfactory.hxx" + #include "comphelper/processfactory.hxx" #include "com/sun/star/beans/PropertyValue.hpp" @@ -1044,6 +1048,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/polyscan.cxx b/vcl/source/gdi/polyscan.cxx deleted file mode 100644 index 81d05bf33354..000000000000 --- a/vcl/source/gdi/polyscan.cxx +++ /dev/null @@ -1,361 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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 "precompiled_vcl.hxx" - -#include <string.h> -#include <tools/new.hxx> -#include <vcl/salbtype.hxx> -#include "polyscan.hxx" -#include <tools/poly.hxx> - -// ---------------- -// - PolyScanline - -// ---------------- - -PolyScanline::PolyScanline() : - mpFirst ( NULL ), - mpLast ( NULL ), - mpAct ( NULL ), - mnLeft ( 0L ), - mnRight ( 0L ) -{ -} - -// ------------------------------------------------------------------------ - -PolyScanline::~PolyScanline() -{ - ImplDelete(); -} - -// ------------------------------------------------------------------------ - -void PolyScanline::ImplDelete() -{ - ScanlinePoint* pAct = mpFirst; - - while( pAct ) - { - ScanlinePoint* pNext = pAct->mpNext; - delete pAct; - pAct = pNext; - } - - mnLeft = mnRight = 0L; - mpFirst = mpAct = mpLast = NULL; -} - -// ------------------------------------------------------------------------ - -void PolyScanline::Insert( long nX ) -{ - // first point to insert? - if( !mpFirst ) - mpLast = mpFirst = new ScanlinePoint( mnLeft = mnRight = nX, NULL ); - else - { - // insert at the beginning of the scanline - if( nX <= mpFirst->mnX ) - mpFirst = new ScanlinePoint( mnLeft = nX, mpFirst ); - else if( nX >= mnRight ) - mpLast = mpLast->mpNext = new ScanlinePoint( mnRight = nX, NULL ); - else - { - ScanlinePoint* pLast = mpFirst; - ScanlinePoint* pAct = mpFirst->mpNext; - - while( pAct ) - { - // insert in the midlle of the scanline? - if( nX <= pAct->mnX ) - { - pLast->mpNext = new ScanlinePoint( nX, pAct ); - break; - } - - pLast = pAct; - pAct = pAct->mpNext; - } - } - } -} - -// ------------------------------------------------------------------------ - -void PolyScanline::Set( long nStart, long nEnd ) -{ - if( mpFirst ) - ImplDelete(); - - if( nStart <= nEnd ) - mpFirst = new ScanlinePoint( mnLeft = nStart, mpLast = new ScanlinePoint( mnRight = nEnd, NULL ) ); - else - mpFirst = new ScanlinePoint( mnLeft = nEnd, mpLast = new ScanlinePoint( mnRight = nStart, NULL ) ); -} - -// ------------------------------------------------------------------------ - -sal_Bool PolyScanline::GetFirstSegment( PolyScanSegment& rSegment ) -{ - sal_Bool bRet = GetFirstX( rSegment.mnStart ); - - if( bRet && !GetNextX( rSegment.mnEnd ) ) - rSegment.mnEnd = rSegment.mnStart; - - return bRet; -} - -// ------------------------------------------------------------------------ - -sal_Bool PolyScanline::GetNextSegment( PolyScanSegment& rSegment ) -{ - sal_Bool bRet = GetNextX( rSegment.mnStart ); - - if( bRet && !GetNextX( rSegment.mnEnd ) ) - rSegment.mnEnd = rSegment.mnStart; - - return bRet; -} - -// --------------- -// - PolyScanner - -// --------------- - -PolyScanner::PolyScanner( const Rectangle& rRect ) -{ - if( !rRect.IsEmpty() ) - { - Rectangle aRect( rRect ); - sal_uLong nHeight; - - aRect.Justify(); - mnLeft = aRect.Left(); - mnTop = aRect.Top(); - mnRight = aRect.Right(); - mnBottom = aRect.Bottom(); - mpArray = new PolyScanline[ nHeight = Height() ]; - - for( sal_uLong i = 0UL; i < nHeight; i++ ) - mpArray[ i ].Set( mnLeft, mnRight ); - } - else - { - mnLeft = mnTop = mnRight = mnBottom = 0L; - mpArray = NULL; - } -} - -// ------------------------------------------------------------------------ - -PolyScanner::PolyScanner( const Polygon& rPoly ) -{ - const long nCount = rPoly.GetSize(); - - if( nCount ) - { - long nLast = nCount - 1; - Point aFirst( rPoly[ 0 ] ); - Point aLast( rPoly[ (sal_uInt16) nLast ] ); - - while( nLast && ( aLast == aFirst ) ) - aLast = rPoly[ (sal_uInt16) --nLast ]; - - if( !nLast ) - { - aLast = rPoly[ 0 ]; - mnLeft = mnRight = aLast.X(); - mnTop = mnBottom = aLast.Y(); - mpArray = new PolyScanline[ 1UL ]; - mpArray[ 0 ].Set( mnLeft, mnRight ); - } - else - { - const Rectangle aRect( rPoly.GetBoundRect() ); - sal_uLong nHeight; - - mnLeft = aRect.Left(); - mnTop = aRect.Top(); - mnRight = aRect.Right(); - mnBottom = aRect.Bottom(); - aLast = aFirst; - mpArray = new PolyScanline[ nHeight = Height() ]; - - for( long i = 1L; i <= nLast; i++ ) - { - const Point& rPt = rPoly[ (sal_uInt16) i ]; - - if( rPt != aLast ) - { - InsertLine( aLast, rPt ); - aLast = rPt; - } - } - - InsertLine( aLast, aFirst ); - } - } - else - mpArray = NULL; -} - -// ------------------------------------------------------------------------ - -PolyScanner::PolyScanner( const PolyPolygon& rPolyPoly ) -{ - mpArray = NULL; -} - -// ------------------------------------------------------------------------ - -PolyScanner::~PolyScanner() -{ - delete[] mpArray; -} - -// ------------------------------------------------------------------------ - -PolyScanline* PolyScanner::operator[]( sal_uLong nPos ) const -{ - DBG_ASSERT( nPos < Count(), "nPos out of range!" ); - return( mpArray ? ( mpArray + nPos ) : NULL ); -} - -// ------------------------------------------------------------------------ - -void PolyScanner::InsertLine( const Point& rStart, const Point& rEnd ) -{ - long nX, nY; - - if( rStart.Y() == rEnd.Y() ) - mpArray[ rStart.Y() - mnTop ].Insert( rStart.X() ); - else if( rStart.X() == rEnd.X() ) - { - // vertical line - const long nEndY = rEnd.Y(); - - nX = rStart.X(); - nY = rStart.Y(); - - if( nEndY > nY ) - while( nY < nEndY ) - mpArray[ nY++ - mnTop ].Insert( nX ); - else - while( nY > nEndY ) - mpArray[ nY-- - mnTop ].Insert( nX ); - } - else - { - const long nDX = labs( rEnd.X() - rStart.X() ); - const long nDY = labs( rEnd.Y() - rStart.Y() ); - const long nStartX = rStart.X(); - const long nStartY = rStart.Y(); - const long nEndX = rEnd.X(); - const long nEndY = rEnd.Y(); - const long nXInc = ( nStartX < nEndX ) ? 1L : -1L; - const long nYInc = ( nStartY < nEndY ) ? 1L : -1L; - long nLastX = nStartX; - long nLastY = nStartY; - sal_Bool bLast = sal_False; - - mpArray[ nStartY - mnTop ].Insert( nStartX ); - - if( nDX >= nDY ) - { - const long nDYX = ( nDY - nDX ) << 1; - const long nDY2 = nDY << 1; - long nD = nDY2 - nDX; - - for( nX = nStartX, nY = nLastY = nStartY; nX != nEndX; ) - { - if( nY != nLastY ) - { - if( bLast ) - mpArray[ nLastY - mnTop ].Insert( nLastX ); - - mpArray[ nY - mnTop ].Insert( nX ); - bLast = sal_False; - } - else - bLast = sal_True; - - nLastX = nX; - nLastY = nY; - - if( nD < 0L ) - nD += nDY2; - else - { - nD += nDYX; - nY += nYInc; - } - - nX += nXInc; - } - } - else - { - const long nDYX = ( nDX - nDY ) << 1; - const long nDY2 = nDX << 1; - long nD = nDY2 - nDY; - - for( nX = nStartX, nY = nStartY; nY != nEndY; ) - { - if( nY != nLastY ) - { - if( bLast ) - mpArray[ nLastY - mnTop ].Insert( nLastX ); - - mpArray[ nY - mnTop ].Insert( nX ); - bLast = sal_False; - } - else - bLast = sal_True; - - nLastX = nX; - nLastY = nY; - - if( nD < 0L ) - nD += nDY2; - else - { - nD += nDYX; - nX += nXInc; - } - - nY += nYInc; - } - } - - if( bLast ) - mpArray[ nLastY - mnTop ].Insert( nLastX ); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 15964d9da09f..4c9461fbcb97 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -32,29 +32,29 @@ #define ENABLE_BYTESTRING_STREAM_OPERATORS #include <list> -#include <svsys.h> -#include <vcl/salinst.hxx> -#include <vcl/salgdi.hxx> -#include <vcl/salptype.hxx> -#include <vcl/salprn.hxx> - -#include <vcl/unohelp.hxx> #include <tools/debug.hxx> #include <tools/resary.hxx> #include <tools/stream.hxx> #include <tools/vcompat.hxx> -#include <vcl/svdata.hxx> + +#include <vcl/unohelp.hxx> #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> -#include <vcl/jobset.h> -#include <vcl/outdev.h> #include <vcl/virdev.hxx> #include <vcl/window.hxx> -#include <vcl/print.h> #include <vcl/gdimtf.hxx> #include <vcl/metaact.hxx> #include <vcl/print.hxx> -#include <vcl/svids.hrc> + +#include <salinst.hxx> +#include <salgdi.hxx> +#include <salptype.hxx> +#include <salprn.hxx> +#include <svdata.hxx> +#include <svids.hrc> +#include <jobset.h> +#include <outdev.h> +#include <print.h> #include <comphelper/processfactory.hxx> diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index 1f160dc3bbb9..add5071ef2dd 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -34,18 +34,22 @@ #include <utility> #include <list> #include <vector> + #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> + #include <tools/debug.hxx> + #include <vcl/virdev.hxx> #include <vcl/metaact.hxx> #include <vcl/gdimtf.hxx> -#include <vcl/print.h> #include <vcl/salbtype.hxx> #include <vcl/print.hxx> #include <vcl/svapp.hxx> -#include <vcl/sallayout.hxx> #include <vcl/bmpacc.hxx> +#include <vcl/rendergraphicrasterizer.hxx> + +#include <print.h> #include "pdfwriter_impl.hxx" @@ -112,6 +116,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; } @@ -199,6 +206,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: @@ -266,6 +283,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: OSL_FAIL("Unexpected case"); break; @@ -378,6 +400,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; @@ -630,7 +653,14 @@ static Rectangle ImplCalcActionBounds( const MetaAction& rAct, const OutputDevic case META_TEXTLINE_ACTION: OSL_FAIL("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; @@ -657,6 +687,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/print3.cxx b/vcl/source/gdi/print3.cxx index a769e948372a..61a40af43bdd 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -29,16 +29,17 @@ #include "precompiled_vcl.hxx" #include "vcl/print.hxx" -#include "vcl/prndlg.hxx" #include "vcl/svapp.hxx" -#include "vcl/svdata.hxx" -#include "vcl/salinst.hxx" -#include "vcl/salprn.hxx" -#include "vcl/svids.hrc" #include "vcl/metaact.hxx" #include "vcl/msgbox.hxx" #include "vcl/configsettings.hxx" +#include "printdlg.hxx" +#include "svdata.hxx" +#include "salinst.hxx" +#include "salprn.hxx" +#include "svids.hrc" + #include "tools/urlobj.hxx" #include "com/sun/star/ui/dialogs/XFilePicker.hpp" diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx index 480a17a9f88b..3992b774630d 100644 --- a/vcl/source/gdi/region.cxx +++ b/vcl/source/gdi/region.cxx @@ -30,14 +30,15 @@ #include "precompiled_vcl.hxx" #include <limits.h> + #include <tools/vcompat.hxx> -#include <vcl/salbtype.hxx> #include <tools/stream.hxx> #include <tools/debug.hxx> -#include <vcl/region.h> #include <vcl/region.hxx> #include <vcl/regband.hxx> +#include <region.h> + #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> 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/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index 9fa4d813b2b7..bf0f7523a453 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -30,28 +30,31 @@ #include "precompiled_vcl.hxx" #include <tools/ref.hxx> -#include <svsys.h> -#include <vcl/salgdi.hxx> -#include <vcl/salframe.hxx> -#include <vcl/salvd.hxx> -#include <vcl/salprn.hxx> #include <tools/debug.hxx> -#include <vcl/svdata.hxx> -#include <vcl/svapp.hxx> #include <tools/poly.hxx> + +#include <vcl/svapp.hxx> #include <vcl/region.hxx> -#include <vcl/region.h> #include <vcl/virdev.hxx> -#include <vcl/window.h> #include <vcl/window.hxx> #include <vcl/metaact.hxx> #include <vcl/gdimtf.hxx> -#include <vcl/outdata.hxx> #include <vcl/print.hxx> -#include <vcl/outdev.h> #include <vcl/outdev.hxx> #include <vcl/unowrap.hxx> -#include <vcl/sallayout.hxx> + +#include <window.h> +#include <region.h> +#include <outdev.h> +#include <sallayout.hxx> +#include <salgdi.hxx> +#include <salframe.hxx> +#include <salvd.hxx> +#include <salprn.hxx> +#include <svdata.hxx> +#include <outdata.hxx> + + #include "basegfx/polygon/b2dpolygon.hxx" // ---------------------------------------------------------------------------- diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 970b0ff3cd0b..9679170df9b9 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -35,12 +35,12 @@ #include <math.h> #include <sal/alloca.h> -#include <svsys.h> -#include <vcl/salgdi.hxx> -#include <vcl/sallayout.hxx> +#include <salgdi.hxx> +#include <sallayout.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> + #include <i18npool/lang.h> #include <tools/debug.hxx> diff --git a/vcl/source/gdi/salmisc.cxx b/vcl/source/gdi/salmisc.cxx index 3a9bd669f54f..d2b794af02d6 100644 --- a/vcl/source/gdi/salmisc.cxx +++ b/vcl/source/gdi/salmisc.cxx @@ -31,7 +31,7 @@ #include <rtl/memory.h> #include <vcl/bmpacc.hxx> #include <vcl/salbtype.hxx> -#include <vcl/bmpfast.hxx> +#include <bmpfast.hxx> // ----------- // - Defines - diff --git a/vcl/source/gdi/salnativewidgets-none.cxx b/vcl/source/gdi/salnativewidgets-none.cxx index cc204069c2c4..8f50802c9431 100644 --- a/vcl/source/gdi/salnativewidgets-none.cxx +++ b/vcl/source/gdi/salnativewidgets-none.cxx @@ -29,7 +29,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <vcl/salgdi.hxx> +#include <salgdi.hxx> using ::rtl::OUString; diff --git a/vcl/source/gdi/svcompat.cxx b/vcl/source/gdi/svcompat.cxx deleted file mode 100644 index c594dd1f93d7..000000000000 --- a/vcl/source/gdi/svcompat.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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 "precompiled_vcl.hxx" -#include <tools/stream.hxx> -#include <svcompat.hxx> - -// -------------- -// - ImplCompat - -// -------------- - -ImplCompat::ImplCompat( SvStream& rStm, sal_uInt16 nStreamMode, sal_uInt16 nVersion ) : - mpRWStm ( &rStm ), - mnStmMode ( nStreamMode ), - mnVersion ( nVersion ) -{ - if( !mpRWStm->GetError() ) - { - if( STREAM_WRITE == mnStmMode ) - { - *mpRWStm << mnVersion; - mnTotalSize = ( mnCompatPos = mpRWStm->Tell() ) + 4UL; - mpRWStm->SeekRel( 4L ); - } - else - { - *mpRWStm >> mnVersion; - *mpRWStm >> mnTotalSize; - mnCompatPos = mpRWStm->Tell(); - } - } -} - -// ------------------------------------------------------------------------ - -ImplCompat::~ImplCompat() -{ - if( STREAM_WRITE == mnStmMode ) - { - const sal_uInt32 nEndPos = mpRWStm->Tell(); - - mpRWStm->Seek( mnCompatPos ); - *mpRWStm << ( nEndPos - mnTotalSize ); - mpRWStm->Seek( nEndPos ); - } - else - { - const sal_uInt32 nReadSize = mpRWStm->Tell() - mnCompatPos; - - if( mnTotalSize > nReadSize ) - mpRWStm->SeekRel( mnTotalSize - nReadSize ); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 diff --git a/vcl/source/gdi/textlayout.cxx b/vcl/source/gdi/textlayout.cxx index 1afa8840fcf3..e1a2667a8f58 100644 --- a/vcl/source/gdi/textlayout.cxx +++ b/vcl/source/gdi/textlayout.cxx @@ -31,8 +31,9 @@ #include "vcl/ctrl.hxx" #include "vcl/outdev.hxx" -#include "vcl/outfont.hxx" -#include "vcl/textlayout.hxx" + +#include "outfont.hxx" +#include "textlayout.hxx" #include <com/sun/star/i18n/ScriptDirection.hpp> diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index 981fc38b7375..5e693d23abf5 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -29,19 +29,20 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <svsys.h> -#include <vcl/salinst.hxx> -#include <vcl/salgdi.hxx> -#include <vcl/salframe.hxx> -#include <vcl/salvd.hxx> #include <tools/debug.hxx> -#include <vcl/svdata.hxx> + #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> -#include <vcl/outdev.h> #include <vcl/virdev.hxx> +#include <salinst.hxx> +#include <salgdi.hxx> +#include <salframe.hxx> +#include <salvd.hxx> +#include <outdev.h> +#include <svdata.hxx> + using namespace ::com::sun::star::uno; // ======================================================================= diff --git a/vcl/source/gdi/wall.cxx b/vcl/source/gdi/wall.cxx index 600f78941cbe..a24d3b0cbd66 100644 --- a/vcl/source/gdi/wall.cxx +++ b/vcl/source/gdi/wall.cxx @@ -28,17 +28,20 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" + #include <tools/stream.hxx> #include <tools/vcompat.hxx> #include <tools/debug.hxx> + #include <vcl/bitmapex.hxx> #include <vcl/gradient.hxx> #include <vcl/wall.hxx> -#include <vcl/wall2.hxx> #include <vcl/svapp.hxx> +#include <wall2.hxx> + -DBG_NAME( Wallpaper ); +DBG_NAME( Wallpaper ) // ----------------------------------------------------------------------- |