1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <drawinglayer/processor2d/linegeometryextractor2d.hxx>
30 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
31 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
32 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
33 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
35 //////////////////////////////////////////////////////////////////////////////
37 using namespace com::sun::star
;
39 //////////////////////////////////////////////////////////////////////////////
41 namespace drawinglayer
45 LineGeometryExtractor2D::LineGeometryExtractor2D(const geometry::ViewInformation2D
& rViewInformation
)
46 : BaseProcessor2D(rViewInformation
),
47 maExtractedHairlines(),
48 maExtractedLineFills(),
49 mbInLineGeometry(false)
53 LineGeometryExtractor2D::~LineGeometryExtractor2D()
57 void LineGeometryExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D
& rCandidate
)
59 switch(rCandidate
.getPrimitive2DID())
61 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D
:
62 case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D
:
64 // enter a line geometry group (with or without LineEnds)
65 bool bOldState(mbInLineGeometry
);
66 mbInLineGeometry
= true;
67 process(rCandidate
.get2DDecomposition(getViewInformation2D()));
68 mbInLineGeometry
= bOldState
;
71 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D
:
75 // extract hairline line geometry in world coordinates
76 const primitive2d::PolygonHairlinePrimitive2D
& rPolygonCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D
& >(rCandidate
));
77 basegfx::B2DPolygon
aLocalPolygon(rPolygonCandidate
.getB2DPolygon());
78 aLocalPolygon
.transform(getViewInformation2D().getObjectTransformation());
79 maExtractedHairlines
.push_back(aLocalPolygon
);
83 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D
:
87 // extract filled line geometry (line with width)
88 const primitive2d::PolyPolygonColorPrimitive2D
& rPolygonCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D
& >(rCandidate
));
89 basegfx::B2DPolyPolygon
aLocalPolyPolygon(rPolygonCandidate
.getB2DPolyPolygon());
90 aLocalPolyPolygon
.transform(getViewInformation2D().getObjectTransformation());
91 maExtractedLineFills
.push_back(aLocalPolyPolygon
);
95 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D
:
97 // remember current transformation and ViewInformation
98 const primitive2d::TransformPrimitive2D
& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D
& >(rCandidate
));
99 const geometry::ViewInformation2D
aLastViewInformation2D(getViewInformation2D());
101 // create new transformations for CurrentTransformation and for local ViewInformation2D
102 const geometry::ViewInformation2D
aViewInformation2D(
103 getViewInformation2D().getObjectTransformation() * rTransformCandidate
.getTransformation(),
104 getViewInformation2D().getViewTransformation(),
105 getViewInformation2D().getViewport(),
106 getViewInformation2D().getVisualizedPage(),
107 getViewInformation2D().getViewTime(),
108 getViewInformation2D().getExtendedInformationSequence());
109 updateViewInformation(aViewInformation2D
);
112 process(rTransformCandidate
.getChildren());
114 // restore transformations
115 updateViewInformation(aLastViewInformation2D
);
119 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D
:
120 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D
:
121 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D
:
122 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D
:
123 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D
:
124 case PRIMITIVE2D_ID_RENDERGRAPHICPRIMITIVE2D
:
125 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D
:
126 case PRIMITIVE2D_ID_MASKPRIMITIVE2D
:
128 // ignorable primitives
133 // process recursively
134 process(rCandidate
.get2DDecomposition(getViewInformation2D()));
139 } // end of namespace processor2d
140 } // end of namespace drawinglayer
142 //////////////////////////////////////////////////////////////////////////////
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */