fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / drawinglayer / source / processor2d / textaspolygonextractor2d.cxx
blobb620c3c654f88a1863010d6ef683db5199506cd4
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 #include <drawinglayer/processor2d/textaspolygonextractor2d.hxx>
21 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
22 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
23 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
24 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
25 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
27 //////////////////////////////////////////////////////////////////////////////
29 namespace drawinglayer
31 namespace processor2d
33 void TextAsPolygonExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
35 switch(rCandidate.getPrimitive2DID())
37 case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D :
39 // TextDecoratedPortionPrimitive2D can produce the following primitives
40 // when being decomposed:
42 // - TextSimplePortionPrimitive2D
43 // - PolygonWavePrimitive2D
44 // - PolygonStrokePrimitive2D
45 // - PolygonStrokePrimitive2D
46 // - PolyPolygonColorPrimitive2D
47 // - PolyPolygonHairlinePrimitive2D
48 // - PolygonHairlinePrimitive2D
49 // - ShadowPrimitive2D
50 // - ModifiedColorPrimitive2D
51 // - TransformPrimitive2D
52 // - TextEffectPrimitive2D
53 // - ModifiedColorPrimitive2D
54 // - TransformPrimitive2D
55 // - GroupPrimitive2D
57 // encapsulate with flag and use decomposition
58 mnInText++;
59 process(rCandidate.get2DDecomposition(getViewInformation2D()));
60 mnInText--;
62 break;
64 case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D :
66 // TextSimplePortionPrimitive2D can produce the following primitives
67 // when being decomposed:
69 // - PolyPolygonColorPrimitive2D
70 // - TextEffectPrimitive2D
71 // - ModifiedColorPrimitive2D
72 // - TransformPrimitive2D
73 // - GroupPrimitive2D
75 // encapsulate with flag and use decomposition
76 mnInText++;
77 process(rCandidate.get2DDecomposition(getViewInformation2D()));
78 mnInText--;
80 break;
83 // as can be seen from the TextSimplePortionPrimitive2D and the
84 // TextDecoratedPortionPrimitive2D, inside of the mnInText marks
85 // the following primitives can occurr containing geometry data
86 // from text decomposition:
88 // - PolyPolygonColorPrimitive2D
89 // - PolygonHairlinePrimitive2D
90 // - PolyPolygonHairlinePrimitive2D (for convenience)
92 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
94 if(mnInText)
96 const primitive2d::PolyPolygonColorPrimitive2D& rPoPoCoCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate));
97 basegfx::B2DPolyPolygon aPolyPolygon(rPoPoCoCandidate.getB2DPolyPolygon());
99 if(aPolyPolygon.count())
101 // transform the PolyPolygon
102 aPolyPolygon.transform(getViewInformation2D().getObjectToViewTransformation());
104 // get evtl. corrected color
105 const basegfx::BColor aColor(maBColorModifierStack.getModifiedColor(rPoPoCoCandidate.getBColor()));
107 // add to result vector
108 maTarget.push_back(TextAsPolygonDataNode(aPolyPolygon, aColor, true));
112 break;
114 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
116 if(mnInText)
118 const primitive2d::PolygonHairlinePrimitive2D& rPoHaCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate));
119 basegfx::B2DPolygon aPolygon(rPoHaCandidate.getB2DPolygon());
121 if(aPolygon.count())
123 // transform the Polygon
124 aPolygon.transform(getViewInformation2D().getObjectToViewTransformation());
126 // get evtl. corrected color
127 const basegfx::BColor aColor(maBColorModifierStack.getModifiedColor(rPoHaCandidate.getBColor()));
129 // add to result vector
130 maTarget.push_back(TextAsPolygonDataNode(basegfx::B2DPolyPolygon(aPolygon), aColor, false));
134 break;
136 case PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D :
138 if(mnInText)
140 const primitive2d::PolyPolygonHairlinePrimitive2D& rPoPoHaCandidate(static_cast< const primitive2d::PolyPolygonHairlinePrimitive2D& >(rCandidate));
141 basegfx::B2DPolyPolygon aPolyPolygon(rPoPoHaCandidate.getB2DPolyPolygon());
143 if(aPolyPolygon.count())
145 // transform the Polygon
146 aPolyPolygon.transform(getViewInformation2D().getObjectToViewTransformation());
148 // get evtl. corrected color
149 const basegfx::BColor aColor(maBColorModifierStack.getModifiedColor(rPoPoHaCandidate.getBColor()));
151 // add to result vector
152 maTarget.push_back(TextAsPolygonDataNode(aPolyPolygon, aColor, false));
156 break;
159 // usage of color modification stack is needed
160 case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D :
162 const primitive2d::ModifiedColorPrimitive2D& rModifiedColorCandidate(static_cast< const primitive2d::ModifiedColorPrimitive2D& >(rCandidate));
164 if(rModifiedColorCandidate.getChildren().hasElements())
166 maBColorModifierStack.push(rModifiedColorCandidate.getColorModifier());
167 process(rModifiedColorCandidate.getChildren());
168 maBColorModifierStack.pop();
171 break;
174 // usage of transformation stack is needed
175 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
177 // remember current transformation and ViewInformation
178 const primitive2d::TransformPrimitive2D& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
179 const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
181 // create new transformations for CurrentTransformation and for local ViewInformation2D
182 const geometry::ViewInformation2D aViewInformation2D(
183 getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
184 getViewInformation2D().getViewTransformation(),
185 getViewInformation2D().getViewport(),
186 getViewInformation2D().getVisualizedPage(),
187 getViewInformation2D().getViewTime(),
188 getViewInformation2D().getExtendedInformationSequence());
189 updateViewInformation(aViewInformation2D);
191 // proccess content
192 process(rTransformCandidate.getChildren());
194 // restore transformations
195 updateViewInformation(aLastViewInformation2D);
197 break;
200 // ignorable primitives
201 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D :
202 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D :
203 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D :
204 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D :
205 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D :
206 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
207 case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
209 break;
212 default :
214 // process recursively
215 process(rCandidate.get2DDecomposition(getViewInformation2D()));
216 break;
221 TextAsPolygonExtractor2D::TextAsPolygonExtractor2D(const geometry::ViewInformation2D& rViewInformation)
222 : BaseProcessor2D(rViewInformation),
223 maTarget(),
224 maBColorModifierStack(),
225 mnInText(0)
229 TextAsPolygonExtractor2D::~TextAsPolygonExtractor2D()
232 } // end of namespace processor2d
233 } // end of namespace drawinglayer
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */