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 <svx/sdr/primitive2d/sdrole2primitive2d.hxx>
30 : : #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
31 : : #include <basegfx/polygon/b2dpolygontools.hxx>
32 : : #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
33 : : #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
34 : : #include <basegfx/polygon/b2dpolygon.hxx>
35 : :
36 : : //////////////////////////////////////////////////////////////////////////////
37 : :
38 : : using namespace com::sun::star;
39 : :
40 : : //////////////////////////////////////////////////////////////////////////////
41 : :
42 : : namespace drawinglayer
43 : : {
44 : : namespace primitive2d
45 : : {
46 : 181 : SdrOle2Primitive2D::SdrOle2Primitive2D(
47 : : const Primitive2DSequence& rOLEContent,
48 : : const basegfx::B2DHomMatrix& rTransform,
49 : : const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute)
50 : : : BasePrimitive2D(),
51 : : maOLEContent(rOLEContent),
52 : : maTransform(rTransform),
53 [ + - ][ + - ]: 181 : maSdrLFSTAttribute(rSdrLFSTAttribute)
[ + - ]
54 : : {
55 : 181 : }
56 : :
57 : 152 : bool SdrOle2Primitive2D::operator==(const BasePrimitive2D& rPrimitive) const
58 : : {
59 [ + - ]: 152 : if(BasePrimitive2D::operator==(rPrimitive))
60 : : {
61 : 152 : const SdrOle2Primitive2D& rCompare = (SdrOle2Primitive2D&)rPrimitive;
62 : :
63 : : // #i108636# The standard operator== on two UNO sequences did not work as i
64 : : // would have expected; it just checks the .is() states and the data type
65 : : // of the sequence. What i need here is detection of equality of the whole
66 : : // sequence content, thus i need to use the arePrimitive2DSequencesEqual helper
67 : : // here instead of the operator== which lead to always returning false and thus
68 : : // always re-decompositions of the subcontent.
69 [ + + + - : 304 : if(arePrimitive2DSequencesEqual(getOLEContent(), rCompare.getOLEContent())
+ - ][ + + ]
70 : 76 : && getTransform() == rCompare.getTransform()
71 : 76 : && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute())
72 : : {
73 : 76 : return true;
74 : : }
75 : : }
76 : :
77 : 152 : return false;
78 : : }
79 : :
80 : 481 : Primitive2DSequence SdrOle2Primitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
81 : : {
82 : : // to take care of getSdrLFSTAttribute() later, the same as in SdrGrafPrimitive2D::create2DDecomposition
83 : : // should happen. For the moment we only need the OLE itself
84 : : // Added complete primitive preparation using getSdrLFSTAttribute() now. To not do stuff which is not needed now, it
85 : : // may be supressed by using a static bool. The paint version only supported text.
86 : : static bool bBehaveCompatibleToPaintVersion(true);
87 [ + - ]: 481 : Primitive2DSequence aRetval;
88 : :
89 : : // create unit outline polygon
90 [ + - ]: 481 : const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
91 : :
92 : : // add fill
93 [ - + ][ # # ]: 481 : if(!bBehaveCompatibleToPaintVersion
[ - + ]
94 [ # # ]: 0 : && !getSdrLFSTAttribute().getFill().isDefault())
95 : : {
96 : : appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
97 : : createPolyPolygonFillPrimitive(
98 : : basegfx::B2DPolyPolygon(aUnitOutline),
99 : 0 : getTransform(),
100 : 0 : getSdrLFSTAttribute().getFill(),
101 [ # # ][ # # ]: 0 : getSdrLFSTAttribute().getFillFloatTransGradient()));
[ # # ][ # # ]
102 : : }
103 : :
104 : : // add line
105 : : // #i97981# condition was inverse to purpose. When being compatible to paint version,
106 : : // border needs to be suppressed
107 [ - + ][ # # ]: 481 : if(!bBehaveCompatibleToPaintVersion
[ - + ]
108 [ # # ]: 0 : && !getSdrLFSTAttribute().getLine().isDefault())
109 : : {
110 : : // if line width is given, polygon needs to be grown by half of it to make the
111 : : // outline to be outside of the bitmap
112 [ # # ][ # # ]: 0 : if(0.0 != getSdrLFSTAttribute().getLine().getWidth())
113 : : {
114 : : // decompose to get scale
115 : 0 : basegfx::B2DVector aScale, aTranslate;
116 : : double fRotate, fShearX;
117 [ # # ]: 0 : getTransform().decompose(aScale, aTranslate, fRotate, fShearX);
118 : :
119 : : // create expanded range (add relative half line width to unit rectangle)
120 [ # # ]: 0 : double fHalfLineWidth(getSdrLFSTAttribute().getLine().getWidth() * 0.5);
121 [ # # ]: 0 : double fScaleX(0.0 != aScale.getX() ? fHalfLineWidth / fabs(aScale.getX()) : 1.0);
122 [ # # ]: 0 : double fScaleY(0.0 != aScale.getY() ? fHalfLineWidth / fabs(aScale.getY()) : 1.0);
123 [ # # ]: 0 : const basegfx::B2DRange aExpandedRange(-fScaleX, -fScaleY, 1.0 + fScaleX, 1.0 + fScaleY);
124 [ # # ]: 0 : basegfx::B2DPolygon aExpandedUnitOutline(basegfx::tools::createPolygonFromRect(aExpandedRange));
125 : :
126 : : appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
127 : : createPolygonLinePrimitive(
128 : : aExpandedUnitOutline,
129 : 0 : getTransform(),
130 : 0 : getSdrLFSTAttribute().getLine(),
131 [ # # # # ]: 0 : attribute::SdrLineStartEndAttribute()));
[ # # ][ # # ]
[ # # ]
132 : : }
133 : : else
134 : : {
135 : : appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
136 : : createPolygonLinePrimitive(
137 : : aUnitOutline,
138 : 0 : getTransform(),
139 : 0 : getSdrLFSTAttribute().getLine(),
140 [ # # # # ]: 0 : attribute::SdrLineStartEndAttribute()));
[ # # ][ # # ]
141 : : }
142 : : }
143 : : else
144 : : {
145 : : // if initially no line is defined, create one for HitTest and BoundRect
146 : : appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
147 : : createHiddenGeometryPrimitives2D(
148 : : false,
149 : : basegfx::B2DPolyPolygon(aUnitOutline),
150 [ + - ][ + - ]: 481 : getTransform()));
[ + - ][ + - ]
151 : : }
152 : :
153 : : // add graphic content
154 [ + - ]: 481 : appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, getOLEContent());
155 : :
156 : : // add text, no need to supress to stay compatible since text was
157 : : // always supported by the old paints, too
158 [ + - ][ - + ]: 481 : if(!getSdrLFSTAttribute().getText().isDefault())
159 : : {
160 : : appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
161 : : createTextPrimitive(
162 : : basegfx::B2DPolyPolygon(aUnitOutline),
163 : 0 : getTransform(),
164 : 0 : getSdrLFSTAttribute().getText(),
165 : 0 : getSdrLFSTAttribute().getLine(),
166 : : false,
167 : : false,
168 [ # # ][ # # ]: 0 : false));
[ # # ][ # # ]
169 : : }
170 : :
171 : : // add shadow
172 [ - + ][ # # ]: 481 : if(!bBehaveCompatibleToPaintVersion
[ - + ]
173 [ # # ]: 0 : && !getSdrLFSTAttribute().getShadow().isDefault())
174 : : {
175 : : aRetval = createEmbeddedShadowPrimitive(
176 : : aRetval,
177 [ # # ][ # # ]: 0 : getSdrLFSTAttribute().getShadow());
[ # # ]
178 : : }
179 : :
180 [ + - ]: 481 : return aRetval;
181 : : }
182 : :
183 : : // provide unique ID
184 : 462 : ImplPrimitrive2DIDBlock(SdrOle2Primitive2D, PRIMITIVE2D_ID_SDROLE2PRIMITIVE2D)
185 : :
186 : : } // end of namespace primitive2d
187 : : } // end of namespace drawinglayer
188 : :
189 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|