LibreOffice Module vcl (master)  1
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
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 .
18  */
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>
33 {
45 };
48 class LineInfo;
49 namespace basegfx { class B2DPolygon; }
51 class WMFWriter
52 {
53 private:
55  bool bStatus;
57  sal_uLong nLastPercent; // with which number pCallback was called last time.
59  css::uno::Reference< css::task::XStatusIndicator > xStatusIndicator;
67  sal_uInt32 nMaxRecordSize; // in words
70  // actual attribute in source metafile:
82  sal_uInt16 eSrcHorTextAlign;
84  // actual attribute in destination metafile:
93  sal_uInt16 eDstHorTextAlign;
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:
101  // to prevent we have to compare all attributes at each operation:
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.
109  bool bEmbedEMF; // optionally embed EMF data into WMF
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.
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)
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);
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())
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
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 tools::Long* pDXAry );
146  void WMFRecord_ExtTextOut(const Point& rPoint, const OUString& rString, const tools::Long* pDXAry);
148  void TrueExtTextOut(const Point& rPoint, const OUString& rString,
149  const OString& rByteString, const tools::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, tools::Long nHorzRound, tools::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(TextAlign 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, std::u16string_view rString);
172  void WMFRecord_IntersectClipRect( const tools::Rectangle& rRect);
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);
180  void SetLineAndFillAttr();
181  void SetAllAttr();
183  void HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon);
184  void WriteRecords(const GDIMetaFile & rMTF);
186  void WriteHeader(bool bPlaceable);
187  void UpdateHeader();
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 );
196  sal_uInt16 CalcSaveTargetMapMode(MapMode& rMapMode, const Size& rPrefSize);
198 public:
199  WMFWriter();
200  bool WriteWMF(const GDIMetaFile & rMTF, SvStream & rTargetStream, FilterConfigItem const * pFilterConfigItem, bool bPlaceable);
201 };
203 #endif
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void WMFRecord_Rectangle(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:675
void CreateSelectDeletePen(const Color &rColor, const LineInfo &rLineInfo)
Definition: wmfwr.cxx:870
void WMFRecord_SetROP2(RasterOp eROP)
Definition: wmfwr.cxx:725
bool WriteWMF(const GDIMetaFile &rMTF, SvStream &rTargetStream, FilterConfigItem const *pFilterConfigItem, bool bPlaceable)
Definition: wmfwr.cxx:1679
void WriteRecordHeader(sal_uInt32 nSizeWords, sal_uInt16 nType)
Definition: wmfwr.cxx:256
void WMFRecord_SetBkMode(bool bTransparent)
Definition: wmfwr.cxx:705
void MayCallback()
Definition: wmfwr.cxx:166
void WMFRecord_SetStretchBltMode()
Definition: wmfwr.cxx:712
void WMFRecord_ExtTextOut(const Point &rPoint, const OUString &rString, const tools::Long *pDXAry)
Definition: wmfwr.cxx:548
signed char sal_Int8
void WMFRecord_SelectObject(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:699
Color aDstLineColor
Definition: wmfwr.hxx:85
void WMFRecord_PolyPolygon(const tools::PolyPolygon &rPolyPoly)
Definition: wmfwr.cxx:648
sal_uIntPtr sal_uLong
long Long
void WMFRecord_Arc(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
Definition: wmfwr.cxx:280
TextAlign eSrcTextAlign
Definition: wmfwr.hxx:76
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:1659
void WriteHeader(bool bPlaceable)
Definition: wmfwr.cxx:1627
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:233
sal_uLong nNumberOfBitmaps
Definition: wmfwr.hxx:104
void WMFRecord_SetTextAlign(TextAlign eFontAlign, sal_uInt16 eHorTextAlign)
Definition: wmfwr.cxx:738
void WMFRecord_MoveTo(const Point &rPoint)
Definition: wmfwr.cxx:606
sal_uLong nWrittenBitmaps
Definition: wmfwr.hxx:106
void WMFRecord_CreatePenIndirect(const Color &rColor, const LineInfo &rLineInfo)
Definition: wmfwr.cxx:371
Definition: wmfwr.cxx:138
sal_uInt16 nDstBrushHandle
Definition: wmfwr.hxx:97
TextAlign eTextAlign
Definition: wmfwr.hxx:39
Definition: outdevstate.hxx:38
void WMFRecord_SetTextColor(const Color &rColor)
Definition: wmfwr.cxx:754
Color aDstTextColor
Definition: wmfwr.hxx:87
sal_uInt16 CalcSaveTargetMapMode(MapMode &rMapMode, const Size &rPrefSize)
Definition: wmfwr.cxx:1805
void WriteRectangle(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:245
Color aSrcFillColor
Definition: wmfwr.hxx:72
void WriteRecords(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:1007
void TrueExtTextOut(const Point &rPoint, const OUString &rString, const OString &rByteString, const tools::Long *pDXAry)
Definition: wmfwr.cxx:564
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:1881
MapMode aTargetMapMode
Definition: wmfwr.hxx:63
void SetAllAttr()
Definition: wmfwr.cxx:932
void WMFRecord_SetWindowOrg(const Point &rPoint)
Definition: wmfwr.cxx:766
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:296
sal_Int32 ScaleWidth(sal_Int32 nDX)
Definition: wmfwr.cxx:227
RasterOp eSrcRasterOp
Definition: wmfwr.hxx:75
void WMFRecord_IntersectClipRect(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:845
void WMFRecord_Ellipse(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:413
bool WMFRecord_Escape_Unicode(const Point &rPoint, const OUString &rStr, const tools::Long *pDXAry)
Definition: wmfwr.cxx:445
Color aSrcLineColor
Definition: wmfwr.hxx:71
Definition: RasterOp.hxx:22
Size aTargetSize
Definition: wmfwr.hxx:64
void SetLineAndFillAttr()
Definition: wmfwr.cxx:912
sal_uLong nActBitmapPercent
Definition: wmfwr.hxx:107
void TrueTextOut(const Point &rPoint, const OString &rString)
Definition: wmfwr.cxx:834
sal_uInt16 nDstFontHandle
Definition: wmfwr.hxx:97
void UpdateRecordHeader()
Definition: wmfwr.cxx:263
bool bEmbedEMF
Definition: wmfwr.hxx:109
vcl::Region aDstClipRegion
Definition: wmfwr.hxx:95
void WMFRecord_CreateFontIndirect(const vcl::Font &rFont)
Definition: wmfwr.cxx:309
void WMFRecord_StretchDIB(const Point &rPoint, const Size &rSize, const Bitmap &rBitmap, sal_uInt32 nROP=0)
Definition: wmfwr.cxx:772
vcl::Font aSrcFont
Definition: wmfwr.hxx:77
void WMFRecord_DeleteObject(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:407
void WMFRecord_PolyLine(const tools::Polygon &rPoly)
Definition: wmfwr.cxx:634
void WMFRecord_TextOut(const Point &rPoint, std::u16string_view rString)
Definition: wmfwr.cxx:827
LineInfo aDstLineInfo
Definition: wmfwr.hxx:88
void WMFRecord_RestoreDC()
Definition: wmfwr.cxx:681
vcl::Region aSrcClipRegion
Definition: wmfwr.hxx:79
void HandleLineInfoPolyPolygons(const LineInfo &rInfo, const basegfx::B2DPolygon &rLinePolygon)
Definition: wmfwr.cxx:966
void WMFRecord_Escape(sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8 *pData)
Definition: wmfwr.cxx:419
bool bStatus
Definition: wmfwr.hxx:55
void WriteHeightWidth(const Size &rSize)
Definition: wmfwr.cxx:239
void WMFRecord_Chord(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
Definition: wmfwr.cxx:288
void WMFRecord_SetPixel(const Point &rPoint, const Color &rColor)
Definition: wmfwr.cxx:718
sal_uLong nActRecordPos
Definition: wmfwr.hxx:68
Definition: wmfwr.hxx:30
void WritePointXY(const Point &rPoint)
Definition: wmfwr.cxx:215
void CountActionsAndBitmaps(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:189
vcl::Font aDstFont
Definition: wmfwr.hxx:91
bool bHandleAllocated[MAXOBJECTHANDLES]
Definition: wmfwr.hxx:96
void WriteEmbeddedEMF(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:1829
void WMFRecord_Polygon(const tools::Polygon &rPoly)
Definition: wmfwr.cxx:620
void FreeHandle(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:865
css::uno::Reference< css::task::XStatusIndicator > xStatusIndicator
Definition: wmfwr.hxx:59
void WMFRecord_LineTo(const Point &rPoint)
Definition: wmfwr.cxx:600
sal_uInt16 AllocHandle()
Definition: wmfwr.cxx:851
Color aDstFillColor
Definition: wmfwr.hxx:86
void CreateSelectDeleteFont(const vcl::Font &rFont)
Definition: wmfwr.cxx:884
void WriteColor(const Color &rColor)
Definition: wmfwr.cxx:251
void WMFRecord_SetWindowExt(const Size &rSize)
Definition: wmfwr.cxx:760
void WMFRecord_RoundRect(const tools::Rectangle &rRect, tools::Long nHorzRound, tools::Long nVertRound)
Definition: wmfwr.cxx:687
TextAlign eDstTextAlign
Definition: wmfwr.hxx:90
void CreateSelectDeleteBrush(const Color &rColor)
Definition: wmfwr.cxx:898
SvStream * pWMF
Definition: wmfwr.hxx:61
void WritePointYX(const Point &rPoint)
Definition: wmfwr.cxx:221
void WMFRecord_Pie(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
Definition: wmfwr.cxx:612
void WMFRecord_SaveDC()
Definition: wmfwr.cxx:694