1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sdr/primitive2d/sdrcaptionprimitive2d.hxx>
21 #include <basegfx/polygon/b2dpolygontools.hxx>
22 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
23 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
24 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
25 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
29 using namespace com::sun::star
;
33 namespace drawinglayer
37 Primitive2DSequence
SdrCaptionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D
& /*aViewInformation*/) const
39 Primitive2DSequence aRetval
;
41 // create unit outline polygon
42 const basegfx::B2DPolygon
aUnitOutline(basegfx::tools::createPolygonFromRect(
43 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
48 if(getSdrLFSTAttribute().getFill().isDefault())
50 // create invisible fill for HitTest
51 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
52 createHiddenGeometryPrimitives2D(
54 basegfx::B2DPolyPolygon(aUnitOutline
),
59 basegfx::B2DPolyPolygon
aTransformed(aUnitOutline
);
61 aTransformed
.transform(getTransform());
62 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
63 createPolyPolygonFillPrimitive(
65 getSdrLFSTAttribute().getFill(),
66 getSdrLFSTAttribute().getFillFloatTransGradient()));
70 if(getSdrLFSTAttribute().getLine().isDefault())
72 // create invisible line for HitTest/BoundRect
73 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
74 createHiddenGeometryPrimitives2D(
76 basegfx::B2DPolyPolygon(aUnitOutline
),
79 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
80 createHiddenGeometryPrimitives2D(
82 basegfx::B2DPolyPolygon(getTail()),
87 basegfx::B2DPolygon
aTransformed(aUnitOutline
);
89 aTransformed
.transform(getTransform());
90 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
91 createPolygonLinePrimitive(
93 getSdrLFSTAttribute().getLine(),
94 attribute::SdrLineStartEndAttribute()));
96 aTransformed
= getTail();
97 aTransformed
.transform(getTransform());
98 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
99 createPolygonLinePrimitive(
101 getSdrLFSTAttribute().getLine(),
102 getSdrLFSTAttribute().getLineStartEnd()));
106 if(!getSdrLFSTAttribute().getText().isDefault())
108 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
110 basegfx::B2DPolyPolygon(aUnitOutline
),
112 getSdrLFSTAttribute().getText(),
113 getSdrLFSTAttribute().getLine(),
120 if(!getSdrLFSTAttribute().getShadow().isDefault())
122 aRetval
= createEmbeddedShadowPrimitive(aRetval
, getSdrLFSTAttribute().getShadow());
128 SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
129 const basegfx::B2DHomMatrix
& rTransform
,
130 const attribute::SdrLineFillShadowTextAttribute
& rSdrLFSTAttribute
,
131 const basegfx::B2DPolygon
& rTail
,
132 double fCornerRadiusX
,
133 double fCornerRadiusY
)
134 : BufferedDecompositionPrimitive2D(),
135 maTransform(rTransform
),
136 maSdrLFSTAttribute(rSdrLFSTAttribute
),
138 mfCornerRadiusX(fCornerRadiusX
),
139 mfCornerRadiusY(fCornerRadiusY
)
141 // transform maTail to unit polygon
142 if(getTail().count())
144 basegfx::B2DHomMatrix
aInverse(getTransform());
146 maTail
.transform(aInverse
);
150 bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
152 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive
))
154 const SdrCaptionPrimitive2D
& rCompare
= static_cast<const SdrCaptionPrimitive2D
&>(rPrimitive
);
156 return (getCornerRadiusX() == rCompare
.getCornerRadiusX()
157 && getCornerRadiusY() == rCompare
.getCornerRadiusY()
158 && getTail() == rCompare
.getTail()
159 && getTransform() == rCompare
.getTransform()
160 && getSdrLFSTAttribute() == rCompare
.getSdrLFSTAttribute());
167 ImplPrimitive2DIDBlock(SdrCaptionPrimitive2D
, PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D
)
169 } // end of namespace primitive2d
170 } // end of namespace drawinglayer
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */