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>
27 #include <basegfx/polygon/b2dpolypolygon.hxx>
30 using namespace com::sun::star
;
33 namespace drawinglayer
37 void SdrRectanglePrimitive2D::create2DDecomposition(Primitive2DContainer
& rContainer
, const geometry::ViewInformation2D
& /*aViewInformation*/) const
39 Primitive2DContainer aRetval
;
41 // create unit outline polygon
42 const basegfx::B2DPolygon
aUnitOutline(basegfx::utils::createPolygonFromRect(
43 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
48 if(!getSdrLFSTAttribute().getFill().isDefault())
50 basegfx::B2DPolyPolygon
aTransformed(aUnitOutline
);
52 aTransformed
.transform(getTransform());
54 createPolyPolygonFillPrimitive(
56 getSdrLFSTAttribute().getFill(),
57 getSdrLFSTAttribute().getFillFloatTransGradient()));
59 else if(getForceFillForHitTest())
61 // if no fill and it's a text frame, create a fill for HitTest and
64 createHiddenGeometryPrimitives2D(
66 basegfx::B2DPolyPolygon(aUnitOutline
),
71 if(!getSdrLFSTAttribute().getLine().isDefault())
73 basegfx::B2DPolygon
aTransformed(aUnitOutline
);
75 aTransformed
.transform(getTransform());
77 createPolygonLinePrimitive(
79 getSdrLFSTAttribute().getLine(),
80 attribute::SdrLineStartEndAttribute()));
82 else if(!getForceFillForHitTest())
84 // if initially no line is defined and it's not a text frame, create
85 // a line for HitTest and BoundRect
87 createHiddenGeometryPrimitives2D(
89 basegfx::B2DPolyPolygon(aUnitOutline
),
94 if(!getSdrLFSTAttribute().getText().isDefault())
98 basegfx::B2DPolyPolygon(aUnitOutline
),
100 getSdrLFSTAttribute().getText(),
101 getSdrLFSTAttribute().getLine(),
107 if(!getSdrLFSTAttribute().getShadow().isDefault())
109 aRetval
= createEmbeddedShadowPrimitive(
111 getSdrLFSTAttribute().getShadow());
114 rContainer
.insert(rContainer
.end(), aRetval
.begin(), aRetval
.end());
117 SdrRectanglePrimitive2D::SdrRectanglePrimitive2D(
118 const basegfx::B2DHomMatrix
& rTransform
,
119 const attribute::SdrLineFillShadowTextAttribute
& rSdrLFSTAttribute
,
120 double fCornerRadiusX
,
121 double fCornerRadiusY
,
122 bool bForceFillForHitTest
)
123 : BufferedDecompositionPrimitive2D(),
124 maTransform(rTransform
),
125 maSdrLFSTAttribute(rSdrLFSTAttribute
),
126 mfCornerRadiusX(fCornerRadiusX
),
127 mfCornerRadiusY(fCornerRadiusY
),
128 mbForceFillForHitTest(bForceFillForHitTest
)
132 bool SdrRectanglePrimitive2D::operator==(const BasePrimitive2D
& rPrimitive
) const
134 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive
))
136 const SdrRectanglePrimitive2D
& rCompare
= static_cast<const SdrRectanglePrimitive2D
&>(rPrimitive
);
138 return (getCornerRadiusX() == rCompare
.getCornerRadiusX()
139 && getCornerRadiusY() == rCompare
.getCornerRadiusY()
140 && getTransform() == rCompare
.getTransform()
141 && getSdrLFSTAttribute() == rCompare
.getSdrLFSTAttribute()
142 && getForceFillForHitTest() == rCompare
.getForceFillForHitTest());
149 ImplPrimitive2DIDBlock(SdrRectanglePrimitive2D
, PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D
)
151 } // end of namespace primitive2d
152 } // end of namespace drawinglayer
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */