Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/drawinglayer/source/attribute/sdrshadowattribute.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 <drawinglayer/attribute/sdrshadowattribute.hxx>
21
#include <basegfx/vector/b2dvector.hxx>
22
#include <basegfx/color/bcolor.hxx>
23
#include <docmodel/theme/FormatScheme.hxx>
24
25
26
namespace drawinglayer::attribute
27
{
28
        class ImpSdrShadowAttribute
29
        {
30
        public:
31
            // shadow definitions
32
            basegfx::B2DVector                  maOffset;                   // shadow offset 1/100th mm
33
            basegfx::B2DVector                  maSize;                     // [0.0 .. 2.0]
34
            double                              mfTransparence;             // [0.0 .. 1.0], 0.0==no transp.
35
            sal_Int32                           mnBlur;                     // [0   .. 180], radius of the blur
36
            model::RectangleAlignment           meAlignment{model::RectangleAlignment::Unset}; // alignment of the shadow
37
            basegfx::BColor                     maColor;                    // color of shadow
38
39
            ImpSdrShadowAttribute(
40
                const basegfx::B2DVector& rOffset,
41
                const basegfx::B2DVector& rSize,
42
                double fTransparence,
43
                sal_Int32 nBlur,
44
                model::RectangleAlignment eAlignment,
45
                const basegfx::BColor& rColor)
46
0
            :   maOffset(rOffset),
47
0
                maSize(rSize),
48
0
                mfTransparence(fTransparence),
49
0
                mnBlur(nBlur),
50
0
                meAlignment(eAlignment),
51
0
                maColor(rColor)
52
0
            {
53
0
            }
54
55
            ImpSdrShadowAttribute()
56
4
            :   mfTransparence(0.0),
57
4
                mnBlur(0)
58
4
            {
59
4
            }
60
61
            // data read access
62
0
            const basegfx::B2DVector& getOffset() const { return maOffset; }
63
0
            const basegfx::B2DVector& getSize() const { return maSize; }
64
0
            double getTransparence() const { return mfTransparence; }
65
0
            sal_Int32 getBlur() const { return mnBlur; }
66
0
            const basegfx::BColor& getColor() const { return maColor; }
67
68
            bool operator==(const ImpSdrShadowAttribute& rCandidate) const
69
0
            {
70
0
                return (getOffset() == rCandidate.getOffset()
71
0
                    && getSize() == rCandidate.getSize()
72
0
                    && getTransparence() == rCandidate.getTransparence()
73
0
                        && getBlur() == rCandidate.getBlur()
74
0
                    && meAlignment == rCandidate.meAlignment
75
0
                    && getColor() == rCandidate.getColor());
76
0
            }
77
        };
78
79
        namespace
80
        {
81
            SdrShadowAttribute::ImplType& theGlobalDefault()
82
4.28k
            {
83
4.28k
                static SdrShadowAttribute::ImplType SINGLETON;
84
4.28k
                return SINGLETON;
85
4.28k
            }
86
        }
87
88
89
        SdrShadowAttribute::SdrShadowAttribute(
90
            const basegfx::B2DVector& rOffset,
91
            const basegfx::B2DVector& rSize,
92
            double fTransparence,
93
            sal_Int32 nBlur,
94
            model::RectangleAlignment eAlignment,
95
            const basegfx::BColor& rColor)
96
0
        :   mpSdrShadowAttribute(ImpSdrShadowAttribute(
97
0
                rOffset, rSize, fTransparence, nBlur, eAlignment, rColor))
98
0
        {
99
0
        }
100
101
        SdrShadowAttribute::SdrShadowAttribute()
102
2.12k
        :   mpSdrShadowAttribute(theGlobalDefault())
103
2.12k
        {
104
2.12k
        }
105
106
3.62k
        SdrShadowAttribute::SdrShadowAttribute(const SdrShadowAttribute&) = default;
107
108
2.12k
        SdrShadowAttribute::SdrShadowAttribute(SdrShadowAttribute&&) = default;
109
110
7.86k
        SdrShadowAttribute::~SdrShadowAttribute() = default;
111
112
        bool SdrShadowAttribute::isDefault() const
113
2.16k
        {
114
2.16k
            return mpSdrShadowAttribute.same_object(theGlobalDefault());
115
2.16k
        }
116
117
0
        SdrShadowAttribute& SdrShadowAttribute::operator=(const SdrShadowAttribute&) = default;
118
119
0
        SdrShadowAttribute& SdrShadowAttribute::operator=(SdrShadowAttribute&&) = default;
120
121
        bool SdrShadowAttribute::operator==(const SdrShadowAttribute& rCandidate) const
122
606
        {
123
            // tdf#87509 default attr is always != non-default attr, even with same values
124
606
            if(rCandidate.isDefault() != isDefault())
125
0
                return false;
126
127
606
            return mpSdrShadowAttribute == rCandidate.mpSdrShadowAttribute;
128
606
        }
129
130
        const basegfx::B2DVector& SdrShadowAttribute::getOffset() const
131
0
        {
132
0
            return mpSdrShadowAttribute->getOffset();
133
0
        }
134
135
        const basegfx::B2DVector& SdrShadowAttribute::getSize() const
136
0
        {
137
0
            return mpSdrShadowAttribute->getSize();
138
0
        }
139
140
        double SdrShadowAttribute::getTransparence() const
141
0
        {
142
0
            return mpSdrShadowAttribute->getTransparence();
143
0
        }
144
145
        sal_Int32 SdrShadowAttribute::getBlur() const
146
0
        {
147
0
            return mpSdrShadowAttribute->getBlur();
148
0
        }
149
150
        model::RectangleAlignment SdrShadowAttribute::getAlignment() const
151
0
        {
152
0
            return mpSdrShadowAttribute->meAlignment;
153
0
        }
154
155
        const basegfx::BColor& SdrShadowAttribute::getColor() const
156
0
        {
157
0
            return mpSdrShadowAttribute->getColor();
158
0
        }
159
160
} // end of namespace
161
162
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */