Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_VCL_SOURCE_FILTER_WMF_WINMTF_HXX
21 : #define INCLUDED_VCL_SOURCE_FILTER_WMF_WINMTF_HXX
22 :
23 : #include <sot/object.hxx>
24 : #include <boost/shared_ptr.hpp>
25 : #include <vcl/graph.hxx>
26 : #include <basegfx/tools/b2dclipstate.hxx>
27 : #include <vcl/font.hxx>
28 : #include <vcl/bmpacc.hxx>
29 : #include <vcl/lineinfo.hxx>
30 : #include <vcl/fltcall.hxx>
31 :
32 : #define ERROR 0
33 : #define NULLREGION 1
34 : #define SIMPLEREGION 2
35 : #define COMPLEXREGION 3
36 :
37 : #define RGN_AND 1
38 : #define RGN_OR 2
39 : #define RGN_XOR 3
40 : #define RGN_DIFF 4
41 : #define RGN_COPY 5
42 :
43 : #define TRANSPARENT 1
44 : #define OPAQUE 2
45 : #define BKMODE_LAST 2
46 :
47 : /* xform stuff */
48 : #define MWT_IDENTITY 1
49 : #define MWT_LEFTMULTIPLY 2
50 : #define MWT_RIGHTMULTIPLY 3
51 : #define MWT_SET 4
52 :
53 : #define ENHMETA_STOCK_OBJECT 0x80000000
54 :
55 : /* Stock Logical Objects */
56 : #define WHITE_BRUSH 0
57 : #define LTGRAY_BRUSH 1
58 : #define GRAY_BRUSH 2
59 : #define DKGRAY_BRUSH 3
60 : #define BLACK_BRUSH 4
61 : #define NULL_BRUSH 5
62 : #define HOLLOW_BRUSH NULL_BRUSH
63 : #define WHITE_PEN 6
64 : #define BLACK_PEN 7
65 : #define NULL_PEN 8
66 : #define OEM_FIXED_FONT 10
67 : #define ANSI_FIXED_FONT 11
68 : #define ANSI_VAR_FONT 12
69 : #define SYSTEM_FONT 13
70 : #define DEVICE_DEFAULT_FONT 14
71 : #define DEFAULT_PALETTE 15
72 : #define SYSTEM_FIXED_FONT 16
73 :
74 : #define R2_BLACK 1
75 : #define R2_NOTMERGEPEN 2
76 : #define R2_MASKNOTPEN 3
77 : #define R2_NOTCOPYPEN 4
78 : #define R2_MASKPENNOT 5
79 : #define R2_NOT 6
80 : #define R2_XORPEN 7
81 : #define R2_NOTMASKPEN 8
82 : #define R2_MASKPEN 9
83 : #define R2_NOTXORPEN 10
84 : #define R2_NOP 11
85 : #define R2_MERGENOTPEN 12
86 : #define R2_COPYPEN 13
87 : #define R2_MERGEPENNOT 14
88 : #define R2_MERGEPEN 15
89 : #define R2_WHITE 16
90 :
91 : /* Mapping modes */
92 : #define MM_TEXT 1
93 : #define MM_LOMETRIC 2
94 : #define MM_HIMETRIC 3
95 : #define MM_LOENGLISH 4
96 : #define MM_HIENGLISH 5
97 : #define MM_TWIPS 6
98 : #define MM_ISOTROPIC 7
99 : #define MM_ANISOTROPIC 8
100 :
101 : /* Graphics modes */
102 : #define GM_COMPATIBLE 1
103 : #define GM_ADVANCED 2
104 : #define GM_LAST 2
105 :
106 : /* StretchBlt() modes */
107 : #define BLACKONWHITE 1
108 : #define WHITEONBLACK 2
109 : #define COLORONCOLOR 3
110 : #define HALFTONE 4
111 : #define MAXSTRETCHBLTMODE 4
112 : #define STRETCH_ANDSCANS BLACKONWHITE
113 : #define STRETCH_ORSCANS WHITEONBLACK
114 : #define STRETCH_DELETESCANS COLORONCOLOR
115 : #define STRETCH_HALFTONE HALFTONE
116 :
117 : #define LF_FACESIZE 32
118 :
119 0 : struct LOGFONTW
120 : {
121 : sal_Int32 lfHeight;
122 : sal_Int32 lfWidth;
123 : sal_Int32 lfEscapement;
124 : sal_Int32 lfOrientation;
125 : sal_Int32 lfWeight;
126 : sal_uInt8 lfItalic;
127 : sal_uInt8 lfUnderline;
128 : sal_uInt8 lfStrikeOut;
129 : sal_uInt8 lfCharSet;
130 : sal_uInt8 lfOutPrecision;
131 : sal_uInt8 lfClipPrecision;
132 : sal_uInt8 lfQuality;
133 : sal_uInt8 lfPitchAndFamily;
134 : OUString alfFaceName;
135 : };
136 : struct WMF_EXTERNALHEADER;
137 :
138 : #define TA_NOUPDATECP 0x0000
139 : #define TA_UPDATECP 0x0001
140 : #define TA_LEFT 0x0000
141 : #define TA_RIGHT 0x0002
142 : #define TA_CENTER 0x0006
143 : #define TA_RIGHT_CENTER (TA_RIGHT | TA_CENTER)
144 : #define TA_TOP 0x0000
145 : #define TA_BOTTOM 0x0008
146 : #define TA_BASELINE 0x0018
147 :
148 : #define SRCCOPY 0x00CC0020L
149 : #define SRCPAINT 0x00EE0086L
150 : #define SRCAND 0x008800C6L
151 : #define SRCINVERT 0x00660046L
152 : #define SRCERASE 0x00440328L
153 : #define NOTSRCCOPY 0x00330008L
154 : #define NOTSRCERASE 0x001100A6L
155 : #define MERGECOPY 0x00C000CAL
156 : #define MERGEPAINT 0x00BB0226L
157 : #define PATCOPY 0x00F00021L
158 : #define PATPAINT 0x00FB0A09L
159 : #define PATINVERT 0x005A0049L
160 : #define DSTINVERT 0x00550009L
161 : #define BLACKNESS 0x00000042L
162 : #define WHITENESS 0x00FF0062L
163 :
164 : #define PS_SOLID 0
165 : #define PS_DASH 1
166 : #define PS_DOT 2
167 : #define PS_DASHDOT 3
168 : #define PS_DASHDOTDOT 4
169 : #define PS_NULL 5
170 : #define PS_INSIDEFRAME 6
171 : #define PS_USERSTYLE 7
172 : #define PS_ALTERNATE 8
173 : #define PS_STYLE_MASK 15
174 :
175 : #define PS_ENDCAP_ROUND 0x000
176 : #define PS_ENDCAP_SQUARE 0x100
177 : #define PS_ENDCAP_FLAT 0x200
178 : #define PS_ENDCAP_MASK 0xF00
179 :
180 : #define PS_JOIN_ROUND 0x0000
181 : #define PS_JOIN_BEVEL 0x1000
182 : #define PS_JOIN_MITER 0x2000
183 : #define PS_JOIN_MASK 0xF000
184 :
185 : #define PS_COSMETIC 0x00000
186 : #define PS_GEOMETRIC 0x10000
187 : #define PS_TYPE_MASK 0xF0000
188 :
189 : #define ANSI_CHARSET 0
190 : #define DEFAULT_CHARSET 1
191 : #define SYMBOL_CHARSET 2
192 : #define SHIFTJIS_CHARSET 128
193 : #define HANGEUL_CHARSET 129
194 : #define GB2312_CHARSET 134
195 : #define CHINESEBIG5_CHARSET 136
196 : #define OEM_CHARSET 255
197 : /*WINVER >= 0x0400*/
198 : #define JOHAB_CHARSET 130
199 : #define HEBREW_CHARSET 177
200 : #define ARABIC_CHARSET 178
201 : #define GREEK_CHARSET 161
202 : #define TURKISH_CHARSET 162
203 : #define VIETNAMESE_CHARSET 163
204 : #define THAI_CHARSET 222
205 : #define EASTEUROPE_CHARSET 238
206 : #define RUSSIAN_CHARSET 204
207 : #define MAC_CHARSET 77
208 : #define BALTIC_CHARSET 186
209 :
210 : #define ETO_OPAQUE 0x0002
211 : #define ETO_CLIPPED 0x0004
212 : /*WINVER >= 0x0400*/
213 : #define ETO_GLYPH_INDEX 0x0010
214 : #define ETO_RTLREADING 0x0080
215 : #define ETO_NUMERICSLOCAL 0x0400
216 : #define ETO_NUMERICSLATIN 0x0800
217 : #define ETO_IGNORELANGUAGE 0x1000
218 : /*_WIN32_WINNT >= 0x0500*/
219 : #define ETO_PDY 0x2000
220 :
221 : #define DEFAULT_PITCH 0x00
222 : #define FIXED_PITCH 0x01
223 : #define VARIABLE_PITCH 0x02
224 :
225 : /* Font Families */
226 : #define FF_DONTCARE 0x00
227 : #define FF_ROMAN 0x10
228 : #define FF_SWISS 0x20
229 : #define FF_MODERN 0x30
230 : #define FF_SCRIPT 0x40
231 : #define FF_DECORATIVE 0x50
232 :
233 : #define FW_DONTCARE 0
234 : #define FW_THIN 100
235 : #define FW_EXTRALIGHT 200
236 : #define FW_LIGHT 300
237 : #define FW_NORMAL 400
238 : #define FW_MEDIUM 500
239 : #define FW_SEMIBOLD 600
240 : #define FW_BOLD 700
241 : #define FW_EXTRABOLD 800
242 : #define FW_HEAVY 900
243 : #define FW_ULTRALIGHT 200
244 : #define FW_REGULAR 400
245 : #define FW_DEMIBOLD 600
246 : #define FW_ULTRABOLD 800
247 : #define FW_BLACK 900
248 :
249 : #define BS_SOLID 0
250 : #define BS_NULL 1
251 : #define BS_HOLLOW 1
252 : #define BS_HATCHED 2
253 : #define BS_PATTERN 3
254 : #define BS_INDEXED 4
255 : #define BS_DIBPATTERN 5
256 : #define BS_DIBPATTERNPT 6
257 : #define BS_PATTERN8X8 7
258 : #define BS_DIBPATTERN8X8 8
259 : #define BS_MONOPATTERN 9
260 :
261 : #define W_HS_HORIZONTAL 0
262 : #define W_HS_VERTICAL 1
263 : #define W_HS_FDIAGONAL 2
264 : #define W_HS_BDIAGONAL 3
265 : #define W_HS_CROSS 4
266 : #define W_HS_DIAGCROSS 5
267 :
268 : #define RDH_RECTANGLES 1
269 :
270 : #define W_MFCOMMENT 15
271 :
272 : #define PRIVATE_ESCAPE_UNICODE 2
273 :
274 : //Scalar constants
275 :
276 : #define UNDOCUMENTED_WIN_RCL_RELATION 32
277 : #define MS_FIXPOINT_BITCOUNT_28_4 4
278 : #define HUNDREDTH_MILLIMETERS_PER_MILLIINCH 2.54
279 : #define MILLIINCH_PER_TWIPS 1.44
280 :
281 : //============================ WMFReader ==================================
282 :
283 0 : class WinMtfClipPath
284 : {
285 : basegfx::tools::B2DClipState maClip;
286 :
287 : public :
288 0 : WinMtfClipPath(): maClip() {};
289 :
290 : void setClipPath( const PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode );
291 : void intersectClipRect( const Rectangle& rRect );
292 : void excludeClipRect( const Rectangle& rRect );
293 : void moveClipRegion( const Size& rSize );
294 :
295 0 : bool isEmpty() const { return maClip.isCleared(); }
296 :
297 : basegfx::B2DPolyPolygon getClipPath() const;
298 :
299 0 : bool operator==( const WinMtfClipPath& rPath ) const
300 : {
301 0 : return maClip == rPath.maClip;
302 : };
303 : };
304 :
305 0 : class WinMtfPathObj : public PolyPolygon
306 : {
307 : bool bClosed;
308 :
309 : public :
310 :
311 0 : WinMtfPathObj() { bClosed = true; }
312 0 : void Init() { Clear(); bClosed = true; };
313 : void ClosePath();
314 : void AddPoint( const Point& rPoint );
315 : void AddPolygon( const Polygon& rPoly );
316 : void AddPolyLine( const Polygon& rPoly );
317 : void AddPolyPolygon( const PolyPolygon& rPolyPolygon );
318 : };
319 :
320 0 : struct WinMtfFontStyle
321 : {
322 : Font aFont;
323 :
324 : WinMtfFontStyle( LOGFONTW& rLogFont );
325 : };
326 :
327 : // -----------------------------------------------------------------------------
328 :
329 : typedef enum {
330 : FillStyleSolid,
331 : FillStylePattern
332 : } WinMtfFillStyleType;
333 :
334 0 : struct WinMtfFillStyle
335 : {
336 : Color aFillColor;
337 : bool bTransparent;
338 : WinMtfFillStyleType aType;
339 : Bitmap aBmp;
340 :
341 0 : WinMtfFillStyle()
342 : : aFillColor(Color(COL_BLACK))
343 : , bTransparent(false)
344 0 : , aType(FillStyleSolid)
345 : {
346 0 : }
347 :
348 0 : WinMtfFillStyle(const Color& rColor, bool bTrans = false)
349 : : aFillColor(rColor)
350 : , bTransparent(bTrans)
351 0 : , aType(FillStyleSolid)
352 : {
353 0 : }
354 :
355 0 : WinMtfFillStyle(Bitmap& rBmp)
356 : : bTransparent(false)
357 : , aType(FillStylePattern)
358 0 : , aBmp(rBmp)
359 : {
360 0 : }
361 :
362 0 : bool operator==( const WinMtfFillStyle& rStyle )
363 : {
364 0 : return ( ( aFillColor == rStyle.aFillColor )
365 0 : && ( bTransparent == rStyle.bTransparent )
366 0 : && ( aType == rStyle.aType )
367 0 : );
368 : }
369 : bool operator==( WinMtfFillStyle* pStyle )
370 : {
371 : return ( ( aFillColor == pStyle->aFillColor )
372 : && ( bTransparent == pStyle->bTransparent )
373 : && ( aType == pStyle->aType )
374 : );
375 : }
376 0 : WinMtfFillStyle& operator=( const WinMtfFillStyle& rStyle )
377 : {
378 0 : aFillColor = rStyle.aFillColor;
379 0 : bTransparent = rStyle.bTransparent;
380 0 : aBmp = rStyle.aBmp;
381 0 : aType = rStyle.aType;
382 0 : return *this;
383 : }
384 0 : WinMtfFillStyle& operator=( WinMtfFillStyle* pStyle )
385 : {
386 0 : aFillColor = pStyle->aFillColor;
387 0 : bTransparent = pStyle->bTransparent;
388 0 : aBmp = pStyle->aBmp;
389 0 : aType = pStyle->aType;
390 0 : return *this;
391 : }
392 : };
393 :
394 0 : struct WinMtfLineStyle
395 : {
396 : Color aLineColor;
397 : LineInfo aLineInfo;
398 : bool bTransparent;
399 :
400 0 : WinMtfLineStyle() :
401 : aLineColor ( COL_BLACK ),
402 0 : bTransparent( false ) {}
403 :
404 0 : WinMtfLineStyle( const Color& rColor, bool bTrans = false ) :
405 : aLineColor ( rColor ),
406 0 : bTransparent( bTrans ) {}
407 :
408 0 : WinMtfLineStyle( const Color& rColor, const LineInfo& rStyle, bool bTrans = false ) :
409 : aLineColor ( rColor ),
410 : aLineInfo ( rStyle ),
411 0 : bTransparent( bTrans ) {}
412 :
413 0 : bool operator==( const WinMtfLineStyle& rStyle )
414 : {
415 0 : return ( ( aLineColor == rStyle.aLineColor )
416 0 : && ( bTransparent == rStyle.bTransparent )
417 0 : && ( aLineInfo == rStyle.aLineInfo )
418 0 : );
419 : }
420 : bool operator==( WinMtfLineStyle* pStyle )
421 : {
422 : return ( ( aLineColor == pStyle->aLineColor )
423 : && ( bTransparent == pStyle->bTransparent )
424 : && ( aLineInfo == pStyle->aLineInfo )
425 : );
426 : }
427 0 : WinMtfLineStyle& operator=( const WinMtfLineStyle& rStyle )
428 : {
429 0 : aLineColor = rStyle.aLineColor;
430 0 : bTransparent = rStyle.bTransparent;
431 0 : aLineInfo = rStyle.aLineInfo;
432 0 : return *this;
433 : }
434 :
435 0 : WinMtfLineStyle& operator=( WinMtfLineStyle* pStyle )
436 : {
437 0 : aLineColor = pStyle->aLineColor;
438 0 : bTransparent = pStyle->bTransparent;
439 0 : aLineInfo = pStyle->aLineInfo;
440 0 : return *this;
441 : }
442 : };
443 :
444 : struct XForm
445 : {
446 : float eM11;
447 : float eM12;
448 : float eM21;
449 : float eM22;
450 : float eDx;
451 : float eDy;
452 0 : XForm()
453 : {
454 0 : eM11 = eM22 = 1.0f;
455 0 : eDx = eDy = eM12 = eM21 = 0.0f;
456 0 : }
457 : };
458 :
459 0 : struct SaveStruct
460 : {
461 : sal_uInt32 nBkMode, nMapMode, nGfxMode, nTextLayoutMode;
462 : sal_Int32 nWinOrgX, nWinOrgY, nWinExtX, nWinExtY;
463 : sal_Int32 nDevOrgX, nDevOrgY, nDevWidth, nDevHeight;
464 :
465 : WinMtfLineStyle aLineStyle;
466 : WinMtfFillStyle aFillStyle;
467 :
468 : Font aFont;
469 : Color aBkColor;
470 : Color aTextColor;
471 : sal_uInt32 nTextAlign;
472 : RasterOp eRasterOp;
473 :
474 : Point aActPos;
475 : WinMtfPathObj aPathObj;
476 : WinMtfClipPath aClipPath;
477 : XForm aXForm;
478 :
479 : bool bRecordPath;
480 : bool bFillStyleSelected;
481 : };
482 :
483 : typedef ::boost::shared_ptr< SaveStruct > SaveStructPtr;
484 :
485 0 : struct BSaveStruct
486 : {
487 : Bitmap aBmp;
488 : Rectangle aOutRect;
489 : sal_uInt32 nWinRop;
490 : WinMtfFillStyle aStyle;
491 :
492 0 : BSaveStruct(
493 : const Bitmap& rBmp,
494 : const Rectangle& rOutRect,
495 : sal_uInt32 nRop,
496 : WinMtfFillStyle& rStyle
497 : )
498 : : aBmp( rBmp )
499 : , aOutRect( rOutRect )
500 : , nWinRop( nRop )
501 0 : , aStyle ( rStyle )
502 0 : {}
503 : };
504 :
505 : typedef ::std::vector< BSaveStruct* > BSaveStructList_impl;
506 :
507 : enum GDIObjectType {
508 : GDI_DUMMY = 0,
509 : GDI_PEN = 1,
510 : GDI_BRUSH = 2,
511 : GDI_FONT = 3,
512 : GDI_PALETTE = 4,
513 : GDI_BITMAP = 5,
514 : GDI_REGION = 6
515 : };
516 :
517 : struct GDIObj
518 : {
519 : void* pStyle;
520 : GDIObjectType eType;
521 :
522 0 : GDIObj() :
523 : pStyle ( NULL ),
524 0 : eType ( GDI_DUMMY )
525 : {
526 0 : }
527 :
528 0 : GDIObj( GDIObjectType eT, void* pS ) { pStyle = pS; eType = eT; }
529 0 : void Set( GDIObjectType eT, void* pS ) { pStyle = pS; eType = eT; }
530 0 : void Delete()
531 : {
532 0 : if ( pStyle )
533 : {
534 0 : switch ( eType )
535 : {
536 : case GDI_PEN :
537 0 : delete (WinMtfLineStyle*)pStyle;
538 0 : break;
539 : case GDI_BRUSH :
540 0 : delete (WinMtfFillStyle*)pStyle;
541 0 : break;
542 : case GDI_FONT :
543 0 : delete (WinMtfFontStyle*)pStyle;
544 0 : break;
545 :
546 : default:
547 : OSL_FAIL( "unsupported style deleted" );
548 0 : break;
549 : }
550 0 : pStyle = NULL;
551 : }
552 0 : }
553 :
554 0 : ~GDIObj()
555 : {
556 0 : Delete();
557 0 : }
558 : };
559 :
560 : class WinMtfOutput
561 : {
562 : WinMtfPathObj aPathObj;
563 : WinMtfClipPath aClipPath;
564 :
565 : WinMtfLineStyle maLatestLineStyle;
566 : WinMtfLineStyle maLineStyle;
567 : WinMtfFillStyle maLatestFillStyle;
568 : WinMtfFillStyle maFillStyle;
569 : Font maLatestFont;
570 : Font maFont;
571 : sal_uInt32 mnLatestTextAlign;
572 : sal_uInt32 mnTextAlign;
573 : Color maLatestTextColor;
574 : Color maTextColor;
575 : Color maLatestBkColor;
576 : Color maBkColor;
577 : sal_uInt32 mnLatestTextLayoutMode;
578 : sal_uInt32 mnTextLayoutMode;
579 : sal_uInt32 mnLatestBkMode;
580 : sal_uInt32 mnBkMode;
581 : RasterOp meLatestRasterOp;
582 : RasterOp meRasterOp;
583 :
584 : std::vector< GDIObj* > vGDIObj;
585 :
586 : Point maActPos;
587 :
588 : sal_uInt32 mnRop;
589 : bool mbNopMode;
590 : bool mbFillStyleSelected;
591 : bool mbClipNeedsUpdate;
592 : bool mbComplexClip;
593 :
594 : std::vector< SaveStructPtr > vSaveStack;
595 :
596 : sal_uInt32 mnGfxMode;
597 : sal_uInt32 mnMapMode;
598 :
599 : XForm maXForm;
600 : sal_Int32 mnDevOrgX, mnDevOrgY;
601 : sal_Int32 mnDevWidth, mnDevHeight;
602 : sal_Int32 mnWinOrgX, mnWinOrgY; // aktuel window origin
603 : sal_Int32 mnWinExtX, mnWinExtY; // aktuel window extend
604 : bool mbIsMapWinSet;
605 : bool mbIsMapDevSet;
606 :
607 : sal_Int32 mnPixX, mnPixY; // Reference Device in pixel
608 : sal_Int32 mnMillX, mnMillY; // Reference Device in Mill
609 : Rectangle mrclFrame; // rectangle in logical units 1/100th mm
610 : Rectangle mrclBounds;
611 :
612 : GDIMetaFile* mpGDIMetaFile;
613 :
614 : void UpdateLineStyle();
615 : void UpdateFillStyle();
616 :
617 : Point ImplMap( const Point& rPt );
618 : Point ImplScale( const Point& rPt );
619 : Size ImplMap( const Size& rSz );
620 : Rectangle ImplMap( const Rectangle& rRectangle );
621 : void ImplMap( Font& rFont );
622 : Polygon& ImplMap( Polygon& rPolygon );
623 : PolyPolygon& ImplMap( PolyPolygon& rPolyPolygon );
624 : Polygon& ImplScale( Polygon& rPolygon );
625 : PolyPolygon& ImplScale( PolyPolygon& rPolyPolygon );
626 : void ImplResizeObjectArry( sal_uInt32 nNewEntry );
627 : void ImplSetNonPersistentLineColorTransparenz();
628 : void ImplDrawClippedPolyPolygon( const PolyPolygon& rPolyPoly );
629 : void ImplDrawBitmap( const Point& rPos, const Size& rSize, const BitmapEx rBitmap );
630 :
631 : public:
632 :
633 : void SetDevByWin(); //Hack to set varying defaults for incompletely defined files.
634 : void SetDevOrg( const Point& rPoint );
635 : void SetDevOrgOffset( sal_Int32 nXAdd, sal_Int32 nYAdd );
636 : void SetDevExt( const Size& rSize ,bool regular = true);
637 : void ScaleDevExt( double fX, double fY );
638 :
639 : void SetWinOrg( const Point& rPoint , bool bIsEMF = false);
640 : void SetWinOrgOffset( sal_Int32 nX, sal_Int32 nY );
641 : void SetWinExt( const Size& rSize , bool bIsEMF = false);
642 : void ScaleWinExt( double fX, double fY );
643 :
644 : void SetrclBounds( const Rectangle& rRect );
645 : void SetrclFrame( const Rectangle& rRect );
646 : void SetRefPix( const Size& rSize );
647 : void SetRefMill( const Size& rSize );
648 :
649 : sal_uInt32 GetMapMode() const { return mnMapMode; };
650 : void SetMapMode( sal_uInt32 mnMapMode );
651 : void SetWorldTransform( const XForm& rXForm );
652 : const XForm& GetWorldTransform() const { return maXForm; }
653 : void ModifyWorldTransform( const XForm& rXForm, sal_uInt32 nMode );
654 :
655 : void Push();
656 : void Pop();
657 :
658 : sal_uInt32 SetRasterOp( sal_uInt32 nRasterOp );
659 : void StrokeAndFillPath( bool bStroke, bool bFill );
660 :
661 0 : void SetGfxMode( sal_Int32 nGfxMode ){ mnGfxMode = nGfxMode; };
662 0 : sal_Int32 GetGfxMode() const { return mnGfxMode; };
663 : void SetBkMode( sal_uInt32 nMode );
664 : void SetBkColor( const Color& rColor );
665 : void SetTextColor( const Color& rColor );
666 : void SetTextAlign( sal_uInt32 nAlign );
667 : void CreateObject( GDIObjectType, void* pStyle = NULL );
668 : void CreateObject( sal_Int32 nIndex, GDIObjectType, void* pStyle = NULL );
669 : void DeleteObject( sal_Int32 nIndex );
670 : void SelectObject( sal_Int32 nIndex );
671 0 : rtl_TextEncoding GetCharSet(){ return maFont.GetCharSet(); };
672 0 : WinMtfFillStyle& GetFillStyle () { return maFillStyle; }
673 : const Font& GetFont() const;
674 : void SetTextLayoutMode( const sal_uInt32 nLayoutMode );
675 :
676 0 : void ClearPath(){ aPathObj.Init(); };
677 0 : void ClosePath(){ aPathObj.ClosePath(); };
678 0 : const PolyPolygon& GetPathObj(){ return aPathObj; };
679 :
680 : void MoveTo( const Point& rPoint, bool bRecordPath = false );
681 : void LineTo( const Point& rPoint, bool bRecordPath = false );
682 : void DrawPixel( const Point& rSource, const Color& rColor );
683 : void DrawRect( const Rectangle& rRect, bool bEdge = true );
684 : void DrawRoundRect( const Rectangle& rRect, const Size& rSize );
685 : void DrawEllipse( const Rectangle& rRect );
686 : void DrawArc(
687 : const Rectangle& rRect,
688 : const Point& rStartAngle,
689 : const Point& rEndAngle,
690 : bool bDrawTo = false
691 : );
692 : void DrawPie(
693 : const Rectangle& rRect,
694 : const Point& rStartAngle,
695 : const Point& rEndAngle
696 : );
697 : void DrawChord(
698 : const Rectangle& rRect,
699 : const Point& rStartAngle,
700 : const Point& rEndAngle
701 : );
702 : void DrawPolygon( Polygon& rPolygon, bool bRecordPath = false );
703 0 : void DrawPolygon( Polygon& rPolygon, bool /*bDrawTo*/, bool bRecordPath)
704 : {
705 : //For ReadAndDrawPolygon template compatibility
706 0 : DrawPolygon(rPolygon, bRecordPath);
707 0 : }
708 : void DrawPolyPolygon( PolyPolygon& rPolyPolygon, bool bRecordPath = false );
709 : void DrawPolyLine(
710 : Polygon& rPolygon,
711 : bool bDrawTo = false,
712 : bool bRecordPath = false
713 : );
714 : void DrawPolyBezier(
715 : Polygon& rPolygin,
716 : bool bDrawTo = false,
717 : bool bRecordPath = false
718 : );
719 : void DrawText(
720 : Point& rPosition,
721 : OUString& rString,
722 : sal_Int32* pDXArry = NULL,
723 : bool bRecordPath = false,
724 : sal_Int32 nGraphicsMode = GM_COMPATIBLE
725 : );
726 : void ResolveBitmapActions( BSaveStructList_impl& rSaveList );
727 :
728 : void IntersectClipRect( const Rectangle& rRect );
729 : void ExcludeClipRect( const Rectangle& rRect );
730 : void MoveClipRegion( const Size& rSize );
731 : void SetClipPath(
732 : const PolyPolygon& rPolyPoly,
733 : sal_Int32 nClippingMode,
734 : bool bIsMapped
735 : );
736 : void UpdateClipRegion();
737 : void AddFromGDIMetaFile( GDIMetaFile& rGDIMetaFile );
738 :
739 : void PassEMFPlus( void* pBuffer, sal_uInt32 nLength );
740 : void PassEMFPlusHeaderInfo();
741 :
742 : WinMtfOutput( GDIMetaFile& rGDIMetaFile );
743 : virtual ~WinMtfOutput();
744 : };
745 :
746 : class WinMtf
747 : {
748 : protected:
749 :
750 : WinMtfOutput* pOut;
751 : SvStream* pWMF; // the WMF/EMF file to be read
752 :
753 : sal_uInt32 nStartPos, nEndPos;
754 : BSaveStructList_impl aBmpSaveList;
755 :
756 : FilterConfigItem* pFilterConfigItem;
757 :
758 : com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
759 :
760 : // assures aSampledBrush is the actual brush of the GDIMetaFile
761 :
762 : Color ReadColor();
763 : void Callback( sal_uInt16 nPercent );
764 :
765 : WinMtf(
766 : WinMtfOutput* pOut,
767 : SvStream& rStreamWMF,
768 : FilterConfigItem* pConfigItem = NULL
769 : );
770 : ~WinMtf();
771 : };
772 :
773 : class EnhWMFReader : public WinMtf
774 : {
775 : bool bRecordPath;
776 : sal_Int32 nRecordCount;
777 : bool bEMFPlus;
778 :
779 : bool ReadHeader();
780 : // reads and converts the rectangle
781 : Rectangle ReadRectangle( sal_Int32, sal_Int32, sal_Int32, sal_Int32 );
782 :
783 : public:
784 0 : EnhWMFReader(
785 : SvStream& rStreamWMF,
786 : GDIMetaFile& rGDIMetaFile,
787 : FilterConfigItem* pConfigItem = NULL
788 : )
789 0 : : WinMtf( new WinMtfOutput( rGDIMetaFile )
790 : , rStreamWMF
791 : , pConfigItem )
792 : , bRecordPath( false )
793 0 : , bEMFPlus( false )
794 0 : {};
795 : ~EnhWMFReader();
796 :
797 : bool ReadEnhWMF();
798 : void ReadEMFPlusComment(sal_uInt32 length, bool& bHaveDC);
799 : private:
800 : template <class T> void ReadAndDrawPolyPolygon();
801 : template <class T> void ReadAndDrawPolyLine();
802 : template <class T> Polygon ReadPolygon(sal_uInt32 nStartIndex, sal_uInt32 nPoints);
803 : template <class T, class Drawer> void ReadAndDrawPolygon(Drawer drawer, const bool skipFirst);
804 : };
805 :
806 : class WMFReader : public WinMtf
807 : {
808 : private:
809 :
810 : sal_uInt16 nUnitsPerInch;
811 : sal_uInt32 nRecSize;
812 :
813 : // embedded EMF data
814 : SvMemoryStream* pEMFStream;
815 :
816 : // total number of comment records containing EMF data
817 : sal_uInt32 nEMFRecCount;
818 :
819 : // number of EMF records read
820 : sal_uInt32 nEMFRec;
821 :
822 : // total size of embedded EMF data
823 : sal_uInt32 nEMFSize;
824 :
825 : sal_uInt32 nSkipActions;
826 : sal_uInt32 nCurrentAction;
827 : sal_uInt32 nUnicodeEscapeAction;
828 :
829 : WMF_EXTERNALHEADER* pExternalHeader;
830 :
831 : // reads header of the WMF-Datei
832 : bool ReadHeader();
833 :
834 : // reads parameters of the record with the functionnumber nFunction.
835 : void ReadRecordParams( sal_uInt16 nFunction );
836 :
837 : Point ReadPoint(); // reads and converts a point (first X then Y)
838 : Point ReadYX(); // reads and converts a point (first Y then X)
839 : Rectangle ReadRectangle(); // reads and converts a rectangle
840 : Size ReadYXExt();
841 : bool GetPlaceableBound( Rectangle& rSize, SvStream* pStrm );
842 :
843 : public:
844 :
845 0 : WMFReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile,
846 : FilterConfigItem* pConfigItem = NULL,
847 : WMF_EXTERNALHEADER* pExtHeader = NULL)
848 0 : : WinMtf(new WinMtfOutput(rGDIMetaFile) , rStreamWMF, pConfigItem)
849 : , nUnitsPerInch(96)
850 : , nRecSize(0)
851 : , pEMFStream(NULL)
852 : , nEMFRecCount(0)
853 : , nEMFRec(0)
854 : , nEMFSize(0)
855 : , nSkipActions(0)
856 : , nCurrentAction(0)
857 : , nUnicodeEscapeAction(0)
858 0 : , pExternalHeader(pExtHeader)
859 : {
860 0 : }
861 :
862 : ~WMFReader();
863 :
864 : // read WMF file from stream and fill the GDIMetaFile
865 : void ReadWMF();
866 : };
867 :
868 : #endif
869 :
870 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|