Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / svx / source / sdr / primitive2d / sdrcaptionprimitive2d.cxx
blob48bcff2b034bc7cfd2a77bfc2dc1162306084309
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
44 namespace primitive2d
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),
53 getCornerRadiusX(),
54 getCornerRadiusY()));
56 // add fill
57 if(getSdrLFSTAttribute().getFill().isDefault())
59 // create invisible fill for HitTest
60 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
61 createHiddenGeometryPrimitives2D(
62 true,
63 basegfx::B2DPolyPolygon(aUnitOutline),
64 getTransform()));
66 else
68 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
69 createPolyPolygonFillPrimitive(
70 basegfx::B2DPolyPolygon(aUnitOutline),
71 getTransform(),
72 getSdrLFSTAttribute().getFill(),
73 getSdrLFSTAttribute().getFillFloatTransGradient()));
76 // add line
77 if(getSdrLFSTAttribute().getLine().isDefault())
79 // create invisible line for HitTest/BoundRect
80 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
81 createHiddenGeometryPrimitives2D(
82 false,
83 basegfx::B2DPolyPolygon(aUnitOutline),
84 getTransform()));
86 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
87 createHiddenGeometryPrimitives2D(
88 false,
89 basegfx::B2DPolyPolygon(getTail()),
90 getTransform()));
92 else
94 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
95 createPolygonLinePrimitive(
96 aUnitOutline,
97 getTransform(),
98 getSdrLFSTAttribute().getLine(),
99 attribute::SdrLineStartEndAttribute()));
101 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
102 createPolygonLinePrimitive(
103 getTail(),
104 getTransform(),
105 getSdrLFSTAttribute().getLine(),
106 getSdrLFSTAttribute().getLineStartEnd()));
109 // add text
110 if(!getSdrLFSTAttribute().getText().isDefault())
112 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
113 createTextPrimitive(
114 basegfx::B2DPolyPolygon(aUnitOutline),
115 getTransform(),
116 getSdrLFSTAttribute().getText(),
117 getSdrLFSTAttribute().getLine(),
118 false,
119 false,
120 false));
123 // add shadow
124 if(!getSdrLFSTAttribute().getShadow().isDefault())
126 aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrLFSTAttribute().getShadow());
129 return aRetval;
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),
141 maTail(rTail),
142 mfCornerRadiusX(fCornerRadiusX),
143 mfCornerRadiusY(fCornerRadiusY)
145 // transform maTail to unit polygon
146 if(getTail().count())
148 basegfx::B2DHomMatrix aInverse(getTransform());
149 aInverse.invert();
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());
167 return false;
170 // provide unique ID
171 ImplPrimitrive2DIDBlock(SdrCaptionPrimitive2D, PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D)
173 } // end of namespace primitive2d
174 } // end of namespace drawinglayer
176 //////////////////////////////////////////////////////////////////////////////
177 // eof
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */