Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / drawinglayer / inc / wmfemfhelper.hxx
blob36e720601b07932267fc7519eedb038c7316c07b
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_INC_WMFEMFHELPER_HXX
21 #define INCLUDED_DRAWINGLAYER_INC_WMFEMFHELPER_HXX
23 #include <sal/config.h>
24 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
25 #include <vcl/font.hxx>
26 #include <vcl/outdevstate.hxx>
27 #include <basegfx/matrix/b2dhommatrix.hxx>
28 #include <basegfx/polygon/b2dpolypolygon.hxx>
29 #include <memory>
31 // predefines
32 namespace drawinglayer { namespace geometry { class ViewInformation2D; }}
33 class GDIMetaFile;
34 namespace wmfemfhelper { class PropertyHolder; }
36 namespace wmfemfhelper
38 /** Helper class to buffer and hold a Primitive target vector. It
39 encapsulates the new/delete functionality and allows to work
40 on pointers of the implementation classes. All data will
41 be converted to uno sequences of uno references when accessing the
42 data.
44 class TargetHolder
46 private:
47 std::vector< std::unique_ptr<drawinglayer::primitive2d::BasePrimitive2D> > aTargets;
49 public:
50 TargetHolder();
51 ~TargetHolder();
52 sal_uInt32 size() const;
53 void append(std::unique_ptr<drawinglayer::primitive2d::BasePrimitive2D> pCandidate);
54 drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequence(const PropertyHolder& rPropertyHolder);
58 namespace wmfemfhelper
60 /** Helper class which builds a stack on the TargetHolder class */
61 class TargetHolders
63 private:
64 std::vector< TargetHolder* > maTargetHolders;
66 public:
67 TargetHolders();
68 sal_uInt32 size() const;
69 void Push();
70 void Pop();
71 TargetHolder& Current();
72 ~TargetHolders();
76 namespace wmfemfhelper
78 /** helper class for graphic context
80 This class allows to hold a complete representation of classic
81 VCL OutputDevice state. This data is needed for correct
82 interpretation of the MetaFile action flow.
84 class PropertyHolder
86 private:
87 /// current transformation (aka MapMode)
88 basegfx::B2DHomMatrix maTransformation;
89 MapUnit maMapUnit;
91 /// current colors
92 basegfx::BColor maLineColor;
93 basegfx::BColor maFillColor;
94 basegfx::BColor maTextColor;
95 basegfx::BColor maTextFillColor;
96 basegfx::BColor maTextLineColor;
97 basegfx::BColor maOverlineColor;
99 /// clipping
100 basegfx::B2DPolyPolygon maClipPolyPoygon;
102 /// font, etc.
103 vcl::Font maFont;
104 RasterOp maRasterOp;
105 ComplexTextLayoutFlags mnLayoutMode;
106 LanguageType maLanguageType;
107 PushFlags mnPushFlags;
109 /// contains all active markers
110 bool mbLineColor : 1;
111 bool mbFillColor : 1;
112 bool mbTextColor : 1;
113 bool mbTextFillColor : 1;
114 bool mbTextLineColor : 1;
115 bool mbOverlineColor : 1;
116 bool mbClipPolyPolygonActive : 1;
118 public:
119 PropertyHolder();
121 /// read/write accesses
122 const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; }
123 void setTransformation(const basegfx::B2DHomMatrix& rNew) { if (rNew != maTransformation) maTransformation = rNew; }
125 MapUnit getMapUnit() const { return maMapUnit; }
126 void setMapUnit(MapUnit eNew) { if (eNew != maMapUnit) maMapUnit = eNew; }
128 const basegfx::BColor& getLineColor() const { return maLineColor; }
129 void setLineColor(const basegfx::BColor& rNew) { if (rNew != maLineColor) maLineColor = rNew; }
130 bool getLineColorActive() const { return mbLineColor; }
131 void setLineColorActive(bool bNew) { if (bNew != mbLineColor) mbLineColor = bNew; }
133 const basegfx::BColor& getFillColor() const { return maFillColor; }
134 void setFillColor(const basegfx::BColor& rNew) { if (rNew != maFillColor) maFillColor = rNew; }
135 bool getFillColorActive() const { return mbFillColor; }
136 void setFillColorActive(bool bNew) { if (bNew != mbFillColor) mbFillColor = bNew; }
138 const basegfx::BColor& getTextColor() const { return maTextColor; }
139 void setTextColor(const basegfx::BColor& rNew) { if (rNew != maTextColor) maTextColor = rNew; }
140 bool getTextColorActive() const { return mbTextColor; }
141 void setTextColorActive(bool bNew) { if (bNew != mbTextColor) mbTextColor = bNew; }
143 const basegfx::BColor& getTextFillColor() const { return maTextFillColor; }
144 void setTextFillColor(const basegfx::BColor& rNew) { if (rNew != maTextFillColor) maTextFillColor = rNew; }
145 bool getTextFillColorActive() const { return mbTextFillColor; }
146 void setTextFillColorActive(bool bNew) { if (bNew != mbTextFillColor) mbTextFillColor = bNew; }
148 const basegfx::BColor& getTextLineColor() const { return maTextLineColor; }
149 void setTextLineColor(const basegfx::BColor& rNew) { if (rNew != maTextLineColor) maTextLineColor = rNew; }
150 bool getTextLineColorActive() const { return mbTextLineColor; }
151 void setTextLineColorActive(bool bNew) { if (bNew != mbTextLineColor) mbTextLineColor = bNew; }
153 const basegfx::BColor& getOverlineColor() const { return maOverlineColor; }
154 void setOverlineColor(const basegfx::BColor& rNew) { if (rNew != maOverlineColor) maOverlineColor = rNew; }
155 bool getOverlineColorActive() const { return mbOverlineColor; }
156 void setOverlineColorActive(bool bNew) { if (bNew != mbOverlineColor) mbOverlineColor = bNew; }
158 const basegfx::B2DPolyPolygon& getClipPolyPolygon() const { return maClipPolyPoygon; }
159 void setClipPolyPolygon(const basegfx::B2DPolyPolygon& rNew) { if (rNew != maClipPolyPoygon) maClipPolyPoygon = rNew; }
160 bool getClipPolyPolygonActive() const { return mbClipPolyPolygonActive; }
161 void setClipPolyPolygonActive(bool bNew) { if (bNew != mbClipPolyPolygonActive) mbClipPolyPolygonActive = bNew; }
163 const vcl::Font& getFont() const { return maFont; }
164 void setFont(const vcl::Font& rFont) { if (rFont != maFont) maFont = rFont; }
166 const RasterOp& getRasterOp() const { return maRasterOp; }
167 void setRasterOp(const RasterOp& rRasterOp) { if (rRasterOp != maRasterOp) maRasterOp = rRasterOp; }
168 bool isRasterOpInvert() const { return (RasterOp::Xor == maRasterOp || RasterOp::Invert == maRasterOp); }
169 bool isRasterOpForceBlack() const { return RasterOp::N0 == maRasterOp; }
170 bool isRasterOpActive() const { return isRasterOpInvert() || isRasterOpForceBlack(); }
172 ComplexTextLayoutFlags getLayoutMode() const { return mnLayoutMode; }
173 void setLayoutMode(ComplexTextLayoutFlags nNew) { if (nNew != mnLayoutMode) mnLayoutMode = nNew; }
175 LanguageType getLanguageType() const { return maLanguageType; }
176 void setLanguageType(LanguageType aNew) { if (aNew != maLanguageType) maLanguageType = aNew; }
178 PushFlags getPushFlags() const { return mnPushFlags; }
179 void setPushFlags(PushFlags nNew) { if (nNew != mnPushFlags) mnPushFlags = nNew; }
181 bool getLineOrFillActive() const { return (mbLineColor || mbFillColor); }
185 namespace wmfemfhelper
187 /** stack for properties
189 This class builds a stack based on the PropertyHolder
190 class. It encapsulates the pointer/new/delete usage to
191 make it safe and implements the push/pop as needed by a
192 VCL Metafile interpreter. The critical part here are the
193 flag values VCL OutputDevice uses here; not all stuff is
194 pushed and thus needs to be copied at pop.
196 class PropertyHolders
198 private:
199 std::vector< PropertyHolder* > maPropertyHolders;
201 public:
202 PropertyHolders();
203 void PushDefault();
204 void Push(PushFlags nPushFlags);
205 void Pop();
206 PropertyHolder& Current();
207 ~PropertyHolders();
211 namespace wmfemfhelper
213 drawinglayer::primitive2d::Primitive2DContainer interpretMetafile(
214 const GDIMetaFile& rMetaFile,
215 const drawinglayer::geometry::ViewInformation2D& rViewInformation);
217 void HandleNewClipRegion(
218 const basegfx::B2DPolyPolygon& rClipPolyPolygon,
219 TargetHolders& rTargetHolders,
220 PropertyHolders& rPropertyHolders);
223 #endif
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */