LibreOffice Module svx (master)  1
sdrcaptionprimitive2d.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 
26 
27 
28 using namespace com::sun::star;
29 
30 
32 {
33  void SdrCaptionPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*aViewInformation*/) const
34  {
35  Primitive2DContainer aRetval;
36 
37  // create unit outline polygon
39  basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
40  getCornerRadiusX(),
41  getCornerRadiusY()));
42 
43  // add fill
44  if(getSdrLFSTAttribute().getFill().isDefault())
45  {
46  // create invisible fill for HitTest
47  aRetval.push_back(
49  true,
50  basegfx::B2DPolyPolygon(aUnitOutline),
51  getTransform()));
52  }
53  else
54  {
55  basegfx::B2DPolyPolygon aTransformed(aUnitOutline);
56 
57  aTransformed.transform(getTransform());
58  aRetval.push_back(
60  aTransformed,
61  getSdrLFSTAttribute().getFill(),
62  getSdrLFSTAttribute().getFillFloatTransGradient()));
63  }
64 
65  // add line
66  if(getSdrLFSTAttribute().getLine().isDefault())
67  {
68  // create invisible line for HitTest/BoundRect
69  aRetval.push_back(
71  false,
72  basegfx::B2DPolyPolygon(aUnitOutline),
73  getTransform()));
74 
75  aRetval.push_back(
77  false,
78  basegfx::B2DPolyPolygon(getTail()),
79  {}));
80  }
81  else
82  {
83  basegfx::B2DPolygon aTransformed(aUnitOutline);
84 
85  aTransformed.transform(getTransform());
86  aRetval.push_back(
88  aTransformed,
89  getSdrLFSTAttribute().getLine(),
91 
92  aRetval.push_back(
94  getTail(),
95  getSdrLFSTAttribute().getLine(),
96  getSdrLFSTAttribute().getLineStartEnd()));
97  }
98 
99  // add text
100  if(!getSdrLFSTAttribute().getText().isDefault())
101  {
102  aRetval.push_back(
104  basegfx::B2DPolyPolygon(aUnitOutline),
105  getTransform(),
106  getSdrLFSTAttribute().getText(),
107  getSdrLFSTAttribute().getLine(),
108  false,
109  false));
110  }
111 
112  // add shadow
113  if(!getSdrLFSTAttribute().getShadow().isDefault())
114  {
115  aRetval = createEmbeddedShadowPrimitive(std::move(aRetval), getSdrLFSTAttribute().getShadow());
116  }
117 
118  rContainer.insert(rContainer.end(), aRetval.begin(), aRetval.end());
119  }
120 
121  SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
122  const basegfx::B2DHomMatrix& rTransform,
123  const attribute::SdrLineFillEffectsTextAttribute& rSdrLFSTAttribute,
124  const basegfx::B2DPolygon& rTail,
125  double fCornerRadiusX,
126  double fCornerRadiusY)
127  : maTransform(rTransform),
128  maSdrLFSTAttribute(rSdrLFSTAttribute),
129  maTail(rTail),
130  mfCornerRadiusX(fCornerRadiusX),
131  mfCornerRadiusY(fCornerRadiusY)
132  {
133  }
134 
136  {
137  if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
138  {
139  const SdrCaptionPrimitive2D& rCompare = static_cast<const SdrCaptionPrimitive2D&>(rPrimitive);
140 
141  return (getCornerRadiusX() == rCompare.getCornerRadiusX()
142  && getCornerRadiusY() == rCompare.getCornerRadiusY()
143  && getTail() == rCompare.getTail()
144  && getTransform() == rCompare.getTransform()
145  && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
146  }
147 
148  return false;
149  }
150 
151  // provide unique ID
153  {
155  }
156 
157 } // end of namespace
158 
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Primitive2DContainer createEmbeddedShadowPrimitive(Primitive2DContainer &&rContent, const attribute::SdrShadowAttribute &rShadow, const basegfx::B2DHomMatrix &rObjectMatrix, const Primitive2DContainer *pContentForShadow)
const ::basegfx::B2DHomMatrix & getTransform() const
basegfx::B2DHomMatrix maTransform
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
void transform(const basegfx::B2DHomMatrix &rMatrix)
const attribute::SdrLineFillEffectsTextAttribute & getSdrLFSTAttribute() const
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
virtual sal_uInt32 getPrimitive2DID() const override
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)
Primitive2DReference createHiddenGeometryPrimitives2D(const basegfx::B2DHomMatrix &rMatrix)
const ::basegfx::B2DPolygon & getTail() const
#define PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D
Primitive2DReference createPolygonLinePrimitive(const basegfx::B2DPolygon &rPolygon, const attribute::SdrLineAttribute &rLine, const attribute::SdrLineStartEndAttribute &rStroke)
Primitive2DReference createPolyPolygonFillPrimitive(const basegfx::B2DPolyPolygon &rPolyPolygon, const attribute::SdrFillAttribute &rFill, const attribute::FillGradientAttribute &rFillGradient)