Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <drawinglayer/processor2d/textaspolygonextractor2d.hxx>
30 : : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
31 : : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
32 : : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
33 : : #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
34 : : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
35 : :
36 : : //////////////////////////////////////////////////////////////////////////////
37 : :
38 : : namespace drawinglayer
39 : : {
40 : : namespace processor2d
41 : : {
42 : 144 : void TextAsPolygonExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
43 : : {
44 [ - - + - : 144 : switch(rCandidate.getPrimitive2DID())
+ - - +
+ ]
45 : : {
46 : : case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D :
47 : : {
48 : : // TextDecoratedPortionPrimitive2D can produce the following primitives
49 : : // when being decomposed:
50 : : //
51 : : // - TextSimplePortionPrimitive2D
52 : : // - PolygonWavePrimitive2D
53 : : // - PolygonStrokePrimitive2D
54 : : // - PolygonStrokePrimitive2D
55 : : // - PolyPolygonColorPrimitive2D
56 : : // - PolyPolygonHairlinePrimitive2D
57 : : // - PolygonHairlinePrimitive2D
58 : : // - ShadowPrimitive2D
59 : : // - ModifiedColorPrimitive2D
60 : : // - TransformPrimitive2D
61 : : // - TextEffectPrimitive2D
62 : : // - ModifiedColorPrimitive2D
63 : : // - TransformPrimitive2D
64 : : // - GroupPrimitive2D
65 : :
66 : : // encapsulate with flag and use decomposition
67 : 0 : mnInText++;
68 [ # # ]: 0 : process(rCandidate.get2DDecomposition(getViewInformation2D()));
69 : 0 : mnInText--;
70 : :
71 : 0 : break;
72 : : }
73 : : case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D :
74 : : {
75 : : // TextSimplePortionPrimitive2D can produce the following primitives
76 : : // when being decomposed:
77 : : //
78 : : // - PolyPolygonColorPrimitive2D
79 : : // - TextEffectPrimitive2D
80 : : // - ModifiedColorPrimitive2D
81 : : // - TransformPrimitive2D
82 : : // - GroupPrimitive2D
83 : :
84 : : // encapsulate with flag and use decomposition
85 : 0 : mnInText++;
86 [ # # ]: 0 : process(rCandidate.get2DDecomposition(getViewInformation2D()));
87 : 0 : mnInText--;
88 : :
89 : 0 : break;
90 : : }
91 : :
92 : : // as can be seen from the TextSimplePortionPrimitive2D and the
93 : : // TextDecoratedPortionPrimitive2D, inside of the mnInText marks
94 : : // the following primitives can occurr containing geometry data
95 : : // from text decomposition:
96 : : //
97 : : // - PolyPolygonColorPrimitive2D
98 : : // - PolygonHairlinePrimitive2D
99 : : // - PolyPolygonHairlinePrimitive2D (for convenience)
100 : : //
101 : : case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
102 : : {
103 [ - + ]: 26 : if(mnInText)
104 : : {
105 : 0 : const primitive2d::PolyPolygonColorPrimitive2D& rPoPoCoCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate));
106 [ # # ]: 0 : basegfx::B2DPolyPolygon aPolyPolygon(rPoPoCoCandidate.getB2DPolyPolygon());
107 : :
108 [ # # ][ # # ]: 0 : if(aPolyPolygon.count())
109 : : {
110 : : // transform the PolyPolygon
111 [ # # ][ # # ]: 0 : aPolyPolygon.transform(getViewInformation2D().getObjectToViewTransformation());
112 : :
113 : : // get evtl. corrected color
114 [ # # ]: 0 : const basegfx::BColor aColor(maBColorModifierStack.getModifiedColor(rPoPoCoCandidate.getBColor()));
115 : :
116 : : // add to result vector
117 [ # # ][ # # ]: 0 : maTarget.push_back(TextAsPolygonDataNode(aPolyPolygon, aColor, true));
[ # # ]
118 [ # # ]: 0 : }
119 : : }
120 : :
121 : 26 : break;
122 : : }
123 : : case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
124 : : {
125 [ # # ]: 0 : if(mnInText)
126 : : {
127 : 0 : const primitive2d::PolygonHairlinePrimitive2D& rPoHaCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate));
128 [ # # ]: 0 : basegfx::B2DPolygon aPolygon(rPoHaCandidate.getB2DPolygon());
129 : :
130 [ # # ][ # # ]: 0 : if(aPolygon.count())
131 : : {
132 : : // transform the Polygon
133 [ # # ][ # # ]: 0 : aPolygon.transform(getViewInformation2D().getObjectToViewTransformation());
134 : :
135 : : // get evtl. corrected color
136 [ # # ]: 0 : const basegfx::BColor aColor(maBColorModifierStack.getModifiedColor(rPoHaCandidate.getBColor()));
137 : :
138 : : // add to result vector
139 [ # # ][ # # ]: 0 : maTarget.push_back(TextAsPolygonDataNode(basegfx::B2DPolyPolygon(aPolygon), aColor, false));
[ # # ][ # # ]
[ # # ]
140 [ # # ]: 0 : }
141 : : }
142 : :
143 : 0 : break;
144 : : }
145 : : case PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D :
146 : : {
147 [ - + ]: 38 : if(mnInText)
148 : : {
149 : 0 : const primitive2d::PolyPolygonHairlinePrimitive2D& rPoPoHaCandidate(static_cast< const primitive2d::PolyPolygonHairlinePrimitive2D& >(rCandidate));
150 [ # # ]: 0 : basegfx::B2DPolyPolygon aPolyPolygon(rPoPoHaCandidate.getB2DPolyPolygon());
151 : :
152 [ # # ][ # # ]: 0 : if(aPolyPolygon.count())
153 : : {
154 : : // transform the Polygon
155 [ # # ][ # # ]: 0 : aPolyPolygon.transform(getViewInformation2D().getObjectToViewTransformation());
156 : :
157 : : // get evtl. corrected color
158 [ # # ]: 0 : const basegfx::BColor aColor(maBColorModifierStack.getModifiedColor(rPoPoHaCandidate.getBColor()));
159 : :
160 : : // add to result vector
161 [ # # ][ # # ]: 0 : maTarget.push_back(TextAsPolygonDataNode(aPolyPolygon, aColor, false));
[ # # ]
162 [ # # ]: 0 : }
163 : : }
164 : :
165 : 38 : break;
166 : : }
167 : :
168 : : // usage of color modification stack is needed
169 : : case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D :
170 : : {
171 : 0 : const primitive2d::ModifiedColorPrimitive2D& rModifiedColorCandidate(static_cast< const primitive2d::ModifiedColorPrimitive2D& >(rCandidate));
172 : :
173 [ # # ]: 0 : if(rModifiedColorCandidate.getChildren().hasElements())
174 : : {
175 : 0 : maBColorModifierStack.push(rModifiedColorCandidate.getColorModifier());
176 : 0 : process(rModifiedColorCandidate.getChildren());
177 : 0 : maBColorModifierStack.pop();
178 : : }
179 : :
180 : 0 : break;
181 : : }
182 : :
183 : : // usage of transformation stack is needed
184 : : case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
185 : : {
186 : : // remember current transformation and ViewInformation
187 : 0 : const primitive2d::TransformPrimitive2D& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
188 [ # # ]: 0 : const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
189 : :
190 : : // create new transformations for CurrentTransformation and for local ViewInformation2D
191 : : const geometry::ViewInformation2D aViewInformation2D(
192 [ # # ]: 0 : getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
193 [ # # ]: 0 : getViewInformation2D().getViewTransformation(),
194 [ # # ]: 0 : getViewInformation2D().getViewport(),
195 [ # # ]: 0 : getViewInformation2D().getVisualizedPage(),
196 : 0 : getViewInformation2D().getViewTime(),
197 [ # # # # ]: 0 : getViewInformation2D().getExtendedInformationSequence());
[ # # ][ # # ]
[ # # ]
198 [ # # ]: 0 : updateViewInformation(aViewInformation2D);
199 : :
200 : : // proccess content
201 [ # # ]: 0 : process(rTransformCandidate.getChildren());
202 : :
203 : : // restore transformations
204 [ # # ]: 0 : updateViewInformation(aLastViewInformation2D);
205 : :
206 [ # # ][ # # ]: 0 : break;
207 : : }
208 : :
209 : : // ignorable primitives
210 : : case PRIMITIVE2D_ID_SCENEPRIMITIVE2D :
211 : : case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D :
212 : : case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D :
213 : : case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D :
214 : : case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D :
215 : : case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D :
216 : : case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
217 : : case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
218 : : {
219 : 2 : break;
220 : : }
221 : :
222 : : default :
223 : : {
224 : : // process recursively
225 [ + - ]: 78 : process(rCandidate.get2DDecomposition(getViewInformation2D()));
226 : 78 : break;
227 : : }
228 : : }
229 : 144 : }
230 : :
231 : 40 : TextAsPolygonExtractor2D::TextAsPolygonExtractor2D(const geometry::ViewInformation2D& rViewInformation)
232 : : : BaseProcessor2D(rViewInformation),
233 : : maTarget(),
234 : : maBColorModifierStack(),
235 [ + - ][ + - ]: 40 : mnInText(0)
236 : : {
237 : 40 : }
238 : :
239 : 40 : TextAsPolygonExtractor2D::~TextAsPolygonExtractor2D()
240 : : {
241 [ - + ]: 40 : }
242 : : } // end of namespace processor2d
243 : : } // end of namespace drawinglayer
244 : :
245 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|