/src/libreoffice/drawinglayer/inc/wmfemfhelper.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
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> |
29 | | |
30 | | // predefines |
31 | | namespace drawinglayer::geometry { class ViewInformation2D; } |
32 | | class GDIMetaFile; |
33 | | namespace wmfemfhelper { class PropertyHolder; } |
34 | | |
35 | | namespace wmfemfhelper |
36 | | { |
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. |
42 | | */ |
43 | | class TargetHolder |
44 | | { |
45 | | private: |
46 | | drawinglayer::primitive2d::Primitive2DContainer aTargets; |
47 | | |
48 | | public: |
49 | | TargetHolder(); |
50 | | ~TargetHolder(); |
51 | | sal_uInt32 size() const; |
52 | | void append(const rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> & pCandidate) |
53 | 14.7k | { |
54 | 14.7k | append(pCandidate.get()); |
55 | 14.7k | } |
56 | | void append(drawinglayer::primitive2d::Primitive2DContainer xCandidate) |
57 | 0 | { |
58 | 0 | aTargets.append(std::move(xCandidate)); |
59 | 0 | } |
60 | | void append(drawinglayer::primitive2d::BasePrimitive2D* pCandidate); |
61 | | drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequence(const PropertyHolder& rPropertyHolder); |
62 | | }; |
63 | | |
64 | | /** Helper class which builds a stack on the TargetHolder class */ |
65 | | class TargetHolders |
66 | | { |
67 | | private: |
68 | | std::vector< TargetHolder* > maTargetHolders; |
69 | | |
70 | | public: |
71 | | TargetHolders(); |
72 | | sal_uInt32 size() const; |
73 | | void Push(); |
74 | | void Pop(); |
75 | | TargetHolder& Current(); |
76 | | ~TargetHolders(); |
77 | | }; |
78 | | |
79 | | /** helper class for graphic context |
80 | | |
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. |
84 | | */ |
85 | | class PropertyHolder |
86 | | { |
87 | | private: |
88 | | /// current transformation (aka MapMode) |
89 | | basegfx::B2DHomMatrix maTransformation; |
90 | | MapUnit maMapUnit; |
91 | | |
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; |
99 | | |
100 | | /// clipping |
101 | | basegfx::B2DPolyPolygon maClipPolyPolygon; |
102 | | |
103 | | /// font, etc. |
104 | | vcl::Font maFont; |
105 | | RasterOp maRasterOp; |
106 | | vcl::text::ComplexTextLayoutFlags mnLayoutMode; |
107 | | LanguageType maLanguageType; |
108 | | vcl::PushFlags mnPushFlags; |
109 | | |
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; |
118 | | |
119 | | public: |
120 | | PropertyHolder(); |
121 | | |
122 | | /// read/write accesses |
123 | 393k | const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } |
124 | 15.8k | void setTransformation(const basegfx::B2DHomMatrix& rNew) { if (rNew != maTransformation) maTransformation = rNew; } |
125 | | |
126 | 14.1k | MapUnit getMapUnit() const { return maMapUnit; } |
127 | 35.6k | void setMapUnit(MapUnit eNew) { if (eNew != maMapUnit) maMapUnit = eNew; } |
128 | | |
129 | 333k | const basegfx::BColor& getLineColor() const { return maLineColor; } |
130 | 19.6k | void setLineColor(const basegfx::BColor& rNew) { if (rNew != maLineColor) maLineColor = rNew; } |
131 | 365k | bool getLineColorActive() const { return mbLineColor; } |
132 | 31.0k | void setLineColorActive(bool bNew) { if (bNew != mbLineColor) mbLineColor = bNew; } |
133 | | |
134 | 42.1k | const basegfx::BColor& getFillColor() const { return maFillColor; } |
135 | 19.1k | void setFillColor(const basegfx::BColor& rNew) { if (rNew != maFillColor) maFillColor = rNew; } |
136 | 43.4k | bool getFillColorActive() const { return mbFillColor; } |
137 | 20.8k | void setFillColorActive(bool bNew) { if (bNew != mbFillColor) mbFillColor = bNew; } |
138 | | |
139 | 27.7k | const basegfx::BColor& getTextColor() const { return maTextColor; } |
140 | 29.3k | void setTextColor(const basegfx::BColor& rNew) { if (rNew != maTextColor) maTextColor = rNew; } |
141 | 27.7k | bool getTextColorActive() const { return mbTextColor; } |
142 | 21.8k | void setTextColorActive(bool bNew) { if (bNew != mbTextColor) mbTextColor = bNew; } |
143 | | |
144 | 21.5k | const basegfx::BColor& getTextFillColor() const { return maTextFillColor; } |
145 | 28.5k | void setTextFillColor(const basegfx::BColor& rNew) { if (rNew != maTextFillColor) maTextFillColor = rNew; } |
146 | 27.7k | bool getTextFillColorActive() const { return mbTextFillColor; } |
147 | 31.2k | void setTextFillColorActive(bool bNew) { if (bNew != mbTextFillColor) mbTextFillColor = bNew; } |
148 | | |
149 | 14.0k | const basegfx::BColor& getTextLineColor() const { return maTextLineColor; } |
150 | 14.0k | void setTextLineColor(const basegfx::BColor& rNew) { if (rNew != maTextLineColor) maTextLineColor = rNew; } |
151 | 23.2k | bool getTextLineColorActive() const { return mbTextLineColor; } |
152 | 14.0k | void setTextLineColorActive(bool bNew) { if (bNew != mbTextLineColor) mbTextLineColor = bNew; } |
153 | | |
154 | 14.0k | const basegfx::BColor& getOverlineColor() const { return maOverlineColor; } |
155 | 14.0k | void setOverlineColor(const basegfx::BColor& rNew) { if (rNew != maOverlineColor) maOverlineColor = rNew; } |
156 | 23.2k | bool getOverlineColorActive() const { return mbOverlineColor; } |
157 | 14.0k | void setOverlineColorActive(bool bNew) { if (bNew != mbOverlineColor) mbOverlineColor = bNew; } |
158 | | |
159 | 4.93k | const basegfx::B2DPolyPolygon& getClipPolyPolygon() const { return maClipPolyPolygon; } |
160 | 3.70k | void setClipPolyPolygon(const basegfx::B2DPolyPolygon& rNew) { if (rNew != maClipPolyPolygon) maClipPolyPolygon = rNew; } |
161 | 47.7k | bool getClipPolyPolygonActive() const { return mbClipPolyPolygonActive; } |
162 | 4.90k | void setClipPolyPolygonActive(bool bNew) { if (bNew != mbClipPolyPolygonActive) mbClipPolyPolygonActive = bNew; } |
163 | | |
164 | 79.1k | const vcl::Font& getFont() const { return maFont; } |
165 | 21.9k | void setFont(const vcl::Font& rFont) { if (rFont != maFont) maFont = rFont; } |
166 | | |
167 | 14.0k | const RasterOp& getRasterOp() const { return maRasterOp; } |
168 | 87.8k | void setRasterOp(const RasterOp& rRasterOp) { if (rRasterOp != maRasterOp) maRasterOp = rRasterOp; } |
169 | 147k | bool isRasterOpInvert() const { return (RasterOp::Xor == maRasterOp || RasterOp::Invert == maRasterOp); } |
170 | 130k | bool isRasterOpForceBlack() const { return RasterOp::N0 == maRasterOp; } |
171 | 147k | bool isRasterOpActive() const { return isRasterOpInvert() || isRasterOpForceBlack(); } |
172 | | |
173 | 41.3k | vcl::text::ComplexTextLayoutFlags getLayoutMode() const { return mnLayoutMode; } |
174 | 15.6k | void setLayoutMode(vcl::text::ComplexTextLayoutFlags nNew) { if (nNew != mnLayoutMode) mnLayoutMode = nNew; } |
175 | | |
176 | 27.7k | LanguageType getLanguageType() const { return maLanguageType; } |
177 | 14.0k | void setLanguageType(LanguageType aNew) { if (aNew != maLanguageType) maLanguageType = aNew; } |
178 | | |
179 | 42.2k | vcl::PushFlags getPushFlags() const { return mnPushFlags; } |
180 | 14.0k | void setPushFlags(vcl::PushFlags nNew) { if (nNew != mnPushFlags) mnPushFlags = nNew; } |
181 | | |
182 | 35.0k | bool getLineOrFillActive() const { return (mbLineColor || mbFillColor); } |
183 | | }; |
184 | | |
185 | | /** stack for properties |
186 | | |
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. |
193 | | */ |
194 | | class PropertyHolders |
195 | | { |
196 | | private: |
197 | | std::vector< PropertyHolder* > maPropertyHolders; |
198 | | |
199 | | public: |
200 | | PropertyHolders(); |
201 | | void PushDefault(); |
202 | | void Push(vcl::PushFlags nPushFlags); |
203 | | void Pop(); |
204 | | PropertyHolder& Current(); |
205 | | ~PropertyHolders(); |
206 | | }; |
207 | | |
208 | | drawinglayer::primitive2d::Primitive2DContainer interpretMetafile( |
209 | | const GDIMetaFile& rMetaFile, |
210 | | const drawinglayer::geometry::ViewInformation2D& rViewInformation); |
211 | | |
212 | | void HandleNewClipRegion( |
213 | | const basegfx::B2DPolyPolygon& rClipPolyPolygon, |
214 | | TargetHolders& rTargetHolders, |
215 | | PropertyHolders& rPropertyHolders); |
216 | | } |
217 | | |
218 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |