Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : :
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>
34 : :
35 : : //////////////////////////////////////////////////////////////////////////////
36 : :
37 : : using namespace com::sun::star;
38 : :
39 : : //////////////////////////////////////////////////////////////////////////////
40 : :
41 : : namespace drawinglayer
42 : : {
43 : : namespace processor2d
44 : : {
45 : 0 : LineGeometryExtractor2D::LineGeometryExtractor2D(const geometry::ViewInformation2D& rViewInformation)
46 : : : BaseProcessor2D(rViewInformation),
47 : : maExtractedHairlines(),
48 : : maExtractedLineFills(),
49 [ # # ][ # # ]: 0 : mbInLineGeometry(false)
50 : : {
51 : 0 : }
52 : :
53 : 0 : LineGeometryExtractor2D::~LineGeometryExtractor2D()
54 : : {
55 [ # # ]: 0 : }
56 : :
57 : 0 : void LineGeometryExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
58 : : {
59 [ # # # # : 0 : switch(rCandidate.getPrimitive2DID())
# # ]
60 : : {
61 : : case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D :
62 : : case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D :
63 : : {
64 : : // enter a line geometry group (with or without LineEnds)
65 : 0 : bool bOldState(mbInLineGeometry);
66 : 0 : mbInLineGeometry = true;
67 [ # # ]: 0 : process(rCandidate.get2DDecomposition(getViewInformation2D()));
68 : 0 : mbInLineGeometry = bOldState;
69 : 0 : break;
70 : : }
71 : : case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
72 : : {
73 [ # # ]: 0 : if(mbInLineGeometry)
74 : : {
75 : : // extract hairline line geometry in world coordinates
76 : 0 : const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate));
77 [ # # ]: 0 : basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon());
78 [ # # ][ # # ]: 0 : aLocalPolygon.transform(getViewInformation2D().getObjectTransformation());
79 [ # # ][ # # ]: 0 : maExtractedHairlines.push_back(aLocalPolygon);
80 : : }
81 : 0 : break;
82 : : }
83 : : case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
84 : : {
85 [ # # ]: 0 : if(mbInLineGeometry)
86 : : {
87 : : // extract filled line geometry (line with width)
88 : 0 : const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate));
89 [ # # ]: 0 : basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
90 [ # # ][ # # ]: 0 : aLocalPolyPolygon.transform(getViewInformation2D().getObjectTransformation());
91 [ # # ][ # # ]: 0 : maExtractedLineFills.push_back(aLocalPolyPolygon);
92 : : }
93 : 0 : break;
94 : : }
95 : : case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
96 : : {
97 : : // remember current transformation and ViewInformation
98 : 0 : const primitive2d::TransformPrimitive2D& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
99 [ # # ]: 0 : const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
100 : :
101 : : // create new transformations for CurrentTransformation and for local ViewInformation2D
102 : : const geometry::ViewInformation2D aViewInformation2D(
103 [ # # ]: 0 : getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
104 [ # # ]: 0 : getViewInformation2D().getViewTransformation(),
105 [ # # ]: 0 : getViewInformation2D().getViewport(),
106 [ # # ]: 0 : getViewInformation2D().getVisualizedPage(),
107 : 0 : getViewInformation2D().getViewTime(),
108 [ # # # # ]: 0 : getViewInformation2D().getExtendedInformationSequence());
[ # # ][ # # ]
[ # # ]
109 [ # # ]: 0 : updateViewInformation(aViewInformation2D);
110 : :
111 : : // proccess content
112 [ # # ]: 0 : process(rTransformCandidate.getChildren());
113 : :
114 : : // restore transformations
115 [ # # ]: 0 : updateViewInformation(aLastViewInformation2D);
116 : :
117 [ # # ][ # # ]: 0 : break;
118 : : }
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 :
127 : : {
128 : : // ignorable primitives
129 : 0 : break;
130 : : }
131 : : default :
132 : : {
133 : : // process recursively
134 [ # # ]: 0 : process(rCandidate.get2DDecomposition(getViewInformation2D()));
135 : 0 : break;
136 : : }
137 : : }
138 : 0 : }
139 : : } // end of namespace processor2d
140 : : } // end of namespace drawinglayer
141 : :
142 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|