Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "winmtf.hxx"
31 : : #include <osl/endian.h>
32 : : #include <boost/bind.hpp>
33 : :
34 : : using namespace std;
35 : : //=========================== GDI-Array ===================================
36 : :
37 : : #define EMR_HEADER 1
38 : : #define EMR_POLYBEZIER 2
39 : : #define EMR_POLYGON 3
40 : : #define EMR_POLYLINE 4
41 : : #define EMR_POLYBEZIERTO 5
42 : : #define EMR_POLYLINETO 6
43 : : #define EMR_POLYPOLYLINE 7
44 : : #define EMR_POLYPOLYGON 8
45 : : #define EMR_SETWINDOWEXTEX 9
46 : : #define EMR_SETWINDOWORGEX 10
47 : : #define EMR_SETVIEWPORTEXTEX 11
48 : : #define EMR_SETVIEWPORTORGEX 12
49 : : #define EMR_SETBRUSHORGEX 13
50 : : #define EMR_EOF 14
51 : : #define EMR_SETPIXELV 15
52 : : #define EMR_SETMAPPERFLAGS 16
53 : : #define EMR_SETMAPMODE 17
54 : : #define EMR_SETBKMODE 18
55 : : #define EMR_SETPOLYFILLMODE 19
56 : : #define EMR_SETROP2 20
57 : : #define EMR_SETSTRETCHBLTMODE 21
58 : : #define EMR_SETTEXTALIGN 22
59 : : #define EMR_SETCOLORADJUSTMENT 23
60 : : #define EMR_SETTEXTCOLOR 24
61 : : #define EMR_SETBKCOLOR 25
62 : : #define EMR_OFFSETCLIPRGN 26
63 : : #define EMR_MOVETOEX 27
64 : : #define EMR_SETMETARGN 28
65 : : #define EMR_EXCLUDECLIPRECT 29
66 : : #define EMR_INTERSECTCLIPRECT 30
67 : : #define EMR_SCALEVIEWPORTEXTEX 31
68 : : #define EMR_SCALEWINDOWEXTEX 32
69 : : #define EMR_SAVEDC 33
70 : : #define EMR_RESTOREDC 34
71 : : #define EMR_SETWORLDTRANSFORM 35
72 : : #define EMR_MODIFYWORLDTRANSFORM 36
73 : : #define EMR_SELECTOBJECT 37
74 : : #define EMR_CREATEPEN 38
75 : : #define EMR_CREATEBRUSHINDIRECT 39
76 : : #define EMR_DELETEOBJECT 40
77 : : #define EMR_ANGLEARC 41
78 : : #define EMR_ELLIPSE 42
79 : : #define EMR_RECTANGLE 43
80 : : #define EMR_ROUNDRECT 44
81 : : #define EMR_ARC 45
82 : : #define EMR_CHORD 46
83 : : #define EMR_PIE 47
84 : : #define EMR_SELECTPALETTE 48
85 : : #define EMR_CREATEPALETTE 49
86 : : #define EMR_SETPALETTEENTRIES 50
87 : : #define EMR_RESIZEPALETTE 51
88 : : #define EMR_REALIZEPALETTE 52
89 : : #define EMR_EXTFLOODFILL 53
90 : : #define EMR_LINETO 54
91 : : #define EMR_ARCTO 55
92 : : #define EMR_POLYDRAW 56
93 : : #define EMR_SETARCDIRECTION 57
94 : : #define EMR_SETMITERLIMIT 58
95 : : #define EMR_BEGINPATH 59
96 : : #define EMR_ENDPATH 60
97 : : #define EMR_CLOSEFIGURE 61
98 : : #define EMR_FILLPATH 62
99 : : #define EMR_STROKEANDFILLPATH 63
100 : : #define EMR_STROKEPATH 64
101 : : #define EMR_FLATTENPATH 65
102 : : #define EMR_WIDENPATH 66
103 : : #define EMR_SELECTCLIPPATH 67
104 : : #define EMR_ABORTPATH 68
105 : :
106 : : #define EMR_GDICOMMENT 70
107 : : #define EMR_FILLRGN 71
108 : : #define EMR_FRAMERGN 72
109 : : #define EMR_INVERTRGN 73
110 : : #define EMR_PAINTRGN 74
111 : : #define EMR_EXTSELECTCLIPRGN 75
112 : : #define EMR_BITBLT 76
113 : : #define EMR_STRETCHBLT 77
114 : : #define EMR_MASKBLT 78
115 : : #define EMR_PLGBLT 79
116 : : #define EMR_SETDIBITSTODEVICE 80
117 : : #define EMR_STRETCHDIBITS 81
118 : : #define EMR_EXTCREATEFONTINDIRECTW 82
119 : : #define EMR_EXTTEXTOUTA 83
120 : : #define EMR_EXTTEXTOUTW 84
121 : : #define EMR_POLYBEZIER16 85
122 : : #define EMR_POLYGON16 86
123 : : #define EMR_POLYLINE16 87
124 : : #define EMR_POLYBEZIERTO16 88
125 : : #define EMR_POLYLINETO16 89
126 : : #define EMR_POLYPOLYLINE16 90
127 : : #define EMR_POLYPOLYGON16 91
128 : : #define EMR_POLYDRAW16 92
129 : : #define EMR_CREATEMONOBRUSH 93
130 : : #define EMR_CREATEDIBPATTERNBRUSHPT 94
131 : : #define EMR_EXTCREATEPEN 95
132 : : #define EMR_POLYTEXTOUTA 96
133 : : #define EMR_POLYTEXTOUTW 97
134 : :
135 : : // WINDOWS VERSION >= 0x400
136 : : #define EMR_SETICMMODE 98
137 : : #define EMR_CREATECOLORSPACE 99
138 : : #define EMR_SETCOLORSPACE 100
139 : : #define EMR_DELETECOLORSPACE 101
140 : : #define EMR_GLSRECORD 102
141 : : #define EMR_GLSBOUNDEDRECORD 103
142 : : #define EMR_PIXELFORMAT 104
143 : :
144 : : // WINDOWS VERSION >= 0x500
145 : : #define EMR_DRAWESCAPE 105
146 : : #define EMR_EXTESCAPE 106
147 : : #define EMR_STARTDOC 107
148 : : #define EMR_SMALLTEXTOUT 108
149 : : #define EMR_FORCEUFIMAPPING 109
150 : : #define EMR_NAMEDESCAPE 110
151 : : #define EMR_COLORCORRECTPALETTE 111
152 : : #define EMR_SETICMPROFILEA 112
153 : : #define EMR_SETICMPROFILEW 113
154 : : #define EMR_ALPHABLEND 114
155 : : #define EMR_ALPHADIBBLEND 115
156 : : #define EMR_TRANSPARENTBLT 116
157 : : #define EMR_TRANSPARENTDIB 117
158 : : #define EMR_GRADIENTFILL 118
159 : : #define EMR_SETLINKEDUFIS 119
160 : : #define EMR_SETTEXTJUSTIFICATION 120
161 : :
162 : : #if OSL_DEBUG_LEVEL > 1
163 : : #define EMFP_DEBUG(x) x
164 : : #else
165 : : #define EMFP_DEBUG(x)
166 : : #endif
167 : :
168 : : //-----------------------------------------------------------------------------------
169 : :
170 : : #ifdef OSL_BIGENDIAN
171 : : // currently unused
172 : : static float GetSwapFloat( SvStream& rSt )
173 : : {
174 : : float fTmp;
175 : : sal_Int8* pPtr = (sal_Int8*)&fTmp;
176 : : rSt >> pPtr[3] >> pPtr[2] >> pPtr[1] >> pPtr[0]; // Little Endian <-> Big Endian switch
177 : : return fTmp;
178 : : }
179 : : #endif
180 : :
181 : 110 : SvStream& operator>>( SvStream& rIn, XForm& rXForm )
182 : : {
183 : : if ( sizeof( float ) != 4 )
184 : : {
185 : : OSL_FAIL( "EnhWMFReader::sizeof( float ) != 4" );
186 : : rXForm = XForm();
187 : : }
188 : : else
189 : : {
190 : : #ifdef OSL_BIGENDIAN
191 : : rXForm.eM11 = GetSwapFloat( rIn );
192 : : rXForm.eM12 = GetSwapFloat( rIn );
193 : : rXForm.eM21 = GetSwapFloat( rIn );
194 : : rXForm.eM22 = GetSwapFloat( rIn );
195 : : rXForm.eDx = GetSwapFloat( rIn );
196 : : rXForm.eDy = GetSwapFloat( rIn );
197 : : #else
198 : 110 : rIn >> rXForm.eM11 >> rXForm.eM12 >> rXForm.eM21 >> rXForm.eM22
199 : 110 : >> rXForm.eDx >> rXForm.eDy;
200 : : #endif
201 : : }
202 : 110 : return rIn;
203 : : }
204 : :
205 : 0 : static sal_Bool ImplReadRegion( PolyPolygon& rPolyPoly, SvStream& rSt, sal_uInt32 nLen )
206 : : {
207 : 0 : sal_Bool bOk = sal_False;
208 [ # # ]: 0 : if ( nLen )
209 : : {
210 : : sal_uInt32 nHdSize, nType, nCount, nRgnSize, i;
211 [ # # ]: 0 : rSt >> nHdSize
212 [ # # ]: 0 : >> nType
213 [ # # ]: 0 : >> nCount
214 [ # # ]: 0 : >> nRgnSize;
215 : :
216 [ # # ][ # # ]: 0 : if ( nCount && ( nType == RDH_RECTANGLES ) &&
[ # # ]
217 : : ( nLen >= ( ( nCount << 4 ) + ( nHdSize - 16 ) ) ) )
218 : : {
219 : : sal_Int32 nx1, ny1, nx2, ny2;
220 : :
221 [ # # ]: 0 : for ( i = 0; i < nCount; i++ )
222 : : {
223 [ # # ][ # # ]: 0 : rSt >> nx1 >> ny1 >> nx2 >> ny2;
[ # # ][ # # ]
224 : :
225 [ # # ]: 0 : Rectangle aRect( Point( nx1, ny1 ), Point( nx2, ny2 ) );
226 [ # # ]: 0 : Polygon aPolygon( aRect );
227 [ # # ]: 0 : PolyPolygon aPolyPolyOr1( aPolygon );
228 [ # # ]: 0 : PolyPolygon aPolyPolyOr2( rPolyPoly );
229 [ # # ]: 0 : rPolyPoly.GetUnion( aPolyPolyOr1, aPolyPolyOr2 );
230 [ # # ]: 0 : rPolyPoly = aPolyPolyOr2;
231 [ # # ][ # # ]: 0 : }
[ # # ]
232 : 0 : bOk = sal_True;
233 : : }
234 : : }
235 : 0 : return bOk;
236 : : }
237 : :
238 : : EMFP_DEBUG(void dumpWords( SvStream& s, int i )
239 : : {
240 : : sal_uInt32 pos = s.Tell();
241 : : sal_Int16 data;
242 : : for( ; i > 0; i -- ) {
243 : : s >> data;
244 : : EMFP_DEBUG(printf ("\t\t\tdata: %04hx\n", data));
245 : : }
246 : : s.Seek (pos);
247 : : });
248 : :
249 : 201 : void EnhWMFReader::ReadEMFPlusComment(sal_uInt32 length, sal_Bool& bHaveDC)
250 : : {
251 [ + + ]: 201 : if (!bEMFPlus) {
252 [ + - ]: 9 : pOut->PassEMFPlusHeaderInfo();
253 : :
254 : : // debug code - write the stream to debug file /tmp/emf-stream.emf
255 : : EMFP_DEBUG(int pos = pWMF->Tell();
256 : : pWMF->Seek(0);
257 : : SvFileStream file( rtl::OUString( "/tmp/emf-stream.emf" ), STREAM_WRITE | STREAM_TRUNC );
258 : :
259 : : *pWMF >> file;
260 : : file.Flush();
261 : : file.Close();
262 : :
263 : : pWMF->Seek( pos );)
264 : : }
265 : 201 : bEMFPlus = true;
266 : :
267 : 201 : sal_Size pos = pWMF->Tell();
268 : 201 : void *buffer = malloc( length );
269 [ + - ][ + - ]: 201 : pOut->PassEMFPlus( buffer, pWMF->Read( buffer, length ) );
270 : 201 : free( buffer );
271 [ + - ]: 201 : pWMF->Seek( pos );
272 : :
273 : 201 : bHaveDC = false;
274 : :
275 : : OSL_ASSERT(length >= 4);
276 : : //reduce by 32bit length itself, skip in SeekRel if
277 : : //impossibly unavailble
278 [ + - ]: 201 : sal_uInt32 nRemainder = length >= 4 ? length-4 : length;
279 : :
280 : 201 : const size_t nRequiredHeaderSize = 12;
281 [ + + ]: 696 : while (nRemainder >= nRequiredHeaderSize)
282 : : {
283 : 495 : sal_uInt16 type(0), flags(0);
284 : 495 : sal_uInt32 size(0), dataSize(0);
285 : :
286 [ + - ][ + - ]: 495 : *pWMF >> type >> flags >> size >> dataSize;
[ + - ][ + - ]
287 : 495 : nRemainder -= nRequiredHeaderSize;
288 : :
289 : : EMFP_DEBUG(printf ("\t\tEMF+ record type: %d\n", type));
290 : :
291 : : // GetDC
292 [ + + ]: 495 : if( type == 16388 ) {
293 : 54 : bHaveDC = true;
294 : : EMFP_DEBUG(printf ("\t\tEMF+ lock DC (device context)\n"));
295 : : }
296 : :
297 : : //Get the length of the remaining data of this record based
298 : : //on the alleged size
299 : : sal_uInt32 nRemainingRecordData = size >= nRequiredHeaderSize ?
300 [ + - ]: 495 : size-nRequiredHeaderSize : 0;
301 : : //clip to available size
302 [ + - ]: 495 : nRemainingRecordData = std::min(nRemainingRecordData, nRemainder);
303 [ + - ]: 495 : pWMF->SeekRel(nRemainingRecordData);
304 : 495 : nRemainder -= nRemainingRecordData;
305 : : }
306 [ + - ]: 201 : pWMF->SeekRel(nRemainder);
307 : 201 : }
308 : :
309 : : /**
310 : : * Reads polygons from the stream.
311 : : * The <class T> parameter is for the type of the points (sal_uInt32 or sal_uInt16).
312 : : * The <class Drawer> parameter is a boost binding for the method that will draw the polygon.
313 : : * skipFirst: if the first point read is the 0th point or the 1st point in the array.
314 : : * */
315 : : template <class T, class Drawer>
316 : 558 : void EnhWMFReader::ReadAndDrawPolygon(Drawer drawer, const sal_Bool skipFirst)
317 : : {
318 : 558 : sal_uInt32 nPoints(0), nStartIndex(0);
319 [ # # ][ + - ]: 558 : pWMF->SeekRel( 16 );
320 [ # # ][ + - ]: 558 : *pWMF >> nPoints;
321 [ # # ][ - + ]: 558 : if (skipFirst)
322 : : {
323 : 0 : nPoints ++;
324 : 0 : nStartIndex ++;
325 : : }
326 : :
327 [ # # ][ + - ]: 558 : Polygon aPolygon = ReadPolygon<T>(nStartIndex, nPoints);
328 [ # # ][ # # ]: 558 : drawer(pOut, aPolygon, skipFirst, bRecordPath);
[ + - ][ + - ]
329 : 558 : }
330 : :
331 : :
332 : : /**
333 : : * Reads polygons from the stream.
334 : : * The <class T> parameter is for the type of the points
335 : : * nStartIndex: which is the starting index in the polygon of the first point read
336 : : * nPoints: number of points
337 : : * pWMF: the stream containings the polygons
338 : : * */
339 : : template <class T>
340 : 558 : Polygon EnhWMFReader::ReadPolygon(sal_uInt32 nStartIndex, sal_uInt32 nPoints)
341 : : {
342 : 558 : Polygon aPolygon(nPoints);
343 [ # # ][ # # ]: 2682 : for (sal_uInt16 i = nStartIndex ; i < nPoints && pWMF->good(); i++ )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ + + ]
[ + - ][ + + ]
344 : : {
345 : : T nX, nY;
346 [ # # ][ # # ]: 2124 : *pWMF >> nX >> nY;
[ # # ][ # # ]
[ # # ][ # # ]
[ + - ][ + - ]
347 [ # # ][ # # ]: 2124 : if (!pWMF->good())
[ # # ][ + - ]
348 : : break;
349 [ # # ][ # # ]: 2124 : aPolygon[ i ] = Point( nX, nY );
[ # # ][ + - ]
350 : : }
351 : :
352 : 558 : return aPolygon;
353 : : }
354 : :
355 : : /**
356 : : * Reads a polyline from the WMF file and draws it
357 : : * The <class T> parameter refers to the type of the points. (e.g. sal_uInt16 or sal_uInt32)
358 : : * */
359 : : template <class T>
360 : 0 : void EnhWMFReader::ReadAndDrawPolyLine()
361 : : {
362 : : sal_uInt32 nPoints;
363 : 0 : sal_Int32 i, nPoly(0), nGesPoints(0);
364 [ # # ][ # # ]: 0 : pWMF->SeekRel( 0x10 );
365 : : // Number of Polygons:
366 [ # # ][ # # ]: 0 : *pWMF >> nPoly >> nGesPoints;
[ # # ][ # # ]
367 : :
368 : : // taking the amount of points of each polygon, retrieving the total number of points
369 [ # # ][ # # ]: 0 : if ( pWMF->good() &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
370 : : ( static_cast< sal_uInt32 >(nPoly) < SAL_MAX_UINT32 / sizeof(sal_uInt16) ) &&
371 : : ( static_cast< sal_uInt32 >( nPoly ) * sizeof(sal_uInt16) ) <= ( nEndPos - pWMF->Tell() )
372 : : )
373 : : {
374 [ # # ][ # # ]: 0 : sal_uInt16* pnPoints = new sal_uInt16[ nPoly ];
[ # # ][ # # ]
375 [ # # ][ # # ]: 0 : for ( i = 0; i < nPoly && pWMF->good(); i++ )
[ # # ][ # # ]
[ # # ][ # # ]
376 : : {
377 [ # # ][ # # ]: 0 : *pWMF >> nPoints;
378 : 0 : pnPoints[ i ] = (sal_uInt16)nPoints;
379 : : }
380 : : // Get polygon points:
381 [ # # ][ # # ]: 0 : for ( i = 0; ( i < nPoly ) && pWMF->good(); i++ )
[ # # ][ # # ]
[ # # ][ # # ]
382 : : {
383 [ # # ][ # # ]: 0 : Polygon aPolygon = ReadPolygon<T>(0, pnPoints[i]);
384 [ # # ][ # # ]: 0 : pOut->DrawPolyLine( aPolygon, sal_False, bRecordPath );
[ # # ][ # # ]
385 : : }
386 [ # # ][ # # ]: 0 : delete[] pnPoints;
387 : : }
388 : 0 : }
389 : :
390 : : /**
391 : : * Reads a poly polygon from the WMF file and draws it.
392 : : * The <class T> parameter refers to the type of the points. (e.g. sal_uInt16 or sal_uInt32)
393 : : * */
394 : : template <class T>
395 : 0 : void EnhWMFReader::ReadAndDrawPolyPolygon()
396 : : {
397 : : sal_uInt32 i, nPoly, nGesPoints, nPoints;
398 [ # # ][ # # ]: 0 : pWMF->SeekRel( 0x10 );
399 : : // Number of polygons
400 [ # # ][ # # ]: 0 : *pWMF >> nPoly >> nGesPoints;
[ # # ][ # # ]
401 [ # # ][ # # ]: 0 : if ( pWMF->good() &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
402 : : ( nGesPoints < SAL_MAX_UINT32 / sizeof(Point) ) && //check against numeric overflowing
403 : : ( nPoly < SAL_MAX_UINT32 / sizeof(sal_uInt16) ) &&
404 : : ( ( nPoly * sizeof( sal_uInt16 ) ) <= ( nEndPos - pWMF->Tell() ) ))
405 : : {
406 : : //Get number of points in each polygon
407 [ # # ][ # # ]: 0 : sal_uInt16 * pnPoints = new sal_uInt16[ nPoly ];
[ # # ][ # # ]
408 [ # # ][ # # ]: 0 : for ( i = 0; i < nPoly && pWMF->good(); i++ )
[ # # ][ # # ]
[ # # ][ # # ]
409 : : {
410 [ # # ][ # # ]: 0 : *pWMF >> nPoints;
411 : 0 : pnPoints[ i ] = (sal_uInt16)nPoints;
412 : : } //end for
413 [ # # ][ # # ]: 0 : if ( pWMF->good() && ( nGesPoints * (sizeof(T)+sizeof(T)) ) <= ( nEndPos - pWMF->Tell() ) )
[ # # ][ # # ]
[ # # ][ # # ]
414 : : {
415 : : // Get polygon points
416 [ # # ][ # # ]: 0 : Point * pPtAry = new Point[ nGesPoints ];
[ # # ][ # # ]
417 [ # # ][ # # ]: 0 : for ( i = 0; i < nGesPoints && pWMF->good(); i++ )
[ # # ][ # # ]
[ # # ][ # # ]
418 : : {
419 : : T nX, nY;
420 [ # # ][ # # ]: 0 : *pWMF >> nX >> nY;
[ # # ][ # # ]
421 : 0 : pPtAry[ i ] = Point( nX, nY );
422 : : } //end for
423 : : // Create PolyPolygon Actions
424 [ # # ][ # # ]: 0 : PolyPolygon aPolyPoly( (sal_uInt16)nPoly, pnPoints, pPtAry );
425 [ # # ][ # # ]: 0 : pOut->DrawPolyPolygon( aPolyPoly, bRecordPath );
426 [ # # ][ # # ]: 0 : delete[] pPtAry;
[ # # ][ # # ]
427 : : } //end if
428 [ # # ][ # # ]: 0 : delete[] pnPoints;
429 : : } //end if
430 : 0 : }
431 : :
432 : 44 : sal_Bool EnhWMFReader::ReadEnhWMF()
433 : : {
434 : 44 : sal_uInt32 nStretchBltMode = 0;
435 : 44 : sal_uInt32 nRecType(0), nRecSize(0), nNextPos(0),
436 : 44 : nW(0), nH(0), nColor(0), nIndex(0),
437 : 44 : nDat32(0), nNom1(0), nDen1(0), nNom2(0), nDen2(0);
438 : 44 : sal_Int32 nX32(0), nY32(0), nx32(0), ny32(0);
439 : :
440 [ + - ]: 44 : sal_Bool bFlag(sal_False), bStatus = ReadHeader();
441 : 44 : sal_Bool bHaveDC = false;
442 : :
443 [ + + ][ + - ]: 44 : static sal_Bool bEnableEMFPlus = ( getenv( "EMF_PLUS_DISABLE" ) == NULL );
444 : :
445 [ + - ][ + + ]: 9238 : while( bStatus && nRecordCount-- && pWMF->good())
[ + - ][ + + ]
446 : : {
447 [ + - ][ + - ]: 9203 : *pWMF >> nRecType >> nRecSize;
448 : :
449 [ + - ][ + - ]: 9203 : if ( !pWMF->good() || ( nRecSize < 8 ) || ( nRecSize & 3 ) ) // Parameters are always divisible by 4
[ + + ][ + + ]
450 : : {
451 : 6 : bStatus = sal_False;
452 : 6 : break;
453 : : }
454 : :
455 : 9197 : nNextPos = pWMF->Tell() + ( nRecSize - 8 );
456 : :
457 [ + + ][ + + ]: 9197 : if ( !pWMF->good() || nNextPos > nEndPos )
[ + - ]
458 : : {
459 : 3 : bStatus = sal_False;
460 : 3 : break;
461 : : }
462 : :
463 [ + + ][ + + ]: 9194 : if( !aBmpSaveList.empty()
[ + + ][ + + ]
464 : : && ( nRecType != EMR_STRETCHBLT )
465 : : && ( nRecType != EMR_STRETCHDIBITS )
466 : : )
467 [ + - ]: 77 : pOut->ResolveBitmapActions( aBmpSaveList );
468 : :
469 : 9194 : bFlag = sal_False;
470 : :
471 : : EMFP_DEBUG(printf ("0x%04x-0x%04x record type: %d size: %d\n",(unsigned int) (nNextPos - nRecSize),(unsigned int) nNextPos, (int)nRecType,(int) nRecSize));
472 : :
473 [ + - ][ + + ]: 9194 : if( bEnableEMFPlus && nRecType == EMR_GDICOMMENT ) {
474 : : sal_uInt32 length;
475 : :
476 [ + - ]: 212 : *pWMF >> length;
477 : :
478 : : EMFP_DEBUG(printf ("\tGDI comment\n\t\tlength: %d\n", (int)length));
479 : :
480 [ + - ][ + - ]: 212 : if( pWMF->good() && length >= 4 ) {
[ + - ]
481 : : sal_uInt32 id;
482 : :
483 [ + - ]: 212 : *pWMF >> id;
484 : :
485 : : EMFP_DEBUG(printf ("\t\tbegin %c%c%c%c id: 0x%x\n", (char)(id & 0xff), (char)((id & 0xff00) >> 8), (char)((id & 0xff0000) >> 16), (char)((id & 0xff000000) >> 24), (unsigned int)id));
486 : :
487 : : // EMF+ comment (fixme: BE?)
488 [ + + ][ + - ]: 212 : if( id == 0x2B464D45 && nRecSize >= 12 )
489 [ + - ]: 201 : ReadEMFPlusComment( length, bHaveDC );
490 : : // GDIC comment, doesn't do anything useful yet
491 [ # # ]: 212 : else if( id == 0x43494447 && nRecSize >= 12 ) {
492 : : //ToDo: ReadGDIComment()
493 : : } else {
494 : : EMFP_DEBUG(printf ("\t\tunknown id: 0x%x\n",(unsigned int) id));
495 : : }
496 : 212 : }
497 [ + + ][ + + ]: 8982 : } else if( !bEMFPlus || bHaveDC || nRecType == EMR_EOF )
[ + + ]
498 : :
499 [ - - + - : 6039 : switch( nRecType )
+ - - + +
- + + + +
- + + - +
- + + + -
- + + + -
- + + - +
+ - + - -
- - - - -
- - - - -
- - + + +
+ - + - -
- - - - -
- + + ]
500 : : {
501 : : case EMR_POLYBEZIERTO :
502 [ # # ][ # # ]: 0 : ReadAndDrawPolygon<sal_Int32>(boost::bind(&WinMtfOutput::DrawPolyBezier, _1, _2, _3, _4), sal_True);
503 : 0 : break;
504 : : case EMR_POLYBEZIER :
505 [ # # ][ # # ]: 0 : ReadAndDrawPolygon<sal_Int32>(boost::bind(&WinMtfOutput::DrawPolyBezier, _1, _2, _3, _4), sal_False);
506 : 0 : break;
507 : :
508 : : case EMR_POLYGON :
509 [ + - ][ + - ]: 144 : ReadAndDrawPolygon<sal_Int32>(boost::bind(&WinMtfOutput::DrawPolygon, _1, _2, _3, _4), sal_False);
510 : 144 : break;
511 : :
512 : : case EMR_POLYLINETO :
513 [ # # ][ # # ]: 0 : ReadAndDrawPolygon<sal_Int32>(boost::bind(&WinMtfOutput::DrawPolyLine, _1, _2, _3, _4), sal_True);
514 : 0 : break;
515 : : case EMR_POLYLINE :
516 [ + - ][ + - ]: 414 : ReadAndDrawPolygon<sal_Int32>(boost::bind(&WinMtfOutput::DrawPolyLine, _1, _2, _3, _4), sal_False);
517 : 414 : break;
518 : :
519 : : case EMR_POLYPOLYLINE :
520 [ # # ]: 0 : ReadAndDrawPolyLine<sal_uInt32>();
521 : 0 : break;
522 : :
523 : : case EMR_POLYPOLYGON :
524 [ # # ]: 0 : ReadAndDrawPolyPolygon<sal_uInt32>();
525 : 0 : break;
526 : :
527 : : case EMR_SETWINDOWEXTEX :
528 : : { // #75383#
529 [ + - ][ + - ]: 63 : *pWMF >> nW >> nH;
530 [ + - ]: 63 : pOut->SetWinExt( Size( nW, nH ) );
531 : : }
532 : 63 : break;
533 : :
534 : : case EMR_SETWINDOWORGEX :
535 : : {
536 [ + - ][ + - ]: 52 : *pWMF >> nX32 >> nY32;
537 [ + - ]: 52 : pOut->SetWinOrg( Point( nX32, nY32 ) );
538 : : }
539 : 52 : break;
540 : :
541 : : case EMR_SCALEWINDOWEXTEX :
542 : : {
543 [ # # ][ # # ]: 0 : *pWMF >> nNom1 >> nDen1 >> nNom2 >> nDen2;
[ # # ][ # # ]
544 [ # # ]: 0 : pOut->ScaleWinExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 );
545 : : }
546 : 0 : break;
547 : :
548 : : case EMR_SETVIEWPORTORGEX :
549 : : {
550 [ + - ][ + - ]: 30 : *pWMF >> nX32 >> nY32;
551 [ + - ]: 30 : pOut->SetDevOrg( Point( nX32, nY32 ) );
552 : : }
553 : 30 : break;
554 : :
555 : : case EMR_SCALEVIEWPORTEXTEX :
556 : : {
557 [ + - ][ + - ]: 9 : *pWMF >> nNom1 >> nDen1 >> nNom2 >> nDen2;
[ + - ][ + - ]
558 [ + - ]: 9 : pOut->ScaleDevExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 );
559 : : }
560 : 9 : break;
561 : :
562 : : case EMR_SETVIEWPORTEXTEX :
563 : : {
564 [ + - ][ + - ]: 23 : *pWMF >> nW >> nH;
565 [ + - ]: 23 : pOut->SetDevExt( Size( nW, nH ) );
566 : : }
567 : 23 : break;
568 : :
569 : : case EMR_EOF :
570 : 35 : nRecordCount = 0; // #76846#
571 : 35 : break;
572 : :
573 : : case EMR_SETPIXELV :
574 : : {
575 [ # # ][ # # ]: 0 : *pWMF >> nX32 >> nY32;
576 [ # # ][ # # ]: 0 : pOut->DrawPixel( Point( nX32, nY32 ), ReadColor() );
577 : : }
578 : 0 : break;
579 : :
580 : : case EMR_SETMAPMODE :
581 : : {
582 : : sal_uInt32 nMapMode;
583 [ + - ]: 40 : *pWMF >> nMapMode;
584 [ + - ]: 40 : pOut->SetMapMode( nMapMode );
585 : : }
586 : 40 : break;
587 : :
588 : : case EMR_SETBKMODE :
589 : : {
590 [ + - ]: 32 : *pWMF >> nDat32;
591 [ + - ]: 32 : pOut->SetBkMode( nDat32 );
592 : : }
593 : 32 : break;
594 : :
595 : : case EMR_SETPOLYFILLMODE :
596 : 0 : break;
597 : :
598 : : case EMR_SETROP2 :
599 : : {
600 [ + - ]: 210 : *pWMF >> nDat32;
601 [ + - ]: 210 : pOut->SetRasterOp( nDat32 );
602 : : }
603 : 210 : break;
604 : :
605 : : case EMR_SETSTRETCHBLTMODE :
606 : : {
607 [ # # ]: 0 : *pWMF >> nStretchBltMode;
608 : : }
609 : 0 : break;
610 : :
611 : : case EMR_SETTEXTALIGN :
612 : : {
613 [ + - ]: 173 : *pWMF >> nDat32;
614 [ + - ]: 173 : pOut->SetTextAlign( nDat32 );
615 : : }
616 : 173 : break;
617 : :
618 : : case EMR_SETTEXTCOLOR :
619 : : {
620 [ + - ][ + - ]: 182 : pOut->SetTextColor( ReadColor() );
621 : : }
622 : 182 : break;
623 : :
624 : : case EMR_SETBKCOLOR :
625 : : {
626 [ + - ][ + - ]: 20 : pOut->SetBkColor( ReadColor() );
627 : : }
628 : 20 : break;
629 : :
630 : : case EMR_OFFSETCLIPRGN :
631 : : {
632 [ # # ][ # # ]: 0 : *pWMF >> nX32 >> nY32;
633 [ # # ]: 0 : pOut->MoveClipRegion( Size( nX32, nY32 ) );
634 : : }
635 : 0 : break;
636 : :
637 : : case EMR_MOVETOEX :
638 : : {
639 [ # # ][ # # ]: 0 : *pWMF >> nX32 >> nY32;
640 [ # # ]: 0 : pOut->MoveTo( Point( nX32, nY32 ), bRecordPath );
641 : : }
642 : 0 : break;
643 : :
644 : : case EMR_INTERSECTCLIPRECT :
645 : : {
646 [ + - ][ + - ]: 9 : *pWMF >> nX32 >> nY32 >> nx32 >> ny32;
[ + - ][ + - ]
647 [ + - ][ + - ]: 9 : pOut->IntersectClipRect( ReadRectangle( nX32, nY32, nx32, ny32 ) );
648 : : }
649 : 9 : break;
650 : :
651 : : case EMR_SAVEDC :
652 : : {
653 [ + - ]: 245 : pOut->Push();
654 : : }
655 : 245 : break;
656 : :
657 : : case EMR_RESTOREDC :
658 : : {
659 [ + - ]: 209 : pOut->Pop();
660 : : }
661 : 209 : break;
662 : :
663 : : case EMR_SETWORLDTRANSFORM :
664 : : {
665 : 0 : XForm aTempXForm;
666 [ # # ]: 0 : *pWMF >> aTempXForm;
667 [ # # ]: 0 : pOut->SetWorldTransform( aTempXForm );
668 : : }
669 : 0 : break;
670 : :
671 : : case EMR_MODIFYWORLDTRANSFORM :
672 : : {
673 : : sal_uInt32 nMode;
674 : 0 : XForm aTempXForm;
675 [ # # ][ # # ]: 0 : *pWMF >> aTempXForm >> nMode;
676 [ # # ]: 0 : pOut->ModifyWorldTransform( aTempXForm, nMode );
677 : : }
678 : 0 : break;
679 : :
680 : : case EMR_SELECTOBJECT :
681 : : {
682 [ + - ]: 1923 : *pWMF >> nIndex;
683 [ + - ]: 1923 : pOut->SelectObject( nIndex );
684 : : }
685 : 1923 : break;
686 : :
687 : : case EMR_CREATEPEN :
688 : : {
689 [ + - ]: 585 : *pWMF >> nIndex;
690 [ + - ]: 585 : if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
691 : : {
692 : :
693 [ + - ]: 585 : LineInfo aLineInfo;
694 : : sal_uInt32 nStyle;
695 : 585 : Size aSize;
696 : : //#fdo39428 Remove SvStream operator>>(long&)
697 : 585 : sal_Int32 nTmpW(0), nTmpH(0);
698 : :
699 [ + - ][ + - ]: 585 : *pWMF >> nStyle >> nTmpW >> nTmpH;
[ + - ]
700 : 585 : aSize.Width() = nTmpW;
701 : 585 : aSize.Height() = nTmpH;
702 : :
703 [ - + ]: 585 : if ( aSize.Width() )
704 [ # # ]: 0 : aLineInfo.SetWidth( aSize.Width() );
705 : :
706 : 585 : sal_Bool bTransparent = sal_False;
707 : 585 : sal_uInt16 nDashCount = 0;
708 : 585 : sal_uInt16 nDotCount = 0;
709 [ - - - - : 585 : switch( nStyle )
+ + ]
710 : : {
711 : : case PS_DASHDOTDOT :
712 : 0 : nDotCount++;
713 : : case PS_DASHDOT :
714 : 0 : nDashCount++;
715 : : case PS_DOT :
716 : 0 : nDotCount++;
717 : 0 : break;
718 : : case PS_DASH :
719 : 0 : nDashCount++;
720 : 0 : break;
721 : : case PS_NULL :
722 : 144 : bTransparent = sal_True;
723 [ + - ]: 144 : aLineInfo.SetStyle( LINE_NONE );
724 : 144 : break;
725 : : default :
726 : : case PS_INSIDEFRAME :
727 : : case PS_SOLID :
728 [ + - ]: 441 : aLineInfo.SetStyle( LINE_SOLID );
729 : : }
730 [ - + ]: 585 : if ( nDashCount | nDotCount )
731 : : {
732 [ # # ]: 0 : aLineInfo.SetStyle( LINE_DASH );
733 [ # # ]: 0 : aLineInfo.SetDashCount( nDashCount );
734 [ # # ]: 0 : aLineInfo.SetDotCount( nDotCount );
735 : : }
736 [ + - ][ + - ]: 585 : pOut->CreateObject( nIndex, GDI_PEN, new WinMtfLineStyle( ReadColor(), aLineInfo, bTransparent ) );
[ + - ][ + - ]
[ + - ]
737 : : }
738 : : }
739 : 585 : break;
740 : :
741 : : case EMR_EXTCREATEPEN :
742 : : {
743 : : sal_Int32 elpHatch;
744 : : sal_uInt32 offBmi, cbBmi, offBits, cbBits, nStyle, nWidth, nBrushStyle, elpNumEntries;
745 : 0 : Color aColorRef;
746 : :
747 [ # # ]: 0 : *pWMF >> nIndex;
748 [ # # ]: 0 : if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
749 : : {
750 [ # # ][ # # ]: 0 : *pWMF >> offBmi >> cbBmi >> offBits >> cbBits >> nStyle >> nWidth >> nBrushStyle;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
751 [ # # ]: 0 : aColorRef = ReadColor();
752 [ # # ][ # # ]: 0 : *pWMF >> elpHatch >> elpNumEntries;
753 : :
754 [ # # ]: 0 : LineInfo aLineInfo;
755 [ # # ]: 0 : if ( nWidth )
756 [ # # ]: 0 : aLineInfo.SetWidth( nWidth );
757 : :
758 : 0 : sal_Bool bTransparent = sal_False;
759 : 0 : sal_uInt16 nDashCount = 0;
760 : 0 : sal_uInt16 nDotCount = 0;
761 : :
762 [ # # # # : 0 : switch( nStyle & PS_STYLE_MASK )
# # ]
763 : : {
764 : : case PS_DASHDOTDOT :
765 : 0 : nDotCount++;
766 : : case PS_DASHDOT :
767 : 0 : nDashCount++;
768 : : case PS_DOT :
769 : 0 : nDotCount++;
770 : 0 : break;
771 : : case PS_DASH :
772 : 0 : nDashCount++;
773 : 0 : break;
774 : : case PS_NULL :
775 : 0 : bTransparent = sal_True;
776 [ # # ]: 0 : aLineInfo.SetStyle( LINE_NONE );
777 : 0 : break;
778 : :
779 : : default :
780 : : case PS_INSIDEFRAME :
781 : : case PS_SOLID :
782 [ # # ]: 0 : aLineInfo.SetStyle( LINE_SOLID );
783 : : }
784 [ # # ]: 0 : if ( nDashCount | nDotCount )
785 : : {
786 [ # # ]: 0 : aLineInfo.SetStyle( LINE_DASH );
787 [ # # ]: 0 : aLineInfo.SetDashCount( nDashCount );
788 [ # # ]: 0 : aLineInfo.SetDotCount( nDotCount );
789 : : }
790 [ # # ][ # # ]: 0 : pOut->CreateObject( nIndex, GDI_PEN, new WinMtfLineStyle( aColorRef, aLineInfo, bTransparent ) );
[ # # ][ # # ]
791 : : }
792 : : }
793 : 0 : break;
794 : :
795 : : case EMR_CREATEBRUSHINDIRECT :
796 : : {
797 : : sal_uInt32 nStyle;
798 [ + - ]: 179 : *pWMF >> nIndex;
799 [ + - ]: 179 : if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
800 : : {
801 [ + - ]: 179 : *pWMF >> nStyle;
802 [ + - ][ + - ]: 179 : pOut->CreateObject( nIndex, GDI_BRUSH, new WinMtfFillStyle( ReadColor(), ( nStyle == BS_HOLLOW ) ? sal_True : sal_False ) );
[ + + ][ + - ]
[ + - ]
803 : : }
804 : : }
805 : 179 : break;
806 : :
807 : : case EMR_DELETEOBJECT :
808 : : {
809 [ + - ]: 919 : *pWMF >> nIndex;
810 [ + - ]: 919 : if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
811 [ + - ]: 919 : pOut->DeleteObject( nIndex );
812 : : }
813 : 919 : break;
814 : :
815 : : case EMR_ELLIPSE :
816 : : {
817 [ # # ][ # # ]: 0 : *pWMF >> nX32 >> nY32 >> nx32 >> ny32;
[ # # ][ # # ]
818 [ # # ][ # # ]: 0 : pOut->DrawEllipse( ReadRectangle( nX32, nY32, nx32, ny32 ) );
819 : : }
820 : 0 : break;
821 : :
822 : : case EMR_RECTANGLE :
823 : : {
824 [ + - ][ + - ]: 27 : *pWMF >> nX32 >> nY32 >> nx32 >> ny32;
[ + - ][ + - ]
825 [ + - ][ + - ]: 27 : pOut->DrawRect( ReadRectangle( nX32, nY32, nx32, ny32 ) );
826 : : }
827 : 27 : break;
828 : :
829 : : case EMR_ROUNDRECT :
830 : : {
831 [ # # ][ # # ]: 0 : *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nW >> nH;
[ # # ][ # # ]
[ # # ][ # # ]
832 : 0 : Size aSize( Size( nW, nH ) );
833 [ # # ][ # # ]: 0 : pOut->DrawRoundRect( ReadRectangle( nX32, nY32, nx32, ny32 ), aSize );
834 : : }
835 : 0 : break;
836 : :
837 : : case EMR_ARC :
838 : : {
839 : : sal_uInt32 nStartX, nStartY, nEndX, nEndY;
840 [ # # ][ # # ]: 0 : *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
841 [ # # ][ # # ]: 0 : pOut->DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) );
842 : : }
843 : 0 : break;
844 : :
845 : : case EMR_CHORD :
846 : : {
847 : : sal_uInt32 nStartX, nStartY, nEndX, nEndY;
848 [ # # ][ # # ]: 0 : *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
849 [ # # ][ # # ]: 0 : pOut->DrawChord( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) );
850 : : }
851 : 0 : break;
852 : :
853 : : case EMR_PIE :
854 : : {
855 : : sal_uInt32 nStartX, nStartY, nEndX, nEndY;
856 [ # # ][ # # ]: 0 : *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
857 [ # # ]: 0 : const Rectangle aRect( ReadRectangle( nX32, nY32, nx32, ny32 ));
858 : :
859 : : // #i73608# OutputDevice deviates from WMF
860 : : // semantics. start==end means full ellipse here.
861 [ # # ][ # # ]: 0 : if( nStartX == nEndX && nStartY == nEndY )
862 [ # # ]: 0 : pOut->DrawEllipse( aRect );
863 : : else
864 [ # # ]: 0 : pOut->DrawPie( aRect, Point( nStartX, nStartY ), Point( nEndX, nEndY ) );
865 : : }
866 : 0 : break;
867 : :
868 : : case EMR_LINETO :
869 : : {
870 [ # # ][ # # ]: 0 : *pWMF >> nX32 >> nY32;
871 [ # # ]: 0 : pOut->LineTo( Point( nX32, nY32 ), bRecordPath );
872 : : }
873 : 0 : break;
874 : :
875 : : case EMR_ARCTO :
876 : : {
877 : : sal_uInt32 nStartX, nStartY, nEndX, nEndY;
878 [ # # ][ # # ]: 0 : *pWMF >> nX32 >> nY32 >> nx32 >> ny32 >> nStartX >> nStartY >> nEndX >> nEndY;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
879 [ # # ][ # # ]: 0 : pOut->DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), sal_True );
880 : : }
881 : 0 : break;
882 : :
883 : : case EMR_BEGINPATH :
884 : : {
885 [ # # ]: 0 : pOut->ClearPath();
886 : 0 : bRecordPath = sal_True;
887 : : }
888 : 0 : break;
889 : :
890 : : case EMR_ABORTPATH :
891 [ # # ]: 0 : pOut->ClearPath();
892 : : case EMR_ENDPATH :
893 : 0 : bRecordPath = sal_False;
894 : 0 : break;
895 : :
896 : : case EMR_CLOSEFIGURE :
897 [ # # ]: 0 : pOut->ClosePath();
898 : 0 : break;
899 : :
900 : : case EMR_FILLPATH :
901 [ # # ]: 0 : pOut->StrokeAndFillPath( sal_False, sal_True );
902 : 0 : break;
903 : :
904 : : case EMR_STROKEANDFILLPATH :
905 [ # # ]: 0 : pOut->StrokeAndFillPath( sal_True, sal_True );
906 : 0 : break;
907 : :
908 : : case EMR_STROKEPATH :
909 [ # # ]: 0 : pOut->StrokeAndFillPath( sal_True, sal_False );
910 : 0 : break;
911 : :
912 : : case EMR_SELECTCLIPPATH :
913 : : {
914 : : sal_Int32 nClippingMode;
915 [ # # ]: 0 : *pWMF >> nClippingMode;
916 [ # # ]: 0 : pOut->SetClipPath( pOut->GetPathObj(), nClippingMode, sal_True );
917 : : }
918 : 0 : break;
919 : :
920 : : case EMR_EXTSELECTCLIPRGN :
921 : : {
922 : : sal_Int32 iMode, cbRgnData;
923 [ + - ]: 9 : *pWMF >> cbRgnData
924 [ + - ]: 9 : >> iMode;
925 : :
926 [ + - ]: 9 : PolyPolygon aPolyPoly;
927 [ - + ]: 9 : if ( cbRgnData )
928 [ # # ]: 0 : ImplReadRegion( aPolyPoly, *pWMF, nRecSize );
929 [ + - ][ + - ]: 9 : pOut->SetClipPath( aPolyPoly, iMode, sal_False );
930 : : }
931 : 9 : break;
932 : :
933 : : case EMR_BITBLT : // PASSTHROUGH INTENDED
934 : : case EMR_STRETCHBLT :
935 : : {
936 : : sal_Int32 xDest, yDest, cxDest, cyDest, xSrc, ySrc, cxSrc, cySrc;
937 : : sal_uInt32 dwRop, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc;
938 : 110 : XForm xformSrc;
939 : :
940 : 110 : sal_uInt32 nStart = pWMF->Tell() - 8;
941 : :
942 [ + - ]: 110 : pWMF->SeekRel( 0x10 );
943 [ + - ][ + - ]: 110 : *pWMF >> xDest >> yDest >> cxDest >> cyDest >> dwRop >> xSrc >> ySrc
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
944 [ + - ][ + - ]: 110 : >> xformSrc >> nColor >> iUsageSrc >> offBmiSrc >> cbBmiSrc
[ + - ][ + - ]
[ + - ]
945 [ + - ][ + - ]: 110 : >> offBitsSrc >> cbBitsSrc;
946 : :
947 [ + + ]: 110 : if ( nRecType == EMR_STRETCHBLT )
948 [ + - ][ + - ]: 90 : *pWMF >> cxSrc >> cySrc;
949 : : else
950 : 20 : cxSrc = cySrc = 0;
951 : :
952 [ + - ]: 110 : Bitmap aBitmap;
953 [ + - ]: 110 : Rectangle aRect( Point( xDest, yDest ), Size( cxDest, cyDest ) );
954 : :
955 : 110 : cxDest = abs( (int)cxDest ); // sj: i37894, size can be negative
956 : 110 : cyDest = abs( (int)cyDest ); // and also 122889
957 : :
958 [ + - ][ - + ]: 110 : if ( (cbBitsSrc > (SAL_MAX_UINT32 - 14)) || ((SAL_MAX_UINT32 - 14) - cbBitsSrc < cbBmiSrc) )
959 : 0 : bStatus = sal_False;
960 : : else
961 : : {
962 : 110 : sal_uInt32 nSize = cbBmiSrc + cbBitsSrc + 14;
963 [ + - ]: 110 : if ( nSize <= ( nEndPos - nStartPos ) )
964 : : {
965 [ + - ]: 110 : char* pBuf = new char[ nSize ];
966 [ + - ]: 110 : SvMemoryStream aTmp( pBuf, nSize, STREAM_READ | STREAM_WRITE );
967 : 110 : aTmp.ObjectOwnsMemory( sal_True );
968 [ + - ]: 110 : aTmp << (sal_uInt8)'B'
969 [ + - ]: 110 : << (sal_uInt8)'M'
970 [ + - ]: 110 : << (sal_uInt32)cbBitsSrc
971 [ + - ]: 110 : << (sal_uInt16)0
972 [ + - ]: 110 : << (sal_uInt16)0
973 [ + - ]: 110 : << (sal_uInt32)cbBmiSrc + 14;
974 [ + - ]: 110 : pWMF->Seek( nStart + offBmiSrc );
975 [ + - ]: 110 : pWMF->Read( pBuf + 14, cbBmiSrc );
976 [ + - ]: 110 : pWMF->Seek( nStart + offBitsSrc );
977 [ + - ]: 110 : pWMF->Read( pBuf + 14 + cbBmiSrc, cbBitsSrc );
978 [ + - ]: 110 : aTmp.Seek( 0 );
979 [ + - ]: 110 : aBitmap.Read( aTmp, sal_True );
980 : :
981 : : // test if it is sensible to crop
982 [ - + ][ # # ]: 220 : if ( ( cxSrc > 0 ) && ( cySrc > 0 ) &&
[ # # ][ # #
# # # # ]
[ - + ]
983 : : ( xSrc >= 0 ) && ( ySrc >= 0 ) &&
984 [ # # ][ - + ]: 110 : ( xSrc + cxSrc <= aBitmap.GetSizePixel().Width() ) &&
[ # # ]
985 [ # # ][ - + ]: 110 : ( ySrc + cySrc <= aBitmap.GetSizePixel().Height() ) )
[ # # ]
986 : : {
987 [ # # ]: 0 : Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
988 [ # # ]: 0 : aBitmap.Crop( aCropRect );
989 : : }
990 [ + - ][ + - ]: 110 : aBmpSaveList.push_back( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ) );
[ + - ][ + - ]
991 : : }
992 [ + - ]: 110 : }
993 : : }
994 : 110 : break;
995 : :
996 : : case EMR_STRETCHDIBITS :
997 : : {
998 : : sal_Int32 xDest, yDest, xSrc, ySrc, cxSrc, cySrc, cxDest, cyDest;
999 : : sal_uInt32 offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, iUsageSrc, dwRop;
1000 : 12 : sal_uInt32 nStart = pWMF->Tell() - 8;
1001 : :
1002 [ + - ]: 12 : pWMF->SeekRel( 0x10 );
1003 [ + - ]: 12 : *pWMF >> xDest
1004 [ + - ]: 12 : >> yDest
1005 [ + - ]: 12 : >> xSrc
1006 [ + - ]: 12 : >> ySrc
1007 [ + - ]: 12 : >> cxSrc
1008 [ + - ]: 12 : >> cySrc
1009 [ + - ]: 12 : >> offBmiSrc
1010 [ + - ]: 12 : >> cbBmiSrc
1011 [ + - ]: 12 : >> offBitsSrc
1012 [ + - ]: 12 : >> cbBitsSrc
1013 [ + - ]: 12 : >> iUsageSrc
1014 [ + - ]: 12 : >> dwRop
1015 [ + - ]: 12 : >> cxDest
1016 [ + - ]: 12 : >> cyDest;
1017 : :
1018 [ + - ]: 12 : Bitmap aBitmap;
1019 [ + - ]: 12 : Rectangle aRect( Point( xDest, yDest ), Size( cxDest, cyDest ) );
1020 : :
1021 : 12 : cxDest = abs( (int)cxDest ); // sj: i37894, size can be negative
1022 : 12 : cyDest = abs( (int)cyDest ); // and also 122889
1023 : :
1024 [ + - ][ - + ]: 12 : if ( ((SAL_MAX_UINT32 - 14) < cbBitsSrc)
1025 : : || ((SAL_MAX_UINT32 - 14) - cbBitsSrc < cbBmiSrc )
1026 : : )
1027 : : {
1028 : 0 : bStatus = sal_False;
1029 : : }
1030 : : else
1031 : : {
1032 : 12 : sal_uInt32 nSize = cbBmiSrc + cbBitsSrc + 14;
1033 [ + - ]: 12 : if ( nSize <= ( nEndPos - nStartPos ) )
1034 : : {
1035 [ + - ]: 12 : char* pBuf = new char[ nSize ];
1036 [ + - ]: 12 : SvMemoryStream aTmp( pBuf, nSize, STREAM_READ | STREAM_WRITE );
1037 : 12 : aTmp.ObjectOwnsMemory( sal_True );
1038 [ + - ]: 12 : aTmp << (sal_uInt8)'B'
1039 [ + - ]: 12 : << (sal_uInt8)'M'
1040 [ + - ]: 12 : << (sal_uInt32)cbBitsSrc
1041 [ + - ]: 12 : << (sal_uInt16)0
1042 [ + - ]: 12 : << (sal_uInt16)0
1043 [ + - ]: 12 : << (sal_uInt32)cbBmiSrc + 14;
1044 [ + - ]: 12 : pWMF->Seek( nStart + offBmiSrc );
1045 [ + - ]: 12 : pWMF->Read( pBuf + 14, cbBmiSrc );
1046 [ + - ]: 12 : pWMF->Seek( nStart + offBitsSrc );
1047 [ + - ]: 12 : pWMF->Read( pBuf + 14 + cbBmiSrc, cbBitsSrc );
1048 [ + - ]: 12 : aTmp.Seek( 0 );
1049 [ + - ]: 12 : aBitmap.Read( aTmp, sal_True );
1050 : :
1051 : : // test if it is sensible to crop
1052 [ + - ][ + - ]: 48 : if ( ( cxSrc > 0 ) && ( cySrc > 0 ) &&
[ + - ][ + -
+ - + - ]
[ + - ]
1053 : : ( xSrc >= 0 ) && ( ySrc >= 0 ) &&
1054 [ + - ][ + - ]: 24 : ( xSrc + cxSrc <= aBitmap.GetSizePixel().Width() ) &&
[ # # ]
1055 [ + - ][ + - ]: 24 : ( ySrc + cySrc <= aBitmap.GetSizePixel().Height() ) )
[ # # ]
1056 : : {
1057 [ + - ]: 12 : Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
1058 [ + - ]: 12 : aBitmap.Crop( aCropRect );
1059 : : }
1060 [ + - ][ + - ]: 12 : aBmpSaveList.push_back( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ) );
[ + - ][ + - ]
1061 : : }
1062 [ + - ]: 12 : }
1063 : : }
1064 : 12 : break;
1065 : :
1066 : : case EMR_EXTCREATEFONTINDIRECTW :
1067 : : {
1068 [ + - ]: 185 : *pWMF >> nIndex;
1069 [ + - ]: 185 : if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
1070 : : {
1071 [ + - ]: 185 : LOGFONTW aLogFont;
1072 [ + - ]: 185 : *pWMF >> aLogFont.lfHeight
1073 [ + - ]: 185 : >> aLogFont.lfWidth
1074 [ + - ]: 185 : >> aLogFont.lfEscapement
1075 [ + - ]: 185 : >> aLogFont.lfOrientation
1076 [ + - ]: 185 : >> aLogFont.lfWeight
1077 [ + - ]: 185 : >> aLogFont.lfItalic
1078 [ + - ]: 185 : >> aLogFont.lfUnderline
1079 [ + - ]: 185 : >> aLogFont.lfStrikeOut
1080 [ + - ]: 185 : >> aLogFont.lfCharSet
1081 [ + - ]: 185 : >> aLogFont.lfOutPrecision
1082 [ + - ]: 185 : >> aLogFont.lfClipPrecision
1083 [ + - ]: 185 : >> aLogFont.lfQuality
1084 [ + - ]: 185 : >> aLogFont.lfPitchAndFamily;
1085 : :
1086 : : sal_Unicode lfFaceName[ LF_FACESIZE ];
1087 : :
1088 [ + + ]: 6105 : for ( int i = 0; i < LF_FACESIZE; i++ )
1089 : : {
1090 : : sal_uInt16 nChar;
1091 [ + - ]: 5920 : *pWMF >> nChar;
1092 : 5920 : lfFaceName[ i ] = nChar;
1093 : : }
1094 [ + - ]: 185 : aLogFont.alfFaceName = rtl::OUString( lfFaceName );
1095 [ + - ][ + - ]: 185 : pOut->CreateObject( nIndex, GDI_FONT, new WinMtfFontStyle( aLogFont ) );
[ + - ][ + - ]
1096 : : }
1097 : : }
1098 : 185 : break;
1099 : :
1100 : : case EMR_EXTTEXTOUTA :
1101 : 0 : bFlag = sal_True;
1102 : : case EMR_EXTTEXTOUTW :
1103 : : {
1104 : : sal_Int32 nLeft, nTop, nRight, nBottom, ptlReferenceX, ptlReferenceY, nGfxMode, nXScale, nYScale;
1105 : : sal_uInt32 nCurPos, nLen, nOffString, nOptions, offDx;
1106 : 191 : sal_Int32* pDX = NULL;
1107 : :
1108 : 191 : nCurPos = pWMF->Tell() - 8;
1109 : :
1110 [ + - ][ + - ]: 191 : *pWMF >> nLeft >> nTop >> nRight >> nBottom >> nGfxMode >> nXScale >> nYScale
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
1111 [ + - ][ + - ]: 191 : >> ptlReferenceX >> ptlReferenceY >> nLen >> nOffString >> nOptions;
[ + - ][ + - ]
[ + - ]
1112 : :
1113 [ + - ]: 191 : pWMF->SeekRel( 0x10 );
1114 [ + - ]: 191 : *pWMF >> offDx;
1115 : :
1116 : 191 : sal_Int32 nTextLayoutMode = TEXT_LAYOUT_DEFAULT;
1117 [ - + ]: 191 : if ( nOptions & ETO_RTLREADING )
1118 : 0 : nTextLayoutMode = TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_LEFT;
1119 [ + - ]: 191 : pOut->SetTextLayoutMode( nTextLayoutMode );
1120 : : DBG_ASSERT( ( nOptions & ( ETO_PDY | ETO_GLYPH_INDEX ) ) == 0, "SJ: ETO_PDY || ETO_GLYPH_INDEX in EMF" );
1121 : :
1122 : 191 : Point aPos( ptlReferenceX, ptlReferenceY );
1123 [ + - ][ + - ]: 191 : if ( nLen && ( nLen < SAL_MAX_UINT32 / sizeof(sal_Int32) ) )
1124 : : {
1125 [ + - ][ + - ]: 191 : if ( offDx && (( nCurPos + offDx + nLen * 4 ) <= nNextPos ) )
1126 : : {
1127 [ + - ]: 191 : pWMF->Seek( nCurPos + offDx );
1128 [ + - ]: 191 : if ( ( nLen * sizeof(sal_uInt32) ) <= ( nEndPos - pWMF->Tell() ) )
1129 : : {
1130 [ + - ]: 191 : pDX = new sal_Int32[ nLen ];
1131 : : sal_uInt32 i;
1132 [ + + ]: 985 : for ( i = 0; i < nLen; i++ )
1133 [ + - ]: 794 : *pWMF >> pDX[ i ];
1134 : : }
1135 : : }
1136 [ + - ]: 191 : pWMF->Seek( nCurPos + nOffString );
1137 [ + - ]: 191 : String aText;
1138 [ - + ]: 191 : if ( bFlag )
1139 : : {
1140 [ # # ]: 0 : if ( nLen <= ( nEndPos - pWMF->Tell() ) )
1141 : : {
1142 [ # # ]: 0 : sal_Char* pBuf = new sal_Char[ nLen ];
1143 [ # # ]: 0 : pWMF->Read( pBuf, nLen );
1144 [ # # ][ # # ]: 0 : aText = String( pBuf, (sal_uInt16)nLen, pOut->GetCharSet() );
[ # # ][ # # ]
1145 [ # # ]: 0 : delete[] pBuf;
1146 : :
1147 [ # # ]: 0 : if ( aText.Len() != nLen )
1148 : : {
1149 : : sal_uInt16 i, j;
1150 : 0 : sal_Int32* pOldDx = pDX;
1151 [ # # ]: 0 : pDX = new sal_Int32[ aText.Len() ];
1152 [ # # ]: 0 : for ( i = 0, j = 0; i < aText.Len(); i++ )
1153 : : {
1154 : 0 : sal_Unicode cUniChar = aText.GetChar(i);
1155 [ # # ][ # # ]: 0 : rtl::OString aCharacter(&cUniChar, 1, pOut->GetCharSet());
1156 : 0 : pDX[ i ] = 0;
1157 [ # # ][ # # ]: 0 : for (sal_Int32 k = 0; ( k < aCharacter.getLength() ) && ( j < nLen ) && ( i < aText.Len() ); ++k)
[ # # ][ # # ]
1158 : 0 : pDX[ i ] += pOldDx[ j++ ];
1159 : 0 : }
1160 [ # # ]: 0 : delete[] pOldDx;
1161 : : }
1162 : : }
1163 : : }
1164 : : else
1165 : : {
1166 [ + - ]: 191 : if ( ( nLen * sizeof(sal_Unicode) ) <= ( nEndPos - pWMF->Tell() ) )
1167 : : {
1168 [ + - ]: 191 : sal_Unicode* pBuf = new sal_Unicode[ nLen ];
1169 [ + - ]: 191 : pWMF->Read( pBuf, nLen << 1 );
1170 : : #ifdef OSL_BIGENDIAN
1171 : : sal_Char nTmp, *pTmp = (sal_Char*)( pBuf + nLen );
1172 : : while ( pTmp-- != (sal_Char*)pBuf )
1173 : : {
1174 : : nTmp = *pTmp--;
1175 : : pTmp[ 1 ] = *pTmp;
1176 : : *pTmp = nTmp;
1177 : : }
1178 : : #endif
1179 [ + - ]: 191 : aText = rtl::OUString(pBuf, nLen);
1180 [ + - ]: 191 : delete[] pBuf;
1181 : : }
1182 : : }
1183 [ + - ][ + - ]: 191 : pOut->DrawText( aPos, aText, pDX, bRecordPath, nGfxMode );
1184 : : }
1185 [ + - ]: 191 : delete[] pDX;
1186 : : }
1187 : 191 : break;
1188 : :
1189 : : case EMR_POLYBEZIERTO16 :
1190 [ # # ][ # # ]: 0 : ReadAndDrawPolygon<sal_Int16>(boost::bind(&WinMtfOutput::DrawPolyBezier, _1, _2, _3, _4), sal_True);
1191 : 0 : break;
1192 : : case EMR_POLYBEZIER16 :
1193 [ # # ][ # # ]: 0 : ReadAndDrawPolygon<sal_Int16>(boost::bind(&WinMtfOutput::DrawPolyBezier, _1, _2, _3, _4), sal_False);
1194 : 0 : break;
1195 : :
1196 : : case EMR_POLYGON16 :
1197 [ # # ][ # # ]: 0 : ReadAndDrawPolygon<sal_Int16>(boost::bind(&WinMtfOutput::DrawPolygon, _1, _2, _3, _4), sal_False);
1198 : 0 : break;
1199 : :
1200 : : case EMR_POLYLINETO16 :
1201 [ # # ][ # # ]: 0 : ReadAndDrawPolygon<sal_Int16>(boost::bind(&WinMtfOutput::DrawPolyLine, _1, _2, _3, _4), sal_True);
1202 : 0 : break;
1203 : : case EMR_POLYLINE16 :
1204 [ # # ][ # # ]: 0 : ReadAndDrawPolygon<sal_Int16>(boost::bind(&WinMtfOutput::DrawPolyLine, _1, _2, _3, _4), sal_False);
1205 : 0 : break;
1206 : :
1207 : : case EMR_POLYPOLYLINE16 :
1208 [ # # ]: 0 : ReadAndDrawPolyLine<sal_uInt16>();
1209 : 0 : break;
1210 : :
1211 : : case EMR_POLYPOLYGON16 :
1212 [ # # ]: 0 : ReadAndDrawPolyPolygon<sal_uInt16>();
1213 : 0 : break;
1214 : :
1215 : : case EMR_FILLRGN :
1216 : : {
1217 : : sal_uInt32 nLen;
1218 [ # # ]: 0 : PolyPolygon aPolyPoly;
1219 [ # # ]: 0 : pWMF->SeekRel( 0x10 );
1220 [ # # ][ # # ]: 0 : *pWMF >> nLen >> nIndex;
1221 : :
1222 [ # # ][ # # ]: 0 : if ( ImplReadRegion( aPolyPoly, *pWMF, nRecSize ) )
1223 : : {
1224 [ # # ]: 0 : pOut->Push();
1225 [ # # ]: 0 : pOut->SelectObject( nIndex );
1226 [ # # ]: 0 : pOut->DrawPolyPolygon( aPolyPoly, sal_False );
1227 [ # # ]: 0 : pOut->Pop();
1228 [ # # ]: 0 : }
1229 : : }
1230 : 0 : break;
1231 : :
1232 : : case EMR_CREATEDIBPATTERNBRUSHPT :
1233 : : {
1234 : 3 : sal_uInt32 nStart = pWMF->Tell() - 8;
1235 [ + - ]: 3 : Bitmap aBitmap;
1236 : :
1237 [ + - ]: 3 : *pWMF >> nIndex;
1238 : :
1239 [ + - ]: 3 : if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
1240 : : {
1241 : : sal_uInt32 usage, offBmi, cbBmi, offBits, cbBits;
1242 : :
1243 [ + - ]: 3 : *pWMF >> usage;
1244 [ + - ]: 3 : *pWMF >> offBmi;
1245 [ + - ]: 3 : *pWMF >> cbBmi;
1246 [ + - ]: 3 : *pWMF >> offBits;
1247 [ + - ]: 3 : *pWMF >> cbBits;
1248 : :
1249 [ + - ][ - + ]: 3 : if ( (cbBits > (SAL_MAX_UINT32 - 14)) || ((SAL_MAX_UINT32 - 14) - cbBits < cbBmi) )
1250 : 0 : bStatus = sal_False;
1251 [ + - ]: 3 : else if ( offBmi )
1252 : : {
1253 : 3 : sal_uInt32 nSize = cbBmi + cbBits + 14;
1254 [ + - ]: 3 : if ( nSize <= ( nEndPos - nStartPos ) )
1255 : : {
1256 [ + - ]: 3 : char* pBuf = new char[ nSize ];
1257 : :
1258 [ + - ]: 3 : SvMemoryStream aTmp( pBuf, nSize, STREAM_READ | STREAM_WRITE );
1259 : 3 : aTmp.ObjectOwnsMemory( sal_True );
1260 [ + - ]: 3 : aTmp << (sal_uInt8)'B'
1261 [ + - ]: 3 : << (sal_uInt8)'M'
1262 [ + - ]: 3 : << (sal_uInt32)cbBits
1263 [ + - ]: 3 : << (sal_uInt16)0
1264 [ + - ]: 3 : << (sal_uInt16)0
1265 [ + - ]: 3 : << (sal_uInt32)cbBmi + 14;
1266 [ + - ]: 3 : pWMF->Seek( nStart + offBmi );
1267 [ + - ]: 3 : pWMF->Read( pBuf + 14, cbBmi );
1268 [ + - ]: 3 : pWMF->Seek( nStart + offBits );
1269 [ + - ]: 3 : pWMF->Read( pBuf + 14 + cbBmi, cbBits );
1270 [ + - ]: 3 : aTmp.Seek( 0 );
1271 [ + - ][ + - ]: 3 : aBitmap.Read( aTmp, sal_True );
1272 : : }
1273 : : }
1274 : : }
1275 : :
1276 [ + - ][ + - ]: 3 : pOut->CreateObject( nIndex, GDI_BRUSH, new WinMtfFillStyle( aBitmap ) );
[ + - ][ + - ]
1277 : : }
1278 : 3 : break;
1279 : :
1280 : : #ifdef WIN_MTF_ASSERT
1281 : : default : WinMtfAssertHandler( "Unknown Meta Action" ); break;
1282 : : case EMR_MASKBLT : WinMtfAssertHandler( "MaskBlt" ); break;
1283 : : case EMR_PLGBLT : WinMtfAssertHandler( "PlgBlt" ); break;
1284 : : case EMR_SETDIBITSTODEVICE : WinMtfAssertHandler( "SetDIBitsToDevice" ); break;
1285 : : case EMR_FRAMERGN : WinMtfAssertHandler( "FrameRgn" ); break;
1286 : : case EMR_INVERTRGN : WinMtfAssertHandler( "InvertRgn" ); break;
1287 : : case EMR_PAINTRGN : WinMtfAssertHandler( "PaintRgn" ); break;
1288 : : case EMR_FLATTENPATH : WinMtfAssertHandler( "FlattenPath" ); break;
1289 : : case EMR_WIDENPATH : WinMtfAssertHandler( "WidenPath" ); break;
1290 : : case EMR_POLYDRAW : WinMtfAssertHandler( "Polydraw" ); break;
1291 : : case EMR_SETARCDIRECTION : WinMtfAssertHandler( "SetArcDirection" ); break;
1292 : : case EMR_SETPALETTEENTRIES : WinMtfAssertHandler( "SetPaletteEntries" ); break;
1293 : : case EMR_RESIZEPALETTE : WinMtfAssertHandler( "ResizePalette" ); break;
1294 : : case EMR_EXTFLOODFILL : WinMtfAssertHandler( "ExtFloodFill" ); break;
1295 : : case EMR_ANGLEARC : WinMtfAssertHandler( "AngleArc" ); break;
1296 : : case EMR_SETCOLORADJUSTMENT : WinMtfAssertHandler( "SetColorAdjustment" ); break;
1297 : : case EMR_POLYDRAW16 : WinMtfAssertHandler( "PolyDraw16" ); break;
1298 : : case EMR_POLYTEXTOUTA : WinMtfAssertHandler( "PolyTextOutA" ); break;
1299 : : case EMR_POLYTEXTOUTW : WinMtfAssertHandler( "PolyTextOutW" ); break;
1300 : : case EMR_CREATECOLORSPACE : WinMtfAssertHandler( "CreateColorSpace" ); break;
1301 : : case EMR_SETCOLORSPACE : WinMtfAssertHandler( "SetColorSpace" ); break;
1302 : : case EMR_DELETECOLORSPACE : WinMtfAssertHandler( "DeleteColorSpace" ); break;
1303 : : case EMR_GLSRECORD : WinMtfAssertHandler( "GlsRecord" ); break;
1304 : : case EMR_GLSBOUNDEDRECORD : WinMtfAssertHandler( "GlsBoundRecord" ); break;
1305 : : case EMR_PIXELFORMAT : WinMtfAssertHandler( "PixelFormat" ); break;
1306 : : case EMR_DRAWESCAPE : WinMtfAssertHandler( "DrawEscape" ); break;
1307 : : case EMR_EXTESCAPE : WinMtfAssertHandler( "ExtEscape" ); break;
1308 : : case EMR_STARTDOC : WinMtfAssertHandler( "StartDoc" ); break;
1309 : : case EMR_SMALLTEXTOUT : WinMtfAssertHandler( "SmallTextOut" ); break;
1310 : : case EMR_FORCEUFIMAPPING : WinMtfAssertHandler( "ForceUFIMapping" ); break;
1311 : : case EMR_NAMEDESCAPE : WinMtfAssertHandler( "NamedEscape" ); break;
1312 : : case EMR_COLORCORRECTPALETTE : WinMtfAssertHandler( "ColorCorrectPalette" ); break;
1313 : : case EMR_SETICMPROFILEA : WinMtfAssertHandler( "SetICMProfileA" ); break;
1314 : : case EMR_SETICMPROFILEW : WinMtfAssertHandler( "SetICMProfileW" ); break;
1315 : : case EMR_ALPHABLEND : WinMtfAssertHandler( "Alphablend" ); break;
1316 : : case EMR_TRANSPARENTBLT : WinMtfAssertHandler( "TransparenBlt" ); break;
1317 : : case EMR_TRANSPARENTDIB : WinMtfAssertHandler( "TransparenDib" ); break;
1318 : : case EMR_GRADIENTFILL : WinMtfAssertHandler( "GradientFill" ); break;
1319 : : case EMR_SETLINKEDUFIS : WinMtfAssertHandler( "SetLinkedUFIS" ); break;
1320 : :
1321 : : case EMR_SETMAPPERFLAGS : WinMtfAssertHandler( "SetMapperFlags", 0 ); break;
1322 : : case EMR_SETICMMODE : WinMtfAssertHandler( "SetICMMode", 0 ); break;
1323 : : case EMR_CREATEMONOBRUSH : WinMtfAssertHandler( "CreateMonoBrush", 0 ); break;
1324 : : case EMR_SETBRUSHORGEX : WinMtfAssertHandler( "SetBrushOrgEx", 0 ); break;
1325 : : case EMR_SETMETARGN : WinMtfAssertHandler( "SetMetArgn", 0 ); break;
1326 : : case EMR_SETMITERLIMIT : WinMtfAssertHandler( "SetMiterLimit", 0 ); break;
1327 : : case EMR_EXCLUDECLIPRECT : WinMtfAssertHandler( "ExcludeClipRect", 0 ); break;
1328 : : case EMR_REALIZEPALETTE : WinMtfAssertHandler( "RealizePalette", 0 ); break;
1329 : : case EMR_SELECTPALETTE : WinMtfAssertHandler( "SelectPalette", 0 ); break;
1330 : : case EMR_CREATEPALETTE : WinMtfAssertHandler( "CreatePalette", 0 ); break;
1331 : : case EMR_ALPHADIBBLEND : WinMtfAssertHandler( "AlphaDibBlend", 0 ); break;
1332 : : case EMR_SETTEXTJUSTIFICATION : WinMtfAssertHandler( "SetTextJustification", 0 ); break;
1333 : :
1334 : : case EMR_GDICOMMENT :
1335 : : case EMR_HEADER : // has already been read at ReadHeader()
1336 : : break;
1337 : : #endif
1338 : : }
1339 [ + - ]: 9194 : pWMF->Seek( nNextPos );
1340 : : }
1341 [ - + ]: 44 : if( !aBmpSaveList.empty() )
1342 [ # # ]: 0 : pOut->ResolveBitmapActions( aBmpSaveList );
1343 : :
1344 [ + + ]: 44 : if ( bStatus )
1345 [ + - ]: 35 : pWMF->Seek(nEndPos);
1346 : :
1347 : 44 : return bStatus;
1348 : : };
1349 : :
1350 : : //-----------------------------------------------------------------------------------
1351 : :
1352 : 44 : sal_Bool EnhWMFReader::ReadHeader()
1353 : : {
1354 : : sal_uInt32 nsal_uInt32, nHeaderSize, nPalEntries;
1355 : : sal_Int32 nLeft, nTop, nRight, nBottom;
1356 : :
1357 : : // Spare me the METAFILEHEADER here
1358 : : // Reading the METAHEADER
1359 [ + - ][ + - ]: 44 : *pWMF >> nsal_uInt32 >> nHeaderSize;
1360 [ - + ]: 44 : if ( nsal_uInt32 != 1 ) // Type
1361 : 0 : return sal_False;
1362 : :
1363 : : // bound size
1364 [ + - ]: 44 : Rectangle rclBounds; // rectangle in logical units 1/100th mm
1365 [ + - ][ + - ]: 44 : *pWMF >> nLeft >> nTop >> nRight >> nBottom;
[ + - ][ + - ]
1366 : 44 : rclBounds.Left() = nLeft;
1367 : 44 : rclBounds.Top() = nTop;
1368 : 44 : rclBounds.Right() = nRight;
1369 : 44 : rclBounds.Bottom() = nBottom;
1370 : :
1371 : : // picture frame size
1372 [ + - ]: 44 : Rectangle rclFrame; // rectangle in device units
1373 [ + - ][ + - ]: 44 : *pWMF >> nLeft >> nTop >> nRight >> nBottom;
[ + - ][ + - ]
1374 : 44 : rclFrame.Left() = nLeft;
1375 : 44 : rclFrame.Top() = nTop;
1376 : 44 : rclFrame.Right() = nRight;
1377 : 44 : rclFrame.Bottom() = nBottom;
1378 : :
1379 [ + - ]: 44 : *pWMF >> nsal_uInt32; // signature
1380 : :
1381 [ - + ]: 44 : if ( nsal_uInt32 != 0x464d4520 )
1382 : 0 : return sal_False;
1383 : :
1384 [ + - ]: 44 : *pWMF >> nsal_uInt32; // nVersion
1385 [ + - ]: 44 : *pWMF >> nEndPos; // size of metafile
1386 : 44 : nEndPos += nStartPos;
1387 : :
1388 : 44 : sal_uInt32 nStrmPos = pWMF->Tell(); // checking if nEndPos is valid
1389 [ + - ]: 44 : pWMF->Seek( STREAM_SEEK_TO_END );
1390 [ + + ]: 44 : if ( pWMF->Tell() < nEndPos )
1391 : 3 : nEndPos = pWMF->Tell();
1392 [ + - ]: 44 : pWMF->Seek( nStrmPos );
1393 : :
1394 [ + - ]: 44 : *pWMF >> nRecordCount;
1395 : :
1396 [ - + ]: 44 : if ( !nRecordCount )
1397 : 0 : return sal_False;
1398 : :
1399 [ + - ]: 44 : pWMF->SeekRel( 0xc );
1400 : :
1401 : : sal_Int32 nPixX, nPixY, nMillX, nMillY;
1402 [ + - ][ + - ]: 44 : *pWMF >> nPalEntries >> nPixX >> nPixY >> nMillX >> nMillY;
[ + - ][ + - ]
[ + - ]
1403 : :
1404 [ + - ]: 44 : pOut->SetrclFrame( rclFrame );
1405 [ + - ]: 44 : pOut->SetrclBounds( rclBounds );
1406 [ + - ]: 44 : pOut->SetRefPix( Size( nPixX, nPixY ) );
1407 [ + - ]: 44 : pOut->SetRefMill( Size( nMillX, nMillY ) );
1408 : :
1409 [ + - ]: 44 : pWMF->Seek( nStartPos + nHeaderSize );
1410 : 44 : return sal_True;
1411 : : }
1412 : :
1413 : : //-----------------------------------------------------------------------------------
1414 : :
1415 : 36 : Rectangle EnhWMFReader::ReadRectangle( sal_Int32 x1, sal_Int32 y1, sal_Int32 x2, sal_Int32 y2 )
1416 : : {
1417 : 36 : Point aTL ( Point( x1, y1 ) );
1418 : 36 : Point aBR( Point( --x2, --y2 ) );
1419 [ + - ]: 36 : return Rectangle( aTL, aBR );
1420 : : }
1421 : :
1422 : 44 : EnhWMFReader::~EnhWMFReader()
1423 : : {
1424 : :
1425 [ + - ][ + - ]: 887 : };
1426 : :
1427 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|