1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_WMFWR_HXX
21 #define INCLUDED_VCL_SOURCE_FILTER_WMF_WMFWR_HXX
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>
30 #define MAXOBJECTHANDLES 16
32 struct WMFWriterAttrStackMember
34 struct WMFWriterAttrStackMember
* pSucc
;
43 vcl::Region aClipRegion
;
47 class StarSymbolToMSMultiFont
;
49 namespace basegfx
{ class B2DPolygon
; }
57 sal_uLong nLastPercent
; // with which number pCallback was called last time.
59 css::uno::Reference
< css::task::XStatusIndicator
> xStatusIndicator
;
62 VclPtr
<VirtualDevice
> pVirDev
;
63 MapMode aTargetMapMode
;
66 sal_uLong nMetafileHeaderPos
;
67 sal_uInt32 nMaxRecordSize
; // in words
68 sal_uLong nActRecordPos
;
70 // actual attribute in source metafile:
74 LineInfo aSrcLineInfo
;
75 RasterOp eSrcRasterOp
;
76 FontAlign eSrcTextAlign
;
79 vcl::Region aSrcClipRegion
;
80 WMFWriterAttrStackMember
* pAttrStack
;
82 sal_uInt16 eSrcHorTextAlign
;
84 // actual attribute in destination metafile:
88 LineInfo aDstLineInfo
;
90 FontAlign eDstTextAlign
;
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
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
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 long* pDXAry
);
146 void WMFRecord_ExtTextOut(const Point
& rPoint
, const OUString
& rString
, const long* pDXAry
);
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
);
163 void WMFRecord_SetStretchBltMode();
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
);
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();
183 void HandleLineInfoPolyPolygons(const LineInfo
& rInfo
, const basegfx::B2DPolygon
& rLinePolygon
);
184 void WriteRecords(const GDIMetaFile
& rMTF
);
186 void WriteHeader(bool bPlaceable
);
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
);
200 bool WriteWMF(const GDIMetaFile
& rMTF
, SvStream
& rTargetStream
, FilterConfigItem
const * pFilterConfigItem
, bool bPlaceable
);
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */