Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx
Line
Count
Source
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
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>
28
29
30
using namespace com::sun::star;
31
32
33
namespace drawinglayer::primitive2d
34
{
35
        Primitive2DReference SdrCaptionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
36
0
        {
37
0
            Primitive2DContainer aRetval;
38
39
            // create unit outline polygon
40
0
            const basegfx::B2DPolygon aUnitOutline(basegfx::utils::createPolygonFromRect(
41
0
                basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
42
0
                getCornerRadiusX(),
43
0
                getCornerRadiusY()));
44
45
            // add fill
46
0
            if(getSdrLFSTAttribute().getFill().isDefault())
47
0
            {
48
                // create invisible fill for HitTest
49
0
                aRetval.push_back(
50
0
                    createHiddenGeometryPrimitives2D(
51
0
                        true,
52
0
                        basegfx::B2DPolyPolygon(aUnitOutline),
53
0
                        getTransform()));
54
0
            }
55
0
            else
56
0
            {
57
0
                basegfx::B2DPolyPolygon aTransformed(aUnitOutline);
58
59
0
                aTransformed.transform(getTransform());
60
0
                aRetval.push_back(
61
0
                    createPolyPolygonFillPrimitive(
62
0
                        aTransformed,
63
0
                        getSdrLFSTAttribute().getFill(),
64
0
                        getSdrLFSTAttribute().getFillFloatTransGradient()));
65
0
            }
66
67
            // add line
68
0
            if(getSdrLFSTAttribute().getLine().isDefault())
69
0
            {
70
                // create invisible line for HitTest/BoundRect
71
0
                aRetval.push_back(
72
0
                    createHiddenGeometryPrimitives2D(
73
0
                        false,
74
0
                        basegfx::B2DPolyPolygon(aUnitOutline),
75
0
                        getTransform()));
76
77
0
                aRetval.push_back(
78
0
                    createHiddenGeometryPrimitives2D(
79
0
                        false,
80
0
                        basegfx::B2DPolyPolygon(getTail()),
81
0
                        {}));
82
0
            }
83
0
            else
84
0
            {
85
0
                basegfx::B2DPolygon aTransformed(aUnitOutline);
86
87
0
                aTransformed.transform(getTransform());
88
0
                aRetval.push_back(
89
0
                    createPolygonLinePrimitive(
90
0
                        aTransformed,
91
0
                        getSdrLFSTAttribute().getLine(),
92
0
                        attribute::SdrLineStartEndAttribute()));
93
94
0
                aRetval.push_back(
95
0
                    createPolygonLinePrimitive(
96
0
                        getTail(),
97
0
                        getSdrLFSTAttribute().getLine(),
98
0
                        getSdrLFSTAttribute().getLineStartEnd()));
99
0
            }
100
101
            // add text
102
0
            if(!getSdrLFSTAttribute().getText().isDefault())
103
0
            {
104
0
                aRetval.push_back(
105
0
                    createTextPrimitive(
106
0
                        basegfx::B2DPolyPolygon(aUnitOutline),
107
0
                        getTransform(),
108
0
                        getSdrLFSTAttribute().getText(),
109
0
                        getSdrLFSTAttribute().getLine(),
110
0
                        false,
111
0
                        false));
112
0
            }
113
114
            // add shadow
115
0
            if(!getSdrLFSTAttribute().getShadow().isDefault())
116
0
            {
117
0
                aRetval = createEmbeddedShadowPrimitive(std::move(aRetval), getSdrLFSTAttribute().getShadow());
118
0
            }
119
120
0
            return new GroupPrimitive2D(std::move(aRetval));
121
0
        }
122
123
        SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
124
            basegfx::B2DHomMatrix aTransform,
125
            const attribute::SdrLineFillEffectsTextAttribute& rSdrLFSTAttribute,
126
            basegfx::B2DPolygon aTail,
127
            double fCornerRadiusX,
128
            double fCornerRadiusY)
129
0
        :   maTransform(std::move(aTransform)),
130
0
            maSdrLFSTAttribute(rSdrLFSTAttribute),
131
0
            maTail(std::move(aTail)),
132
0
            mfCornerRadiusX(fCornerRadiusX),
133
0
            mfCornerRadiusY(fCornerRadiusY)
134
0
        {
135
0
        }
136
137
        bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
138
0
        {
139
0
            if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
140
0
            {
141
0
                const SdrCaptionPrimitive2D& rCompare = static_cast<const SdrCaptionPrimitive2D&>(rPrimitive);
142
143
0
                return (getCornerRadiusX() == rCompare.getCornerRadiusX()
144
0
                    && getCornerRadiusY() == rCompare.getCornerRadiusY()
145
0
                    && getTail() == rCompare.getTail()
146
0
                    && getTransform() == rCompare.getTransform()
147
0
                    && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
148
0
            }
149
150
0
            return false;
151
0
        }
152
153
        // provide unique ID
154
        sal_uInt32 SdrCaptionPrimitive2D::getPrimitive2DID() const
155
0
        {
156
0
            return PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D;
157
0
        }
158
159
} // end of namespace
160
161
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */