LibreOffice Module drawinglayer (master) 1
emfphelperdata.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 <wmfemfhelper.hxx>
25#include <tools/stream.hxx>
27#include <map>
28
29// predefines
30class SvStream;
31namespace basegfx { class B2DPolyPolygon; }
32
33namespace emfplushelper
34{
35 // EMF+ commands
36 #define EmfPlusRecordTypeHeader 0x4001
37 #define EmfPlusRecordTypeEndOfFile 0x4002
38 #define EmfPlusRecordTypeComment 0x4003
39 #define EmfPlusRecordTypeGetDC 0x4004
40 //TODO EmfPlusRecordTypeMultiFormatStart 0x4005
41 //TODO EmfPlusRecordTypeMultiFormatSection 0x4006
42 //TODO EmfPlusRecordTypeMultiFormatEnd 0x4007
43 #define EmfPlusRecordTypeObject 0x4008
44 //TODO EmfPlusRecordTypeClear 0x4009
45 #define EmfPlusRecordTypeFillRects 0x400A
46 #define EmfPlusRecordTypeDrawRects 0x400B
47 #define EmfPlusRecordTypeFillPolygon 0x400C
48 #define EmfPlusRecordTypeDrawLines 0x400D
49 #define EmfPlusRecordTypeFillEllipse 0x400E
50 #define EmfPlusRecordTypeDrawEllipse 0x400F
51 #define EmfPlusRecordTypeFillPie 0x4010
52 #define EmfPlusRecordTypeDrawPie 0x4011
53 #define EmfPlusRecordTypeDrawArc 0x4012
54 #define EmfPlusRecordTypeFillRegion 0x4013
55 #define EmfPlusRecordTypeFillPath 0x4014
56 #define EmfPlusRecordTypeDrawPath 0x4015
57 #define EmfPlusRecordTypeFillClosedCurve 0x4016
58 #define EmfPlusRecordTypeDrawClosedCurve 0x4017
59 #define EmfPlusRecordTypeDrawCurve 0x4018
60 #define EmfPlusRecordTypeDrawBeziers 0x4019
61 #define EmfPlusRecordTypeDrawImage 0x401A
62 #define EmfPlusRecordTypeDrawImagePoints 0x401B
63 #define EmfPlusRecordTypeDrawString 0x401C
64 #define EmfPlusRecordTypeSetRenderingOrigin 0x401D
65 #define EmfPlusRecordTypeSetAntiAliasMode 0x401E
66 #define EmfPlusRecordTypeSetTextRenderingHint 0x401F
67 #define EmfPlusRecordTypeSetTextContrast 0x4020
68 #define EmfPlusRecordTypeSetInterpolationMode 0x4021
69 #define EmfPlusRecordTypeSetPixelOffsetMode 0x4022
70 //TODO EmfPlusRecordTypeSetCompositingMode 0x4023
71 #define EmfPlusRecordTypeSetCompositingQuality 0x4024
72 #define EmfPlusRecordTypeSave 0x4025
73 #define EmfPlusRecordTypeRestore 0x4026
74 #define EmfPlusRecordTypeBeginContainer 0x4027
75 #define EmfPlusRecordTypeBeginContainerNoParams 0x4028
76 #define EmfPlusRecordTypeEndContainer 0x4029
77 #define EmfPlusRecordTypeSetWorldTransform 0x402A
78 #define EmfPlusRecordTypeResetWorldTransform 0x402B
79 #define EmfPlusRecordTypeMultiplyWorldTransform 0x402C
80 #define EmfPlusRecordTypeTranslateWorldTransform 0x402D
81 #define EmfPlusRecordTypeScaleWorldTransform 0x402E
82 #define EmfPlusRecordTypeRotateWorldTransform 0x402F
83 #define EmfPlusRecordTypeSetPageTransform 0x4030
84 #define EmfPlusRecordTypeResetClip 0x4031
85 #define EmfPlusRecordTypeSetClipRect 0x4032
86 #define EmfPlusRecordTypeSetClipPath 0x4033
87 #define EmfPlusRecordTypeSetClipRegion 0x4034
88 #define EmfPlusRecordTypeOffsetClip 0x4035
89 #define EmfPlusRecordTypeDrawDriverString 0x4036
90 //TODO EmfPlusRecordTypeStrokeFillPath 0x4037
91 //TODO EmfPlusRecordTypeSerializableObject 0x4038
92 //TODO EmfPlusRecordTypeSetTSGraphics 0x4039
93 //TODO EmfPlusRecordTypeSetTSClip 0x403A
94
95 // EMF+object types
96 #define EmfPlusObjectTypeBrush 0x100
97 #define EmfPlusObjectTypePen 0x200
98 #define EmfPlusObjectTypePath 0x300
99 #define EmfPlusObjectTypeRegion 0x400
100 #define EmfPlusObjectTypeImage 0x500
101 #define EmfPlusObjectTypeFont 0x600
102 #define EmfPlusObjectTypeStringFormat 0x700
103 #define EmfPlusObjectTypeImageAttributes 0x800
104 #define EmfPlusObjectTypeCustomLineCap 0x900
105
107 {
113 };
114
116 {
123 };
124
126 {
135 };
136
138 {
145 };
146
148 {
155 UnitTypeMillimeter = 0x06
156 };
157
159 {
166 };
167
168 const char* emfTypeToName(sal_uInt16 type);
169 OUString UnitTypeToString(sal_uInt16 nType);
170
172 {
173 virtual ~EMFPObject();
174 };
175
176 typedef std::map<int, wmfemfhelper::PropertyHolder> GraphicStateMap;
177
179 {
180 private:
181 /* EMF+ */
185
186 std::unique_ptr<EMFPObject> maEMFPObjects[256];
188 sal_Int32 mnOriginX;
189 sal_Int32 mnOriginY;
190 sal_uInt32 mnHDPI;
191 sal_uInt32 mnVDPI;
193 sal_uInt16 mnTextContrast;
194
195 /* EMF+ emf header info */
196 sal_Int32 mnFrameLeft;
197 sal_Int32 mnFrameTop;
198 sal_Int32 mnFrameRight;
199 sal_Int32 mnFrameBottom;
200 sal_Int32 mnPixX;
201 sal_Int32 mnPixY;
202 sal_Int32 mnMmX;
203 sal_Int32 mnMmY;
204
205 /* multipart object data */
207 sal_uInt16 mMFlags;
209
210 /* emf+ graphic state stack */
213
214 /* Performance optimizators */
215 /* Extracted Scale values from Transformation Matrix */
218
224
225 // readers
226 void processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_uInt32 dataSize, bool bUseWholeStream = false);
227 static void ReadPoint(SvStream& s, float& x, float& y, sal_uInt32 flags);
228
229 // internal mapper
230 void mappingChanged();
231
232 // stack actions
233 void GraphicStatePush(GraphicStateMap& map, sal_Int32 index);
234 void GraphicStatePop(GraphicStateMap& map, sal_Int32 index);
235
237 const float aPenWidth) const;
238
239 // primitive creators
240 void EMFPPlusDrawPolygon(const ::basegfx::B2DPolyPolygon& polygon, sal_uInt32 penIndex);
241 void EMFPPlusFillPolygon(const ::basegfx::B2DPolyPolygon& polygon, const bool isColor, const sal_uInt32 brushIndexOrColor);
242 void EMFPPlusFillPolygonSolidColor(const ::basegfx::B2DPolyPolygon& polygon, Color const& color);
243
244 // helper functions
245 Color EMFPGetBrushColorOrARGBColor(const sal_uInt16 flags, const sal_uInt32 brushIndexOrColor) const;
246
247 public:
249 SvMemoryStream& rMS,
250 wmfemfhelper::TargetHolders& rTargetHolders,
251 wmfemfhelper::PropertyHolders& rPropertyHolders);
253
255 SvMemoryStream& rMS,
256 const drawinglayer::geometry::ViewInformation2D& rViewInformation);
257
258 // mappers
259 ::basegfx::B2DPoint Map(double ix, double iy) const;
260
261 // readers
262 static void ReadRectangle(SvStream& s, float& x, float& y, float &width, float& height, bool bCompressed = false);
263 static bool readXForm(SvStream& rIn, basegfx::B2DHomMatrix& rTarget);
264 static ::basegfx::B2DPolyPolygon combineClip(::basegfx::B2DPolyPolygon const & leftPolygon, int combineMode, ::basegfx::B2DPolyPolygon const & rightPolygon);
265
266 static float getUnitToPixelMultiplier(const UnitType aUnitType, const sal_uInt32 aDPI);
267 };
268}
269
270/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
helper class for graphic context
Helper class which builds a stack on the TargetHolder class.
@ TextRenderingHintAntialiasGridFit
@ TextRenderingHintSingleBitPerPixel
@ TextRenderingHintClearTypeGridFit
@ TextRenderingHintSingleBitPerPixelGridFit
OUString UnitTypeToString(sal_uInt16 nType)
const char * emfTypeToName(sal_uInt16 type)
std::map< int, wmfemfhelper::PropertyHolder > GraphicStateMap
@ InterpolationModeHighQualityBicubic
@ InterpolationModeNearestNeighbor
@ InterpolationModeHighQualityBilinear
void GraphicStatePush(GraphicStateMap &map, sal_Int32 index)
basegfx::B2DHomMatrix maBaseTransform
static bool readXForm(SvStream &rIn, basegfx::B2DHomMatrix &rTarget)
void GraphicStatePop(GraphicStateMap &map, sal_Int32 index)
::basegfx::B2DPoint Map(double ix, double iy) const
void EMFPPlusDrawPolygon(const ::basegfx::B2DPolyPolygon &polygon, sal_uInt32 penIndex)
EmfPlusHelperData(SvMemoryStream &rMS, wmfemfhelper::TargetHolders &rTargetHolders, wmfemfhelper::PropertyHolders &rPropertyHolders)
basegfx::B2DHomMatrix maWorldTransform
void EMFPPlusFillPolygon(const ::basegfx::B2DPolyPolygon &polygon, const bool isColor, const sal_uInt32 brushIndexOrColor)
void processEmfPlusData(SvMemoryStream &rMS, const drawinglayer::geometry::ViewInformation2D &rViewInformation)
wmfemfhelper::PropertyHolders & mrPropertyHolders
void EMFPPlusFillPolygonSolidColor(const ::basegfx::B2DPolyPolygon &polygon, Color const &color)
basegfx::B2DHomMatrix maMapTransform
static void ReadRectangle(SvStream &s, float &x, float &y, float &width, float &height, bool bCompressed=false)
std::unique_ptr< EMFPObject > maEMFPObjects[256]
static void ReadPoint(SvStream &s, float &x, float &y, sal_uInt32 flags)
wmfemfhelper::TargetHolders & mrTargetHolders
data holders
::basegfx::B2DPolyPolygon combineClip(::basegfx::B2DPolyPolygon const &leftPolygon, int combineMode, ::basegfx::B2DPolyPolygon const &rightPolygon)
void processObjectRecord(SvMemoryStream &rObjectStream, sal_uInt16 flags, sal_uInt32 dataSize, bool bUseWholeStream=false)
Color EMFPGetBrushColorOrARGBColor(const sal_uInt16 flags, const sal_uInt32 brushIndexOrColor) const
static float getUnitToPixelMultiplier(const UnitType aUnitType, const sal_uInt32 aDPI)
wmfemfhelper::PropertyHolder aGetDCState
drawinglayer::attribute::LineStartEndAttribute CreateLineEnd(const sal_Int32 aCap, const float aPenWidth) const