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