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/b2dpolypolygon.hxx>
22 #include <basegfx/polygon/b2dpolygontools.hxx>
23 #include <sdr/primitive2d/sdrdecompositiontools.hxx>
24 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
25 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
26 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
30 using namespace com::sun::star
;
33 namespace drawinglayer::primitive2d
35 Primitive2DReference
SdrCaptionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D
& /*aViewInformation*/) const
37 Primitive2DContainer aRetval
;
39 // create unit outline polygon
40 const basegfx::B2DPolygon
aUnitOutline(basegfx::utils::createPolygonFromRect(
41 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
46 if(getSdrLFSTAttribute().getFill().isDefault())
48 // create invisible fill for HitTest
50 createHiddenGeometryPrimitives2D(
52 basegfx::B2DPolyPolygon(aUnitOutline
),
57 basegfx::B2DPolyPolygon
aTransformed(aUnitOutline
);
59 aTransformed
.transform(getTransform());
61 createPolyPolygonFillPrimitive(
63 getSdrLFSTAttribute().getFill(),
64 getSdrLFSTAttribute().getFillFloatTransGradient()));
68 if(getSdrLFSTAttribute().getLine().isDefault())
70 // create invisible line for HitTest/BoundRect
72 createHiddenGeometryPrimitives2D(
74 basegfx::B2DPolyPolygon(aUnitOutline
),
78 createHiddenGeometryPrimitives2D(
80 basegfx::B2DPolyPolygon(getTail()),
85 basegfx::B2DPolygon
aTransformed(aUnitOutline
);
87 aTransformed
.transform(getTransform());
89 createPolygonLinePrimitive(
91 getSdrLFSTAttribute().getLine(),
92 attribute::SdrLineStartEndAttribute()));
95 createPolygonLinePrimitive(
97 getSdrLFSTAttribute().getLine(),
98 getSdrLFSTAttribute().getLineStartEnd()));
102 if(!getSdrLFSTAttribute().getText().isDefault())
106 basegfx::B2DPolyPolygon(aUnitOutline
),
108 getSdrLFSTAttribute().getText(),
109 getSdrLFSTAttribute().getLine(),
115 if(!getSdrLFSTAttribute().getShadow().isDefault())
117 aRetval
= createEmbeddedShadowPrimitive(std::move(aRetval
), getSdrLFSTAttribute().getShadow());
120 return new GroupPrimitive2D(std::move(aRetval
));
123 SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
124 basegfx::B2DHomMatrix aTransform
,
125 const attribute::SdrLineFillEffectsTextAttribute
& rSdrLFSTAttribute
,
126 basegfx::B2DPolygon aTail
,
127 double fCornerRadiusX
,
128 double fCornerRadiusY
)
129 : maTransform(std::move(aTransform
)),
130 maSdrLFSTAttribute(rSdrLFSTAttribute
),
131 maTail(std::move(aTail
)),
132 mfCornerRadiusX(fCornerRadiusX
),
133 mfCornerRadiusY(fCornerRadiusY
)
137 bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
139 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive
))
141 const SdrCaptionPrimitive2D
& rCompare
= static_cast<const SdrCaptionPrimitive2D
&>(rPrimitive
);
143 return (getCornerRadiusX() == rCompare
.getCornerRadiusX()
144 && getCornerRadiusY() == rCompare
.getCornerRadiusY()
145 && getTail() == rCompare
.getTail()
146 && getTransform() == rCompare
.getTransform()
147 && getSdrLFSTAttribute() == rCompare
.getSdrLFSTAttribute());
154 sal_uInt32
SdrCaptionPrimitive2D::getPrimitive2DID() const
156 return PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D
;
159 } // end of namespace
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */