1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/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 maExtractedHairlines(),
35 maExtractedLineFills(),
36 mbInLineGeometry(false)
40 LineGeometryExtractor2D::~LineGeometryExtractor2D()
44 void LineGeometryExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D
& rCandidate
)
46 switch(rCandidate
.getPrimitive2DID())
48 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D
:
49 case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D
:
51 // enter a line geometry group (with or without LineEnds)
52 bool bOldState(mbInLineGeometry
);
53 mbInLineGeometry
= true;
55 mbInLineGeometry
= bOldState
;
58 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D
:
62 // extract hairline line geometry in world coordinates
63 const primitive2d::PolygonHairlinePrimitive2D
& rPolygonCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D
& >(rCandidate
));
64 basegfx::B2DPolygon
aLocalPolygon(rPolygonCandidate
.getB2DPolygon());
65 aLocalPolygon
.transform(getViewInformation2D().getObjectTransformation());
66 maExtractedHairlines
.push_back(aLocalPolygon
);
70 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D
:
74 // extract filled line geometry (line with width)
75 const primitive2d::PolyPolygonColorPrimitive2D
& rPolygonCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D
& >(rCandidate
));
76 basegfx::B2DPolyPolygon
aLocalPolyPolygon(rPolygonCandidate
.getB2DPolyPolygon());
77 aLocalPolyPolygon
.transform(getViewInformation2D().getObjectTransformation());
78 maExtractedLineFills
.push_back(aLocalPolyPolygon
);
82 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D
:
84 // remember current transformation and ViewInformation
85 const primitive2d::TransformPrimitive2D
& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D
& >(rCandidate
));
86 const geometry::ViewInformation2D
aLastViewInformation2D(getViewInformation2D());
88 // create new transformations for CurrentTransformation and for local ViewInformation2D
89 const geometry::ViewInformation2D
aViewInformation2D(
90 getViewInformation2D().getObjectTransformation() * rTransformCandidate
.getTransformation(),
91 getViewInformation2D().getViewTransformation(),
92 getViewInformation2D().getViewport(),
93 getViewInformation2D().getVisualizedPage(),
94 getViewInformation2D().getViewTime(),
95 getViewInformation2D().getExtendedInformationSequence());
96 updateViewInformation(aViewInformation2D
);
99 process(rTransformCandidate
.getChildren());
101 // restore transformations
102 updateViewInformation(aLastViewInformation2D
);
106 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D
:
107 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D
:
108 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D
:
109 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D
:
110 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D
:
111 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D
:
112 case PRIMITIVE2D_ID_MASKPRIMITIVE2D
:
114 // ignorable primitives
119 // process recursively
126 } // end of namespace
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */