Update ooo320-m1
[ooovba.git] / drawinglayer / source / processor2d / linegeometryextractor2d.cxx
blobfc7740eaccb9bf47e589a10f8434a514d7a149a8
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: linegeometryextractor2d.cxx,v $
7 * $Revision: 1.1 $
9 * last change: $Author: aw $ $Date: 2008-06-24 15:44:27 $
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/linegeometryextractor2d.hxx>
40 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
41 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
42 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
43 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
45 //////////////////////////////////////////////////////////////////////////////
47 using namespace com::sun::star;
49 //////////////////////////////////////////////////////////////////////////////
51 namespace drawinglayer
53 namespace processor2d
55 LineGeometryExtractor2D::LineGeometryExtractor2D(const geometry::ViewInformation2D& rViewInformation)
56 : BaseProcessor2D(rViewInformation),
57 maExtractedHairlines(),
58 maExtractedLineFills(),
59 mbInLineGeometry(false)
63 LineGeometryExtractor2D::~LineGeometryExtractor2D()
67 void LineGeometryExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
69 switch(rCandidate.getPrimitiveID())
71 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D :
72 case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D :
74 // enter a line geometry group (with or without LineEnds)
75 bool bOldState(mbInLineGeometry);
76 mbInLineGeometry = true;
77 process(rCandidate.get2DDecomposition(getViewInformation2D()));
78 mbInLineGeometry = bOldState;
79 break;
81 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
83 if(mbInLineGeometry)
85 // extract hairline line geometry in world coordinates
86 const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate));
87 basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon());
88 aLocalPolygon.transform(getViewInformation2D().getObjectTransformation());
89 maExtractedHairlines.push_back(aLocalPolygon);
91 break;
93 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
95 if(mbInLineGeometry)
97 // extract filled line geometry (line with width)
98 const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate));
99 basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
100 aLocalPolyPolygon.transform(getViewInformation2D().getObjectTransformation());
101 maExtractedLineFills.push_back(aLocalPolyPolygon);
103 break;
105 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
107 // remember current transformation and ViewInformation
108 const primitive2d::TransformPrimitive2D& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
109 const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
111 // create new transformations for CurrentTransformation and for local ViewInformation2D
112 const geometry::ViewInformation2D aViewInformation2D(
113 getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
114 getViewInformation2D().getViewTransformation(),
115 getViewInformation2D().getViewport(),
116 getViewInformation2D().getVisualizedPage(),
117 getViewInformation2D().getViewTime(),
118 getViewInformation2D().getExtendedInformationSequence());
119 updateViewInformation(aViewInformation2D);
121 // proccess content
122 process(rTransformCandidate.getChildren());
124 // restore transformations
125 updateViewInformation(aLastViewInformation2D);
127 break;
129 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D :
130 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D :
131 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D :
132 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D :
133 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D :
134 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
135 case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
137 // ignorable primitives
138 break;
140 default :
142 // process recursively
143 process(rCandidate.get2DDecomposition(getViewInformation2D()));
144 break;
148 } // end of namespace processor2d
149 } // end of namespace drawinglayer
151 //////////////////////////////////////////////////////////////////////////////
152 // eof