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#pragma once
21
22#include <vcl/gdimtf.hxx>
23#include <vcl/lineinfo.hxx>
24#include <vcl/virdev.hxx>
26#include <com/sun/star/task/XStatusIndicator.hpp>
27#include <tools/stream.hxx>
28
29#define MAXOBJECTHANDLES 16
30
32{
44};
45
47class LineInfo;
48namespace basegfx { class B2DPolygon; }
49
51{
52private:
53
54 bool bStatus;
55
56 sal_uLong nLastPercent; // with which number pCallback was called last time.
57
58 css::uno::Reference< css::task::XStatusIndicator > xStatusIndicator;
59
64
66 sal_uInt32 nMaxRecordSize; // in words
68
69 // actual attribute in source metafile:
80
81 sal_uInt16 eSrcHorTextAlign;
82
83 // actual attribute in destination metafile:
91
92 sal_uInt16 eDstHorTextAlign;
93
94 vcl::Region aDstClipRegion; // ???: not taken into account at the moment
95 bool bHandleAllocated[MAXOBJECTHANDLES]; // which handles have been assigned
96 sal_uInt16 nDstPenHandle,nDstFontHandle,nDstBrushHandle; // which handles are owned by
97 // Selected-Objects
98 // 0xFFFF = none:
99
100 // to prevent we have to compare all attributes at each operation:
101
102 sal_uLong nNumberOfActions; // number of actions in the GDIMetafile
103 sal_uLong nNumberOfBitmaps; // number of bitmaps
104 sal_uLong nWrittenActions; // number of processed actions while writing the directory
105 sal_uLong nWrittenBitmaps; // number of bitmaps written
106 sal_uLong nActBitmapPercent; // percentage of next bitmap written.
107
108 bool bEmbedEMF; // optionally embed EMF data into WMF
109
110 void MayCallback();
111 // this function calculates percentage using the above 5 parameters
112 // and triggers a callback if needed. Puts bStatus to FALSE if the
113 // users wants to abort.
114
115 void CountActionsAndBitmaps(const GDIMetaFile & rMTF);
116 // Counts bitmaps and actions (nNumberOfActions and nNumberOfBitmaps should
117 // be initialised to 0 at start, as this method is recursive)
118
119 void WritePointXY(const Point & rPoint);
120 void WritePointYX(const Point & rPoint);
121 sal_Int32 ScaleWidth( sal_Int32 nDX );
122 void WriteSize(const Size & rSize);
123 void WriteHeightWidth(const Size & rSize);
124 void WriteRectangle(const tools::Rectangle & rRect);
125 void WriteColor(const Color & rColor);
126
127 void WriteRecordHeader(sal_uInt32 nSizeWords, sal_uInt16 nType);
128 // nSizeWords is the size of the all records in number of words.
129 // If nSizeWords is unknown, then use 0 (see UpdateRecordHeader())
130
131 void UpdateRecordHeader();
132 // returns the size of the record after writing the parameters, if
133 // nSizeWords was unknown upon calling WriteRecordHeader(..)
134 // if needed it inserts a BYTE 0 to make number of bytes even
135
136 void WMFRecord_Arc(const tools::Rectangle& rRect, const Point& rStartPt, const Point& rEndPt);
137 void WMFRecord_Chord(const tools::Rectangle& rRect, const Point& rStartPt, const Point& rEndPt);
138 void WMFRecord_CreateBrushIndirect(const Color& rColor);
139 void WMFRecord_CreateFontIndirect(const vcl::Font& rFont);
140 void WMFRecord_CreatePenIndirect(const Color& rColor, const LineInfo& rLineInfo );
141 void WMFRecord_DeleteObject(sal_uInt16 nObjectHandle);
142 void WMFRecord_Ellipse(const tools::Rectangle& rRect);
143 void WMFRecord_Escape( sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8* pData );
144 bool WMFRecord_Escape_Unicode( const Point& rPoint, const OUString& rStr, KernArraySpan pDXAry );
145 void WMFRecord_ExtTextOut(const Point& rPoint, std::u16string_view rString, KernArraySpan pDXAry);
146
147 void TrueExtTextOut(const Point& rPoint, std::u16string_view rString,
148 const OString& rByteString, KernArraySpan pDXAry);
149 void TrueTextOut(const Point& rPoint, const OString& rString);
150 void WMFRecord_LineTo(const Point & rPoint);
151 void WMFRecord_MoveTo(const Point & rPoint);
152 void WMFRecord_Pie(const tools::Rectangle & rRect, const Point & rStartPt, const Point & rEndPt);
153 void WMFRecord_Polygon(const tools::Polygon & rPoly);
154 void WMFRecord_PolyLine(const tools::Polygon & rPoly);
155 void WMFRecord_PolyPolygon(const tools::PolyPolygon & rPolyPoly);
156 void WMFRecord_Rectangle(const tools::Rectangle & rRect);
157 void WMFRecord_RestoreDC();
158 void WMFRecord_RoundRect(const tools::Rectangle & rRect, tools::Long nHorzRound, tools::Long nVertRound);
159 void WMFRecord_SaveDC();
160 void WMFRecord_SelectObject(sal_uInt16 nObjectHandle);
161 void WMFRecord_SetBkMode(bool bTransparent);
163 void WMFRecord_SetPixel(const Point & rPoint, const Color & rColor);
164 void WMFRecord_SetROP2(RasterOp eROP);
165 void WMFRecord_SetTextAlign(TextAlign eFontAlign, sal_uInt16 eHorTextAlign);
166 void WMFRecord_SetTextColor(const Color & rColor);
167 void WMFRecord_SetWindowExt(const Size & rSize);
168 void WMFRecord_SetWindowOrg(const Point & rPoint);
169 void WMFRecord_StretchDIB(const Point & rPoint, const Size & rSize, const Bitmap & rBitmap, sal_uInt32 nROP = 0 );
170 void WMFRecord_TextOut(const Point & rPoint, std::u16string_view rString);
172
173 sal_uInt16 AllocHandle();
174 void FreeHandle(sal_uInt16 nObjectHandle);
175 void CreateSelectDeletePen( const Color& rColor, const LineInfo& rLineInfo );
176 void CreateSelectDeleteFont(const vcl::Font & rFont);
177 void CreateSelectDeleteBrush(const Color& rColor);
178
179 void SetLineAndFillAttr();
180 void SetAllAttr();
181
182 void HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon);
183 void WriteRecords(const GDIMetaFile & rMTF);
184
185 void WriteHeader(bool bPlaceable);
186 void UpdateHeader();
187
188 void WriteEmbeddedEMF( const GDIMetaFile& rMTF );
189 void WriteEMFRecord( SvMemoryStream& rStream, sal_uInt32 nCurSize,
190 sal_uInt32 nRemainingSize,
191 sal_uInt32 nTotalSize,
192 sal_uInt32 nRecCounts,
193 sal_uInt16 nCheckSum );
194
195 sal_uInt16 CalcSaveTargetMapMode(MapMode& rMapMode, const Size& rPrefSize);
196
197public:
198 WMFWriter();
199 bool WriteWMF(const GDIMetaFile & rMTF, SvStream & rTargetStream, FilterConfigItem const * pFilterConfigItem, bool bPlaceable);
200};
201
202/* 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:96
void WMFRecord_PolyLine(const tools::Polygon &rPoly)
Definition: wmfwr.cxx:634
Color aSrcLineColor
Definition: wmfwr.hxx:70
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:54
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:1879
sal_uLong nWrittenBitmaps
Definition: wmfwr.hxx:105
bool bHandleAllocated[MAXOBJECTHANDLES]
Definition: wmfwr.hxx:95
vcl::Font aDstFont
Definition: wmfwr.hxx:90
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:96
void UpdateHeader()
Definition: wmfwr.cxx:1657
void WriteHeader(bool bPlaceable)
Definition: wmfwr.cxx:1625
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:84
LineInfo aDstLineInfo
Definition: wmfwr.hxx:87
void WMFRecord_ExtTextOut(const Point &rPoint, std::u16string_view rString, KernArraySpan pDXAry)
Definition: wmfwr.cxx:548
bool WriteWMF(const GDIMetaFile &rMTF, SvStream &rTargetStream, FilterConfigItem const *pFilterConfigItem, bool bPlaceable)
Definition: wmfwr.cxx:1677
sal_uLong nWrittenActions
Definition: wmfwr.hxx:104
SvStream * pWMF
Definition: wmfwr.hxx:60
TextAlign eDstTextAlign
Definition: wmfwr.hxx:89
void WMFRecord_SetWindowOrg(const Point &rPoint)
Definition: wmfwr.cxx:766
sal_uLong nLastPercent
Definition: wmfwr.hxx:56
void MayCallback()
Definition: wmfwr.cxx:166
RasterOp eDstROP2
Definition: wmfwr.hxx:88
Color aDstFillColor
Definition: wmfwr.hxx:85
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:81
WMFWriter()
Definition: wmfwr.cxx:138
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:58
sal_uInt16 CalcSaveTargetMapMode(MapMode &rMapMode, const Size &rPrefSize)
Definition: wmfwr.cxx:1803
Color aSrcTextColor
Definition: wmfwr.hxx:72
sal_uInt16 AllocHandle()
Definition: wmfwr.cxx:851
sal_uLong nNumberOfBitmaps
Definition: wmfwr.hxx:103
sal_uLong nMetafileHeaderPos
Definition: wmfwr.hxx:65
VclPtr< VirtualDevice > pVirDev
Definition: wmfwr.hxx:61
void SetLineAndFillAttr()
Definition: wmfwr.cxx:912
void WMFRecord_Ellipse(const tools::Rectangle &rRect)
Definition: wmfwr.cxx:413
bool WMFRecord_Escape_Unicode(const Point &rPoint, const OUString &rStr, KernArraySpan pDXAry)
Definition: wmfwr.cxx:445
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:78
vcl::Region aDstClipRegion
Definition: wmfwr.hxx:94
bool bEmbedEMF
Definition: wmfwr.hxx:108
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:86
sal_uLong nActBitmapPercent
Definition: wmfwr.hxx:106
void WriteSize(const Size &rSize)
Definition: wmfwr.cxx:233
sal_uLong nNumberOfActions
Definition: wmfwr.hxx:102
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 TrueExtTextOut(const Point &rPoint, std::u16string_view rString, const OString &rByteString, KernArraySpan pDXAry)
Definition: wmfwr.cxx:564
void WMFRecord_Polygon(const tools::Polygon &rPoly)
Definition: wmfwr.cxx:620
void WriteEmbeddedEMF(const GDIMetaFile &rMTF)
Definition: wmfwr.cxx:1827
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:66
void WritePointYX(const Point &rPoint)
Definition: wmfwr.cxx:221
vcl::Font aSrcFont
Definition: wmfwr.hxx:76
void WMFRecord_CreateBrushIndirect(const Color &rColor)
Definition: wmfwr.cxx:296
sal_uInt16 eDstHorTextAlign
Definition: wmfwr.hxx:92
Color aSrcFillColor
Definition: wmfwr.hxx:71
MapMode aTargetMapMode
Definition: wmfwr.hxx:62
void WMFRecord_SetTextColor(const Color &rColor)
Definition: wmfwr.cxx:754
TextAlign eSrcTextAlign
Definition: wmfwr.hxx:75
LineInfo aSrcLineInfo
Definition: wmfwr.hxx:73
MapMode aSrcMapMode
Definition: wmfwr.hxx:77
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:67
sal_uInt16 nDstBrushHandle
Definition: wmfwr.hxx:96
Size aTargetSize
Definition: wmfwr.hxx:63
RasterOp eSrcRasterOp
Definition: wmfwr.hxx:74
void WMFRecord_Escape(sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8 *pData)
Definition: wmfwr.cxx:419
WMFWriterAttrStackMember * pAttrStack
Definition: wmfwr.hxx:79
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:38
struct WMFWriterAttrStackMember * pSucc
Definition: wmfwr.hxx:33
vcl::Region aClipRegion
Definition: wmfwr.hxx:42
vcl::PushFlags nFlags
Definition: wmfwr.hxx:43
signed char sal_Int8
#define MAXOBJECTHANDLES
Definition: wmfwr.hxx:29