bump product version to 6.4.0.3
[LibreOffice.git] / drawinglayer / source / tools / emfphelperdata.hxx
blob53047b7a025f0052180828e980fe1775f3ff2eb0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_DRAWINGLAYER_SOURCE_TOOLS_EMFPHELPERDATA_HXX
21 #define INCLUDED_DRAWINGLAYER_SOURCE_TOOLS_EMFPHELPERDATA_HXX
23 #include <emfplushelper.hxx>
24 #include <basegfx/matrix/b2dhommatrix.hxx>
25 #include <tools/stream.hxx>
26 #include <basegfx/point/b2dpoint.hxx>
27 #include <map>
29 // predefines
30 class SvStream;
31 namespace basegfx { class B2DPolyPolygon; }
33 namespace emfplushelper
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 //TODO EmfPlusRecordTypeFillClosedCurve 0x4016
58 //TODO EmfPlusRecordTypeDrawClosedCurve 0x4017
59 //TODO 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 //TODO EmfPlusSetTextContrast 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 //TODO 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
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
106 enum UnitType
108 UnitTypeWorld = 0x00,
109 UnitTypeDisplay = 0x01,
110 UnitTypePixel = 0x02,
111 UnitTypePoint = 0x03,
112 UnitTypeInch = 0x04,
113 UnitTypeDocument = 0x05,
114 UnitTypeMillimeter = 0x06
117 enum EmfPlusCombineMode
119 EmfPlusCombineModeReplace = 0x00000000,
120 EmfPlusCombineModeIntersect = 0x00000001,
121 EmfPlusCombineModeUnion = 0x00000002,
122 EmfPlusCombineModeXOR = 0x00000003,
123 EmfPlusCombineModeExclude = 0x00000004,
124 EmfPlusCombineModeComplement = 0x00000005
127 const char* emfTypeToName(sal_uInt16 type);
128 struct EMFPObject
130 virtual ~EMFPObject();
133 typedef std::map<int, wmfemfhelper::PropertyHolder> GraphicStateMap;
135 struct EmfPlusHelperData
137 private:
138 /* EMF+ */
139 basegfx::B2DHomMatrix maBaseTransform;
140 basegfx::B2DHomMatrix maWorldTransform;
141 basegfx::B2DHomMatrix maMapTransform;
143 std::unique_ptr<EMFPObject> maEMFPObjects[256];
144 float mfPageScale;
145 sal_Int32 mnOriginX;
146 sal_Int32 mnOriginY;
147 sal_uInt32 mnHDPI;
148 sal_uInt32 mnVDPI;
150 /* EMF+ emf header info */
151 sal_Int32 mnFrameLeft;
152 sal_Int32 mnFrameTop;
153 sal_Int32 mnFrameRight;
154 sal_Int32 mnFrameBottom;
155 sal_Int32 mnPixX;
156 sal_Int32 mnPixY;
157 sal_Int32 mnMmX;
158 sal_Int32 mnMmY;
160 /* multipart object data */
161 bool mbMultipart;
162 sal_uInt16 mMFlags;
163 SvMemoryStream mMStream;
165 /* emf+ graphic state stack */
166 GraphicStateMap mGSStack;
167 GraphicStateMap mGSContainerStack;
169 /// data holders
170 wmfemfhelper::TargetHolders& mrTargetHolders;
171 wmfemfhelper::PropertyHolders& mrPropertyHolders;
172 bool bIsGetDCProcessing;
174 // readers
175 void processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_uInt32 dataSize, bool bUseWholeStream = false);
176 static void ReadPoint(SvStream& s, float& x, float& y, sal_uInt32 flags);
178 // internal mapper
179 void mappingChanged();
181 // stack actions
182 void GraphicStatePush(GraphicStateMap& map, sal_Int32 index);
183 void GraphicStatePop (GraphicStateMap& map, sal_Int32 index, wmfemfhelper::PropertyHolder& rState);
185 // primitive creators
186 void EMFPPlusDrawPolygon(const ::basegfx::B2DPolyPolygon& polygon, sal_uInt32 penIndex);
187 void EMFPPlusFillPolygon(const ::basegfx::B2DPolyPolygon& polygon, const bool isColor, const sal_uInt32 brushIndexOrColor);
188 void EMFPPlusFillPolygonSolidColor(const ::basegfx::B2DPolyPolygon& polygon, Color const& color);
190 // helper functions
191 Color EMFPGetBrushColorOrARGBColor(const sal_uInt16 flags, const sal_uInt32 brushIndexOrColor) const;
193 public:
194 EmfPlusHelperData(
195 SvMemoryStream& rMS,
196 wmfemfhelper::TargetHolders& rTargetHolders,
197 wmfemfhelper::PropertyHolders& rPropertyHolders);
198 ~EmfPlusHelperData();
200 void processEmfPlusData(
201 SvMemoryStream& rMS,
202 const drawinglayer::geometry::ViewInformation2D& rViewInformation);
204 // mappers
205 ::basegfx::B2DPoint Map(double ix, double iy) const;
207 // readers
208 static void ReadRectangle(SvStream& s, float& x, float& y, float &width, float& height, bool bCompressed = false);
209 static bool readXForm(SvStream& rIn, basegfx::B2DHomMatrix& rTarget);
210 static ::basegfx::B2DPolyPolygon combineClip(::basegfx::B2DPolyPolygon const & leftPolygon, int combineMode, ::basegfx::B2DPolyPolygon const & rightPolygon);
212 static float getUnitToPixelMultiplier(const UnitType aUnitType);
216 #endif // INCLUDED_DRAWINGLAYER_SOURCE_TOOLS_EMFPHELPERDATA_HXX
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */