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/metaact.hxx>
24 #include <vcl/graph.hxx>
25 #include <vcl/gdimtf.hxx>
26 #include <vcl/virdev.hxx>
27 #include <vcl/fltcall.hxx>
29 #define MAXOBJECTHANDLES 16
31 struct WMFWriterAttrStackMember
33 struct WMFWriterAttrStackMember
* pSucc
;
42 vcl::Region aClipRegion
;
46 class StarSymbolToMSMultiFont
;
48 namespace basegfx
{ class B2DPolygon
; }
56 sal_uLong nLastPercent
; // with which number pCallback was called last time.
58 com::sun::star::uno::Reference
< com::sun::star::task::XStatusIndicator
> xStatusIndicator
;
61 VclPtr
<VirtualDevice
> pVirDev
;
62 MapMode aTargetMapMode
;
65 sal_uLong nMetafileHeaderPos
;
66 sal_uInt32 nMaxRecordSize
; // in words
67 sal_uLong nActRecordPos
;
69 // actual attribute in source metafile:
73 LineInfo aSrcLineInfo
;
74 RasterOp eSrcRasterOp
;
75 FontAlign eSrcTextAlign
;
79 vcl::Region aSrcClipRegion
;
80 WMFWriterAttrStackMember
* pAttrStack
;
82 sal_uInt32 eSrcHorTextAlign
;
84 // actual attribute in destination metafile:
88 LineInfo aDstLineInfo
;
90 FontAlign eDstTextAlign
;
93 sal_uInt32 eDstHorTextAlign
;
95 bool bDstIsClipping
; // ???: not taken into account at the moment
96 vcl::Region aDstClipRegion
; // ???: not taken into account at the moment
97 bool bHandleAllocated
[MAXOBJECTHANDLES
]; // which handles have been assigned
98 sal_uInt16 nDstPenHandle
,nDstFontHandle
,nDstBrushHandle
; // which handles are owned by
102 // to prevent we have to compare all attributes at each operation:
104 sal_uLong nNumberOfActions
; // number of actions in the GDIMetafile
105 sal_uLong nNumberOfBitmaps
; // number of bitmaps
106 sal_uLong nWrittenActions
; // number of processed actions while writing the directory
107 sal_uLong nWrittenBitmaps
; // number of bitmaps written
108 sal_uLong nActBitmapPercent
; // percentage of next bitmap written.
110 bool bEmbedEMF
; // optionally embedd EMF data into WMF
113 // this function calculates percentage using the above 5 parameters
114 // and triggers a callback if needed. Puts bStatus to FALSE if the
115 // users wants to abort.
117 void CountActionsAndBitmaps(const GDIMetaFile
& rMTF
);
118 // Counts bitmaps and actions (nNumberOfActions and nNumberOfBitmaps should
119 // be initialised to 0 at start, as this method is recursive)
121 void WritePointXY(const Point
& rPoint
);
122 void WritePointYX(const Point
& rPoint
);
123 sal_Int32
ScaleWidth( sal_Int32 nDX
);
124 void WriteSize(const Size
& rSize
);
125 void WriteHeightWidth(const Size
& rSize
);
126 void WriteRectangle(const Rectangle
& rRect
);
127 void WriteColor(const Color
& rColor
);
129 void WriteRecordHeader(sal_uInt32 nSizeWords
, sal_uInt16 nType
);
130 // nSizeWords is the size of the all records in number of words.
131 // If nSizeWords is unknown, then use 0 (see UpdateRecordHeader())
133 void UpdateRecordHeader();
134 // returns the size of the record after writing the parameters, if
135 // nSizeWords was unknown upon calling WriteRecordHeader(..)
136 // if needed it inserts a BYTE 0 to make number of bytes even
138 void WMFRecord_Arc(const Rectangle
& rRect
, const Point
& rStartPt
, const Point
& rEndPt
);
139 void WMFRecord_Chord(const Rectangle
& rRect
, const Point
& rStartPt
, const Point
& rEndPt
);
140 void WMFRecord_CreateBrushIndirect(const Color
& rColor
);
141 void WMFRecord_CreateFontIndirect(const vcl::Font
& rFont
);
142 void WMFRecord_CreatePenIndirect(const Color
& rColor
, const LineInfo
& rLineInfo
);
143 void WMFRecord_DeleteObject(sal_uInt16 nObjectHandle
);
144 void WMFRecord_Ellipse(const Rectangle
& rRect
);
145 void WMFRecord_Escape( sal_uInt32 nEsc
, sal_uInt32 nLen
, const sal_Int8
* pData
);
146 bool WMFRecord_Escape_Unicode( const Point
& rPoint
, const OUString
& rStr
, const long* pDXAry
);
147 void WMFRecord_ExtTextOut(const Point
& rPoint
, const OUString
& rString
, const long* pDXAry
);
149 void TrueExtTextOut(const Point
& rPoint
, const OUString
& rString
,
150 const OString
& rByteString
, const long* pDXAry
);
151 void TrueTextOut(const Point
& rPoint
, const OString
& rString
);
152 void WMFRecord_LineTo(const Point
& rPoint
);
153 void WMFRecord_MoveTo(const Point
& rPoint
);
154 void WMFRecord_Pie(const Rectangle
& rRect
, const Point
& rStartPt
, const Point
& rEndPt
);
155 void WMFRecord_Polygon(const Polygon
& rPoly
);
156 void WMFRecord_PolyLine(const Polygon
& rPoly
);
157 void WMFRecord_PolyPolygon(const tools::PolyPolygon
& rPolyPoly
);
158 void WMFRecord_Rectangle(const Rectangle
& rRect
);
159 void WMFRecord_RestoreDC();
160 void WMFRecord_RoundRect(const Rectangle
& rRect
, long nHorzRound
, long nVertRound
);
161 void WMFRecord_SaveDC();
162 void WMFRecord_SelectObject(sal_uInt16 nObjectHandle
);
163 void WMFRecord_SetBkMode(bool bTransparent
);
164 void WMFRecord_SetStretchBltMode();
165 void WMFRecord_SetPixel(const Point
& rPoint
, const Color
& rColor
);
166 void WMFRecord_SetROP2(RasterOp eROP
);
167 void WMFRecord_SetTextAlign(FontAlign eFontAlign
, sal_uInt32 eHorTextAlign
);
168 void WMFRecord_SetTextColor(const Color
& rColor
);
169 void WMFRecord_SetWindowExt(const Size
& rSize
);
170 void WMFRecord_SetWindowOrg(const Point
& rPoint
);
171 void WMFRecord_StretchDIB(const Point
& rPoint
, const Size
& rSize
, const Bitmap
& rBitmap
, sal_uInt32 nROP
= 0UL );
172 void WMFRecord_TextOut(const Point
& rPoint
, const OUString
& rString
);
173 void WMFRecord_EndOfFile();
174 void WMFRecord_IntersectClipRect( const Rectangle
& rRect
);
176 sal_uInt16
AllocHandle();
177 void FreeHandle(sal_uInt16 nObjectHandle
);
178 void CreateSelectDeletePen( const Color
& rColor
, const LineInfo
& rLineInfo
);
179 void CreateSelectDeleteFont(const vcl::Font
& rFont
);
180 void CreateSelectDeleteBrush(const Color
& rColor
);
182 void SetLineAndFillAttr();
185 void HandleLineInfoPolyPolygons(const LineInfo
& rInfo
, const basegfx::B2DPolygon
& rLinePolygon
);
186 void WriteRecords(const GDIMetaFile
& rMTF
);
188 void WriteHeader(const GDIMetaFile
& rMTF
, bool bPlaceable
);
191 void WriteEmbeddedEMF( const GDIMetaFile
& rMTF
);
192 void WriteEMFRecord( SvMemoryStream
& rStream
, sal_uInt32 nCurSize
,
193 sal_uInt32 nRemainingSize
,
194 sal_uInt32 nTotalSize
,
195 sal_uInt32 nRecCounts
,
196 sal_uInt16 nCheckSum
);
198 sal_uInt16
CalcSaveTargetMapMode(MapMode
& rMapMode
, const Size
& rPrefSize
);
202 bool WriteWMF(const GDIMetaFile
& rMTF
, SvStream
& rTargetStream
, FilterConfigItem
* pFilterConfigItem
, bool bPlaceable
=true);
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */