cid#1606940 Check of thread-shared field evades lock acquisition
[LibreOffice.git] / svx / source / sdr / primitive2d / sdrcaptionprimitive2d.cxx
blob531a508e2209b6743f276ebefb60119ea787df10
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/sdrcaptionprimitive2d.hxx>
21 #include <basegfx/polygon/b2dpolypolygon.hxx>
22 #include <basegfx/polygon/b2dpolygontools.hxx>
23 #include <sdr/primitive2d/sdrdecompositiontools.hxx>
24 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
25 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
26 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
27 #include <utility>
30 using namespace com::sun::star;
33 namespace drawinglayer::primitive2d
35 Primitive2DReference SdrCaptionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
37 Primitive2DContainer aRetval;
39 // create unit outline polygon
40 const basegfx::B2DPolygon aUnitOutline(basegfx::utils::createPolygonFromRect(
41 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
42 getCornerRadiusX(),
43 getCornerRadiusY()));
45 // add fill
46 if(getSdrLFSTAttribute().getFill().isDefault())
48 // create invisible fill for HitTest
49 aRetval.push_back(
50 createHiddenGeometryPrimitives2D(
51 true,
52 basegfx::B2DPolyPolygon(aUnitOutline),
53 getTransform()));
55 else
57 basegfx::B2DPolyPolygon aTransformed(aUnitOutline);
59 aTransformed.transform(getTransform());
60 aRetval.push_back(
61 createPolyPolygonFillPrimitive(
62 aTransformed,
63 getSdrLFSTAttribute().getFill(),
64 getSdrLFSTAttribute().getFillFloatTransGradient()));
67 // add line
68 if(getSdrLFSTAttribute().getLine().isDefault())
70 // create invisible line for HitTest/BoundRect
71 aRetval.push_back(
72 createHiddenGeometryPrimitives2D(
73 false,
74 basegfx::B2DPolyPolygon(aUnitOutline),
75 getTransform()));
77 aRetval.push_back(
78 createHiddenGeometryPrimitives2D(
79 false,
80 basegfx::B2DPolyPolygon(getTail()),
81 {}));
83 else
85 basegfx::B2DPolygon aTransformed(aUnitOutline);
87 aTransformed.transform(getTransform());
88 aRetval.push_back(
89 createPolygonLinePrimitive(
90 aTransformed,
91 getSdrLFSTAttribute().getLine(),
92 attribute::SdrLineStartEndAttribute()));
94 aRetval.push_back(
95 createPolygonLinePrimitive(
96 getTail(),
97 getSdrLFSTAttribute().getLine(),
98 getSdrLFSTAttribute().getLineStartEnd()));
101 // add text
102 if(!getSdrLFSTAttribute().getText().isDefault())
104 aRetval.push_back(
105 createTextPrimitive(
106 basegfx::B2DPolyPolygon(aUnitOutline),
107 getTransform(),
108 getSdrLFSTAttribute().getText(),
109 getSdrLFSTAttribute().getLine(),
110 false,
111 false));
114 // add shadow
115 if(!getSdrLFSTAttribute().getShadow().isDefault())
117 aRetval = createEmbeddedShadowPrimitive(std::move(aRetval), getSdrLFSTAttribute().getShadow());
120 return new GroupPrimitive2D(std::move(aRetval));
123 SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
124 basegfx::B2DHomMatrix aTransform,
125 const attribute::SdrLineFillEffectsTextAttribute& rSdrLFSTAttribute,
126 basegfx::B2DPolygon aTail,
127 double fCornerRadiusX,
128 double fCornerRadiusY)
129 : maTransform(std::move(aTransform)),
130 maSdrLFSTAttribute(rSdrLFSTAttribute),
131 maTail(std::move(aTail)),
132 mfCornerRadiusX(fCornerRadiusX),
133 mfCornerRadiusY(fCornerRadiusY)
137 bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
139 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
141 const SdrCaptionPrimitive2D& rCompare = static_cast<const SdrCaptionPrimitive2D&>(rPrimitive);
143 return (getCornerRadiusX() == rCompare.getCornerRadiusX()
144 && getCornerRadiusY() == rCompare.getCornerRadiusY()
145 && getTail() == rCompare.getTail()
146 && getTransform() == rCompare.getTransform()
147 && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
150 return false;
153 // provide unique ID
154 sal_uInt32 SdrCaptionPrimitive2D::getPrimitive2DID() const
156 return PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D;
159 } // end of namespace
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */