1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _WINMTF_HXX
25 #define _WINMTF_HXX
26 
27 #ifdef DBG_UTIL
28 #define WIN_MTF_ASSERT
29 #endif
30 
31 #include <sot/object.hxx>
32 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
33 #include <boost/shared_ptr.hpp>
34 #endif
35 #ifndef _TOOL_DEBUG_HXX
36 #include <tools/debug.hxx>
37 #endif
38 #include <tools/stack.hxx>
39 #include <tools/table.hxx>
40 #include <tools/dynary.hxx>
41 #include <vcl/graph.hxx>
42 #include <tools/poly.hxx>
43 #include <vcl/font.hxx>
44 #include <vcl/bmpacc.hxx>
45 #include <vcl/lineinfo.hxx>
46 #include <svtools/fltcall.hxx>
47 
48 #include <vector>
49 #include <math.h>
50 #include <stdlib.h>
51 
52 #define ERROR                   0
53 #define NULLREGION              1
54 #define SIMPLEREGION            2
55 #define COMPLEXREGION           3
56 
57 #define RGN_AND					1
58 #define RGN_OR					2
59 #define RGN_XOR					3
60 #define RGN_DIFF				4
61 #define RGN_COPY				5
62 
63 #define TRANSPARENT				1
64 #define OPAQUE					2
65 #define BKMODE_LAST				2
66 
67 /* xform stuff */
68 #define MWT_IDENTITY			1
69 #define MWT_LEFTMULTIPLY		2
70 #define MWT_RIGHTMULTIPLY		3
71 #define MWT_SET                 4
72 
73 #define ENHMETA_STOCK_OBJECT    0x80000000
74 
75 /* Stock Logical Objects */
76 #define WHITE_BRUSH				0
77 #define LTGRAY_BRUSH			1
78 #define GRAY_BRUSH				2
79 #define DKGRAY_BRUSH			3
80 #define BLACK_BRUSH				4
81 #define NULL_BRUSH				5
82 #define HOLLOW_BRUSH			NULL_BRUSH
83 #define WHITE_PEN				6
84 #define BLACK_PEN				7
85 #define NULL_PEN				8
86 #define OEM_FIXED_FONT			10
87 #define ANSI_FIXED_FONT			11
88 #define ANSI_VAR_FONT			12
89 #define SYSTEM_FONT				13
90 #define DEVICE_DEFAULT_FONT		14
91 #define DEFAULT_PALETTE			15
92 #define SYSTEM_FIXED_FONT		16
93 
94 
95 #define R2_BLACK				1
96 #define R2_NOTMERGEPEN			2
97 #define R2_MASKNOTPEN			3
98 #define R2_NOTCOPYPEN			4
99 #define R2_MASKPENNOT			5
100 #define R2_NOT					6
101 #define R2_XORPEN				7
102 #define R2_NOTMASKPEN			8
103 #define R2_MASKPEN				9
104 #define R2_NOTXORPEN			10
105 #define R2_NOP					11
106 #define R2_MERGENOTPEN			12
107 #define R2_COPYPEN				13
108 #define R2_MERGEPENNOT			14
109 #define R2_MERGEPEN				15
110 #define R2_WHITE				16
111 
112 /* Mapping Modes */
113 #define MM_TEXT					1
114 #define MM_LOMETRIC				2
115 #define MM_HIMETRIC				3
116 #define MM_LOENGLISH			4
117 #define MM_HIENGLISH			5
118 #define MM_TWIPS				6
119 #define MM_ISOTROPIC			7
120 #define MM_ANISOTROPIC			8
121 
122 
123 /* Graphics Modes */
124 #define GM_COMPATIBLE			1
125 #define GM_ADVANCED				2
126 #define GM_LAST					2
127 
128 /* StretchBlt() Modes */
129 #define BLACKONWHITE			1
130 #define WHITEONBLACK			2
131 #define COLORONCOLOR			3
132 #define HALFTONE				4
133 #define MAXSTRETCHBLTMODE		4
134 #define STRETCH_ANDSCANS		BLACKONWHITE
135 #define STRETCH_ORSCANS			WHITEONBLACK
136 #define STRETCH_DELETESCANS		COLORONCOLOR
137 #define STRETCH_HALFTONE		HALFTONE
138 
139 #define LF_FACESIZE				32
140 
141 struct LOGFONTW
142 {
143 	sal_Int32		lfHeight;
144 	sal_Int32		lfWidth;
145 	sal_Int32		lfEscapement;
146 	sal_Int32		lfOrientation;
147 	sal_Int32		lfWeight;
148 	sal_uInt8		lfItalic;
149 	sal_uInt8		lfUnderline;
150 	sal_uInt8		lfStrikeOut;
151 	sal_uInt8		lfCharSet;
152 	sal_uInt8		lfOutPrecision;
153 	sal_uInt8		lfClipPrecision;
154 	sal_uInt8		lfQuality;
155 	sal_uInt8		lfPitchAndFamily;
156 	String		alfFaceName;
157 };
158 
159 #define TA_NOUPDATECP			0x0000
160 #define TA_UPDATECP				0x0001
161 #define TA_LEFT					0x0000
162 #define TA_RIGHT				0x0002
163 #define TA_CENTER				0x0006
164 #define TA_RIGHT_CENTER	 (TA_RIGHT | TA_CENTER)
165 #define TA_TOP					0x0000
166 #define TA_BOTTOM				0x0008
167 #define TA_BASELINE				0x0018
168 
169 #define SRCCOPY					0x00CC0020L
170 #define SRCPAINT				0x00EE0086L
171 #define SRCAND					0x008800C6L
172 #define SRCINVERT				0x00660046L
173 #define SRCERASE				0x00440328L
174 #define NOTSRCCOPY				0x00330008L
175 #define NOTSRCERASE				0x001100A6L
176 #define MERGECOPY				0x00C000CAL
177 #define MERGEPAINT				0x00BB0226L
178 #define PATCOPY					0x00F00021L
179 #define PATPAINT				0x00FB0A09L
180 #define PATINVERT				0x005A0049L
181 #define DSTINVERT				0x00550009L
182 #define BLACKNESS				0x00000042L
183 #define WHITENESS				0x00FF0062L
184 
185 #define PS_SOLID				0
186 #define PS_DASH					1
187 #define PS_DOT					2
188 #define PS_DASHDOT				3
189 #define PS_DASHDOTDOT			4
190 #define PS_NULL					5
191 #define PS_INSIDEFRAME			6
192 #define PS_USERSTYLE            7
193 #define PS_ALTERNATE            8
194 #define PS_STYLE_MASK           15
195 
196 #define PS_ENDCAP_ROUND     0x000
197 #define PS_ENDCAP_SQUARE    0x100
198 #define PS_ENDCAP_FLAT      0x200
199 #define PS_ENDCAP_MASK      0xF00
200 
201 #define PS_JOIN_ROUND       0x0000
202 #define PS_JOIN_BEVEL       0x1000
203 #define PS_JOIN_MITER       0x2000
204 #define PS_JOIN_MASK        0xF000
205 
206 #define PS_COSMETIC         0x00000
207 #define PS_GEOMETRIC        0x10000
208 #define PS_TYPE_MASK        0xF0000
209 
210 #define ANSI_CHARSET			0
211 #define DEFAULT_CHARSET			1
212 #define SYMBOL_CHARSET			2
213 #define SHIFTJIS_CHARSET		128
214 #define HANGEUL_CHARSET			129
215 #define GB2312_CHARSET			134
216 #define CHINESEBIG5_CHARSET		136
217 #define OEM_CHARSET				255
218 /*WINVER >= 0x0400*/
219 #define JOHAB_CHARSET           130
220 #define HEBREW_CHARSET          177
221 #define ARABIC_CHARSET          178
222 #define GREEK_CHARSET           161
223 #define TURKISH_CHARSET         162
224 #define VIETNAMESE_CHARSET      163
225 #define THAI_CHARSET            222
226 #define EASTEUROPE_CHARSET      238
227 #define RUSSIAN_CHARSET         204
228 #define MAC_CHARSET             77
229 #define BALTIC_CHARSET          186
230 
231 #define ETO_OPAQUE				0x0002
232 #define ETO_CLIPPED				0x0004
233 /*WINVER >= 0x0400*/
234 #define ETO_GLYPH_INDEX			0x0010
235 #define ETO_RTLREADING			0x0080
236 #define ETO_NUMERICSLOCAL		0x0400
237 #define ETO_NUMERICSLATIN		0x0800
238 #define ETO_IGNORELANGUAGE		0x1000
239 /*_WIN32_WINNT >= 0x0500*/
240 #define ETO_PDY					0x2000
241 
242 
243 #define DEFAULT_PITCH			0x00
244 #define FIXED_PITCH				0x01
245 #define VARIABLE_PITCH			0x02
246 
247 /* Font Families */
248 #define FF_DONTCARE				0x00
249 #define FF_ROMAN				0x10
250 #define FF_SWISS				0x20
251 #define FF_MODERN				0x30
252 #define FF_SCRIPT				0x40
253 #define FF_DECORATIVE			0x50
254 
255 #define FW_DONTCARE				0
256 #define FW_THIN					100
257 #define FW_EXTRALIGHT			200
258 #define FW_LIGHT				300
259 #define FW_NORMAL				400
260 #define FW_MEDIUM				500
261 #define FW_SEMIBOLD				600
262 #define FW_BOLD					700
263 #define FW_EXTRABOLD			800
264 #define FW_HEAVY				900
265 #define FW_ULTRALIGHT			200
266 #define FW_REGULAR				400
267 #define FW_DEMIBOLD				600
268 #define FW_ULTRABOLD			800
269 #define FW_BLACK				900
270 
271 #define BS_SOLID				0
272 #define BS_NULL					1
273 #define BS_HOLLOW				1
274 #define BS_HATCHED				2
275 #define BS_PATTERN				3
276 #define BS_INDEXED				4
277 #define BS_DIBPATTERN			5
278 #define BS_DIBPATTERNPT			6
279 #define BS_PATTERN8X8			7
280 #define BS_DIBPATTERN8X8		8
281 #define BS_MONOPATTERN			9
282 
283 #define W_HS_HORIZONTAL			0
284 #define W_HS_VERTICAL			1
285 #define W_HS_FDIAGONAL			2
286 #define W_HS_BDIAGONAL			3
287 #define W_HS_CROSS				4
288 #define W_HS_DIAGCROSS			5
289 
290 #define RDH_RECTANGLES  1
291 
292 #define W_MFCOMMENT				15
293 
294 #define PRIVATE_ESCAPE_UNICODE	2
295 
296 //============================ WMFReader ==================================
297 
298 
299 #ifdef WIN_MTF_ASSERT
300 #define WIN_MTF_ASSERT_INIT     0x80000000
301 #define WIN_MTF_ASSERT_ONCE     0x40000000
302 #define WIN_MTF_ASSERT_MIFE     0x20000000
303 
304 void WinMtfAssertHandler( const sal_Char*, sal_uInt32 nFlags = WIN_MTF_ASSERT_MIFE );
305 #endif
306 
307 enum WinMtfClipPathType{ EMPTY, RECTANGLE, COMPLEX };
308 
309 class WinMtfClipPath
310 {
311 		PolyPolygon			aPolyPoly;
312 		WinMtfClipPathType	eType;
313 		sal_Int32			nDepth;
314 
315 		void		ImpUpdateType();
316 
317 	public :
318 
319 		sal_Bool	bNeedsUpdate;
320 
WinMtfClipPath()321 					WinMtfClipPath(): eType(EMPTY), nDepth( 0 ), bNeedsUpdate( sal_False ){};
322 
323 		void		SetClipPath( const PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode );
324 		void		IntersectClipRect( const Rectangle& rRect );
325 		void		ExcludeClipRect( const Rectangle& rRect );
326 		void		MoveClipRegion( const Size& rSize );
327 
GetType() const328 		WinMtfClipPathType GetType() const { return eType; };
GetClipPath() const329 		const PolyPolygon& GetClipPath() const { return aPolyPoly; };
330 
operator ==(const WinMtfClipPath & rPath)331     	sal_Bool operator==( const WinMtfClipPath& rPath )
332         {
333             return  ( rPath.eType == eType ) &&
334                     ( rPath.aPolyPoly == aPolyPoly );
335         };
336 };
337 
338 class WinMtfPathObj : public PolyPolygon
339 {
340 		sal_Bool	bClosed;
341 
342 	public :
343 
WinMtfPathObj()344                 WinMtfPathObj() { bClosed = sal_True; }
Init()345         void    Init() { Clear(); bClosed = sal_True; };
346 		void	ClosePath();
347 
348 		void	AddPoint( const Point& rPoint );
349 		void	AddPolygon( const Polygon& rPoly );
350 		void	AddPolyLine( const Polygon& rPoly );
351 		void	AddPolyPolygon( const PolyPolygon& rPolyPolygon );
352 };
353 
354 struct WinMtfFontStyle
355 {
356 	Font		aFont;
357 
358 	WinMtfFontStyle( LOGFONTW& rLogFont );
359 };
360 
361 // -----------------------------------------------------------------------------
362 
363 struct WinMtfFillStyle
364 {
365 	Color	aFillColor;
366 	sal_Bool	bTransparent;
367 
WinMtfFillStyleWinMtfFillStyle368 	WinMtfFillStyle() :
369 		aFillColor	( Color( COL_BLACK ) ),
370 		bTransparent( sal_False )
371 	{
372 	};
373 
WinMtfFillStyleWinMtfFillStyle374 	WinMtfFillStyle( const Color& rColor, sal_Bool bTrans = sal_False ) :
375 		aFillColor	( rColor ),
376 		bTransparent( bTrans )
377 	{
378 	};
379 
operator ==WinMtfFillStyle380 	sal_Bool operator==( const WinMtfFillStyle& rStyle )
381 		{ return ( ( aFillColor == rStyle.aFillColor ) && ( bTransparent == rStyle.bTransparent ) ); };
operator ==WinMtfFillStyle382 	sal_Bool operator==( WinMtfFillStyle* pStyle )
383 		{ return ( ( aFillColor == pStyle->aFillColor ) && ( bTransparent == pStyle->bTransparent ) ); };
operator =WinMtfFillStyle384 	void operator=( const WinMtfFillStyle& rStyle ) { aFillColor = rStyle.aFillColor; bTransparent = rStyle.bTransparent; };
operator =WinMtfFillStyle385 	void operator=( WinMtfFillStyle* pStyle ) { aFillColor = pStyle->aFillColor; bTransparent = pStyle->bTransparent; };
386 };
387 
388 // -----------------------------------------------------------------------------
389 
390 struct WinMtfLineStyle
391 {
392 	Color		aLineColor;
393 	LineInfo	aLineInfo;
394 	sal_Bool		bTransparent;
395 
WinMtfLineStyleWinMtfLineStyle396 	WinMtfLineStyle() :
397 		aLineColor	( COL_BLACK ),
398 		bTransparent( sal_False ) {};
399 
WinMtfLineStyleWinMtfLineStyle400 	WinMtfLineStyle( const Color& rColor, sal_Bool bTrans = sal_False ) :
401 		aLineColor	( rColor ),
402 		bTransparent( bTrans ) {};
403 
WinMtfLineStyleWinMtfLineStyle404 	WinMtfLineStyle( const Color& rColor, const LineInfo rStyle, sal_Bool bTrans = sal_False ) :
405 		aLineColor	( rColor ),
406 		aLineInfo	( rStyle ),
407 		bTransparent( bTrans ) {};
408 
operator ==WinMtfLineStyle409 	sal_Bool operator==( const WinMtfLineStyle& rStyle ) { return ( ( aLineColor == rStyle.aLineColor ) && ( bTransparent == rStyle.bTransparent ) && ( aLineInfo == rStyle.aLineInfo ) ); };
operator ==WinMtfLineStyle410 	sal_Bool operator==( WinMtfLineStyle* pStyle ) { return ( ( aLineColor == pStyle->aLineColor ) && ( bTransparent == pStyle->bTransparent ) && ( aLineInfo == pStyle->aLineInfo ) ); };
operator =WinMtfLineStyle411 	void operator=( const WinMtfLineStyle& rStyle )
412 	{
413 		aLineColor = rStyle.aLineColor;
414 		bTransparent = rStyle.bTransparent;
415 		aLineInfo = rStyle.aLineInfo;
416 	};
417 
operator =WinMtfLineStyle418 	void operator=( WinMtfLineStyle* pStyle )
419 	{
420 		aLineColor = pStyle->aLineColor;
421 		bTransparent = pStyle->bTransparent;
422 		aLineInfo = pStyle->aLineInfo;
423 	};
424 };
425 
426 // -----------------------------------------------------------------------------
427 
428 struct XForm
429 {
430 	float	eM11;
431 	float	eM12;
432 	float	eM21;
433 	float	eM22;
434 	float	eDx;
435 	float	eDy;
XFormXForm436 	XForm()
437 	{
438 		eM11 =  eM22 = 1.0f;
439         eDx = eDy = eM12 = eM21 = 0.0f;
440 	};
441 
442     friend SvStream& operator>>( SvStream& rIn, XForm& rXForm );
443 };
444 
445 // -----------------------------------------------------------------------------
446 
447 struct SaveStruct
448 {
449 	sal_uInt32          nBkMode, nMapMode, nGfxMode, nTextLayoutMode;
450 	sal_Int32			nWinOrgX, nWinOrgY, nWinExtX, nWinExtY;
451 	sal_Int32			nDevOrgX, nDevOrgY, nDevWidth, nDevHeight;
452 
453 	WinMtfLineStyle		aLineStyle;
454 	WinMtfFillStyle		aFillStyle;
455 
456 	Font				aFont;
457 	Color				aBkColor;
458 	Color				aTextColor;
459     sal_uInt32          nTextAlign;
460     RasterOp            eRasterOp;
461 
462 	Point				aActPos;
463 	WinMtfPathObj		aPathObj;
464 	WinMtfClipPath		aClipPath;
465     XForm				aXForm;
466 
467 	sal_Bool			bRecordPath;
468 	sal_Bool			bFillStyleSelected;
469 };
470 
471 typedef ::boost::shared_ptr< SaveStruct > SaveStructPtr;
472 
473 // -----------------------------------------------------------------------------
474 
475 struct BSaveStruct
476 {
477 	Bitmap		aBmp;
478 	Rectangle	aOutRect;
479 	sal_uInt32		nWinRop;
480 
BSaveStructBSaveStruct481 				BSaveStruct( const Bitmap& rBmp, const Rectangle& rOutRect, sal_uInt32 nRop ) :
482 					aBmp( rBmp ), aOutRect( rOutRect ), nWinRop( nRop ){};
483 };
484 
485 // -----------------------------------------------------------------------------
486 
487 enum GDIObjectType { GDI_DUMMY = 0, GDI_PEN = 1, GDI_BRUSH = 2, GDI_FONT = 3, GDI_PALETTE = 4, GDI_BITMAP = 5, GDI_REGION = 6 };
488 
489 struct GDIObj
490 {
491 	void*			pStyle;
492 	GDIObjectType 	eType;
493 
GDIObjGDIObj494 	GDIObj() :
495 		pStyle	( NULL ),
496 		eType	( GDI_DUMMY )
497 	{
498 	};
499 
GDIObjGDIObj500 	GDIObj( GDIObjectType eT, void* pS ) { pStyle = pS; eType = eT; };
SetGDIObj501 	void Set( GDIObjectType eT, void* pS ) { pStyle = pS; eType = eT; };
DeleteGDIObj502 	void Delete()
503 	{
504 		if ( pStyle )
505 		{
506 			switch ( eType )
507 			{
508 				case GDI_PEN :
509 					delete (WinMtfLineStyle*)pStyle;
510 				break;
511 				case GDI_BRUSH :
512 					delete (WinMtfFillStyle*)pStyle;
513 				break;
514 				case GDI_FONT :
515 					delete (WinMtfFontStyle*)pStyle;
516 				break;
517 
518 				default:
519                     DBG_ERROR( "unsupported style deleted" );
520                     break;
521 			}
522 			pStyle = NULL;
523 		}
524 	};
525 
~GDIObjGDIObj526 	~GDIObj()
527 	{
528 		Delete();
529 	}
530 };
531 
532 // -----------------------------------------------------------------------------
533 
534 class WinMtfOutput
535 {
536 
537 		WinMtfPathObj		aPathObj;
538 		WinMtfClipPath		aClipPath;
539 
540 		WinMtfLineStyle		maLatestLineStyle;
541 		WinMtfLineStyle		maLineStyle;
542 		WinMtfFillStyle		maLatestFillStyle;
543 		WinMtfFillStyle		maFillStyle;
544         Font                maLatestFont;
545 		Font				maFont;
546         sal_uInt32          mnLatestTextAlign;
547         sal_uInt32          mnTextAlign;
548         Color               maLatestTextColor;
549 		Color				maTextColor;
550         Color               maLatestBkColor;
551 		Color				maBkColor;
552 		sal_uInt32			mnLatestTextLayoutMode;
553 		sal_uInt32			mnTextLayoutMode;
554         sal_uInt32          mnLatestBkMode;
555 		sal_uInt32          mnBkMode;
556 		RasterOp            meLatestRasterOp;
557         RasterOp			meRasterOp;
558 
559 		std::vector< GDIObj* > vGDIObj;
560 
561 		Point				maActPos;
562 
563 		sal_uInt32          mnRop;
564 		sal_Bool            mbNopMode;
565 		sal_Bool			mbFillStyleSelected;
566 
567 		std::vector< SaveStructPtr > vSaveStack;
568 
569 		sal_uInt32			mnGfxMode;
570         sal_uInt32          mnMapMode;
571 		XForm				maXForm;
572 		sal_Int32			mnDevOrgX, mnDevOrgY;
573 		sal_Int32			mnDevWidth, mnDevHeight;
574 		sal_Int32			mnWinOrgX, mnWinOrgY;		// aktuelles Window-Origin
575 		sal_Int32			mnWinExtX, mnWinExtY;		// aktuelles Window-Extent
576 
577 		sal_Int32			mnPixX, mnPixY;				// Reference Device in pixel
578 		sal_Int32			mnMillX, mnMillY;			// Reference Device in Mill
579 		Rectangle			mrclFrame;					// rectangle in logical units 1/100th mm
580 		Rectangle			mrclBounds;
581 
582 		GDIMetaFile*		mpGDIMetaFile;
583 
584 		void				UpdateLineStyle();
585 		void				UpdateFillStyle();
586 
587 		Point				ImplMap( const Point& rPt );
588 		Size				ImplMap( const Size& rSz );
589 		Rectangle			ImplMap( const Rectangle& rRectangle );
590 		void				ImplMap( Font& rFont );
591 		Polygon&			ImplMap( Polygon& rPolygon );
592 		PolyPolygon&		ImplMap( PolyPolygon& rPolyPolygon );
593 		void				ImplResizeObjectArry( sal_uInt32 nNewEntry );
594 		void				ImplSetNonPersistentLineColorTransparenz();
595 		void				ImplDrawClippedPolyPolygon( const PolyPolygon& rPolyPoly );
596 		void				ImplDrawBitmap( const Point& rPos, const Size& rSize, const BitmapEx rBitmap );
597 
598 	public:
599 
600 		void				SetDevOrg( const Point& rPoint );
601 		void				SetDevOrgOffset( sal_Int32 nXAdd, sal_Int32 nYAdd );
602 		void				SetDevExt( const Size& rSize );
603 		void				ScaleDevExt( double fX, double fY );
604 
605 		void				SetWinOrg( const Point& rPoint );
606 		void				SetWinOrgOffset( sal_Int32 nX, sal_Int32 nY );
607 		void				SetWinExt( const Size& rSize );
608 		void				ScaleWinExt( double fX, double fY );
609 
610 		void				SetrclBounds( const Rectangle& rRect );
611 		void				SetrclFrame( const Rectangle& rRect );
612 		void				SetRefPix( const Size& rSize );
613 		void				SetRefMill( const Size& rSize );
614 
GetMapMode() const615 		sal_uInt32			GetMapMode() const { return mnMapMode; };
616         void                SetMapMode( sal_uInt32 mnMapMode );
617 		void				SetWorldTransform( const XForm& rXForm );
GetWorldTransform() const618         const XForm& GetWorldTransform() const { return maXForm; }
619 		void				ModifyWorldTransform( const XForm& rXForm, sal_uInt32 nMode );
620 
621 		void				Push();
622 		void				Pop();
623 
624 		sal_uInt32				SetRasterOp( sal_uInt32 nRasterOp );
625 		void				StrokeAndFillPath( sal_Bool bStroke, sal_Bool bFill );
626 
SetGfxMode(sal_Int32 nGfxMode)627 		void				SetGfxMode( sal_Int32 nGfxMode ){ mnGfxMode = nGfxMode; };
GetGfxMode() const628 		sal_Int32			GetGfxMode() const { return mnGfxMode; };
629 		void				SetBkMode( sal_uInt32 nMode );
630 		void				SetBkColor( const Color& rColor );
631 		void				SetTextColor( const Color& rColor );
632 		void				SetTextAlign( sal_uInt32 nAlign );
633 		void				CreateObject( GDIObjectType, void* pStyle = NULL );
634 		void				CreateObject( sal_Int32 nIndex, GDIObjectType, void* pStyle = NULL );
635 		void				DeleteObject( sal_Int32 nIndex );
636 		void				SelectObject( sal_Int32 nIndex );
GetCharSet()637 		CharSet				GetCharSet(){ return maFont.GetCharSet(); };
638 		void				SetFont( const Font& rFont );
639 		const Font&			GetFont() const;
640 		void				SetTextLayoutMode( const sal_uInt32 nLayoutMode );
641 		sal_uInt32			GetTextLayoutMode() const;
642 
ClearPath()643 		void				ClearPath(){ aPathObj.Init(); };
ClosePath()644 		void				ClosePath(){ aPathObj.ClosePath(); };
GetPathObj()645 		const PolyPolygon&	GetPathObj(){ return aPathObj; };
646 
647 		void				MoveTo( const Point& rPoint, sal_Bool bRecordPath = sal_False );
648 		void				LineTo( const Point& rPoint, sal_Bool bRecordPath = sal_False );
649 		void				DrawPixel( const Point& rSource, const Color& rColor );
650 		void				DrawLine( const Point& rSource, const Point& rDest );
651 		void				DrawRect( const Rectangle& rRect, sal_Bool bEdge = sal_True );
652 		void				DrawRoundRect( const Rectangle& rRect, const Size& rSize );
653 		void				DrawEllipse( const Rectangle& rRect );
654 		void				DrawArc( const Rectangle& rRect, const Point& rStartAngle, const Point& rEndAngle, sal_Bool bDrawTo = sal_False );
655 		void				DrawPie( const Rectangle& rRect, const Point& rStartAngle, const Point& rEndAngle );
656 		void				DrawChord( const Rectangle& rRect, const Point& rStartAngle, const Point& rEndAngle );
657 		void				DrawPolygon( Polygon& rPolygon, sal_Bool bRecordPath = sal_False );
658 		void				DrawPolyPolygon( PolyPolygon& rPolyPolygon, sal_Bool bRecordPath = sal_False );
659 		void				DrawPolyLine( Polygon& rPolygon, sal_Bool bDrawTo = sal_False, sal_Bool bRecordPath = sal_False );
660 		void				DrawPolyBezier( Polygon& rPolygin, sal_Bool bDrawTo = sal_False, sal_Bool bRecordPath = sal_False );
661 		void				DrawText( Point& rPosition, String& rString, sal_Int32* pDXArry = NULL, sal_Bool bRecordPath = sal_False,
662 										sal_Int32 nGraphicsMode = GM_COMPATIBLE );
663 		void				ResolveBitmapActions( List& rSaveList );
664 
665 		void				IntersectClipRect( const Rectangle& rRect );
666 		void				ExcludeClipRect( const Rectangle& rRect );
667 		void				MoveClipRegion( const Size& rSize );
668 		void				SetClipPath( const PolyPolygon& rPolyPoly, sal_Int32 nClippingMode, sal_Bool bIsMapped );
669 		void				UpdateClipRegion();
670 		void				AddFromGDIMetaFile( GDIMetaFile& rGDIMetaFile );
671 
672 							WinMtfOutput( GDIMetaFile& rGDIMetaFile );
673 		virtual				~WinMtfOutput();
674 };
675 
676 // -----------------------------------------------------------------------------
677 
678 class WinMtf
679 {
680 	protected:
681 
682 	WinMtfOutput*		pOut;					//
683 	SvStream*			pWMF;					// Die einzulesende WMF/EMF-Datei
684 
685 	sal_uInt32				nStartPos, nEndPos;
686 	List				aBmpSaveList;
687 
688 	FilterConfigItem*	pFilterConfigItem;
689 
690 	com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
691 
692 	// Sorgt dafuer, das aSampledBrush der aktuelle Brush des GDIMetaFiles ist.
693 
694 	Color				ReadColor();
695 	void				Callback( sal_uInt16 nPercent );
696 
697 						WinMtf( WinMtfOutput* pOut, SvStream& rStreamWMF, FilterConfigItem* pConfigItem = NULL );
698 						~WinMtf();
699 
700 	public:
701 
702 };
703 
704 //============================ EMFReader ==================================
705 
706 class EnhWMFReader : public WinMtf
707 {
708 	sal_Bool		bRecordPath;
709 	sal_Int32		nRecordCount;
710 
711 	sal_Bool			ReadHeader();
712 	Rectangle		ReadRectangle( sal_Int32, sal_Int32, sal_Int32, sal_Int32 );			// Liesst und konvertiert ein Rechteck
713 	void			ImplExtTextOut( sal_Bool bWideCharakter );
714 
715 public:
EnhWMFReader(SvStream & rStreamWMF,GDIMetaFile & rGDIMetaFile,FilterConfigItem * pConfigItem=NULL)716 					EnhWMFReader( SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, FilterConfigItem* pConfigItem = NULL )
717 									: WinMtf( new WinMtfOutput( rGDIMetaFile ), rStreamWMF, pConfigItem ), bRecordPath( sal_False ) {};
718 					~EnhWMFReader();
719 
720 	sal_Bool			ReadEnhWMF();
721 };
722 
723 //============================ WMFReader ==================================
724 
725 class WMFReader : public WinMtf
726 {
727 private:
728 	sal_uInt16			nUnitsPerInch;
729 	sal_uInt32		nRecSize;
730 
731 	// embedded EMF data
732 	SvMemoryStream* pEMFStream;
733 
734 	// total number of comment records containing EMF data
735 	sal_uInt32      nEMFRecCount;
736 
737 	// number of EMF records read
738 	sal_uInt32      nEMFRec;
739 
740 	// total size of embedded EMF data
741 	sal_uInt32      nEMFSize;
742 
743 	sal_uInt32		nSkipActions;
744 	sal_uInt32		nCurrentAction;
745 	sal_uInt32		nUnicodeEscapeAction;
746 
747 	// Liesst den Kopf der WMF-Datei
748 	sal_Bool			ReadHeader();
749 
750 	// Liesst die Parameter des Rocords mit der Funktionsnummer nFunction.
751 	void			ReadRecordParams( sal_uInt16 nFunction );
752 
753 	Point			ReadPoint();				// Liesst und konvertiert einen Punkt (erst X dann Y)
754 	Point			ReadYX();					// Liesst und konvertiert einen Punkt (erst Y dann X)
755 	Rectangle		ReadRectangle();			// Liesst und konvertiert ein Rechteck
756 	Size			ReadYXExt();
757     sal_Bool        GetPlaceableBound( Rectangle& rSize, SvStream* pStrm );
758 
759 public:
760 
WMFReader(SvStream & rStreamWMF,GDIMetaFile & rGDIMetaFile,FilterConfigItem * pConfigItem=NULL)761 					WMFReader( SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, FilterConfigItem* pConfigItem = NULL )
762 						: WinMtf( new WinMtfOutput( rGDIMetaFile ), rStreamWMF, pConfigItem ) {};
763 
764                     ~WMFReader();
765 
766 	// Liesst aus dem Stream eine WMF-Datei und fuellt das GDIMetaFile
767 	void			ReadWMF();
768 };
769 
770 #endif
771