Update ooo320-m1
[ooovba.git] / drawinglayer / source / processor2d / textaspolygonextractor2d.cxx
blob2ca8f3ff384ae71eeed8ab850445675180cc9a3d
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: contourextractor2d.cxx,v $
7 * $Revision: 1.6 $
9 * last change: $Author: aw $ $Date: 2008-06-24 15:31:08 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/processor2d/textaspolygonextractor2d.hxx>
40 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
41 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
42 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
43 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
44 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
46 //////////////////////////////////////////////////////////////////////////////
48 namespace drawinglayer
50 namespace processor2d
52 void TextAsPolygonExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
54 switch(rCandidate.getPrimitiveID())
56 case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D :
58 // TextDecoratedPortionPrimitive2D can produce the following primitives
59 // when being decomposed:
61 // - TextSimplePortionPrimitive2D
62 // - PolygonWavePrimitive2D
63 // - PolygonStrokePrimitive2D
64 // - PolygonStrokePrimitive2D
65 // - PolyPolygonColorPrimitive2D
66 // - PolyPolygonHairlinePrimitive2D
67 // - PolygonHairlinePrimitive2D
68 // - ShadowPrimitive2D
69 // - ModifiedColorPrimitive2D
70 // - TransformPrimitive2D
71 // - TextEffectPrimitive2D
72 // - ModifiedColorPrimitive2D
73 // - TransformPrimitive2D
74 // - GroupPrimitive2D
76 // encapsulate with flag and use decomposition
77 mnInText++;
78 process(rCandidate.get2DDecomposition(getViewInformation2D()));
79 mnInText--;
81 break;
83 case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D :
85 // TextSimplePortionPrimitive2D can produce the following primitives
86 // when being decomposed:
88 // - PolyPolygonColorPrimitive2D
89 // - TextEffectPrimitive2D
90 // - ModifiedColorPrimitive2D
91 // - TransformPrimitive2D
92 // - GroupPrimitive2D
94 // encapsulate with flag and use decomposition
95 mnInText++;
96 process(rCandidate.get2DDecomposition(getViewInformation2D()));
97 mnInText--;
99 break;
102 // as can be seen from the TextSimplePortionPrimitive2D and the
103 // TextDecoratedPortionPrimitive2D, inside of the mnInText marks
104 // the following primitives can occurr containing geometry data
105 // from text decomposition:
107 // - PolyPolygonColorPrimitive2D
108 // - PolygonHairlinePrimitive2D
109 // - PolyPolygonHairlinePrimitive2D (for convenience)
111 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
113 if(mnInText)
115 const primitive2d::PolyPolygonColorPrimitive2D& rPoPoCoCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate));
116 basegfx::B2DPolyPolygon aPolyPolygon(rPoPoCoCandidate.getB2DPolyPolygon());
118 if(aPolyPolygon.count())
120 // transform the PolyPolygon
121 aPolyPolygon.transform(getViewInformation2D().getObjectToViewTransformation());
123 // get evtl. corrected color
124 const basegfx::BColor aColor(maBColorModifierStack.getModifiedColor(rPoPoCoCandidate.getBColor()));
126 // add to result vector
127 maTarget.push_back(TextAsPolygonDataNode(aPolyPolygon, aColor, true));
131 break;
133 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
135 if(mnInText)
137 const primitive2d::PolygonHairlinePrimitive2D& rPoHaCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate));
138 basegfx::B2DPolygon aPolygon(rPoHaCandidate.getB2DPolygon());
140 if(aPolygon.count())
142 // transform the Polygon
143 aPolygon.transform(getViewInformation2D().getObjectToViewTransformation());
145 // get evtl. corrected color
146 const basegfx::BColor aColor(maBColorModifierStack.getModifiedColor(rPoHaCandidate.getBColor()));
148 // add to result vector
149 maTarget.push_back(TextAsPolygonDataNode(basegfx::B2DPolyPolygon(aPolygon), aColor, false));
153 break;
155 case PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D :
157 if(mnInText)
159 const primitive2d::PolyPolygonHairlinePrimitive2D& rPoPoHaCandidate(static_cast< const primitive2d::PolyPolygonHairlinePrimitive2D& >(rCandidate));
160 basegfx::B2DPolyPolygon aPolyPolygon(rPoPoHaCandidate.getB2DPolyPolygon());
162 if(aPolyPolygon.count())
164 // transform the Polygon
165 aPolyPolygon.transform(getViewInformation2D().getObjectToViewTransformation());
167 // get evtl. corrected color
168 const basegfx::BColor aColor(maBColorModifierStack.getModifiedColor(rPoPoHaCandidate.getBColor()));
170 // add to result vector
171 maTarget.push_back(TextAsPolygonDataNode(aPolyPolygon, aColor, false));
175 break;
178 // usage of color modification stack is needed
179 case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D :
181 const primitive2d::ModifiedColorPrimitive2D& rModifiedColorCandidate(static_cast< const primitive2d::ModifiedColorPrimitive2D& >(rCandidate));
183 if(rModifiedColorCandidate.getChildren().hasElements())
185 maBColorModifierStack.push(rModifiedColorCandidate.getColorModifier());
186 process(rModifiedColorCandidate.getChildren());
187 maBColorModifierStack.pop();
190 break;
193 // usage of transformation stack is needed
194 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
196 // remember current transformation and ViewInformation
197 const primitive2d::TransformPrimitive2D& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
198 const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
200 // create new transformations for CurrentTransformation and for local ViewInformation2D
201 const geometry::ViewInformation2D aViewInformation2D(
202 getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
203 getViewInformation2D().getViewTransformation(),
204 getViewInformation2D().getViewport(),
205 getViewInformation2D().getVisualizedPage(),
206 getViewInformation2D().getViewTime(),
207 getViewInformation2D().getExtendedInformationSequence());
208 updateViewInformation(aViewInformation2D);
210 // proccess content
211 process(rTransformCandidate.getChildren());
213 // restore transformations
214 updateViewInformation(aLastViewInformation2D);
216 break;
219 // ignorable primitives
220 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D :
221 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D :
222 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D :
223 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D :
224 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D :
225 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
226 case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
228 break;
231 default :
233 // process recursively
234 process(rCandidate.get2DDecomposition(getViewInformation2D()));
235 break;
240 TextAsPolygonExtractor2D::TextAsPolygonExtractor2D(const geometry::ViewInformation2D& rViewInformation)
241 : BaseProcessor2D(rViewInformation),
242 maTarget(),
243 maBColorModifierStack(),
244 mnInText(0)
248 TextAsPolygonExtractor2D::~TextAsPolygonExtractor2D()
251 } // end of namespace processor2d
252 } // end of namespace drawinglayer
254 //////////////////////////////////////////////////////////////////////////////
255 // eof