Bump version to 6.4-15
[LibreOffice.git] / svx / source / sdr / primitive2d / sdrrectangleprimitive2d.cxx
blobb8acf23556876a0de5d96cb22810a528bf0de443
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
35 namespace primitive2d
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),
44 getCornerRadiusX(),
45 getCornerRadiusY()));
47 // add fill
48 if(!getSdrLFSTAttribute().getFill().isDefault())
50 basegfx::B2DPolyPolygon aTransformed(aUnitOutline);
52 aTransformed.transform(getTransform());
53 aRetval.push_back(
54 createPolyPolygonFillPrimitive(
55 aTransformed,
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
62 // BoundRect fallback
63 aRetval.push_back(
64 createHiddenGeometryPrimitives2D(
65 true,
66 basegfx::B2DPolyPolygon(aUnitOutline),
67 getTransform()));
70 // add line
71 if(!getSdrLFSTAttribute().getLine().isDefault())
73 basegfx::B2DPolygon aTransformed(aUnitOutline);
75 aTransformed.transform(getTransform());
76 aRetval.push_back(
77 createPolygonLinePrimitive(
78 aTransformed,
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
86 aRetval.push_back(
87 createHiddenGeometryPrimitives2D(
88 false,
89 basegfx::B2DPolyPolygon(aUnitOutline),
90 getTransform()));
93 // add text
94 if(!getSdrLFSTAttribute().getText().isDefault())
96 aRetval.push_back(
97 createTextPrimitive(
98 basegfx::B2DPolyPolygon(aUnitOutline),
99 getTransform(),
100 getSdrLFSTAttribute().getText(),
101 getSdrLFSTAttribute().getLine(),
102 false,
103 false));
106 // add shadow
107 if(!getSdrLFSTAttribute().getShadow().isDefault())
109 aRetval = createEmbeddedShadowPrimitive(
110 aRetval,
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());
145 return false;
148 // provide unique ID
149 ImplPrimitive2DIDBlock(SdrRectanglePrimitive2D, PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D)
151 } // end of namespace primitive2d
152 } // end of namespace drawinglayer
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */