LibreOffice Module svx (master)  1
sdrpathprimitive2d.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 
24 
25 
26 using namespace com::sun::star;
27 
28 
30 {
31  void SdrPathPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*aViewInformation*/) const
32  {
33  Primitive2DContainer aRetval;
34 
35  // add fill
36  if(!getSdrLFSTAttribute().getFill().isDefault()
37  && getUnitPolyPolygon().isClosed())
38  {
39  // #i108255# no need to use correctOrientations here; target is
40  // straight visualisation
41  basegfx::B2DPolyPolygon aTransformed(getUnitPolyPolygon());
42  aTransformed.transform(getTransform());
43 
44  // OperationSmiley: Check if a UnitDefinitionPolyPolygon is set
45  if(getUnitDefinitionPolyPolygon().count()
46  && getUnitDefinitionPolyPolygon() != getUnitPolyPolygon())
47  {
48  // if yes, use the B2DRange of it's transformed form
49  basegfx::B2DPolyPolygon aTransformedDefinition(getUnitDefinitionPolyPolygon());
50  aTransformedDefinition.transform(getTransform());
51 
52  aRetval.push_back(
54  aTransformed,
55  aTransformedDefinition.getB2DRange(),
56  getSdrLFSTAttribute().getFill(),
57  getSdrLFSTAttribute().getFillFloatTransGradient()));
58  }
59  else
60  {
61  aRetval.push_back(
63  aTransformed,
64  getSdrLFSTAttribute().getFill(),
65  getSdrLFSTAttribute().getFillFloatTransGradient()));
66  }
67  }
68 
69  // add line
70  if(getSdrLFSTAttribute().getLine().isDefault())
71  {
72  // if initially no line is defined, create one for HitTest and BoundRect
73  aRetval.push_back(
75  false,
76  getUnitPolyPolygon(),
77  getTransform()));
78  }
79  else
80  {
81  Primitive2DContainer aTemp(getUnitPolyPolygon().count());
82 
83  for(sal_uInt32 a(0); a < getUnitPolyPolygon().count(); a++)
84  {
85  basegfx::B2DPolygon aTransformed(getUnitPolyPolygon().getB2DPolygon(a));
86 
87  aTransformed.transform(getTransform());
89  aTransformed,
90  getSdrLFSTAttribute().getLine(),
91  getSdrLFSTAttribute().getLineStartEnd());
92  }
93 
94  aRetval.append(aTemp);
95  }
96 
97  // add text
98  if(!getSdrLFSTAttribute().getText().isDefault())
99  {
100  aRetval.push_back(
102  getUnitPolyPolygon(),
103  getTransform(),
104  getSdrLFSTAttribute().getText(),
105  getSdrLFSTAttribute().getLine(),
106  false,
107  false));
108  }
109 
110  // add shadow
111  if(!getSdrLFSTAttribute().getShadow().isDefault())
112  {
114  aRetval,
115  getSdrLFSTAttribute().getShadow());
116  }
117 
118  rContainer.insert(rContainer.end(), aRetval.begin(), aRetval.end());
119  }
120 
121  SdrPathPrimitive2D::SdrPathPrimitive2D(
122  const basegfx::B2DHomMatrix& rTransform,
123  const attribute::SdrLineFillEffectsTextAttribute& rSdrLFSTAttribute,
124  const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
125  const basegfx::B2DPolyPolygon& rUnitDefinitionPolyPolygon)
126  : maTransform(rTransform),
127  maSdrLFSTAttribute(rSdrLFSTAttribute),
128  maUnitPolyPolygon(rUnitPolyPolygon),
129  maUnitDefinitionPolyPolygon(rUnitDefinitionPolyPolygon)
130  {
131  }
132 
133  bool SdrPathPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
134  {
135  if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
136  {
137  const SdrPathPrimitive2D& rCompare = static_cast<const SdrPathPrimitive2D&>(rPrimitive);
138 
139  return (getUnitPolyPolygon() == rCompare.getUnitPolyPolygon()
141  && getTransform() == rCompare.getTransform()
142  && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
143  }
144 
145  return false;
146  }
147 
148  // provide unique ID
150  {
152  }
153 
154 } // end of namespace
155 
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D
const basegfx::B2DHomMatrix & getTransform() const
const basegfx::B2DPolyPolygon & getUnitDefinitionPolyPolygon() const
B2DRange getB2DRange() const
Primitive2DContainer createEmbeddedShadowPrimitive(const Primitive2DContainer &rContent, const attribute::SdrShadowAttribute &rShadow, const basegfx::B2DHomMatrix &rObjectMatrix, const Primitive2DContainer *pContentForShadow)
const basegfx::B2DPolyPolygon & getUnitPolyPolygon() const
basegfx::B2DHomMatrix maTransform
uno_Any a
void transform(const basegfx::B2DHomMatrix &rMatrix)
virtual void append(const Primitive2DReference &) 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)
const attribute::SdrLineFillEffectsTextAttribute & getSdrLFSTAttribute() const
Primitive2DReference createHiddenGeometryPrimitives2D(const basegfx::B2DHomMatrix &rMatrix)
virtual sal_uInt32 getPrimitive2DID() const override
Primitive2DReference createPolygonLinePrimitive(const basegfx::B2DPolygon &rPolygon, const attribute::SdrLineAttribute &rLine, const attribute::SdrLineStartEndAttribute &rStroke)
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
Primitive2DReference createPolyPolygonFillPrimitive(const basegfx::B2DPolyPolygon &rPolyPolygon, const attribute::SdrFillAttribute &rFill, const attribute::FillGradientAttribute &rFillGradient)