nss: upgrade to release 3.73
[LibreOffice.git] / drawinglayer / inc / wmfemfhelper.hxx
blob7b643bf5e36c4cf7265a94a5079f0a09eb60bd36
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 #pragma once
22 #include <sal/config.h>
23 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
24 #include <vcl/font.hxx>
25 #include <vcl/outdevstate.hxx>
26 #include <basegfx/matrix/b2dhommatrix.hxx>
27 #include <basegfx/polygon/b2dpolypolygon.hxx>
28 #include <memory>
30 // predefines
31 namespace drawinglayer::geometry { class ViewInformation2D; }
32 class GDIMetaFile;
33 namespace wmfemfhelper { class PropertyHolder; }
35 namespace wmfemfhelper
37 /** Helper class to buffer and hold a Primitive target vector. It
38 encapsulates the new/delete functionality and allows to work
39 on pointers of the implementation classes. All data will
40 be converted to uno sequences of uno references when accessing the
41 data.
43 class TargetHolder
45 private:
46 std::vector< std::unique_ptr<drawinglayer::primitive2d::BasePrimitive2D> > aTargets;
48 public:
49 TargetHolder();
50 ~TargetHolder();
51 sal_uInt32 size() const;
52 void append(std::unique_ptr<drawinglayer::primitive2d::BasePrimitive2D> pCandidate);
53 drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequence(const PropertyHolder& rPropertyHolder);
57 namespace wmfemfhelper
59 /** Helper class which builds a stack on the TargetHolder class */
60 class TargetHolders
62 private:
63 std::vector< TargetHolder* > maTargetHolders;
65 public:
66 TargetHolders();
67 sal_uInt32 size() const;
68 void Push();
69 void Pop();
70 TargetHolder& Current();
71 ~TargetHolders();
75 namespace wmfemfhelper
77 /** helper class for graphic context
79 This class allows to hold a complete representation of classic
80 VCL OutputDevice state. This data is needed for correct
81 interpretation of the MetaFile action flow.
83 class PropertyHolder
85 private:
86 /// current transformation (aka MapMode)
87 basegfx::B2DHomMatrix maTransformation;
88 MapUnit maMapUnit;
90 /// current colors
91 basegfx::BColor maLineColor;
92 basegfx::BColor maFillColor;
93 basegfx::BColor maTextColor;
94 basegfx::BColor maTextFillColor;
95 basegfx::BColor maTextLineColor;
96 basegfx::BColor maOverlineColor;
98 /// clipping
99 basegfx::B2DPolyPolygon maClipPolyPolygon;
101 /// font, etc.
102 vcl::Font maFont;
103 RasterOp maRasterOp;
104 ComplexTextLayoutFlags mnLayoutMode;
105 LanguageType maLanguageType;
106 PushFlags mnPushFlags;
108 /// contains all active markers
109 bool mbLineColor : 1;
110 bool mbFillColor : 1;
111 bool mbTextColor : 1;
112 bool mbTextFillColor : 1;
113 bool mbTextLineColor : 1;
114 bool mbOverlineColor : 1;
115 bool mbClipPolyPolygonActive : 1;
117 public:
118 PropertyHolder();
120 /// read/write accesses
121 const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; }
122 void setTransformation(const basegfx::B2DHomMatrix& rNew) { if (rNew != maTransformation) maTransformation = rNew; }
124 MapUnit getMapUnit() const { return maMapUnit; }
125 void setMapUnit(MapUnit eNew) { if (eNew != maMapUnit) maMapUnit = eNew; }
127 const basegfx::BColor& getLineColor() const { return maLineColor; }
128 void setLineColor(const basegfx::BColor& rNew) { if (rNew != maLineColor) maLineColor = rNew; }
129 bool getLineColorActive() const { return mbLineColor; }
130 void setLineColorActive(bool bNew) { if (bNew != mbLineColor) mbLineColor = bNew; }
132 const basegfx::BColor& getFillColor() const { return maFillColor; }
133 void setFillColor(const basegfx::BColor& rNew) { if (rNew != maFillColor) maFillColor = rNew; }
134 bool getFillColorActive() const { return mbFillColor; }
135 void setFillColorActive(bool bNew) { if (bNew != mbFillColor) mbFillColor = bNew; }
137 const basegfx::BColor& getTextColor() const { return maTextColor; }
138 void setTextColor(const basegfx::BColor& rNew) { if (rNew != maTextColor) maTextColor = rNew; }
139 bool getTextColorActive() const { return mbTextColor; }
140 void setTextColorActive(bool bNew) { if (bNew != mbTextColor) mbTextColor = bNew; }
142 const basegfx::BColor& getTextFillColor() const { return maTextFillColor; }
143 void setTextFillColor(const basegfx::BColor& rNew) { if (rNew != maTextFillColor) maTextFillColor = rNew; }
144 bool getTextFillColorActive() const { return mbTextFillColor; }
145 void setTextFillColorActive(bool bNew) { if (bNew != mbTextFillColor) mbTextFillColor = bNew; }
147 const basegfx::BColor& getTextLineColor() const { return maTextLineColor; }
148 void setTextLineColor(const basegfx::BColor& rNew) { if (rNew != maTextLineColor) maTextLineColor = rNew; }
149 bool getTextLineColorActive() const { return mbTextLineColor; }
150 void setTextLineColorActive(bool bNew) { if (bNew != mbTextLineColor) mbTextLineColor = bNew; }
152 const basegfx::BColor& getOverlineColor() const { return maOverlineColor; }
153 void setOverlineColor(const basegfx::BColor& rNew) { if (rNew != maOverlineColor) maOverlineColor = rNew; }
154 bool getOverlineColorActive() const { return mbOverlineColor; }
155 void setOverlineColorActive(bool bNew) { if (bNew != mbOverlineColor) mbOverlineColor = bNew; }
157 const basegfx::B2DPolyPolygon& getClipPolyPolygon() const { return maClipPolyPolygon; }
158 void setClipPolyPolygon(const basegfx::B2DPolyPolygon& rNew) { if (rNew != maClipPolyPolygon) maClipPolyPolygon = rNew; }
159 bool getClipPolyPolygonActive() const { return mbClipPolyPolygonActive; }
160 void setClipPolyPolygonActive(bool bNew) { if (bNew != mbClipPolyPolygonActive) mbClipPolyPolygonActive = bNew; }
162 const vcl::Font& getFont() const { return maFont; }
163 void setFont(const vcl::Font& rFont) { if (rFont != maFont) maFont = rFont; }
165 const RasterOp& getRasterOp() const { return maRasterOp; }
166 void setRasterOp(const RasterOp& rRasterOp) { if (rRasterOp != maRasterOp) maRasterOp = rRasterOp; }
167 bool isRasterOpInvert() const { return (RasterOp::Xor == maRasterOp || RasterOp::Invert == maRasterOp); }
168 bool isRasterOpForceBlack() const { return RasterOp::N0 == maRasterOp; }
169 bool isRasterOpActive() const { return isRasterOpInvert() || isRasterOpForceBlack(); }
171 ComplexTextLayoutFlags getLayoutMode() const { return mnLayoutMode; }
172 void setLayoutMode(ComplexTextLayoutFlags nNew) { if (nNew != mnLayoutMode) mnLayoutMode = nNew; }
174 LanguageType getLanguageType() const { return maLanguageType; }
175 void setLanguageType(LanguageType aNew) { if (aNew != maLanguageType) maLanguageType = aNew; }
177 PushFlags getPushFlags() const { return mnPushFlags; }
178 void setPushFlags(PushFlags nNew) { if (nNew != mnPushFlags) mnPushFlags = nNew; }
180 bool getLineOrFillActive() const { return (mbLineColor || mbFillColor); }
184 namespace wmfemfhelper
186 /** stack for properties
188 This class builds a stack based on the PropertyHolder
189 class. It encapsulates the pointer/new/delete usage to
190 make it safe and implements the push/pop as needed by a
191 VCL Metafile interpreter. The critical part here are the
192 flag values VCL OutputDevice uses here; not all stuff is
193 pushed and thus needs to be copied at pop.
195 class PropertyHolders
197 private:
198 std::vector< PropertyHolder* > maPropertyHolders;
200 public:
201 PropertyHolders();
202 void PushDefault();
203 void Push(PushFlags nPushFlags);
204 void Pop();
205 PropertyHolder& Current();
206 ~PropertyHolders();
210 namespace wmfemfhelper
212 drawinglayer::primitive2d::Primitive2DContainer interpretMetafile(
213 const GDIMetaFile& rMetaFile,
214 const drawinglayer::geometry::ViewInformation2D& rViewInformation);
216 void HandleNewClipRegion(
217 const basegfx::B2DPolyPolygon& rClipPolyPolygon,
218 TargetHolders& rTargetHolders,
219 PropertyHolders& rPropertyHolders);
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */