1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <sal/config.h>
23 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
24 #include <vcl/font.hxx>
25 #include <rtl/ref.hxx>
26 #include <vcl/rendercontext/State.hxx>
27 #include <basegfx/matrix/b2dhommatrix.hxx>
28 #include <basegfx/polygon/b2dpolypolygon.hxx>
31 namespace drawinglayer::geometry
{ class ViewInformation2D
; }
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
46 drawinglayer::primitive2d::Primitive2DContainer aTargets
;
51 sal_uInt32
size() const;
52 void append(const rtl::Reference
<drawinglayer::primitive2d::BasePrimitive2D
> & pCandidate
)
54 append(pCandidate
.get());
56 void append(drawinglayer::primitive2d::Primitive2DContainer xCandidate
)
58 aTargets
.append(std::move(xCandidate
));
60 void append(drawinglayer::primitive2d::BasePrimitive2D
* pCandidate
);
61 drawinglayer::primitive2d::Primitive2DContainer
getPrimitive2DSequence(const PropertyHolder
& rPropertyHolder
);
64 /** Helper class which builds a stack on the TargetHolder class */
68 std::vector
< TargetHolder
* > maTargetHolders
;
72 sal_uInt32
size() const;
75 TargetHolder
& Current();
79 /** helper class for graphic context
81 This class allows to hold a complete representation of classic
82 VCL OutputDevice state. This data is needed for correct
83 interpretation of the MetaFile action flow.
88 /// current transformation (aka MapMode)
89 basegfx::B2DHomMatrix maTransformation
;
93 basegfx::BColor maLineColor
;
94 basegfx::BColor maFillColor
;
95 basegfx::BColor maTextColor
;
96 basegfx::BColor maTextFillColor
;
97 basegfx::BColor maTextLineColor
;
98 basegfx::BColor maOverlineColor
;
101 basegfx::B2DPolyPolygon maClipPolyPolygon
;
106 vcl::text::ComplexTextLayoutFlags mnLayoutMode
;
107 LanguageType maLanguageType
;
108 vcl::PushFlags mnPushFlags
;
110 /// contains all active markers
111 bool mbLineColor
: 1;
112 bool mbFillColor
: 1;
113 bool mbTextColor
: 1;
114 bool mbTextFillColor
: 1;
115 bool mbTextLineColor
: 1;
116 bool mbOverlineColor
: 1;
117 bool mbClipPolyPolygonActive
: 1;
122 /// read/write accesses
123 const basegfx::B2DHomMatrix
& getTransformation() const { return maTransformation
; }
124 void setTransformation(const basegfx::B2DHomMatrix
& rNew
) { if (rNew
!= maTransformation
) maTransformation
= rNew
; }
126 MapUnit
getMapUnit() const { return maMapUnit
; }
127 void setMapUnit(MapUnit eNew
) { if (eNew
!= maMapUnit
) maMapUnit
= eNew
; }
129 const basegfx::BColor
& getLineColor() const { return maLineColor
; }
130 void setLineColor(const basegfx::BColor
& rNew
) { if (rNew
!= maLineColor
) maLineColor
= rNew
; }
131 bool getLineColorActive() const { return mbLineColor
; }
132 void setLineColorActive(bool bNew
) { if (bNew
!= mbLineColor
) mbLineColor
= bNew
; }
134 const basegfx::BColor
& getFillColor() const { return maFillColor
; }
135 void setFillColor(const basegfx::BColor
& rNew
) { if (rNew
!= maFillColor
) maFillColor
= rNew
; }
136 bool getFillColorActive() const { return mbFillColor
; }
137 void setFillColorActive(bool bNew
) { if (bNew
!= mbFillColor
) mbFillColor
= bNew
; }
139 const basegfx::BColor
& getTextColor() const { return maTextColor
; }
140 void setTextColor(const basegfx::BColor
& rNew
) { if (rNew
!= maTextColor
) maTextColor
= rNew
; }
141 bool getTextColorActive() const { return mbTextColor
; }
142 void setTextColorActive(bool bNew
) { if (bNew
!= mbTextColor
) mbTextColor
= bNew
; }
144 const basegfx::BColor
& getTextFillColor() const { return maTextFillColor
; }
145 void setTextFillColor(const basegfx::BColor
& rNew
) { if (rNew
!= maTextFillColor
) maTextFillColor
= rNew
; }
146 bool getTextFillColorActive() const { return mbTextFillColor
; }
147 void setTextFillColorActive(bool bNew
) { if (bNew
!= mbTextFillColor
) mbTextFillColor
= bNew
; }
149 const basegfx::BColor
& getTextLineColor() const { return maTextLineColor
; }
150 void setTextLineColor(const basegfx::BColor
& rNew
) { if (rNew
!= maTextLineColor
) maTextLineColor
= rNew
; }
151 bool getTextLineColorActive() const { return mbTextLineColor
; }
152 void setTextLineColorActive(bool bNew
) { if (bNew
!= mbTextLineColor
) mbTextLineColor
= bNew
; }
154 const basegfx::BColor
& getOverlineColor() const { return maOverlineColor
; }
155 void setOverlineColor(const basegfx::BColor
& rNew
) { if (rNew
!= maOverlineColor
) maOverlineColor
= rNew
; }
156 bool getOverlineColorActive() const { return mbOverlineColor
; }
157 void setOverlineColorActive(bool bNew
) { if (bNew
!= mbOverlineColor
) mbOverlineColor
= bNew
; }
159 const basegfx::B2DPolyPolygon
& getClipPolyPolygon() const { return maClipPolyPolygon
; }
160 void setClipPolyPolygon(const basegfx::B2DPolyPolygon
& rNew
) { if (rNew
!= maClipPolyPolygon
) maClipPolyPolygon
= rNew
; }
161 bool getClipPolyPolygonActive() const { return mbClipPolyPolygonActive
; }
162 void setClipPolyPolygonActive(bool bNew
) { if (bNew
!= mbClipPolyPolygonActive
) mbClipPolyPolygonActive
= bNew
; }
164 const vcl::Font
& getFont() const { return maFont
; }
165 void setFont(const vcl::Font
& rFont
) { if (rFont
!= maFont
) maFont
= rFont
; }
167 const RasterOp
& getRasterOp() const { return maRasterOp
; }
168 void setRasterOp(const RasterOp
& rRasterOp
) { if (rRasterOp
!= maRasterOp
) maRasterOp
= rRasterOp
; }
169 bool isRasterOpInvert() const { return (RasterOp::Xor
== maRasterOp
|| RasterOp::Invert
== maRasterOp
); }
170 bool isRasterOpForceBlack() const { return RasterOp::N0
== maRasterOp
; }
171 bool isRasterOpActive() const { return isRasterOpInvert() || isRasterOpForceBlack(); }
173 vcl::text::ComplexTextLayoutFlags
getLayoutMode() const { return mnLayoutMode
; }
174 void setLayoutMode(vcl::text::ComplexTextLayoutFlags nNew
) { if (nNew
!= mnLayoutMode
) mnLayoutMode
= nNew
; }
176 LanguageType
getLanguageType() const { return maLanguageType
; }
177 void setLanguageType(LanguageType aNew
) { if (aNew
!= maLanguageType
) maLanguageType
= aNew
; }
179 vcl::PushFlags
getPushFlags() const { return mnPushFlags
; }
180 void setPushFlags(vcl::PushFlags nNew
) { if (nNew
!= mnPushFlags
) mnPushFlags
= nNew
; }
182 bool getLineOrFillActive() const { return (mbLineColor
|| mbFillColor
); }
185 /** stack for properties
187 This class builds a stack based on the PropertyHolder
188 class. It encapsulates the pointer/new/delete usage to
189 make it safe and implements the push/pop as needed by a
190 VCL Metafile interpreter. The critical part here are the
191 flag values VCL OutputDevice uses here; not all stuff is
192 pushed and thus needs to be copied at pop.
194 class PropertyHolders
197 std::vector
< PropertyHolder
* > maPropertyHolders
;
202 void Push(vcl::PushFlags nPushFlags
);
204 PropertyHolder
& Current();
208 drawinglayer::primitive2d::Primitive2DContainer
interpretMetafile(
209 const GDIMetaFile
& rMetaFile
,
210 const drawinglayer::geometry::ViewInformation2D
& rViewInformation
);
212 void HandleNewClipRegion(
213 const basegfx::B2DPolyPolygon
& rClipPolyPolygon
,
214 TargetHolders
& rTargetHolders
,
215 PropertyHolders
& rPropertyHolders
);
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */