Bump version to 24.04.3.4
[LibreOffice.git] / drawinglayer / source / processor2d / linegeometryextractor2d.cxx
blob11af79725b41d707b63fd21af0e5d911bcafb417
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/PolygonHairlinePrimitive2D.hxx>
23 #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
24 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
27 using namespace com::sun::star;
30 namespace drawinglayer::processor2d
32 LineGeometryExtractor2D::LineGeometryExtractor2D(const geometry::ViewInformation2D& rViewInformation)
33 : BaseProcessor2D(rViewInformation),
34 mbInLineGeometry(false)
38 LineGeometryExtractor2D::~LineGeometryExtractor2D()
42 void LineGeometryExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
44 switch(rCandidate.getPrimitive2DID())
46 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D :
47 case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D :
49 // enter a line geometry group (with or without LineEnds)
50 bool bOldState(mbInLineGeometry);
51 mbInLineGeometry = true;
52 process(rCandidate);
53 mbInLineGeometry = bOldState;
54 break;
56 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
58 if(mbInLineGeometry)
60 // extract hairline line geometry in world coordinates
61 const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate));
62 basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon());
63 aLocalPolygon.transform(getViewInformation2D().getObjectTransformation());
64 maExtractedHairlines.push_back(aLocalPolygon);
66 break;
68 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
70 if(mbInLineGeometry)
72 // extract filled line geometry (line with width)
73 const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate));
74 basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
75 aLocalPolyPolygon.transform(getViewInformation2D().getObjectTransformation());
76 maExtractedLineFills.push_back(aLocalPolyPolygon);
78 break;
80 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
82 // remember current transformation and ViewInformation
83 const primitive2d::TransformPrimitive2D& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
84 const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
86 // create new transformations for CurrentTransformation and for local ViewInformation2D
87 geometry::ViewInformation2D aViewInformation2D(getViewInformation2D());
88 aViewInformation2D.setObjectTransformation(getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation());
89 updateViewInformation(aViewInformation2D);
91 // process content
92 process(rTransformCandidate.getChildren());
94 // restore transformations
95 updateViewInformation(aLastViewInformation2D);
97 break;
99 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D :
100 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D :
101 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D :
102 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D :
103 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D :
104 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
105 case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
107 // ignorable primitives
108 break;
110 default :
112 // process recursively
113 process(rCandidate);
114 break;
119 } // end of namespace
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */