update dev300-m58
[ooovba.git] / applied_patches / 0395-wmf-pattern-brush.diff
blob856a53bbe231550aec036117d3098c0de2be0c53
1 --- svtools/source/filter.vcl/wmf/enhwmf.cxx.old 2009-04-02 11:06:17.000000000 +0000
2 +++ svtools/source/filter.vcl/wmf/enhwmf.cxx 2009-04-06 16:42:11.000000000 +0000
3 @@ -870,7 +870,10 @@ BOOL EnhWMFReader::ReadEnhWMF()
4 Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
5 aBitmap.Crop( aCropRect );
7 - aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop ), LIST_APPEND );
8 + /* Pseudocomment to add more context so that make patch.unapply
9 + * works better. Ha!
10 + */
11 + aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ), LIST_APPEND );
15 @@ -924,7 +927,8 @@ BOOL EnhWMFReader::ReadEnhWMF()
16 Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
17 aBitmap.Crop( aCropRect );
19 - aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop ), LIST_APPEND );
20 + /* Another pseudocomment to make make patch.unapply work better */
21 + aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ), LIST_APPEND );
25 @@ -1195,6 +1199,54 @@ BOOL EnhWMFReader::ReadEnhWMF()
27 break;
29 + case EMR_CREATEDIBPATTERNBRUSHPT :
30 + {
31 + static int count = 0;
32 + UINT32 nStart = pWMF->Tell() - 8;
33 + Bitmap aBitmap;
35 + *pWMF >> nIndex;
37 + if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
38 + {
39 + UINT32 usage, offBmi, cbBmi, offBits, cbBits;
41 + *pWMF >> usage;
42 + *pWMF >> offBmi;
43 + *pWMF >> cbBmi;
44 + *pWMF >> offBits;
45 + *pWMF >> cbBits;
47 + if ( (cbBits > (SAL_MAX_UINT32 - 14)) || ((SAL_MAX_UINT32 - 14) - cbBits < cbBmi) )
48 + bStatus = FALSE;
49 + else if ( offBmi )
50 + {
51 + UINT32 nSize = cbBmi + cbBits + 14;
52 + if ( nSize <= ( nEndPos - nStartPos ) )
53 + {
54 + char* pBuf = new char[ nSize ];
56 + SvMemoryStream aTmp( pBuf, nSize, STREAM_READ | STREAM_WRITE );
57 + aTmp.ObjectOwnsMemory( TRUE );
58 + aTmp << (BYTE)'B'
59 + << (BYTE)'M'
60 + << (UINT32)cbBits
61 + << (UINT16)0
62 + << (UINT16)0
63 + << (UINT32)cbBmi + 14;
64 + pWMF->Seek( nStart + offBmi );
65 + pWMF->Read( pBuf + 14, cbBmi );
66 + pWMF->Seek( nStart + offBits );
67 + pWMF->Read( pBuf + 14 + cbBmi, cbBits );
68 + aTmp.Seek( 0 );
69 + aBitmap.Read( aTmp, TRUE );
70 + }
71 + }
72 + }
74 + pOut->CreateObject( nIndex, GDI_BRUSH, new WinMtfFillStyle( aBitmap ) );
75 + }
76 + break;
78 #ifdef WIN_MTF_ASSERT
79 default : WinMtfAssertHandler( "Unknown Meta Action" ); break;
80 @@ -1214,7 +1266,6 @@ BOOL EnhWMFReader::ReadEnhWMF()
81 case EMR_ANGLEARC : WinMtfAssertHandler( "AngleArc" ); break;
82 case EMR_SETCOLORADJUSTMENT : WinMtfAssertHandler( "SetColorAdjustment" ); break;
83 case EMR_POLYDRAW16 : WinMtfAssertHandler( "PolyDraw16" ); break;
84 - case EMR_CREATEDIBPATTERNBRUSHPT : WinMtfAssertHandler( "CreateDibPatternBrushPt" ); break;
85 case EMR_POLYTEXTOUTA : WinMtfAssertHandler( "PolyTextOutA" ); break;
86 case EMR_POLYTEXTOUTW : WinMtfAssertHandler( "PolyTextOutW" ); break;
87 case EMR_CREATECOLORSPACE : WinMtfAssertHandler( "CreateColorSpace" ); break;
88 --- svtools/source/filter.vcl/wmf/winmtf.cxx.old 2009-04-02 11:06:17.000000000 +0000
89 +++ svtools/source/filter.vcl/wmf/winmtf.cxx 2009-04-06 16:42:11.000000000 +0000
90 @@ -34,6 +34,7 @@
92 #include "winmtf.hxx"
93 #include <vcl/metaact.hxx>
94 +#include <vcl/graphictools.hxx>
95 #include <vcl/metric.hxx>
96 #include <rtl/tencinfo.h>
98 @@ -1037,7 +1038,8 @@ void WinMtfOutput::UpdateFillStyle()
99 if (!( maLatestFillStyle == maFillStyle ) )
101 maLatestFillStyle = maFillStyle;
102 - mpGDIMetaFile->AddAction( new MetaFillColorAction( maFillStyle.aFillColor, !maFillStyle.bTransparent ) );
103 + if (maFillStyle.aType == FillStyleSolid)
104 + mpGDIMetaFile->AddAction( new MetaFillColorAction( maFillStyle.aFillColor, !maFillStyle.bTransparent ) );
108 @@ -1365,7 +1367,35 @@ void WinMtfOutput::DrawPolygon( Polygon&
109 else
111 UpdateLineStyle();
112 - mpGDIMetaFile->AddAction( new MetaPolygonAction( rPolygon ) );
114 + if (maLatestFillStyle.aType != FillStylePattern)
115 + mpGDIMetaFile->AddAction( new MetaPolygonAction( rPolygon ) );
116 + else {
117 + SvtGraphicFill aFill = SvtGraphicFill( PolyPolygon( rPolygon ),
118 + Color(),
119 + 0.0,
120 + SvtGraphicFill::fillNonZero,
121 + SvtGraphicFill::fillTexture,
122 + SvtGraphicFill::Transform(),
123 + true,
124 + SvtGraphicFill::hatchSingle,
125 + Color(),
126 + SvtGraphicFill::gradientLinear,
127 + Color(),
128 + Color(),
129 + 0,
130 + Graphic (maLatestFillStyle.aBmp) );
132 + SvMemoryStream aMemStm;
134 + aMemStm << aFill;
136 + mpGDIMetaFile->AddAction( new MetaCommentAction( "XPATHFILL_SEQ_BEGIN", 0,
137 + static_cast<const BYTE*>(aMemStm.GetData()),
138 + aMemStm.Seek( STREAM_SEEK_TO_END ) ) );
139 + mpGDIMetaFile->AddAction( new MetaCommentAction( "XPATHFILL_SEQ_END" ) );
145 @@ -1708,7 +1738,7 @@ void WinMtfOutput::ResolveBitmapActions(
146 if ( ( nRasterOperation & 0xaa ) != ( ( nRasterOperation & 0x55 ) << 1 ) )
147 nUsed |= 4; // destination is used
149 - if ( (nUsed & 1) && (( nUsed & 2 ) == 0) )
150 + if ( (nUsed & 1) && (( nUsed & 2 ) == 0) && nWinRop != PATINVERT )
151 { // patterns aren't well supported yet
152 sal_uInt32 nOldRop = SetRasterOp( ROP_OVERPAINT ); // in this case nRasterOperation is either 0 or 0xff
153 UpdateFillStyle();
154 --- svtools/source/filter.vcl/wmf/winmtf.hxx.old 2009-04-02 11:06:17.000000000 +0000
155 +++ svtools/source/filter.vcl/wmf/winmtf.hxx 2009-04-06 16:42:11.000000000 +0000
156 @@ -366,10 +366,17 @@ struct WinMtfFontStyle
158 // -----------------------------------------------------------------------------
160 +typedef enum {
161 + FillStyleSolid,
162 + FillStylePattern
163 +} WinMtfFillStyleType;
165 struct WinMtfFillStyle
167 - Color aFillColor;
168 - BOOL bTransparent;
169 + Color aFillColor;
170 + BOOL bTransparent;
171 + WinMtfFillStyleType aType;
172 + Bitmap aBmp;
174 WinMtfFillStyle() :
175 aFillColor ( Color( COL_BLACK ) ),
176 @@ -379,16 +386,23 @@ struct WinMtfFillStyle
178 WinMtfFillStyle( const Color& rColor, BOOL bTrans = FALSE ) :
179 aFillColor ( rColor ),
180 - bTransparent( bTrans )
181 + bTransparent( bTrans ),
182 + aType ( FillStyleSolid )
184 + };
186 + WinMtfFillStyle( Bitmap& rBmp ) :
187 + aBmp ( rBmp ),
188 + aType( FillStylePattern )
192 BOOL operator==( const WinMtfFillStyle& rStyle )
193 - { return ( ( aFillColor == rStyle.aFillColor ) && ( bTransparent == rStyle.bTransparent ) ); };
194 + { return ( ( aFillColor == rStyle.aFillColor ) && ( bTransparent == rStyle.bTransparent ) && ( aType == rStyle.aType ) ); };
195 BOOL operator==( WinMtfFillStyle* pStyle )
196 - { return ( ( aFillColor == pStyle->aFillColor ) && ( bTransparent == pStyle->bTransparent ) ); };
197 - void operator=( const WinMtfFillStyle& rStyle ) { aFillColor = rStyle.aFillColor; bTransparent = rStyle.bTransparent; };
198 - void operator=( WinMtfFillStyle* pStyle ) { aFillColor = pStyle->aFillColor; bTransparent = pStyle->bTransparent; };
199 + { return ( ( aFillColor == pStyle->aFillColor ) && ( bTransparent == pStyle->bTransparent ) && ( aType == pStyle->aType ) ); };
200 + void operator=( const WinMtfFillStyle& rStyle ) { aFillColor = rStyle.aFillColor; bTransparent = rStyle.bTransparent; aBmp = rStyle.aBmp; aType = rStyle.aType; };
201 + void operator=( WinMtfFillStyle* pStyle ) { aFillColor = pStyle->aFillColor; bTransparent = pStyle->bTransparent; aBmp = pStyle->aBmp; aType = pStyle->aType; };
204 // -----------------------------------------------------------------------------
205 @@ -480,12 +494,13 @@ typedef ::boost::shared_ptr< SaveStruct
207 struct BSaveStruct
209 - Bitmap aBmp;
210 - Rectangle aOutRect;
211 - UINT32 nWinRop;
212 + Bitmap aBmp;
213 + Rectangle aOutRect;
214 + UINT32 nWinRop;
215 + WinMtfFillStyle aStyle;
217 - BSaveStruct( const Bitmap& rBmp, const Rectangle& rOutRect, UINT32 nRop ) :
218 - aBmp( rBmp ), aOutRect( rOutRect ), nWinRop( nRop ){};
219 + BSaveStruct( const Bitmap& rBmp, const Rectangle& rOutRect, UINT32 nRop, WinMtfFillStyle& rStyle ) :
220 + aBmp( rBmp ), aOutRect( rOutRect ), nWinRop( nRop ), aStyle ( rStyle ){};
223 // -----------------------------------------------------------------------------
224 @@ -640,6 +655,7 @@ class WinMtfOutput
225 void DeleteObject( INT32 nIndex );
226 void SelectObject( INT32 nIndex );
227 CharSet GetCharSet(){ return maFont.GetCharSet(); };
228 + WinMtfFillStyle& GetFillStyle () { return maFillStyle; }
229 void SetFont( const Font& rFont );
230 const Font& GetFont() const;
231 void SetTextLayoutMode( const sal_uInt32 nLayoutMode );
232 --- svtools/source/filter.vcl/wmf/winwmf.cxx.old 2009-04-02 11:06:17.000000000 +0000
233 +++ svtools/source/filter.vcl/wmf/winwmf.cxx 2009-04-06 16:42:11.000000000 +0000
234 @@ -566,7 +566,7 @@ void WMFReader::ReadRecordParams( USHORT
235 aBmp.Crop( aCropRect );
237 Rectangle aDestRect( aPoint, Size( nSxe, nSye ) );
238 - aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP ), LIST_APPEND );
239 + aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP, pOut->GetFillStyle () ), LIST_APPEND );
243 @@ -616,7 +616,7 @@ void WMFReader::ReadRecordParams( USHORT
244 Rectangle aCropRect( Point( nSx, nSy ), Size( nSxe, nSye ) );
245 aBmp.Crop( aCropRect );
247 - aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP ), LIST_APPEND );
248 + aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP, pOut->GetFillStyle () ), LIST_APPEND );