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