[en-US] Added 13 words to autocorrect
[LibreOffice.git] / drawinglayer / inc / wmfemfhelper.hxx
blob6c58dac68f7ebdb94b57b5b8380e3b15c7acbd56
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 <rtl/ref.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::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< rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> > aTargets;
49 public:
50 TargetHolder();
51 ~TargetHolder();
52 sal_uInt32 size() const;
53 void append(const rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> & pCandidate)
55 append(pCandidate.get());
57 void append(drawinglayer::primitive2d::BasePrimitive2D* pCandidate);
58 drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequence(const PropertyHolder& rPropertyHolder);
62 namespace wmfemfhelper
64 /** Helper class which builds a stack on the TargetHolder class */
65 class TargetHolders
67 private:
68 std::vector< TargetHolder* > maTargetHolders;
70 public:
71 TargetHolders();
72 sal_uInt32 size() const;
73 void Push();
74 void Pop();
75 TargetHolder& Current();
76 ~TargetHolders();
80 namespace wmfemfhelper
82 /** helper class for graphic context
84 This class allows to hold a complete representation of classic
85 VCL OutputDevice state. This data is needed for correct
86 interpretation of the MetaFile action flow.
88 class PropertyHolder
90 private:
91 /// current transformation (aka MapMode)
92 basegfx::B2DHomMatrix maTransformation;
93 MapUnit maMapUnit;
95 /// current colors
96 basegfx::BColor maLineColor;
97 basegfx::BColor maFillColor;
98 basegfx::BColor maTextColor;
99 basegfx::BColor maTextFillColor;
100 basegfx::BColor maTextLineColor;
101 basegfx::BColor maOverlineColor;
103 /// clipping
104 basegfx::B2DPolyPolygon maClipPolyPolygon;
106 /// font, etc.
107 vcl::Font maFont;
108 RasterOp maRasterOp;
109 ComplexTextLayoutFlags mnLayoutMode;
110 LanguageType maLanguageType;
111 PushFlags mnPushFlags;
113 /// contains all active markers
114 bool mbLineColor : 1;
115 bool mbFillColor : 1;
116 bool mbTextColor : 1;
117 bool mbTextFillColor : 1;
118 bool mbTextLineColor : 1;
119 bool mbOverlineColor : 1;
120 bool mbClipPolyPolygonActive : 1;
122 public:
123 PropertyHolder();
125 /// read/write accesses
126 const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; }
127 void setTransformation(const basegfx::B2DHomMatrix& rNew) { if (rNew != maTransformation) maTransformation = rNew; }
129 MapUnit getMapUnit() const { return maMapUnit; }
130 void setMapUnit(MapUnit eNew) { if (eNew != maMapUnit) maMapUnit = eNew; }
132 const basegfx::BColor& getLineColor() const { return maLineColor; }
133 void setLineColor(const basegfx::BColor& rNew) { if (rNew != maLineColor) maLineColor = rNew; }
134 bool getLineColorActive() const { return mbLineColor; }
135 void setLineColorActive(bool bNew) { if (bNew != mbLineColor) mbLineColor = bNew; }
137 const basegfx::BColor& getFillColor() const { return maFillColor; }
138 void setFillColor(const basegfx::BColor& rNew) { if (rNew != maFillColor) maFillColor = rNew; }
139 bool getFillColorActive() const { return mbFillColor; }
140 void setFillColorActive(bool bNew) { if (bNew != mbFillColor) mbFillColor = bNew; }
142 const basegfx::BColor& getTextColor() const { return maTextColor; }
143 void setTextColor(const basegfx::BColor& rNew) { if (rNew != maTextColor) maTextColor = rNew; }
144 bool getTextColorActive() const { return mbTextColor; }
145 void setTextColorActive(bool bNew) { if (bNew != mbTextColor) mbTextColor = bNew; }
147 const basegfx::BColor& getTextFillColor() const { return maTextFillColor; }
148 void setTextFillColor(const basegfx::BColor& rNew) { if (rNew != maTextFillColor) maTextFillColor = rNew; }
149 bool getTextFillColorActive() const { return mbTextFillColor; }
150 void setTextFillColorActive(bool bNew) { if (bNew != mbTextFillColor) mbTextFillColor = bNew; }
152 const basegfx::BColor& getTextLineColor() const { return maTextLineColor; }
153 void setTextLineColor(const basegfx::BColor& rNew) { if (rNew != maTextLineColor) maTextLineColor = rNew; }
154 bool getTextLineColorActive() const { return mbTextLineColor; }
155 void setTextLineColorActive(bool bNew) { if (bNew != mbTextLineColor) mbTextLineColor = bNew; }
157 const basegfx::BColor& getOverlineColor() const { return maOverlineColor; }
158 void setOverlineColor(const basegfx::BColor& rNew) { if (rNew != maOverlineColor) maOverlineColor = rNew; }
159 bool getOverlineColorActive() const { return mbOverlineColor; }
160 void setOverlineColorActive(bool bNew) { if (bNew != mbOverlineColor) mbOverlineColor = bNew; }
162 const basegfx::B2DPolyPolygon& getClipPolyPolygon() const { return maClipPolyPolygon; }
163 void setClipPolyPolygon(const basegfx::B2DPolyPolygon& rNew) { if (rNew != maClipPolyPolygon) maClipPolyPolygon = rNew; }
164 bool getClipPolyPolygonActive() const { return mbClipPolyPolygonActive; }
165 void setClipPolyPolygonActive(bool bNew) { if (bNew != mbClipPolyPolygonActive) mbClipPolyPolygonActive = bNew; }
167 const vcl::Font& getFont() const { return maFont; }
168 void setFont(const vcl::Font& rFont) { if (rFont != maFont) maFont = rFont; }
170 const RasterOp& getRasterOp() const { return maRasterOp; }
171 void setRasterOp(const RasterOp& rRasterOp) { if (rRasterOp != maRasterOp) maRasterOp = rRasterOp; }
172 bool isRasterOpInvert() const { return (RasterOp::Xor == maRasterOp || RasterOp::Invert == maRasterOp); }
173 bool isRasterOpForceBlack() const { return RasterOp::N0 == maRasterOp; }
174 bool isRasterOpActive() const { return isRasterOpInvert() || isRasterOpForceBlack(); }
176 ComplexTextLayoutFlags getLayoutMode() const { return mnLayoutMode; }
177 void setLayoutMode(ComplexTextLayoutFlags nNew) { if (nNew != mnLayoutMode) mnLayoutMode = nNew; }
179 LanguageType getLanguageType() const { return maLanguageType; }
180 void setLanguageType(LanguageType aNew) { if (aNew != maLanguageType) maLanguageType = aNew; }
182 PushFlags getPushFlags() const { return mnPushFlags; }
183 void setPushFlags(PushFlags nNew) { if (nNew != mnPushFlags) mnPushFlags = nNew; }
185 bool getLineOrFillActive() const { return (mbLineColor || mbFillColor); }
189 namespace wmfemfhelper
191 /** stack for properties
193 This class builds a stack based on the PropertyHolder
194 class. It encapsulates the pointer/new/delete usage to
195 make it safe and implements the push/pop as needed by a
196 VCL Metafile interpreter. The critical part here are the
197 flag values VCL OutputDevice uses here; not all stuff is
198 pushed and thus needs to be copied at pop.
200 class PropertyHolders
202 private:
203 std::vector< PropertyHolder* > maPropertyHolders;
205 public:
206 PropertyHolders();
207 void PushDefault();
208 void Push(PushFlags nPushFlags);
209 void Pop();
210 PropertyHolder& Current();
211 ~PropertyHolders();
215 namespace wmfemfhelper
217 drawinglayer::primitive2d::Primitive2DContainer interpretMetafile(
218 const GDIMetaFile& rMetaFile,
219 const drawinglayer::geometry::ViewInformation2D& rViewInformation);
221 void HandleNewClipRegion(
222 const basegfx::B2DPolyPolygon& rClipPolyPolygon,
223 TargetHolders& rTargetHolders,
224 PropertyHolders& rPropertyHolders);
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */