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 <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>
26 #include <basegfx/polygon/b2dpolygon.hxx>
30 using namespace com::sun::star
;
34 namespace drawinglayer
38 Primitive2DSequence
SdrRectanglePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D
& /*aViewInformation*/) const
40 Primitive2DSequence aRetval
;
42 // create unit outline polygon
43 const basegfx::B2DPolygon
aUnitOutline(basegfx::tools::createPolygonFromRect(
44 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
49 if(!getSdrLFSTAttribute().getFill().isDefault())
51 basegfx::B2DPolyPolygon
aTransformed(aUnitOutline
);
53 aTransformed
.transform(getTransform());
54 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
55 createPolyPolygonFillPrimitive(
57 getSdrLFSTAttribute().getFill(),
58 getSdrLFSTAttribute().getFillFloatTransGradient()));
60 else if(getForceFillForHitTest())
62 // if no fill and it's a text frame, create a fill for HitTest and
64 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
65 createHiddenGeometryPrimitives2D(
67 basegfx::B2DPolyPolygon(aUnitOutline
),
72 if(!getSdrLFSTAttribute().getLine().isDefault())
74 basegfx::B2DPolygon
aTransformed(aUnitOutline
);
76 aTransformed
.transform(getTransform());
77 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
78 createPolygonLinePrimitive(
80 getSdrLFSTAttribute().getLine(),
81 attribute::SdrLineStartEndAttribute()));
83 else if(!getForceFillForHitTest())
85 // if initially no line is defined and it's not a text frame, create
86 // a line for HitTest and BoundRect
87 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
88 createHiddenGeometryPrimitives2D(
90 basegfx::B2DPolyPolygon(aUnitOutline
),
95 if(!getSdrLFSTAttribute().getText().isDefault())
97 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval
,
99 basegfx::B2DPolyPolygon(aUnitOutline
),
101 getSdrLFSTAttribute().getText(),
102 getSdrLFSTAttribute().getLine(),
109 if(!getSdrLFSTAttribute().getShadow().isDefault())
111 aRetval
= createEmbeddedShadowPrimitive(
113 getSdrLFSTAttribute().getShadow());
119 SdrRectanglePrimitive2D::SdrRectanglePrimitive2D(
120 const basegfx::B2DHomMatrix
& rTransform
,
121 const attribute::SdrLineFillShadowTextAttribute
& rSdrLFSTAttribute
,
122 double fCornerRadiusX
,
123 double fCornerRadiusY
,
124 bool bForceFillForHitTest
)
125 : BufferedDecompositionPrimitive2D(),
126 maTransform(rTransform
),
127 maSdrLFSTAttribute(rSdrLFSTAttribute
),
128 mfCornerRadiusX(fCornerRadiusX
),
129 mfCornerRadiusY(fCornerRadiusY
),
130 mbForceFillForHitTest(bForceFillForHitTest
)
134 bool SdrRectanglePrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
136 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive
))
138 const SdrRectanglePrimitive2D
& rCompare
= static_cast<const SdrRectanglePrimitive2D
&>(rPrimitive
);
140 return (getCornerRadiusX() == rCompare
.getCornerRadiusX()
141 && getCornerRadiusY() == rCompare
.getCornerRadiusY()
142 && getTransform() == rCompare
.getTransform()
143 && getSdrLFSTAttribute() == rCompare
.getSdrLFSTAttribute()
144 && getForceFillForHitTest() == rCompare
.getForceFillForHitTest());
151 ImplPrimitive2DIDBlock(SdrRectanglePrimitive2D
, PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D
)
153 } // end of namespace primitive2d
154 } // end of namespace drawinglayer
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */