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>
29 using namespace com::sun::star
;
32 namespace drawinglayer::primitive2d
34 void SdrCaptionPrimitive2D::create2DDecomposition(Primitive2DContainer
& rContainer
, const geometry::ViewInformation2D
& /*aViewInformation*/) const
36 Primitive2DContainer aRetval
;
38 // create unit outline polygon
39 const basegfx::B2DPolygon
aUnitOutline(basegfx::utils::createPolygonFromRect(
40 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
45 if(getSdrLFSTAttribute().getFill().isDefault())
47 // create invisible fill for HitTest
49 createHiddenGeometryPrimitives2D(
51 basegfx::B2DPolyPolygon(aUnitOutline
),
56 basegfx::B2DPolyPolygon
aTransformed(aUnitOutline
);
58 aTransformed
.transform(getTransform());
60 createPolyPolygonFillPrimitive(
62 getSdrLFSTAttribute().getFill(),
63 getSdrLFSTAttribute().getFillFloatTransGradient()));
67 if(getSdrLFSTAttribute().getLine().isDefault())
69 // create invisible line for HitTest/BoundRect
71 createHiddenGeometryPrimitives2D(
73 basegfx::B2DPolyPolygon(aUnitOutline
),
77 createHiddenGeometryPrimitives2D(
79 basegfx::B2DPolyPolygon(getTail()),
84 basegfx::B2DPolygon
aTransformed(aUnitOutline
);
86 aTransformed
.transform(getTransform());
88 createPolygonLinePrimitive(
90 getSdrLFSTAttribute().getLine(),
91 attribute::SdrLineStartEndAttribute()));
94 createPolygonLinePrimitive(
96 getSdrLFSTAttribute().getLine(),
97 getSdrLFSTAttribute().getLineStartEnd()));
101 if(!getSdrLFSTAttribute().getText().isDefault())
105 basegfx::B2DPolyPolygon(aUnitOutline
),
107 getSdrLFSTAttribute().getText(),
108 getSdrLFSTAttribute().getLine(),
114 if(!getSdrLFSTAttribute().getShadow().isDefault())
116 aRetval
= createEmbeddedShadowPrimitive(std::move(aRetval
), getSdrLFSTAttribute().getShadow());
119 rContainer
.append(std::move(aRetval
));
122 SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
123 basegfx::B2DHomMatrix aTransform
,
124 const attribute::SdrLineFillEffectsTextAttribute
& rSdrLFSTAttribute
,
125 basegfx::B2DPolygon aTail
,
126 double fCornerRadiusX
,
127 double fCornerRadiusY
)
128 : maTransform(std::move(aTransform
)),
129 maSdrLFSTAttribute(rSdrLFSTAttribute
),
130 maTail(std::move(aTail
)),
131 mfCornerRadiusX(fCornerRadiusX
),
132 mfCornerRadiusY(fCornerRadiusY
)
136 bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
138 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive
))
140 const SdrCaptionPrimitive2D
& rCompare
= static_cast<const SdrCaptionPrimitive2D
&>(rPrimitive
);
142 return (getCornerRadiusX() == rCompare
.getCornerRadiusX()
143 && getCornerRadiusY() == rCompare
.getCornerRadiusY()
144 && getTail() == rCompare
.getTail()
145 && getTransform() == rCompare
.getTransform()
146 && getSdrLFSTAttribute() == rCompare
.getSdrLFSTAttribute());
153 sal_uInt32
SdrCaptionPrimitive2D::getPrimitive2DID() const
155 return PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D
;
158 } // end of namespace
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */