Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / drawinglayer / source / processor2d / linegeometryextractor2d.cxx
blobe1951eb6a2dcfa75bd1d0283d1e70f28fef96c25
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/linegeometryextractor2d.hxx>
21 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
22 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
23 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
24 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
27 using namespace com::sun::star;
30 namespace drawinglayer
32 namespace processor2d
34 LineGeometryExtractor2D::LineGeometryExtractor2D(const geometry::ViewInformation2D& rViewInformation)
35 : BaseProcessor2D(rViewInformation),
36 maExtractedHairlines(),
37 maExtractedLineFills(),
38 mbInLineGeometry(false)
42 LineGeometryExtractor2D::~LineGeometryExtractor2D()
46 void LineGeometryExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
48 switch(rCandidate.getPrimitive2DID())
50 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D :
51 case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D :
53 // enter a line geometry group (with or without LineEnds)
54 bool bOldState(mbInLineGeometry);
55 mbInLineGeometry = true;
56 process(rCandidate.get2DDecomposition(getViewInformation2D()));
57 mbInLineGeometry = bOldState;
58 break;
60 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
62 if(mbInLineGeometry)
64 // extract hairline line geometry in world coordinates
65 const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate));
66 basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon());
67 aLocalPolygon.transform(getViewInformation2D().getObjectTransformation());
68 maExtractedHairlines.push_back(aLocalPolygon);
70 break;
72 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
74 if(mbInLineGeometry)
76 // extract filled line geometry (line with width)
77 const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate));
78 basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
79 aLocalPolyPolygon.transform(getViewInformation2D().getObjectTransformation());
80 maExtractedLineFills.push_back(aLocalPolyPolygon);
82 break;
84 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
86 // remember current transformation and ViewInformation
87 const primitive2d::TransformPrimitive2D& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
88 const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
90 // create new transformations for CurrentTransformation and for local ViewInformation2D
91 const geometry::ViewInformation2D aViewInformation2D(
92 getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
93 getViewInformation2D().getViewTransformation(),
94 getViewInformation2D().getViewport(),
95 getViewInformation2D().getVisualizedPage(),
96 getViewInformation2D().getViewTime(),
97 getViewInformation2D().getExtendedInformationSequence());
98 updateViewInformation(aViewInformation2D);
100 // process content
101 process(rTransformCandidate.getChildren());
103 // restore transformations
104 updateViewInformation(aLastViewInformation2D);
106 break;
108 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D :
109 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D :
110 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D :
111 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D :
112 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D :
113 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
114 case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
116 // ignorable primitives
117 break;
119 default :
121 // process recursively
122 process(rCandidate.get2DDecomposition(getViewInformation2D()));
123 break;
127 } // end of namespace processor2d
128 } // end of namespace drawinglayer
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */