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 
28 
29 using namespace com::sun::star;
30 
31 
33 {
34  void SdrRectanglePrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*aViewInformation*/) const
35  {
36  Primitive2DContainer aRetval;
37 
38  // create unit outline polygon
40  basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
41  getCornerRadiusX(),
42  getCornerRadiusY()));
43 
44  // add fill
45  if(!getSdrLFSTAttribute().getFill().isDefault())
46  {
47  basegfx::B2DPolyPolygon aTransformed(aUnitOutline);
48 
49  aTransformed.transform(getTransform());
50  aRetval.push_back(
52  aTransformed,
53  getSdrLFSTAttribute().getFill(),
54  getSdrLFSTAttribute().getFillFloatTransGradient()));
55  }
56  else if(getForceFillForHitTest())
57  {
58  // if no fill and it's a text frame, create a fill for HitTest and
59  // BoundRect fallback
60  aRetval.push_back(
62  true,
63  basegfx::B2DPolyPolygon(aUnitOutline),
64  getTransform()));
65  }
66 
67  // add line
68  if(!getSdrLFSTAttribute().getLine().isDefault())
69  {
70  basegfx::B2DPolygon aTransformed(aUnitOutline);
71 
72  aTransformed.transform(getTransform());
73  aRetval.push_back(
75  aTransformed,
76  getSdrLFSTAttribute().getLine(),
78  }
79  else if(!getForceFillForHitTest())
80  {
81  // if initially no line is defined and it's not a text frame, create
82  // a line for HitTest and BoundRect
83  aRetval.push_back(
85  false,
86  basegfx::B2DPolyPolygon(aUnitOutline),
87  getTransform()));
88  }
89 
90  // add text
91  if(!getSdrLFSTAttribute().getText().isDefault())
92  {
93  aRetval.push_back(
95  basegfx::B2DPolyPolygon(aUnitOutline),
96  getTransform(),
97  getSdrLFSTAttribute().getText(),
98  getSdrLFSTAttribute().getLine(),
99  false,
100  false));
101  }
102 
103  // add shadow
104  if(!getSdrLFSTAttribute().getShadow().isDefault())
105  {
107  std::move(aRetval),
108  getSdrLFSTAttribute().getShadow());
109  }
110 
111  rContainer.insert(rContainer.end(), aRetval.begin(), aRetval.end());
112  }
113 
114  SdrRectanglePrimitive2D::SdrRectanglePrimitive2D(
115  const basegfx::B2DHomMatrix& rTransform,
116  const attribute::SdrLineFillEffectsTextAttribute& rSdrLFSTAttribute,
117  double fCornerRadiusX,
118  double fCornerRadiusY,
119  bool bForceFillForHitTest)
120  : maTransform(rTransform),
121  maSdrLFSTAttribute(rSdrLFSTAttribute),
122  mfCornerRadiusX(fCornerRadiusX),
123  mfCornerRadiusY(fCornerRadiusY),
124  mbForceFillForHitTest(bForceFillForHitTest)
125  {
126  }
127 
129  {
130  if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
131  {
132  const SdrRectanglePrimitive2D& rCompare = static_cast<const SdrRectanglePrimitive2D&>(rPrimitive);
133 
134  return (getCornerRadiusX() == rCompare.getCornerRadiusX()
135  && getCornerRadiusY() == rCompare.getCornerRadiusY()
136  && getTransform() == rCompare.getTransform()
137  && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute()
139  }
140 
141  return false;
142  }
143 
144  // provide unique ID
146  {
148  }
149 
150 } // end of namespace
151 
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
const basegfx::B2DHomMatrix & getTransform() const
Primitive2DContainer createEmbeddedShadowPrimitive(Primitive2DContainer &&rContent, const attribute::SdrShadowAttribute &rShadow, const basegfx::B2DHomMatrix &rObjectMatrix, const Primitive2DContainer *pContentForShadow)
basegfx::B2DHomMatrix maTransform
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
void transform(const basegfx::B2DHomMatrix &rMatrix)
Primitive2DReference createTextPrimitive(const basegfx::B2DPolyPolygon &rUnitPolyPolygon, const basegfx::B2DHomMatrix &rObjectTransform, const attribute::SdrTextAttribute &rText, const attribute::SdrLineAttribute &rStroke, bool bCellText, bool bWordWrap)
void transform(const basegfx::B2DHomMatrix &rMatrix)
const attribute::SdrLineFillEffectsTextAttribute & getSdrLFSTAttribute() const
Primitive2DReference createHiddenGeometryPrimitives2D(const basegfx::B2DHomMatrix &rMatrix)
Primitive2DReference createPolygonLinePrimitive(const basegfx::B2DPolygon &rPolygon, const attribute::SdrLineAttribute &rLine, const attribute::SdrLineStartEndAttribute &rStroke)
#define PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D
Primitive2DReference createPolyPolygonFillPrimitive(const basegfx::B2DPolyPolygon &rPolyPolygon, const attribute::SdrFillAttribute &rFill, const attribute::FillGradientAttribute &rFillGradient)