1*464702f4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*464702f4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*464702f4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*464702f4SAndrew Rist  * distributed with this work for additional information
6*464702f4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*464702f4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*464702f4SAndrew Rist  * "License"); you may not use this file except in compliance
9*464702f4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*464702f4SAndrew Rist  *
11*464702f4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*464702f4SAndrew Rist  *
13*464702f4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*464702f4SAndrew Rist  * software distributed under the License is distributed on an
15*464702f4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*464702f4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*464702f4SAndrew Rist  * specific language governing permissions and limitations
18*464702f4SAndrew Rist  * under the License.
19*464702f4SAndrew Rist  *
20*464702f4SAndrew Rist  *************************************************************/
21*464702f4SAndrew Rist 
22*464702f4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <drawinglayer/processor2d/linegeometryextractor2d.hxx>
28cdf0e10cSrcweir #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
29cdf0e10cSrcweir #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
30cdf0e10cSrcweir #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
31cdf0e10cSrcweir #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
34cdf0e10cSrcweir 
35cdf0e10cSrcweir using namespace com::sun::star;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
38cdf0e10cSrcweir 
39cdf0e10cSrcweir namespace drawinglayer
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 	namespace processor2d
42cdf0e10cSrcweir 	{
LineGeometryExtractor2D(const geometry::ViewInformation2D & rViewInformation)43cdf0e10cSrcweir 		LineGeometryExtractor2D::LineGeometryExtractor2D(const geometry::ViewInformation2D& rViewInformation)
44cdf0e10cSrcweir 		:	BaseProcessor2D(rViewInformation),
45cdf0e10cSrcweir 			maExtractedHairlines(),
46cdf0e10cSrcweir 			maExtractedLineFills(),
47cdf0e10cSrcweir             mbInLineGeometry(false)
48cdf0e10cSrcweir 		{
49cdf0e10cSrcweir 		}
50cdf0e10cSrcweir 
~LineGeometryExtractor2D()51cdf0e10cSrcweir 		LineGeometryExtractor2D::~LineGeometryExtractor2D()
52cdf0e10cSrcweir 		{
53cdf0e10cSrcweir 		}
54cdf0e10cSrcweir 
processBasePrimitive2D(const primitive2d::BasePrimitive2D & rCandidate)55cdf0e10cSrcweir 		void LineGeometryExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
56cdf0e10cSrcweir 		{
57cdf0e10cSrcweir 			switch(rCandidate.getPrimitive2DID())
58cdf0e10cSrcweir 			{
59cdf0e10cSrcweir 				case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D :
60cdf0e10cSrcweir 				case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D :
61cdf0e10cSrcweir                 {
62cdf0e10cSrcweir                     // enter a line geometry group (with or without LineEnds)
63cdf0e10cSrcweir                     bool bOldState(mbInLineGeometry);
64cdf0e10cSrcweir                     mbInLineGeometry = true;
65cdf0e10cSrcweir 					process(rCandidate.get2DDecomposition(getViewInformation2D()));
66cdf0e10cSrcweir                     mbInLineGeometry = bOldState;
67cdf0e10cSrcweir                     break;
68cdf0e10cSrcweir                 }
69cdf0e10cSrcweir 				case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
70cdf0e10cSrcweir 				{
71cdf0e10cSrcweir                     if(mbInLineGeometry)
72cdf0e10cSrcweir                     {
73cdf0e10cSrcweir 					    // extract hairline line geometry in world coordinates
74cdf0e10cSrcweir 					    const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate));
75cdf0e10cSrcweir 					    basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon());
76cdf0e10cSrcweir 					    aLocalPolygon.transform(getViewInformation2D().getObjectTransformation());
77cdf0e10cSrcweir                         maExtractedHairlines.push_back(aLocalPolygon);
78cdf0e10cSrcweir                     }
79cdf0e10cSrcweir 					break;
80cdf0e10cSrcweir 				}
81cdf0e10cSrcweir 				case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
82cdf0e10cSrcweir 				{
83cdf0e10cSrcweir                     if(mbInLineGeometry)
84cdf0e10cSrcweir                     {
85cdf0e10cSrcweir 					    // extract filled line geometry (line with width)
86cdf0e10cSrcweir 					    const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate));
87cdf0e10cSrcweir 					    basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
88cdf0e10cSrcweir 					    aLocalPolyPolygon.transform(getViewInformation2D().getObjectTransformation());
89cdf0e10cSrcweir 					    maExtractedLineFills.push_back(aLocalPolyPolygon);
90cdf0e10cSrcweir                     }
91cdf0e10cSrcweir 					break;
92cdf0e10cSrcweir 				}
93cdf0e10cSrcweir 				case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
94cdf0e10cSrcweir 				{
95cdf0e10cSrcweir 					// remember current transformation and ViewInformation
96cdf0e10cSrcweir 					const primitive2d::TransformPrimitive2D& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
97cdf0e10cSrcweir 					const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 					// create new transformations for CurrentTransformation and for local ViewInformation2D
100cdf0e10cSrcweir 					const geometry::ViewInformation2D aViewInformation2D(
101cdf0e10cSrcweir 						getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
102cdf0e10cSrcweir 						getViewInformation2D().getViewTransformation(),
103cdf0e10cSrcweir 						getViewInformation2D().getViewport(),
104cdf0e10cSrcweir 						getViewInformation2D().getVisualizedPage(),
105cdf0e10cSrcweir 						getViewInformation2D().getViewTime(),
106cdf0e10cSrcweir 						getViewInformation2D().getExtendedInformationSequence());
107cdf0e10cSrcweir 					updateViewInformation(aViewInformation2D);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 					// proccess content
110cdf0e10cSrcweir 					process(rTransformCandidate.getChildren());
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 					// restore transformations
113cdf0e10cSrcweir 					updateViewInformation(aLastViewInformation2D);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 					break;
116cdf0e10cSrcweir 				}
117cdf0e10cSrcweir 				case PRIMITIVE2D_ID_SCENEPRIMITIVE2D :
118cdf0e10cSrcweir                 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D :
119cdf0e10cSrcweir 				case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D :
120cdf0e10cSrcweir 				case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D :
121cdf0e10cSrcweir 				case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D :
122cdf0e10cSrcweir 				case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
123cdf0e10cSrcweir 				case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
124cdf0e10cSrcweir                 {
125cdf0e10cSrcweir 					// ignorable primitives
126cdf0e10cSrcweir 					break;
127cdf0e10cSrcweir 				}
128cdf0e10cSrcweir 				default :
129cdf0e10cSrcweir 				{
130cdf0e10cSrcweir 					// process recursively
131cdf0e10cSrcweir 					process(rCandidate.get2DDecomposition(getViewInformation2D()));
132cdf0e10cSrcweir 					break;
133cdf0e10cSrcweir 				}
134cdf0e10cSrcweir 			}
135cdf0e10cSrcweir 		}
136cdf0e10cSrcweir 	} // end of namespace processor2d
137cdf0e10cSrcweir } // end of namespace drawinglayer
138cdf0e10cSrcweir 
139cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
140cdf0e10cSrcweir // eof
141