xref: /trunk/main/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx (revision a893be29343ee97512d484e6e8fefa91df2b44cb)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "precompiled_svx.hxx"
25 #include <svx/sdr/primitive2d/sdrpathprimitive2d.hxx>
26 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
27 #include <basegfx/polygon/b2dpolypolygontools.hxx>
28 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
29 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
30 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
31 
32 //////////////////////////////////////////////////////////////////////////////
33 
34 using namespace com::sun::star;
35 
36 //////////////////////////////////////////////////////////////////////////////
37 
38 namespace drawinglayer
39 {
40     namespace primitive2d
41     {
42         Primitive2DSequence SdrPathPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
43         {
44             Primitive2DSequence aRetval;
45 
46             // add fill
47             if(!getSdrLFSTAttribute().getFill().isDefault()
48                 && getUnitPolyPolygon().isClosed())
49             {
50                 // #i108255# no need to use correctOrientations here; target is
51                 // straight visualisation
52                 basegfx::B2DPolyPolygon aTransformed(getUnitPolyPolygon());
53 
54                 aTransformed.transform(getTransform());
55                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
56                     createPolyPolygonFillPrimitive(
57                         aTransformed,
58                         getSdrLFSTAttribute().getFill(),
59                         getSdrLFSTAttribute().getFillFloatTransGradient()));
60             }
61 
62             // add line
63             if(getSdrLFSTAttribute().getLine().isDefault())
64             {
65                 // if initially no line is defined, create one for HitTest and BoundRect
66                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
67                     createHiddenGeometryPrimitives2D(
68                         false,
69                         getUnitPolyPolygon(),
70                         getTransform()));
71             }
72             else
73             {
74                 Primitive2DSequence aTemp(getUnitPolyPolygon().count());
75 
76                 for(sal_uInt32 a(0); a < getUnitPolyPolygon().count(); a++)
77                 {
78                     basegfx::B2DPolygon aTransformed(getUnitPolyPolygon().getB2DPolygon(a));
79 
80                     aTransformed.transform(getTransform());
81                     aTemp[a] = createPolygonLinePrimitive(
82                         aTransformed,
83                         getSdrLFSTAttribute().getLine(),
84                         getSdrLFSTAttribute().getLineStartEnd());
85                 }
86 
87                 appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, aTemp);
88             }
89 
90             // add text
91             if(!getSdrLFSTAttribute().getText().isDefault())
92             {
93                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
94                     createTextPrimitive(
95                         getUnitPolyPolygon(),
96                         getTransform(),
97                         getSdrLFSTAttribute().getText(),
98                         getSdrLFSTAttribute().getLine(),
99                         false,
100                         false,
101                         false));
102             }
103 
104             // add shadow
105             if(!getSdrLFSTAttribute().getShadow().isDefault())
106             {
107                 aRetval = createEmbeddedShadowPrimitive(
108                     aRetval,
109                     getSdrLFSTAttribute().getShadow());
110             }
111 
112             return aRetval;
113         }
114 
115         SdrPathPrimitive2D::SdrPathPrimitive2D(
116             const basegfx::B2DHomMatrix& rTransform,
117             const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
118             const basegfx::B2DPolyPolygon& rUnitPolyPolygon)
119         :   BufferedDecompositionPrimitive2D(),
120             maTransform(rTransform),
121             maSdrLFSTAttribute(rSdrLFSTAttribute),
122             maUnitPolyPolygon(rUnitPolyPolygon)
123         {
124         }
125 
126         bool SdrPathPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
127         {
128             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
129             {
130                 const SdrPathPrimitive2D& rCompare = (SdrPathPrimitive2D&)rPrimitive;
131 
132                 return (getUnitPolyPolygon() == rCompare.getUnitPolyPolygon()
133                     && getTransform() == rCompare.getTransform()
134                     && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
135             }
136 
137             return false;
138         }
139 
140         // provide unique ID
141         ImplPrimitrive2DIDBlock(SdrPathPrimitive2D, PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D)
142 
143     } // end of namespace primitive2d
144 } // end of namespace drawinglayer
145 
146 //////////////////////////////////////////////////////////////////////////////
147 // eof
148