1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdrcaptionprimitive2d.cxx,v $
11 * $Revision: 1.2.18.1 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "precompiled_svx.hxx"
33 #include <svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx>
34 #include <basegfx/polygon/b2dpolygontools.hxx>
35 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
36 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
37 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
38 #include <drawinglayer/primitive2d/hittestprimitive2d.hxx>
40 //////////////////////////////////////////////////////////////////////////////
42 using namespace com::sun::star
;
44 //////////////////////////////////////////////////////////////////////////////
46 namespace drawinglayer
50 Primitive2DSequence
SdrCaptionPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D
& /*aViewInformation*/) const
52 Primitive2DSequence aRetval
;
53 Primitive2DSequence aHitTestContent
;
55 // create unit outline polygon
56 const basegfx::B2DPolygon
aUnitOutline(basegfx::tools::createPolygonFromRect(
57 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
62 if(getSdrLFSTAttribute().getFill())
64 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
65 createPolyPolygonFillPrimitive(
66 basegfx::B2DPolyPolygon(aUnitOutline
),
68 *getSdrLFSTAttribute().getFill(),
69 getSdrLFSTAttribute().getFillFloatTransGradient()));
73 // if no fill, create one for HitTest and BoundRect fallback
74 appendPrimitive2DReferenceToPrimitive2DSequence(aHitTestContent
,
75 createPolyPolygonFillPrimitive(
76 basegfx::B2DPolyPolygon(aUnitOutline
),
78 attribute::SdrFillAttribute(0.0, basegfx::BColor(0.0, 0.0, 0.0)),
79 getSdrLFSTAttribute().getFillFloatTransGradient()));
83 if(getSdrLFSTAttribute().getLine())
85 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
86 createPolygonLinePrimitive(
89 *getSdrLFSTAttribute().getLine()));
91 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
92 createPolygonLinePrimitive(
95 *getSdrLFSTAttribute().getLine(),
96 getSdrLFSTAttribute().getLineStartEnd()));
100 // if initially no line is defined, create one for HitTest and BoundRect. It
101 // is sufficient to use the tail; the body is already ensured with fill creation
102 appendPrimitive2DReferenceToPrimitive2DSequence(aHitTestContent
,
103 createPolygonLinePrimitive(
106 attribute::SdrLineAttribute(basegfx::BColor(0.0, 0.0, 0.0))));
109 // add HitTest and BoundRect helper geometry (if exists)
110 if(aHitTestContent
.hasElements())
112 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
113 Primitive2DReference(new HitTestPrimitive2D(aHitTestContent
)));
117 if(getSdrLFSTAttribute().getText())
119 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
121 basegfx::B2DPolyPolygon(aUnitOutline
),
123 *getSdrLFSTAttribute().getText(),
124 getSdrLFSTAttribute().getLine(),
130 if(getSdrLFSTAttribute().getShadow())
132 aRetval
= createEmbeddedShadowPrimitive(aRetval
, *getSdrLFSTAttribute().getShadow());
138 SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
139 const basegfx::B2DHomMatrix
& rTransform
,
140 const attribute::SdrLineFillShadowTextAttribute
& rSdrLFSTAttribute
,
141 const basegfx::B2DPolygon
& rTail
,
142 double fCornerRadiusX
,
143 double fCornerRadiusY
)
145 maTransform(rTransform
),
146 maSdrLFSTAttribute(rSdrLFSTAttribute
),
148 mfCornerRadiusX(fCornerRadiusX
),
149 mfCornerRadiusY(fCornerRadiusY
)
151 // transform maTail to unit polygon
152 if(getTail().count())
154 basegfx::B2DHomMatrix
aInverse(getTransform());
156 maTail
.transform(aInverse
);
160 bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
162 if(BasePrimitive2D::operator==(rPrimitive
))
164 const SdrCaptionPrimitive2D
& rCompare
= (SdrCaptionPrimitive2D
&)rPrimitive
;
166 return (getCornerRadiusX() == rCompare
.getCornerRadiusX()
167 && getCornerRadiusY() == rCompare
.getCornerRadiusY()
168 && getTail() == rCompare
.getTail()
169 && getTransform() == rCompare
.getTransform()
170 && getSdrLFSTAttribute() == rCompare
.getSdrLFSTAttribute());
177 ImplPrimitrive2DIDBlock(SdrCaptionPrimitive2D
, PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D
)
179 } // end of namespace primitive2d
180 } // end of namespace drawinglayer
182 //////////////////////////////////////////////////////////////////////////////