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 <svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx>
30 #include <basegfx/polygon/b2dpolygontools.hxx>
31 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
32 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
33 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
34 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
36 //////////////////////////////////////////////////////////////////////////////
38 using namespace com::sun::star
;
40 //////////////////////////////////////////////////////////////////////////////
42 namespace drawinglayer
46 Primitive2DSequence
SdrCaptionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D
& /*aViewInformation*/) const
48 Primitive2DSequence aRetval
;
50 // create unit outline polygon
51 const basegfx::B2DPolygon
aUnitOutline(basegfx::tools::createPolygonFromRect(
52 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
57 if(getSdrLFSTAttribute().getFill().isDefault())
59 // create invisible fill for HitTest
60 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
61 createHiddenGeometryPrimitives2D(
63 basegfx::B2DPolyPolygon(aUnitOutline
),
68 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
69 createPolyPolygonFillPrimitive(
70 basegfx::B2DPolyPolygon(aUnitOutline
),
72 getSdrLFSTAttribute().getFill(),
73 getSdrLFSTAttribute().getFillFloatTransGradient()));
77 if(getSdrLFSTAttribute().getLine().isDefault())
79 // create invisible line for HitTest/BoundRect
80 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
81 createHiddenGeometryPrimitives2D(
83 basegfx::B2DPolyPolygon(aUnitOutline
),
86 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
87 createHiddenGeometryPrimitives2D(
89 basegfx::B2DPolyPolygon(getTail()),
94 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
95 createPolygonLinePrimitive(
98 getSdrLFSTAttribute().getLine(),
99 attribute::SdrLineStartEndAttribute()));
101 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
102 createPolygonLinePrimitive(
105 getSdrLFSTAttribute().getLine(),
106 getSdrLFSTAttribute().getLineStartEnd()));
110 if(!getSdrLFSTAttribute().getText().isDefault())
112 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
114 basegfx::B2DPolyPolygon(aUnitOutline
),
116 getSdrLFSTAttribute().getText(),
117 getSdrLFSTAttribute().getLine(),
124 if(!getSdrLFSTAttribute().getShadow().isDefault())
126 aRetval
= createEmbeddedShadowPrimitive(aRetval
, getSdrLFSTAttribute().getShadow());
132 SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
133 const basegfx::B2DHomMatrix
& rTransform
,
134 const attribute::SdrLineFillShadowTextAttribute
& rSdrLFSTAttribute
,
135 const basegfx::B2DPolygon
& rTail
,
136 double fCornerRadiusX
,
137 double fCornerRadiusY
)
138 : BufferedDecompositionPrimitive2D(),
139 maTransform(rTransform
),
140 maSdrLFSTAttribute(rSdrLFSTAttribute
),
142 mfCornerRadiusX(fCornerRadiusX
),
143 mfCornerRadiusY(fCornerRadiusY
)
145 // transform maTail to unit polygon
146 if(getTail().count())
148 basegfx::B2DHomMatrix
aInverse(getTransform());
150 maTail
.transform(aInverse
);
154 bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
156 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive
))
158 const SdrCaptionPrimitive2D
& rCompare
= (SdrCaptionPrimitive2D
&)rPrimitive
;
160 return (getCornerRadiusX() == rCompare
.getCornerRadiusX()
161 && getCornerRadiusY() == rCompare
.getCornerRadiusY()
162 && getTail() == rCompare
.getTail()
163 && getTransform() == rCompare
.getTransform()
164 && getSdrLFSTAttribute() == rCompare
.getSdrLFSTAttribute());
171 ImplPrimitrive2DIDBlock(SdrCaptionPrimitive2D
, PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D
)
173 } // end of namespace primitive2d
174 } // end of namespace drawinglayer
176 //////////////////////////////////////////////////////////////////////////////
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */