LibreOffice Module svx (master) 1
sdrrectangleprimitive2d.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
27#include <utility>
28
29
30using namespace com::sun::star;
31
32
34{
36 {
38
39 // create unit outline polygon
41 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
44
45 // add fill
46 if(!getSdrLFSTAttribute().getFill().isDefault())
47 {
48 basegfx::B2DPolyPolygon aTransformed(aUnitOutline);
49
50 aTransformed.transform(getTransform());
51 aRetval.push_back(
53 aTransformed,
54 getSdrLFSTAttribute().getFill(),
55 getSdrLFSTAttribute().getFillFloatTransGradient()));
56 }
57 else if(getForceFillForHitTest())
58 {
59 // if no fill and it's a text frame, create a fill for HitTest and
60 // BoundRect fallback
61 aRetval.push_back(
63 true,
64 basegfx::B2DPolyPolygon(aUnitOutline),
65 getTransform()));
66 }
67
68 // add line
69 if(!getSdrLFSTAttribute().getLine().isDefault())
70 {
71 basegfx::B2DPolygon aTransformed(aUnitOutline);
72
73 aTransformed.transform(getTransform());
74 aRetval.push_back(
76 aTransformed,
77 getSdrLFSTAttribute().getLine(),
79 }
80 else if(!getForceFillForHitTest())
81 {
82 // if initially no line is defined and it's not a text frame, create
83 // a line for HitTest and BoundRect
84 aRetval.push_back(
86 false,
87 basegfx::B2DPolyPolygon(aUnitOutline),
88 getTransform()));
89 }
90
91 // add text
92 if(!getSdrLFSTAttribute().getText().isDefault())
93 {
94 aRetval.push_back(
96 basegfx::B2DPolyPolygon(aUnitOutline),
98 getSdrLFSTAttribute().getText(),
99 getSdrLFSTAttribute().getLine(),
100 false,
101 false));
102 }
103
104 // add shadow
105 if(!getSdrLFSTAttribute().getShadow().isDefault())
106 {
108 std::move(aRetval),
109 getSdrLFSTAttribute().getShadow());
110 }
111
112 rContainer.append(std::move(aRetval));
113 }
114
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)
126 {
127 }
128
130 {
131 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
132 {
133 const SdrRectanglePrimitive2D& rCompare = static_cast<const SdrRectanglePrimitive2D&>(rPrimitive);
134
135 return (getCornerRadiusX() == rCompare.getCornerRadiusX()
136 && getCornerRadiusY() == rCompare.getCornerRadiusY()
137 && getTransform() == rCompare.getTransform()
140 }
141
142 return false;
143 }
144
145 // provide unique ID
147 {
149 }
150
151} // end of namespace
152
153/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void transform(const basegfx::B2DHomMatrix &rMatrix)
void transform(const basegfx::B2DHomMatrix &rMatrix)
void append(const Primitive2DReference &)
SdrRectanglePrimitive2D(basegfx::B2DHomMatrix aTransform, const attribute::SdrLineFillEffectsTextAttribute &rSdrLFSTAttribute, double fCornerRadiusX, double fCornerRadiusY, bool bForceFillForHitTest)
virtual void create2DDecomposition(Primitive2DContainer &rContainer, const geometry::ViewInformation2D &aViewInformation) const override
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
const attribute::SdrLineFillEffectsTextAttribute & getSdrLFSTAttribute() const
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
Primitive2DReference createHiddenGeometryPrimitives2D(const basegfx::B2DHomMatrix &rMatrix)
Primitive2DContainer createEmbeddedShadowPrimitive(Primitive2DContainer &&rContent, const attribute::SdrShadowAttribute &rShadow, const basegfx::B2DHomMatrix &rObjectMatrix, const Primitive2DContainer *pContentForShadow)
Primitive2DReference createPolygonLinePrimitive(const basegfx::B2DPolygon &rPolygon, const attribute::SdrLineAttribute &rLine, const attribute::SdrLineStartEndAttribute &rStroke)
Primitive2DReference createTextPrimitive(const basegfx::B2DPolyPolygon &rUnitPolyPolygon, const basegfx::B2DHomMatrix &rObjectTransform, const attribute::SdrTextAttribute &rText, const attribute::SdrLineAttribute &rStroke, bool bCellText, bool bWordWrap)
Primitive2DReference createPolyPolygonFillPrimitive(const basegfx::B2DPolyPolygon &rPolyPolygon, const attribute::SdrFillAttribute &rFill, const attribute::FillGradientAttribute &rFillGradient)
#define PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D
basegfx::B2DHomMatrix maTransform