update dev300-m58
[ooovba.git] / applied_patches / 0485-emf+-vcl-renderer.diff
blob9b7442cce3042c1bdb4bae9fd8d54a254cd86594
1 --- vcl/inc/vcl/gdimtf.hxx.old 2009-04-02 10:44:25.000000000 +0000
2 +++ vcl/inc/vcl/gdimtf.hxx 2009-04-06 16:42:16.000000000 +0000
3 @@ -138,6 +138,7 @@ private:
4 const OutputDevice& rMapDev,
5 const PolyPolygon& rPolyPoly,
6 const Gradient& rGrad );
7 + SAL_DLLPRIVATE bool ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, Size rDestSize );
9 //#endif // __PRIVATE
11 --- vcl/source/gdi/gdimtf.cxx.old 2009-04-02 10:44:19.000000000 +0000
12 +++ vcl/source/gdi/gdimtf.cxx 2009-04-06 16:42:16.000000000 +0000
13 @@ -38,12 +38,24 @@
14 #include <vcl/salbtype.hxx>
15 #include <vcl/outdev.hxx>
16 #include <vcl/window.hxx>
17 -#ifndef _SV_CVTSVM_HXX
18 #include <vcl/cvtsvm.hxx>
19 -#endif
20 #include <vcl/virdev.hxx>
21 +#include <vcl/salbmp.hxx>
22 +#include <vcl/svapp.hxx>
23 +#include <vcl/svdata.hxx>
24 +#include <vcl/salinst.hxx>
25 #include <vcl/gdimtf.hxx>
26 #include <vcl/graphictools.hxx>
27 +#include <vcl/canvastools.hxx>
28 +#include <vcl/unohelp.hxx>
30 +#include <com/sun/star/beans/XFastPropertySet.hpp>
31 +#include <com/sun/star/rendering/XCanvas.hpp>
32 +#include <com/sun/star/rendering/MtfRenderer.hpp>
33 +#include <comphelper/processfactory.hxx>
34 +#include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 +using namespace com::sun::star;
38 // -----------
39 // - Defines -
40 @@ -478,6 +490,76 @@ void GDIMetaFile::Play( OutputDevice* pO
42 // ------------------------------------------------------------------------
44 +bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, Size rDestSize )
46 + const Window* win = dynamic_cast <Window*> ( pOut );
48 + if (!win)
49 + win = Application::GetActiveTopWindow();
50 + if (!win)
51 + win = Application::GetFirstTopLevelWindow();
53 + if (win) {
54 + const uno::Reference<rendering::XCanvas>& xCanvas = win->GetCanvas ();
55 + Size aSize (rDestSize.Width () + 1, rDestSize.Height () + 1);
56 + const uno::Reference<rendering::XBitmap>& xBitmap = xCanvas->getDevice ()->createCompatibleAlphaBitmap (vcl::unotools::integerSize2DFromSize( aSize));
57 + uno::Reference< lang::XMultiServiceFactory > xFactory = vcl::unohelper::GetMultiServiceFactory();
58 + if( xFactory.is() && xBitmap.is () ) {
59 + uno::Reference< rendering::XMtfRenderer > xMtfRenderer;
60 + uno::Sequence< uno::Any > args (1);
61 + uno::Reference< rendering::XBitmapCanvas > xBitmapCanvas( xBitmap, uno::UNO_QUERY );
62 + if( xBitmapCanvas.is() ) {
63 + args[0] = uno::Any( xBitmapCanvas );
64 + xMtfRenderer.set( xFactory->createInstanceWithArguments( ::rtl::OUString::createFromAscii( "com.sun.star.rendering.MtfRenderer" ),
65 + args ), uno::UNO_QUERY );
67 + if( xMtfRenderer.is() ) {
68 + xBitmapCanvas->clear();
69 + uno::Reference< beans::XFastPropertySet > xMtfFastPropertySet( xMtfRenderer, uno::UNO_QUERY );
70 + if( xMtfFastPropertySet.is() )
71 + // set this metafile to the renderer to
72 + // speedup things (instead of copying data to
73 + // sequence of bytes passed to renderer)
74 + xMtfFastPropertySet->setFastPropertyValue( 0, uno::Any( reinterpret_cast<sal_Int64>( this ) ) );
76 + xMtfRenderer->draw( rDestSize.Width(), rDestSize.Height() );
78 + uno::Reference< beans::XFastPropertySet > xFastPropertySet( xBitmapCanvas, uno::UNO_QUERY );
79 + if( xFastPropertySet.get() ) {
80 + // 0 means get BitmapEx
81 + uno::Any aAny = xFastPropertySet->getFastPropertyValue( 0 );
82 + BitmapEx* pBitmapEx = (BitmapEx*) *reinterpret_cast<const sal_Int64*>(aAny.getValue());
83 + if( pBitmapEx ) {
84 + pOut->DrawBitmapEx( rPos, *pBitmapEx );
85 + delete pBitmapEx;
86 + return true;
87 + }
88 + }
90 + SalBitmap* pSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
91 + SalBitmap* pSalMask = ImplGetSVData()->mpDefInst->CreateSalBitmap();
93 + if( pSalBmp->Create( xBitmapCanvas, aSize ) && pSalMask->Create( xBitmapCanvas, aSize, true ) ) {
94 + Bitmap aBitmap( pSalBmp );
95 + Bitmap aMask( pSalMask );
96 + AlphaMask aAlphaMask( aMask );
97 + BitmapEx aBitmapEx( aBitmap, aAlphaMask );
98 + pOut->DrawBitmapEx( rPos, aBitmapEx );
99 + return true;
102 + delete pSalBmp;
103 + delete pSalMask;
109 + return false;
112 +// ------------------------------------------------------------------------
114 void GDIMetaFile::Play( OutputDevice* pOut, const Point& rPos,
115 const Size& rSize, ULONG nPos )
117 @@ -487,8 +569,12 @@ void GDIMetaFile::Play( OutputDevice* pO
119 if( aDestSize.Width() && aDestSize.Height() )
121 - Size aTmpPrefSize( pOut->LogicToPixel( GetPrefSize(), aDrawMap ) );
122 - GDIMetaFile* pMtf = pOut->GetConnectMetaFile();
123 + GDIMetaFile* pMtf = pOut->GetConnectMetaFile();
125 + if( !pMtf && ImplPlayWithRenderer( pOut, rPos, aDestSize ) )
126 + return;
128 + Size aTmpPrefSize( pOut->LogicToPixel( GetPrefSize(), aDrawMap ) );
130 if( !aTmpPrefSize.Width() )
131 aTmpPrefSize.Width() = aDestSize.Width();
132 --- vcl/source/gdi/makefile.mk.old 2009-04-06 16:41:56.000000000 +0000
133 +++ vcl/source/gdi/makefile.mk 2009-04-06 16:42:16.000000000 +0000
134 @@ -118,6 +118,7 @@ EXCEPTIONSFILES= $(SLO)$/salmisc.obj \
135 $(SLO)$/bitmapex.obj \
136 $(SLO)$/outdev.obj \
137 $(SLO)$/outdev3.obj \
138 + $(SLO)$/gdimtf.obj \
139 $(SLO)$/gfxlink.obj \
140 $(SLO)$/print.obj \
141 $(SLO)$/print2.obj \
142 --- vcl/source/gdi/metaact.cxx.old 2009-04-02 10:44:19.000000000 +0000
143 +++ vcl/source/gdi/metaact.cxx 2009-04-06 16:42:16.000000000 +0000
144 @@ -4093,8 +4093,34 @@ void MetaCommentAction::Scale( double fX
146 delete[] mpData;
147 ImplInitDynamicData( static_cast<const BYTE*>( aDest.GetData() ), aDest.Tell() );
150 + } else if( maComment.Equals( "EMF_PLUS_HEADER_INFO" ) ) {
151 + SvMemoryStream aMemStm( (void*)mpData, mnDataSize, STREAM_READ );
152 + SvMemoryStream aDest;
154 + sal_Int32 nLeft, nRight, nTop, nBottom;
155 + sal_Int32 nPixX, nPixY, nMillX, nMillY;
156 + float m11, m12, m21, m22, mdx, mdy;
158 + // read data
159 + aMemStm >> nLeft >> nTop >> nRight >> nBottom;
160 + aMemStm >> nPixX >> nPixY >> nMillX >> nMillY;
161 + aMemStm >> m11 >> m12 >> m21 >> m22 >> mdx >> mdy;
163 + // add scale to the transformation
164 + m11 *= fXScale;
165 + m12 *= fXScale;
166 + m22 *= fYScale;
167 + m21 *= fYScale;
169 + // prepare new data
170 + aDest << nLeft << nTop << nRight << nBottom;
171 + aDest << nPixX << nPixY << nMillX << nMillY;
172 + aDest << m11 << m12 << m21 << m22 << mdx << mdy;
174 + // save them
175 + ImplInitDynamicData( static_cast<const BYTE*>( aDest.GetData() ), aDest.Tell() );