bump product version to 7.6.3.2-android
[LibreOffice.git] / svx / source / sdr / primitive2d / sdrcaptionprimitive2d.cxx
blob51164210a5cc7727566b0480d827377ae8ece057
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 <utility>
29 using namespace com::sun::star;
32 namespace drawinglayer::primitive2d
34 void SdrCaptionPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*aViewInformation*/) const
36 Primitive2DContainer aRetval;
38 // create unit outline polygon
39 const basegfx::B2DPolygon aUnitOutline(basegfx::utils::createPolygonFromRect(
40 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
41 getCornerRadiusX(),
42 getCornerRadiusY()));
44 // add fill
45 if(getSdrLFSTAttribute().getFill().isDefault())
47 // create invisible fill for HitTest
48 aRetval.push_back(
49 createHiddenGeometryPrimitives2D(
50 true,
51 basegfx::B2DPolyPolygon(aUnitOutline),
52 getTransform()));
54 else
56 basegfx::B2DPolyPolygon aTransformed(aUnitOutline);
58 aTransformed.transform(getTransform());
59 aRetval.push_back(
60 createPolyPolygonFillPrimitive(
61 aTransformed,
62 getSdrLFSTAttribute().getFill(),
63 getSdrLFSTAttribute().getFillFloatTransGradient()));
66 // add line
67 if(getSdrLFSTAttribute().getLine().isDefault())
69 // create invisible line for HitTest/BoundRect
70 aRetval.push_back(
71 createHiddenGeometryPrimitives2D(
72 false,
73 basegfx::B2DPolyPolygon(aUnitOutline),
74 getTransform()));
76 aRetval.push_back(
77 createHiddenGeometryPrimitives2D(
78 false,
79 basegfx::B2DPolyPolygon(getTail()),
80 {}));
82 else
84 basegfx::B2DPolygon aTransformed(aUnitOutline);
86 aTransformed.transform(getTransform());
87 aRetval.push_back(
88 createPolygonLinePrimitive(
89 aTransformed,
90 getSdrLFSTAttribute().getLine(),
91 attribute::SdrLineStartEndAttribute()));
93 aRetval.push_back(
94 createPolygonLinePrimitive(
95 getTail(),
96 getSdrLFSTAttribute().getLine(),
97 getSdrLFSTAttribute().getLineStartEnd()));
100 // add text
101 if(!getSdrLFSTAttribute().getText().isDefault())
103 aRetval.push_back(
104 createTextPrimitive(
105 basegfx::B2DPolyPolygon(aUnitOutline),
106 getTransform(),
107 getSdrLFSTAttribute().getText(),
108 getSdrLFSTAttribute().getLine(),
109 false,
110 false));
113 // add shadow
114 if(!getSdrLFSTAttribute().getShadow().isDefault())
116 aRetval = createEmbeddedShadowPrimitive(std::move(aRetval), getSdrLFSTAttribute().getShadow());
119 rContainer.append(std::move(aRetval));
122 SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
123 basegfx::B2DHomMatrix aTransform,
124 const attribute::SdrLineFillEffectsTextAttribute& rSdrLFSTAttribute,
125 basegfx::B2DPolygon aTail,
126 double fCornerRadiusX,
127 double fCornerRadiusY)
128 : maTransform(std::move(aTransform)),
129 maSdrLFSTAttribute(rSdrLFSTAttribute),
130 maTail(std::move(aTail)),
131 mfCornerRadiusX(fCornerRadiusX),
132 mfCornerRadiusY(fCornerRadiusY)
136 bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
138 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
140 const SdrCaptionPrimitive2D& rCompare = static_cast<const SdrCaptionPrimitive2D&>(rPrimitive);
142 return (getCornerRadiusX() == rCompare.getCornerRadiusX()
143 && getCornerRadiusY() == rCompare.getCornerRadiusY()
144 && getTail() == rCompare.getTail()
145 && getTransform() == rCompare.getTransform()
146 && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
149 return false;
152 // provide unique ID
153 sal_uInt32 SdrCaptionPrimitive2D::getPrimitive2DID() const
155 return PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D;
158 } // end of namespace
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */