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/sdrrectangleprimitive2d.hxx>
21 #include <basegfx/polygon/b2dpolygontools.hxx>
22 #include <sdr/primitive2d/sdrdecompositiontools.hxx>
23 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
24 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
25 #include <basegfx/polygon/b2dpolygon.hxx>
26 #include <basegfx/polygon/b2dpolypolygon.hxx>
30 using namespace com::sun::star
;
33 namespace drawinglayer::primitive2d
35 void SdrRectanglePrimitive2D::create2DDecomposition(Primitive2DContainer
& rContainer
, 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 basegfx::B2DPolyPolygon
aTransformed(aUnitOutline
);
50 aTransformed
.transform(getTransform());
52 createPolyPolygonFillPrimitive(
54 getSdrLFSTAttribute().getFill(),
55 getSdrLFSTAttribute().getFillFloatTransGradient()));
57 else if(getForceFillForHitTest())
59 // if no fill and it's a text frame, create a fill for HitTest and
62 createHiddenGeometryPrimitives2D(
64 basegfx::B2DPolyPolygon(aUnitOutline
),
69 if(!getSdrLFSTAttribute().getLine().isDefault())
71 basegfx::B2DPolygon
aTransformed(aUnitOutline
);
73 aTransformed
.transform(getTransform());
75 createPolygonLinePrimitive(
77 getSdrLFSTAttribute().getLine(),
78 attribute::SdrLineStartEndAttribute()));
80 else if(!getForceFillForHitTest())
82 // if initially no line is defined and it's not a text frame, create
83 // a line for HitTest and BoundRect
85 createHiddenGeometryPrimitives2D(
87 basegfx::B2DPolyPolygon(aUnitOutline
),
92 if(!getSdrLFSTAttribute().getText().isDefault())
96 basegfx::B2DPolyPolygon(aUnitOutline
),
98 getSdrLFSTAttribute().getText(),
99 getSdrLFSTAttribute().getLine(),
105 if(!getSdrLFSTAttribute().getShadow().isDefault())
107 aRetval
= createEmbeddedShadowPrimitive(
109 getSdrLFSTAttribute().getShadow());
112 rContainer
.append(std::move(aRetval
));
115 SdrRectanglePrimitive2D::SdrRectanglePrimitive2D(
116 basegfx::B2DHomMatrix aTransform
,
117 const attribute::SdrLineFillEffectsTextAttribute
& rSdrLFSTAttribute
,
118 double fCornerRadiusX
,
119 double fCornerRadiusY
,
120 bool bForceFillForHitTest
)
121 : maTransform(std::move(aTransform
)),
122 maSdrLFSTAttribute(rSdrLFSTAttribute
),
123 mfCornerRadiusX(fCornerRadiusX
),
124 mfCornerRadiusY(fCornerRadiusY
),
125 mbForceFillForHitTest(bForceFillForHitTest
)
129 bool SdrRectanglePrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
131 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive
))
133 const SdrRectanglePrimitive2D
& rCompare
= static_cast<const SdrRectanglePrimitive2D
&>(rPrimitive
);
135 return (getCornerRadiusX() == rCompare
.getCornerRadiusX()
136 && getCornerRadiusY() == rCompare
.getCornerRadiusY()
137 && getTransform() == rCompare
.getTransform()
138 && getSdrLFSTAttribute() == rCompare
.getSdrLFSTAttribute()
139 && getForceFillForHitTest() == rCompare
.getForceFillForHitTest());
146 sal_uInt32
SdrRectanglePrimitive2D::getPrimitive2DID() const
148 return PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D
;
151 } // end of namespace
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */