tdf#154703 docx export framePr: export xAlign/yAlign
[LibreOffice.git] / drawinglayer / inc / wmfemfhelper.hxx
blobf085065c1ea63fd5a40aa7427421d5f12faab25b
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/rendercontext/State.hxx>
27 #include <basegfx/matrix/b2dhommatrix.hxx>
28 #include <basegfx/polygon/b2dpolypolygon.hxx>
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 drawinglayer::primitive2d::Primitive2DContainer aTargets;
48 public:
49 TargetHolder();
50 ~TargetHolder();
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 */
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();
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.
85 class PropertyHolder
87 private:
88 /// current transformation (aka MapMode)
89 basegfx::B2DHomMatrix maTransformation;
90 MapUnit maMapUnit;
92 /// current colors
93 basegfx::BColor maLineColor;
94 basegfx::BColor maFillColor;
95 basegfx::BColor maTextColor;
96 basegfx::BColor maTextFillColor;
97 basegfx::BColor maTextLineColor;
98 basegfx::BColor maOverlineColor;
100 /// clipping
101 basegfx::B2DPolyPolygon maClipPolyPolygon;
103 /// font, etc.
104 vcl::Font maFont;
105 RasterOp maRasterOp;
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;
119 public:
120 PropertyHolder();
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
196 private:
197 std::vector< PropertyHolder* > maPropertyHolders;
199 public:
200 PropertyHolders();
201 void PushDefault();
202 void Push(vcl::PushFlags nPushFlags);
203 void Pop();
204 PropertyHolder& Current();
205 ~PropertyHolders();
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: */