LibreOffice Module vcl (master)  1
wmfwr.hxx
Go to the documentation of this file.
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_WMFWR_HXX
21 #define INCLUDED_VCL_SOURCE_FILTER_WMF_WMFWR_HXX
22 
23 #include <vcl/gdimtf.hxx>
24 #include <vcl/lineinfo.hxx>
25 #include <vcl/virdev.hxx>
26 #include <vcl/FilterConfigItem.hxx>
27 #include <com/sun/star/task/XStatusIndicator.hpp>
28 #include <tools/stream.hxx>
29 
30 #define MAXOBJECTHANDLES 16
31 
33 {
45 };
46 
48 class LineInfo;
49 namespace basegfx { class B2DPolygon; }
50 
51 class WMFWriter
52 {
53 private:
54 
55  bool bStatus;
56 
57  sal_uLong nLastPercent; // with which number pCallback was called last time.
58 
59  css::uno::Reference< css::task::XStatusIndicator > xStatusIndicator;
60 
65 
67  sal_uInt32 nMaxRecordSize; // in words
69 
70  // actual attribute in source metafile:
81 
82  sal_uInt16 eSrcHorTextAlign;
83 
84  // actual attribute in destination metafile:
92 
93  sal_uInt16 eDstHorTextAlign;
94 
95  vcl::Region aDstClipRegion; // ???: not taken into account at the moment
96  bool bHandleAllocated[MAXOBJECTHANDLES]; // which handles have been assigned
97  sal_uInt16 nDstPenHandle,nDstFontHandle,nDstBrushHandle; // which handles are owned by
98  // Selected-Objects
99  // 0xFFFF = none:
100 
101  // to prevent we have to compare all attributes at each operation:
102 
103  sal_uLong nNumberOfActions; // number of actions in the GDIMetafile
104  sal_uLong nNumberOfBitmaps; // number of bitmaps
105  sal_uLong nWrittenActions; // number of processed actions while writing the directory
106  sal_uLong nWrittenBitmaps; // number of bitmaps written
107  sal_uLong nActBitmapPercent; // percentage of next bitmap written.
108 
109  bool bEmbedEMF; // optionally embed EMF data into WMF
110 
111  void MayCallback();
112  // this function calculates percentage using the above 5 parameters
113  // and triggers a callback if needed. Puts bStatus to FALSE if the
114  // users wants to abort.
115 
116  void CountActionsAndBitmaps(const GDIMetaFile & rMTF);
117  // Counts bitmaps and actions (nNumberOfActions and nNumberOfBitmaps should
118  // be initialised to 0 at start, as this method is recursive)
119 
120  void WritePointXY(const Point & rPoint);
121  void WritePointYX(const Point & rPoint);
122  sal_Int32 ScaleWidth( sal_Int32 nDX );
123  void WriteSize(const Size & rSize);
124  void WriteHeightWidth(const Size & rSize);
125  void WriteRectangle(const tools::Rectangle & rRect);
126  void WriteColor(const Color & rColor);
127 
128  void WriteRecordHeader(sal_uInt32 nSizeWords, sal_uInt16 nType);
129  // nSizeWords is the size of the all records in number of words.
130  // If nSizeWords is unknown, then use 0 (see UpdateRecordHeader())
131 
132  void UpdateRecordHeader();
133  // returns the size of the record after writing the parameters, if
134  // nSizeWords was unknown upon calling WriteRecordHeader(..)
135  // if needed it inserts a BYTE 0 to make number of bytes even
136 
137  void WMFRecord_Arc(const tools::Rectangle& rRect, const Point& rStartPt, const Point& rEndPt);
138  void WMFRecord_Chord(const tools::Rectangle& rRect, const Point& rStartPt, const Point& rEndPt);
139  void WMFRecord_CreateBrushIndirect(const Color& rColor);
140  void WMFRecord_CreateFontIndirect(const vcl::Font& rFont);
141  void WMFRecord_CreatePenIndirect(const Color& rColor, const LineInfo& rLineInfo );
142  void WMFRecord_DeleteObject(sal_uInt16 nObjectHandle);
143  void WMFRecord_Ellipse(const tools::Rectangle& rRect);
144  void WMFRecord_Escape( sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8* pData );
145  bool WMFRecord_Escape_Unicode( const Point& rPoint, const OUString& rStr, const long* pDXAry );
146  void WMFRecord_ExtTextOut(const Point& rPoint, const OUString& rString, const long* pDXAry);
147 
148  void TrueExtTextOut(const Point& rPoint, const OUString& rString,
149  const OString& rByteString, const long* pDXAry);
150  void TrueTextOut(const Point& rPoint, const OString& rString);
151  void WMFRecord_LineTo(const Point & rPoint);
152  void WMFRecord_MoveTo(const Point & rPoint);
153  void WMFRecord_Pie(const tools::Rectangle & rRect, const Point & rStartPt, const Point & rEndPt);
154  void WMFRecord_Polygon(const tools::Polygon & rPoly);
155  void WMFRecord_PolyLine(const tools::Polygon & rPoly);
156  void WMFRecord_PolyPolygon(const tools::PolyPolygon & rPolyPoly);
157  void WMFRecord_Rectangle(const tools::Rectangle & rRect);
158  void WMFRecord_RestoreDC();
159  void WMFRecord_RoundRect(const tools::Rectangle & rRect, long nHorzRound, long nVertRound);
160  void WMFRecord_SaveDC();
161  void WMFRecord_SelectObject(sal_uInt16 nObjectHandle);
162  void WMFRecord_SetBkMode(bool bTransparent);
164  void WMFRecord_SetPixel(const Point & rPoint, const Color & rColor);
165  void WMFRecord_SetROP2(RasterOp eROP);
166  void WMFRecord_SetTextAlign(FontAlign eFontAlign, sal_uInt16 eHorTextAlign);
167  void WMFRecord_SetTextColor(const Color & rColor);
168  void WMFRecord_SetWindowExt(const Size & rSize);
169  void WMFRecord_SetWindowOrg(const Point & rPoint);
170  void WMFRecord_StretchDIB(const Point & rPoint, const Size & rSize, const Bitmap & rBitmap, sal_uInt32 nROP = 0 );
171  void WMFRecord_TextOut(const Point & rPoint, const OUString & rString);
172  void WMFRecord_IntersectClipRect( const tools::Rectangle& rRect);
173 
174  sal_uInt16 AllocHandle();
175  void FreeHandle(sal_uInt16 nObjectHandle);
176  void CreateSelectDeletePen( const Color& rColor, const LineInfo& rLineInfo );
177  void CreateSelectDeleteFont(const vcl::Font & rFont);
178  void CreateSelectDeleteBrush(const Color& rColor);
179 
180  void SetLineAndFillAttr();
181  void SetAllAttr();
182 
183  void HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon);
184  void WriteRecords(const GDIMetaFile & rMTF);
185 
186  void WriteHeader(bool bPlaceable);
187  void UpdateHeader();
188 
189  void WriteEmbeddedEMF( const GDIMetaFile& rMTF );
190  void WriteEMFRecord( SvMemoryStream& rStream, sal_uInt32 nCurSize,
191  sal_uInt32 nRemainingSize,
192  sal_uInt32 nTotalSize,
193  sal_uInt32 nRecCounts,
194  sal_uInt16 nCheckSum );
195 
196  sal_uInt16 CalcSaveTargetMapMode(MapMode& rMapMode, const Size& rPrefSize);
197 
198 public:
199  WMFWriter();
200  bool WriteWMF(const GDIMetaFile & rMTF, SvStream & rTargetStream, FilterConfigItem const * pFilterConfigItem, bool bPlaceable);
201 };
202 
203 #endif
204 
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void WMFRecord_Rectangle(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:674
#define FontAlign
Definition: font.hxx:35
void CreateSelectDeletePen(const Color &rColor, const LineInfo &rLineInfo)
Definition: wmfwr.cxx:869
void WMFRecord_SetROP2(RasterOp eROP)
Definition: wmfwr.cxx:724
bool WriteWMF(const GDIMetaFile &rMTF, SvStream &rTargetStream, FilterConfigItem const *pFilterConfigItem, bool bPlaceable)
Definition: wmfwr.cxx:1678
void WriteRecordHeader(sal_uInt32 nSizeWords, sal_uInt16 nType)
Definition: wmfwr.cxx:255
FontAlign eSrcTextAlign
Definition: wmfwr.hxx:76
void WMFRecord_SetBkMode(bool bTransparent)
Definition: wmfwr.cxx:704
void MayCallback()
Definition: wmfwr.cxx:165
void WMFRecord_SetStretchBltMode()
Definition: wmfwr.cxx:711
signed char sal_Int8
void WMFRecord_SelectObject(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:698
Color aDstLineColor
Definition: wmfwr.hxx:85
void WMFRecord_PolyPolygon(const tools::PolyPolygon &rPolyPoly)
Definition: wmfwr.cxx:647
sal_uIntPtr sal_uLong
void WMFRecord_Arc(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
Definition: wmfwr.cxx:279
RasterOp eDstROP2
Definition: wmfwr.hxx:89
sal_uInt16 eSrcHorTextAlign
Definition: wmfwr.hxx:82
sal_uInt16 nDstPenHandle
Definition: wmfwr.hxx:97
sal_uLong nNumberOfActions
Definition: wmfwr.hxx:103
void UpdateHeader()
Definition: wmfwr.cxx:1658
void WriteHeader(bool bPlaceable)
Definition: wmfwr.cxx:1626
sal_uLong nMetafileHeaderPos
Definition: wmfwr.hxx:66
sal_uInt32 nMaxRecordSize
Definition: wmfwr.hxx:67
sal_uLong nLastPercent
Definition: wmfwr.hxx:57
void WriteSize(const Size &rSize)
Definition: wmfwr.cxx:232
sal_uLong nNumberOfBitmaps
Definition: wmfwr.hxx:104
RasterOp
Definition: vclenum.hxx:191
void WMFRecord_MoveTo(const Point &rPoint)
Definition: wmfwr.cxx:605
sal_uLong nWrittenBitmaps
Definition: wmfwr.hxx:106
void WMFRecord_CreatePenIndirect(const Color &rColor, const LineInfo &rLineInfo)
Definition: wmfwr.cxx:370
WMFWriter()
Definition: wmfwr.cxx:137
sal_uInt16 nDstBrushHandle
Definition: wmfwr.hxx:97
TextAlign eTextAlign
Definition: wmfwr.hxx:39
PushFlags
Definition: outdevstate.hxx:38
void WMFRecord_SetTextColor(const Color &rColor)
Definition: wmfwr.cxx:753
Color aDstTextColor
Definition: wmfwr.hxx:87
sal_uInt16 CalcSaveTargetMapMode(MapMode &rMapMode, const Size &rPrefSize)
Definition: wmfwr.cxx:1797
void WriteRectangle(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:244
Color aSrcFillColor
Definition: wmfwr.hxx:72
void WriteRecords(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:1006
VclPtr< VirtualDevice > pVirDev
Definition: wmfwr.hxx:62
sal_uInt16 eDstHorTextAlign
Definition: wmfwr.hxx:93
struct WMFWriterAttrStackMember * pSucc
Definition: wmfwr.hxx:34
LineInfo aSrcLineInfo
Definition: wmfwr.hxx:74
WMFWriterAttrStackMember * pAttrStack
Definition: wmfwr.hxx:80
Color aSrcTextColor
Definition: wmfwr.hxx:73
void WriteEMFRecord(SvMemoryStream &rStream, sal_uInt32 nCurSize, sal_uInt32 nRemainingSize, sal_uInt32 nTotalSize, sal_uInt32 nRecCounts, sal_uInt16 nCheckSum)
Definition: wmfwr.cxx:1873
MapMode aTargetMapMode
Definition: wmfwr.hxx:63
void SetAllAttr()
Definition: wmfwr.cxx:931
void WMFRecord_SetWindowOrg(const Point &rPoint)
Definition: wmfwr.cxx:765
MapMode aSrcMapMode
Definition: wmfwr.hxx:78
vcl::Region aClipRegion
Definition: wmfwr.hxx:43
sal_uLong nWrittenActions
Definition: wmfwr.hxx:105
void WMFRecord_CreateBrushIndirect(const Color &rColor)
Definition: wmfwr.cxx:295
sal_Int32 ScaleWidth(sal_Int32 nDX)
Definition: wmfwr.cxx:226
RasterOp eSrcRasterOp
Definition: wmfwr.hxx:75
void WMFRecord_IntersectClipRect(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:844
void WMFRecord_Ellipse(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:412
void WMFRecord_ExtTextOut(const Point &rPoint, const OUString &rString, const long *pDXAry)
Definition: wmfwr.cxx:547
void WMFRecord_RoundRect(const tools::Rectangle &rRect, long nHorzRound, long nVertRound)
Definition: wmfwr.cxx:686
Color aSrcLineColor
Definition: wmfwr.hxx:71
void WMFRecord_TextOut(const Point &rPoint, const OUString &rString)
Definition: wmfwr.cxx:826
Size aTargetSize
Definition: wmfwr.hxx:64
void SetLineAndFillAttr()
Definition: wmfwr.cxx:911
sal_uLong nActBitmapPercent
Definition: wmfwr.hxx:107
void TrueTextOut(const Point &rPoint, const OString &rString)
Definition: wmfwr.cxx:833
sal_uInt16 nDstFontHandle
Definition: wmfwr.hxx:97
void UpdateRecordHeader()
Definition: wmfwr.cxx:262
bool bEmbedEMF
Definition: wmfwr.hxx:109
void WMFRecord_SetTextAlign(FontAlign eFontAlign, sal_uInt16 eHorTextAlign)
Definition: wmfwr.cxx:737
vcl::Region aDstClipRegion
Definition: wmfwr.hxx:95
void WMFRecord_CreateFontIndirect(const vcl::Font &rFont)
Definition: wmfwr.cxx:308
void WMFRecord_StretchDIB(const Point &rPoint, const Size &rSize, const Bitmap &rBitmap, sal_uInt32 nROP=0)
Definition: wmfwr.cxx:771
vcl::Font aSrcFont
Definition: wmfwr.hxx:77
void WMFRecord_DeleteObject(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:406
void WMFRecord_PolyLine(const tools::Polygon &rPoly)
Definition: wmfwr.cxx:633
LineInfo aDstLineInfo
Definition: wmfwr.hxx:88
void WMFRecord_RestoreDC()
Definition: wmfwr.cxx:680
vcl::Region aSrcClipRegion
Definition: wmfwr.hxx:79
void HandleLineInfoPolyPolygons(const LineInfo &rInfo, const basegfx::B2DPolygon &rLinePolygon)
Definition: wmfwr.cxx:965
void WMFRecord_Escape(sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8 *pData)
Definition: wmfwr.cxx:418
bool bStatus
Definition: wmfwr.hxx:55
void WriteHeightWidth(const Size &rSize)
Definition: wmfwr.cxx:238
void WMFRecord_Chord(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
Definition: wmfwr.cxx:287
void WMFRecord_SetPixel(const Point &rPoint, const Color &rColor)
Definition: wmfwr.cxx:717
sal_uLong nActRecordPos
Definition: wmfwr.hxx:68
#define MAXOBJECTHANDLES
Definition: wmfwr.hxx:30
void WritePointXY(const Point &rPoint)
Definition: wmfwr.cxx:214
void CountActionsAndBitmaps(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:188
vcl::Font aDstFont
Definition: wmfwr.hxx:91
bool bHandleAllocated[MAXOBJECTHANDLES]
Definition: wmfwr.hxx:96
void WriteEmbeddedEMF(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:1821
void WMFRecord_Polygon(const tools::Polygon &rPoly)
Definition: wmfwr.cxx:619
void FreeHandle(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:864
css::uno::Reference< css::task::XStatusIndicator > xStatusIndicator
Definition: wmfwr.hxx:59
void WMFRecord_LineTo(const Point &rPoint)
Definition: wmfwr.cxx:599
sal_uInt16 AllocHandle()
Definition: wmfwr.cxx:850
void TrueExtTextOut(const Point &rPoint, const OUString &rString, const OString &rByteString, const long *pDXAry)
Definition: wmfwr.cxx:563
Color aDstFillColor
Definition: wmfwr.hxx:86
void CreateSelectDeleteFont(const vcl::Font &rFont)
Definition: wmfwr.cxx:883
FontAlign eDstTextAlign
Definition: wmfwr.hxx:90
void WriteColor(const Color &rColor)
Definition: wmfwr.cxx:250
void WMFRecord_SetWindowExt(const Size &rSize)
Definition: wmfwr.cxx:759
void CreateSelectDeleteBrush(const Color &rColor)
Definition: wmfwr.cxx:897
SvStream * pWMF
Definition: wmfwr.hxx:61
bool WMFRecord_Escape_Unicode(const Point &rPoint, const OUString &rStr, const long *pDXAry)
Definition: wmfwr.cxx:444
TextAlign
void WritePointYX(const Point &rPoint)
Definition: wmfwr.cxx:220
void WMFRecord_Pie(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
Definition: wmfwr.cxx:611
void WMFRecord_SaveDC()
Definition: wmfwr.cxx:693