Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / source / filter / wmf / winmtf.hxx
blob3b78821bad430714af659102d6eecc34c7ffc72f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_SOURCE_FILTER_WMF_WINMTF_HXX
21 #define INCLUDED_VCL_SOURCE_FILTER_WMF_WINMTF_HXX
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>
31 #define ERROR 0
32 #define NULLREGION 1
33 #define COMPLEXREGION 3
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
41 enum class BkMode
43 NONE = 0,
44 Transparent = 1,
45 OPAQUE = 2,
46 LAST = 2
49 /* xform stuff */
50 #define MWT_IDENTITY 1
51 #define MWT_LEFTMULTIPLY 2
52 #define MWT_RIGHTMULTIPLY 3
53 #define MWT_SET 4
55 #define ENHMETA_STOCK_OBJECT 0x80000000
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
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
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
88 /* Graphics modes */
89 #define GM_COMPATIBLE 1
90 #define GM_ADVANCED 2
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
101 #define LF_FACESIZE 32
103 struct LOGFONTW
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;
120 struct WMF_EXTERNALHEADER;
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
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
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
151 #define PS_ENDCAP_ROUND 0x000
152 #define PS_ENDCAP_SQUARE 0x100
153 #define PS_ENDCAP_FLAT 0x200
155 #define PS_JOIN_ROUND 0x0000
156 #define PS_JOIN_BEVEL 0x1000
157 #define PS_JOIN_MITER 0x2000
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
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
188 #define DEFAULT_PITCH 0x00
189 #define FIXED_PITCH 0x01
190 #define VARIABLE_PITCH 0x02
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
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
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
225 #define RDH_RECTANGLES 1
227 #define W_MFCOMMENT 15
229 #define PRIVATE_ESCAPE_UNICODE 2
231 //Scalar constants
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
238 //============================ WMFReader ==================================
240 class WinMtfClipPath
242 basegfx::tools::B2DClipState maClip;
244 public :
245 WinMtfClipPath(): maClip() {};
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();
253 bool isEmpty() const { return maClip.isCleared(); }
255 basegfx::B2DPolyPolygon getClipPath() const;
257 bool operator==( const WinMtfClipPath& rPath ) const
259 return maClip == rPath.maClip;
263 class WinMtfPathObj : public tools::PolyPolygon
265 bool bClosed;
267 public:
269 WinMtfPathObj() :
270 bClosed(true)
273 void Init()
275 Clear();
276 bClosed = true;
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 );
286 struct WinMtfFontStyle
288 vcl::Font aFont;
290 WinMtfFontStyle( LOGFONTW& rLogFont );
294 typedef enum
296 FillStyleSolid,
297 FillStylePattern
298 } WinMtfFillStyleType;
300 struct WinMtfFillStyle
302 Color aFillColor;
303 bool bTransparent;
304 WinMtfFillStyleType aType;
305 Bitmap aBmp;
307 WinMtfFillStyle()
308 : aFillColor(Color(COL_BLACK))
309 , bTransparent(false)
310 , aType(FillStyleSolid)
313 WinMtfFillStyle(const Color& rColor, bool bTrans = false)
314 : aFillColor(rColor)
315 , bTransparent(bTrans)
316 , aType(FillStyleSolid)
319 WinMtfFillStyle(Bitmap& rBmp)
320 : bTransparent(false)
321 , aType(FillStylePattern)
322 , aBmp(rBmp)
325 bool operator==( const WinMtfFillStyle& rStyle )
327 return aFillColor == rStyle.aFillColor
328 && bTransparent == rStyle.bTransparent
329 && aType == rStyle.aType;
332 bool operator==(WinMtfFillStyle* pStyle)
334 return aFillColor == pStyle->aFillColor
335 && bTransparent == pStyle->bTransparent
336 && aType == pStyle->aType;
339 WinMtfFillStyle& operator=(const WinMtfFillStyle& rStyle)
341 aFillColor = rStyle.aFillColor;
342 bTransparent = rStyle.bTransparent;
343 aBmp = rStyle.aBmp;
344 aType = rStyle.aType;
345 return *this;
348 WinMtfFillStyle& operator=(WinMtfFillStyle* pStyle)
350 aFillColor = pStyle->aFillColor;
351 bTransparent = pStyle->bTransparent;
352 aBmp = pStyle->aBmp;
353 aType = pStyle->aType;
354 return *this;
358 struct WinMtfLineStyle
360 Color aLineColor;
361 LineInfo aLineInfo;
362 bool bTransparent;
364 WinMtfLineStyle()
365 : aLineColor (COL_BLACK)
366 , bTransparent(false)
369 WinMtfLineStyle(const Color& rColor, bool bTrans = false)
370 : aLineColor (rColor)
371 , bTransparent(bTrans)
374 WinMtfLineStyle( const Color& rColor, const LineInfo& rStyle, bool bTrans = false)
375 : aLineColor (rColor)
376 , aLineInfo (rStyle)
377 , bTransparent(bTrans)
380 bool operator==( const WinMtfLineStyle& rStyle )
382 return aLineColor == rStyle.aLineColor
383 && bTransparent == rStyle.bTransparent
384 && aLineInfo == rStyle.aLineInfo;
387 bool operator==(WinMtfLineStyle* pStyle)
389 return aLineColor == pStyle->aLineColor
390 && bTransparent == pStyle->bTransparent
391 && aLineInfo == pStyle->aLineInfo;
394 WinMtfLineStyle& operator=( const WinMtfLineStyle& rStyle )
396 aLineColor = rStyle.aLineColor;
397 bTransparent = rStyle.bTransparent;
398 aLineInfo = rStyle.aLineInfo;
399 return *this;
402 WinMtfLineStyle& operator=( WinMtfLineStyle* pStyle )
404 aLineColor = pStyle->aLineColor;
405 bTransparent = pStyle->bTransparent;
406 aLineInfo = pStyle->aLineInfo;
407 return *this;
411 struct XForm
413 float eM11;
414 float eM12;
415 float eM21;
416 float eM22;
417 float eDx;
418 float eDy;
420 XForm()
421 : eM11(1.0f)
422 , eM12(0.0f)
423 , eM21(0.0f)
424 , eM22(1.0f)
425 , eDx(0.0f)
426 , eDy(0.0f)
430 struct SaveStruct
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;
438 WinMtfLineStyle aLineStyle;
439 WinMtfFillStyle aFillStyle;
441 vcl::Font aFont;
442 Color aBkColor;
443 Color aTextColor;
444 sal_uInt32 nTextAlign;
445 RasterOp eRasterOp;
447 Point aActPos;
448 WinMtfPathObj aPathObj;
449 WinMtfClipPath aClipPath;
450 XForm aXForm;
452 bool bRecordPath;
453 bool bFillStyleSelected;
456 typedef std::shared_ptr<SaveStruct> SaveStructPtr;
458 struct BSaveStruct
460 Bitmap aBmp;
461 Rectangle aOutRect;
462 sal_uInt32 nWinRop;
463 WinMtfFillStyle aStyle;
465 BSaveStruct(const Bitmap& rBmp, const Rectangle& rOutRect,
466 sal_uInt32 nRop, WinMtfFillStyle& rStyle)
467 : aBmp(rBmp)
468 , aOutRect(rOutRect)
469 , nWinRop(nRop)
470 , aStyle (rStyle)
474 typedef ::std::vector< BSaveStruct* > BSaveStructList_impl;
476 enum GDIObjectType
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
487 struct GDIObj
489 void* pStyle;
490 GDIObjectType eType;
492 GDIObj()
493 : pStyle (NULL)
494 , eType (GDI_DUMMY)
497 GDIObj(GDIObjectType eT, void* pS)
499 pStyle = pS;
500 eType = eT;
503 void Set(GDIObjectType eT, void* pS)
505 pStyle = pS;
506 eType = eT;
509 void Delete()
511 if (pStyle == NULL)
512 return;
514 switch (eType)
516 case GDI_PEN :
517 delete static_cast<WinMtfLineStyle*>(pStyle);
518 break;
519 case GDI_BRUSH :
520 delete static_cast<WinMtfFillStyle*>(pStyle);
521 break;
522 case GDI_FONT :
523 delete static_cast<WinMtfFontStyle*>(pStyle);
524 break;
526 default:
527 OSL_FAIL( "unsupported style deleted" );
528 break;
530 pStyle = NULL;
533 ~GDIObj()
535 Delete();
539 class WinMtfOutput
541 WinMtfPathObj aPathObj;
542 WinMtfClipPath aClipPath;
544 WinMtfLineStyle maLatestLineStyle;
545 WinMtfLineStyle maLineStyle;
546 WinMtfFillStyle maLatestFillStyle;
547 WinMtfFillStyle maFillStyle;
548 WinMtfFillStyle m_NopFillStyle;
549 vcl::Font maLatestFont;
550 vcl::Font maFont;
551 sal_uInt32 mnLatestTextAlign;
552 sal_uInt32 mnTextAlign;
553 Color maLatestTextColor;
554 Color maTextColor;
555 Color maLatestBkColor;
556 Color maBkColor;
557 ComplexTextLayoutMode mnLatestTextLayoutMode;
558 ComplexTextLayoutMode mnTextLayoutMode;
559 BkMode mnLatestBkMode;
560 BkMode mnBkMode;
561 RasterOp meLatestRasterOp;
562 RasterOp meRasterOp;
564 std::vector< GDIObj* > vGDIObj;
566 Point maActPos;
568 sal_uInt32 mnRop;
569 bool mbNopMode;
570 bool mbFillStyleSelected;
571 bool mbClipNeedsUpdate;
572 bool mbComplexClip;
574 std::vector< SaveStructPtr > vSaveStack;
576 sal_uInt32 mnGfxMode;
577 sal_uInt32 mnMapMode;
579 XForm maXForm;
580 sal_Int32 mnDevOrgX, mnDevOrgY;
581 sal_Int32 mnDevWidth, mnDevHeight;
582 sal_Int32 mnWinOrgX, mnWinOrgY; // aktuel window origin
583 sal_Int32 mnWinExtX, mnWinExtY; // aktuel window extend
584 bool mbIsMapWinSet;
585 bool mbIsMapDevSet;
587 sal_Int32 mnPixX, mnPixY; // Reference Device in pixel
588 sal_Int32 mnMillX, mnMillY; // Reference Device in Mill
589 Rectangle mrclFrame; // rectangle in logical units 1/100th mm
590 Rectangle mrclBounds;
592 GDIMetaFile* mpGDIMetaFile;
594 void UpdateLineStyle();
595 void UpdateFillStyle();
597 Point ImplMap( const Point& rPt );
598 Point ImplScale( const Point& rPt );
599 Size ImplMap( const Size& rSize, bool bDoWorldTransform = true);
600 Rectangle ImplMap( const Rectangle& rRectangle );
601 void ImplMap( vcl::Font& rFont );
602 Polygon& ImplMap( Polygon& rPolygon );
603 tools::PolyPolygon& ImplMap( tools::PolyPolygon& rPolyPolygon );
604 Polygon& ImplScale( Polygon& rPolygon );
605 tools::PolyPolygon& ImplScale( tools::PolyPolygon& rPolyPolygon );
606 void ImplResizeObjectArry( sal_uInt32 nNewEntry );
607 void ImplSetNonPersistentLineColorTransparenz();
608 void ImplDrawClippedPolyPolygon( const tools::PolyPolygon& rPolyPoly );
609 void ImplDrawBitmap( const Point& rPos, const Size& rSize, const BitmapEx& rBitmap );
611 public:
613 void SetDevByWin(); //Hack to set varying defaults for incompletely defined files.
614 void SetDevOrg( const Point& rPoint );
615 void SetDevOrgOffset( sal_Int32 nXAdd, sal_Int32 nYAdd );
616 void SetDevExt( const Size& rSize ,bool regular = true);
617 void ScaleDevExt( double fX, double fY );
619 void SetWinOrg( const Point& rPoint , bool bIsEMF = false);
620 void SetWinOrgOffset( sal_Int32 nX, sal_Int32 nY );
621 void SetWinExt( const Size& rSize , bool bIsEMF = false);
622 void ScaleWinExt( double fX, double fY );
624 void SetrclBounds( const Rectangle& rRect );
625 void SetrclFrame( const Rectangle& rRect );
626 void SetRefPix( const Size& rSize );
627 void SetRefMill( const Size& rSize );
629 sal_uInt32 GetMapMode() const { return mnMapMode; };
630 void SetMapMode( sal_uInt32 mnMapMode );
631 void SetWorldTransform( const XForm& rXForm );
632 const XForm& GetWorldTransform() const { return maXForm; }
633 void ModifyWorldTransform( const XForm& rXForm, sal_uInt32 nMode );
635 void Push();
636 void Pop();
638 sal_uInt32 SetRasterOp( sal_uInt32 nRasterOp );
639 void StrokeAndFillPath( bool bStroke, bool bFill );
641 void SetGfxMode( sal_Int32 nGfxMode ){ mnGfxMode = nGfxMode; };
642 sal_Int32 GetGfxMode() const { return mnGfxMode; };
643 void SetBkMode( BkMode nMode );
644 void SetBkColor( const Color& rColor );
645 void SetTextColor( const Color& rColor );
646 void SetTextAlign( sal_uInt32 nAlign );
647 void CreateObject( GDIObjectType, void* pStyle = NULL );
648 void CreateObject( sal_Int32 nIndex, GDIObjectType, void* pStyle = NULL );
649 void DeleteObject( sal_Int32 nIndex );
650 void SelectObject( sal_Int32 nIndex );
651 rtl_TextEncoding GetCharSet(){ return maFont.GetCharSet(); };
652 WinMtfFillStyle& GetFillStyle () { return maFillStyle; }
653 const vcl::Font& GetFont() const { return maFont;}
654 void SetTextLayoutMode( ComplexTextLayoutMode nLayoutMode );
656 void ClearPath(){ aPathObj.Init(); };
657 void ClosePath(){ aPathObj.ClosePath(); };
658 const tools::PolyPolygon& GetPathObj(){ return aPathObj; };
660 void MoveTo( const Point& rPoint, bool bRecordPath = false );
661 void LineTo( const Point& rPoint, bool bRecordPath = false );
662 void DrawPixel( const Point& rSource, const Color& rColor );
663 void DrawRect( const Rectangle& rRect, bool bEdge = true );
664 void DrawRoundRect( const Rectangle& rRect, const Size& rSize );
665 void DrawEllipse( const Rectangle& rRect );
666 void DrawArc(
667 const Rectangle& rRect,
668 const Point& rStartAngle,
669 const Point& rEndAngle,
670 bool bDrawTo = false
672 void DrawPie(
673 const Rectangle& rRect,
674 const Point& rStartAngle,
675 const Point& rEndAngle
677 void DrawChord(
678 const Rectangle& rRect,
679 const Point& rStartAngle,
680 const Point& rEndAngle
682 void DrawPolygon( Polygon& rPolygon, bool bRecordPath = false );
683 void DrawPolygon( Polygon& rPolygon, bool /*bDrawTo*/, bool bRecordPath)
685 //For ReadAndDrawPolygon template compatibility
686 DrawPolygon(rPolygon, bRecordPath);
688 void DrawPolyPolygon( tools::PolyPolygon& rPolyPolygon, bool bRecordPath = false );
689 void DrawPolyLine(
690 Polygon& rPolygon,
691 bool bDrawTo = false,
692 bool bRecordPath = false
694 void DrawPolyBezier(
695 Polygon& rPolygin,
696 bool bDrawTo = false,
697 bool bRecordPath = false
699 void DrawText( Point& rPosition,
700 OUString& rString,
701 long* pDXArry = NULL,
702 bool bRecordPath = false,
703 sal_Int32 nGraphicsMode = GM_COMPATIBLE);
705 void ResolveBitmapActions( BSaveStructList_impl& rSaveList );
707 void IntersectClipRect( const Rectangle& rRect );
708 void ExcludeClipRect( const Rectangle& rRect );
709 void MoveClipRegion( const Size& rSize );
710 void SetClipPath(
711 const tools::PolyPolygon& rPolyPoly,
712 sal_Int32 nClippingMode,
713 bool bIsMapped
715 void SetDefaultClipPath();
716 void UpdateClipRegion();
717 void AddFromGDIMetaFile( GDIMetaFile& rGDIMetaFile );
719 void PassEMFPlus( void* pBuffer, sal_uInt32 nLength );
720 void PassEMFPlusHeaderInfo();
722 WinMtfOutput( GDIMetaFile& rGDIMetaFile );
723 virtual ~WinMtfOutput();
726 class WinMtf
728 protected:
730 WinMtfOutput* pOut;
731 SvStream* pWMF; // the WMF/EMF file to be read
733 sal_uInt32 nStartPos, nEndPos;
734 BSaveStructList_impl aBmpSaveList;
736 FilterConfigItem* pFilterConfigItem;
738 com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
740 // assures aSampledBrush is the actual brush of the GDIMetaFile
742 Color ReadColor();
743 void Callback( sal_uInt16 nPercent );
745 WinMtf(
746 WinMtfOutput* pOut,
747 SvStream& rStreamWMF,
748 FilterConfigItem* pConfigItem = NULL
750 ~WinMtf();
753 class EnhWMFReader : public WinMtf
755 bool bRecordPath;
756 sal_Int32 nRecordCount;
757 bool bEMFPlus;
759 bool ReadHeader();
760 // reads and converts the rectangle
761 static Rectangle ReadRectangle( sal_Int32, sal_Int32, sal_Int32, sal_Int32 );
763 public:
764 EnhWMFReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, FilterConfigItem* pConfigItem = NULL);
765 ~EnhWMFReader();
767 bool ReadEnhWMF();
768 void ReadEMFPlusComment(sal_uInt32 length, bool& bHaveDC);
769 private:
770 template <class T> void ReadAndDrawPolyPolygon();
771 template <class T> void ReadAndDrawPolyLine();
772 template <class T> Polygon ReadPolygon(sal_uInt32 nStartIndex, sal_uInt32 nPoints);
773 template <class T, class Drawer> void ReadAndDrawPolygon(Drawer drawer, const bool skipFirst);
775 Rectangle ReadRectangle();
778 class WMFReader : public WinMtf
780 private:
782 sal_uInt16 nUnitsPerInch;
783 sal_uInt32 nRecSize;
785 // embedded EMF data
786 SvMemoryStream* pEMFStream;
788 // total number of comment records containing EMF data
789 sal_uInt32 nEMFRecCount;
791 // number of EMF records read
792 sal_uInt32 nEMFRec;
794 // total size of embedded EMF data
795 sal_uInt32 nEMFSize;
797 sal_uInt32 nSkipActions;
798 sal_uInt32 nCurrentAction;
799 sal_uInt32 nUnicodeEscapeAction;
801 WMF_EXTERNALHEADER* pExternalHeader;
803 // reads header of the WMF-Datei
804 bool ReadHeader();
806 // reads parameters of the record with the functionnumber nFunction.
807 void ReadRecordParams( sal_uInt16 nFunction );
809 Point ReadPoint(); // reads and converts a point (first X then Y)
810 Point ReadYX(); // reads and converts a point (first Y then X)
811 Rectangle ReadRectangle(); // reads and converts a rectangle
812 Size ReadYXExt();
813 bool GetPlaceableBound( Rectangle& rSize, SvStream* pStrm );
815 public:
817 WMFReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile,
818 FilterConfigItem* pConfigItem = NULL,
819 WMF_EXTERNALHEADER* pExtHeader = NULL);
820 ~WMFReader();
822 // read WMF file from stream and fill the GDIMetaFile
823 void ReadWMF();
826 #endif
828 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */