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