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>
27#include <com/sun/star/task/XStatusIndicator.hpp>
28#include <tools/stream.hxx>
29
30#define MAXOBJECTHANDLES 16
31
33{
45};
46
48class LineInfo;
49namespace basegfx { class B2DPolygon; }
50
52{
53private:
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, o3tl::span<const sal_Int32> pDXAry );
146 void WMFRecord_ExtTextOut(const Point& rPoint, std::u16string_view rString, o3tl::span<const sal_Int32> pDXAry);
147
148 void TrueExtTextOut(const Point& rPoint, std::u16string_view rString,
149 const OString& rByteString, o3tl::span<const sal_Int32> 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);
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
198public:
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: */
RasterOp
Definition: RasterOp.hxx:23
void WriteRecords(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:1007
void SetAllAttr()
Definition: wmfwr.cxx:932
sal_uInt16 nDstFontHandle
Definition: wmfwr.hxx:97
void WMFRecord_PolyLine(const tools::Polygon &rPoly)
Definition: wmfwr.cxx:634
Color aSrcLineColor
Definition: wmfwr.hxx:71
void HandleLineInfoPolyPolygons(const LineInfo &rInfo, const basegfx::B2DPolygon &rLinePolygon)
Definition: wmfwr.cxx:966
void WMFRecord_SaveDC()
Definition: wmfwr.cxx:694
void WMFRecord_LineTo(const Point &rPoint)
Definition: wmfwr.cxx:600
void WMFRecord_StretchDIB(const Point &rPoint, const Size &rSize, const Bitmap &rBitmap, sal_uInt32 nROP=0)
Definition: wmfwr.cxx:772
bool bStatus
Definition: wmfwr.hxx:55
void WMFRecord_CreatePenIndirect(const Color &rColor, const LineInfo &rLineInfo)
Definition: wmfwr.cxx:371
void WMFRecord_SetBkMode(bool bTransparent)
Definition: wmfwr.cxx:705
void WriteEMFRecord(SvMemoryStream &rStream, sal_uInt32 nCurSize, sal_uInt32 nRemainingSize, sal_uInt32 nTotalSize, sal_uInt32 nRecCounts, sal_uInt16 nCheckSum)
Definition: wmfwr.cxx:1882
sal_uLong nWrittenBitmaps
Definition: wmfwr.hxx:106
bool bHandleAllocated[MAXOBJECTHANDLES]
Definition: wmfwr.hxx:96
vcl::Font aDstFont
Definition: wmfwr.hxx:91
void WriteRecordHeader(sal_uInt32 nSizeWords, sal_uInt16 nType)
Definition: wmfwr.cxx:256
void WritePointXY(const Point &rPoint)
Definition: wmfwr.cxx:215
void WMFRecord_SetWindowExt(const Size &rSize)
Definition: wmfwr.cxx:760
sal_uInt16 nDstPenHandle
Definition: wmfwr.hxx:97
void UpdateHeader()
Definition: wmfwr.cxx:1660
void WriteHeader(bool bPlaceable)
Definition: wmfwr.cxx:1628
void CreateSelectDeleteBrush(const Color &rColor)
Definition: wmfwr.cxx:898
void WMFRecord_CreateFontIndirect(const vcl::Font &rFont)
Definition: wmfwr.cxx:309
Color aDstLineColor
Definition: wmfwr.hxx:85
LineInfo aDstLineInfo
Definition: wmfwr.hxx:88
bool WriteWMF(const GDIMetaFile &rMTF, SvStream &rTargetStream, FilterConfigItem const *pFilterConfigItem, bool bPlaceable)
Definition: wmfwr.cxx:1680
sal_uLong nWrittenActions
Definition: wmfwr.hxx:105
SvStream * pWMF
Definition: wmfwr.hxx:61
TextAlign eDstTextAlign
Definition: wmfwr.hxx:90
void WMFRecord_SetWindowOrg(const Point &rPoint)
Definition: wmfwr.cxx:766
sal_uLong nLastPercent
Definition: wmfwr.hxx:57
void MayCallback()
Definition: wmfwr.cxx:166
RasterOp eDstROP2
Definition: wmfwr.hxx:89
Color aDstFillColor
Definition: wmfwr.hxx:86
void UpdateRecordHeader()
Definition: wmfwr.cxx:263
void WMFRecord_RoundRect(const tools::Rectangle &rRect, tools::Long nHorzRound, tools::Long nVertRound)
Definition: wmfwr.cxx:687
sal_uInt16 eSrcHorTextAlign
Definition: wmfwr.hxx:82
WMFWriter()
Definition: wmfwr.cxx:138
void WMFRecord_ExtTextOut(const Point &rPoint, std::u16string_view rString, o3tl::span< const sal_Int32 > pDXAry)
Definition: wmfwr.cxx:548
void WMFRecord_Chord(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
Definition: wmfwr.cxx:288
css::uno::Reference< css::task::XStatusIndicator > xStatusIndicator
Definition: wmfwr.hxx:59
sal_uInt16 CalcSaveTargetMapMode(MapMode &rMapMode, const Size &rPrefSize)
Definition: wmfwr.cxx:1806
Color aSrcTextColor
Definition: wmfwr.hxx:73
sal_uInt16 AllocHandle()
Definition: wmfwr.cxx:851
void TrueExtTextOut(const Point &rPoint, std::u16string_view rString, const OString &rByteString, o3tl::span< const sal_Int32 > pDXAry)
Definition: wmfwr.cxx:564
sal_uLong nNumberOfBitmaps
Definition: wmfwr.hxx:104
sal_uLong nMetafileHeaderPos
Definition: wmfwr.hxx:66
VclPtr< VirtualDevice > pVirDev
Definition: wmfwr.hxx:62
void SetLineAndFillAttr()
Definition: wmfwr.cxx:912
void WMFRecord_Ellipse(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:413
void CreateSelectDeleteFont(const vcl::Font &rFont)
Definition: wmfwr.cxx:884
void WMFRecord_SetTextAlign(TextAlign eFontAlign, sal_uInt16 eHorTextAlign)
Definition: wmfwr.cxx:738
void WMFRecord_TextOut(const Point &rPoint, std::u16string_view rString)
Definition: wmfwr.cxx:827
vcl::Region aSrcClipRegion
Definition: wmfwr.hxx:79
vcl::Region aDstClipRegion
Definition: wmfwr.hxx:95
bool bEmbedEMF
Definition: wmfwr.hxx:109
void WMFRecord_SetPixel(const Point &rPoint, const Color &rColor)
Definition: wmfwr.cxx:718
void CreateSelectDeletePen(const Color &rColor, const LineInfo &rLineInfo)
Definition: wmfwr.cxx:870
void WMFRecord_MoveTo(const Point &rPoint)
Definition: wmfwr.cxx:606
void WMFRecord_DeleteObject(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:407
void WMFRecord_SetStretchBltMode()
Definition: wmfwr.cxx:712
void WriteHeightWidth(const Size &rSize)
Definition: wmfwr.cxx:239
Color aDstTextColor
Definition: wmfwr.hxx:87
sal_uLong nActBitmapPercent
Definition: wmfwr.hxx:107
void WriteSize(const Size &rSize)
Definition: wmfwr.cxx:233
sal_uLong nNumberOfActions
Definition: wmfwr.hxx:103
void WMFRecord_SetROP2(RasterOp eROP)
Definition: wmfwr.cxx:725
void WMFRecord_Pie(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
Definition: wmfwr.cxx:612
void WMFRecord_RestoreDC()
Definition: wmfwr.cxx:681
void WMFRecord_IntersectClipRect(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:845
void WMFRecord_Arc(const tools::Rectangle &rRect, const Point &rStartPt, const Point &rEndPt)
Definition: wmfwr.cxx:280
void WriteColor(const Color &rColor)
Definition: wmfwr.cxx:251
void WMFRecord_Rectangle(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:675
void TrueTextOut(const Point &rPoint, const OString &rString)
Definition: wmfwr.cxx:834
void FreeHandle(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:865
void WMFRecord_Polygon(const tools::Polygon &rPoly)
Definition: wmfwr.cxx:620
void WriteEmbeddedEMF(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:1830
void WMFRecord_PolyPolygon(const tools::PolyPolygon &rPolyPoly)
Definition: wmfwr.cxx:648
void WriteRectangle(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:245
sal_uInt32 nMaxRecordSize
Definition: wmfwr.hxx:67
void WritePointYX(const Point &rPoint)
Definition: wmfwr.cxx:221
vcl::Font aSrcFont
Definition: wmfwr.hxx:77
void WMFRecord_CreateBrushIndirect(const Color &rColor)
Definition: wmfwr.cxx:296
sal_uInt16 eDstHorTextAlign
Definition: wmfwr.hxx:93
Color aSrcFillColor
Definition: wmfwr.hxx:72
MapMode aTargetMapMode
Definition: wmfwr.hxx:63
void WMFRecord_SetTextColor(const Color &rColor)
Definition: wmfwr.cxx:754
TextAlign eSrcTextAlign
Definition: wmfwr.hxx:76
LineInfo aSrcLineInfo
Definition: wmfwr.hxx:74
MapMode aSrcMapMode
Definition: wmfwr.hxx:78
void CountActionsAndBitmaps(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:189
sal_Int32 ScaleWidth(sal_Int32 nDX)
Definition: wmfwr.cxx:227
sal_uLong nActRecordPos
Definition: wmfwr.hxx:68
sal_uInt16 nDstBrushHandle
Definition: wmfwr.hxx:97
Size aTargetSize
Definition: wmfwr.hxx:64
bool WMFRecord_Escape_Unicode(const Point &rPoint, const OUString &rStr, o3tl::span< const sal_Int32 > pDXAry)
Definition: wmfwr.cxx:445
RasterOp eSrcRasterOp
Definition: wmfwr.hxx:75
void WMFRecord_Escape(sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8 *pData)
Definition: wmfwr.cxx:419
WMFWriterAttrStackMember * pAttrStack
Definition: wmfwr.hxx:80
void WMFRecord_SelectObject(sal_uInt16 nObjectHandle)
Definition: wmfwr.cxx:699
TextAlign
long Long
PushFlags
Definition: State.hxx:40
sal_uIntPtr sal_uLong
TextAlign eTextAlign
Definition: wmfwr.hxx:39
struct WMFWriterAttrStackMember * pSucc
Definition: wmfwr.hxx:34
vcl::Region aClipRegion
Definition: wmfwr.hxx:43
vcl::PushFlags nFlags
Definition: wmfwr.hxx:44
signed char sal_Int8
#define MAXOBJECTHANDLES
Definition: wmfwr.hxx:30