Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/sdr/overlay/overlayobject.hxx
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
#pragma once
21
22
#include <basegfx/point/b2dpoint.hxx>
23
#include <basegfx/range/b2drange.hxx>
24
#include <tools/color.hxx>
25
#include <svx/sdr/animation/scheduler.hxx>
26
#include <svx/svxdllapi.h>
27
#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
28
29
#include <vector>
30
31
namespace sdr::overlay
32
{
33
    class OverlayManager;
34
}
35
36
namespace sdr::overlay
37
    {
38
        class SVXCORE_DLLPUBLIC OverlayObject : public sdr::animation::Event
39
        {
40
        private:
41
            OverlayObject(const OverlayObject&) = delete;
42
            OverlayObject& operator=(const OverlayObject&) = delete;
43
44
            // Manager is allowed access to private Member mpOverlayManager
45
            friend class                                    OverlayManager;
46
47
            // pointer to OverlayManager, if object is added. Changed by
48
            // OverlayManager, do not change Yourself.
49
            OverlayManager*                                 mpOverlayManager;
50
51
            // Primitive2DContainer of the OverlayObject
52
            drawinglayer::primitive2d::Primitive2DContainer maPrimitive2DSequence;
53
54
            // Possible Offset added to the geometry (automatically in
55
            // createOverlayObjectPrimitive2DSequence()). Usually zero, may
56
            // be used e.g. from calc when GridOffset is needed
57
            basegfx::B2DVector                              maOffset;
58
59
        protected:
60
            // access methods to maPrimitive2DSequence. The usage of this methods may allow
61
            // later thread-safe stuff to be added if needed. Only to be used by getPrimitive2DSequence()
62
            // implementations for buffering the last decomposition.
63
            // Resetting is allowed e.g. in ::getOverlayObjectPrimitive2DSequence() implementations
64
            // if the conditions have changed to force a re-creation in calling the base implementation.
65
            // The only allowed setter of maPrimitive2DSequence is
66
            // OverlayObject::getOverlayObjectPrimitive2DSequence() which should be called by calling
67
            // the base implementation in derived functions. That one will use the result of
68
            // createOverlayObjectPrimitive2DSequence() to provide the geometry.
69
0
            const drawinglayer::primitive2d::Primitive2DContainer& getPrimitive2DSequence() const { return maPrimitive2DSequence; }
70
0
            void resetPrimitive2DSequence() { maPrimitive2DSequence.clear(); }
71
72
            // the creation method for Primitive2DContainer. Called when getPrimitive2DSequence()
73
            // sees that maPrimitive2DSequence is empty. Needs to be supported by all
74
            // OverlayObject implementations. Default implementation will assert
75
            // a missing implementation
76
            virtual drawinglayer::primitive2d::Primitive2DContainer createOverlayObjectPrimitive2DSequence();
77
78
            // #i53216# check blink time value range (currently 25 < mnBlinkTime < 10000)
79
            static sal_uInt32 impCheckBlinkTimeValueRange(sal_uInt64 nBlinkTime);
80
81
            // region in logical coordinates
82
            basegfx::B2DRange                               maBaseRange;
83
84
            // base color of this OverlayObject
85
            Color                                           maBaseColor;
86
87
            // Flag for visibility
88
            bool                                            mbIsVisible : 1;
89
90
            // Flag to control hittability
91
            bool                                            mbIsHittable : 1;
92
93
            // Flag to hold info if this objects supports animation. Default is
94
            // false. If true, the Trigger() method should be overridden
95
            // to implement the animation effect and to re-initiate the event.
96
            bool                                            mbAllowsAnimation : 1;
97
98
            // Flag to control if this OverlayObject allows AntiAliased visualisation.
99
            // Default is true, but e.g. for selection visualisation in SC and SW,
100
            // it is switched to false
101
            bool                                            mbAllowsAntiAliase : 1;
102
103
            // In High Contrast mode all fg and bg are forced to a pair of normal
104
            // high contrast colors. If this flag is set, then in High Contrast mode
105
            // the colors are instead forced to the high contrast selection fg/bg pair.
106
            // Default is false.
107
            bool                                            mbHighContrastSelection : 1;
108
109
            // set changed flag. Call after change, since the old range is invalidated
110
            // and then the new one is calculated and invalidated, too. This will only
111
            // work after the change.
112
            void objectChange();
113
114
            // write access to AntiAliase flag. This is protected since
115
            // only implementations are allowed to change this, preferably in their
116
            // constructor
117
            void allowAntiAliase(bool bNew);
118
119
        public:
120
            explicit OverlayObject(Color aBaseColor);
121
            virtual ~OverlayObject() override;
122
123
            // get OverlayManager
124
0
            OverlayManager* getOverlayManager() const { return mpOverlayManager; }
125
126
            // the access method for Primitive2DContainer. Will use createPrimitive2DSequence and
127
            // setPrimitive2DSequence if needed. Overriding may be used to allow disposal of last
128
            // created primitives to react on changed circumstances and to re-create primitives
129
            virtual drawinglayer::primitive2d::Primitive2DContainer getOverlayObjectPrimitive2DSequence() const;
130
131
            // access to visibility state
132
0
            bool isVisible() const { return mbIsVisible; }
133
            void setVisible(bool bNew);
134
135
            // access to hittable flag
136
0
            bool isHittable() const { return mbIsHittable; }
137
            void setHittable(bool bNew);
138
139
            // read access to AntiAliase flag
140
0
            bool allowsAntiAliase() const { return mbAllowsAntiAliase; }
141
142
            // read access to DrawModeSettings flag
143
0
            bool isHighContrastSelection() const { return mbHighContrastSelection; }
144
145
            // read access to baseRange. This may trigger createBaseRange() if
146
            // object is changed.
147
            const basegfx::B2DRange& getBaseRange() const;
148
149
            // access to baseColor
150
0
            const Color& getBaseColor() const { return maBaseColor; }
151
            void setBaseColor(Color aNew);
152
153
            // access to Offset
154
0
            const basegfx::B2DVector& getOffset() const { return maOffset; }
155
            void setOffset(const basegfx::B2DVector& rOffset);
156
157
            // execute event from base class sdr::animation::Event. Default
158
            // implementation does nothing and does not create a new event.
159
            virtual void Trigger(sal_uInt32 nTime) override;
160
161
            // access to AllowsAnimation flag
162
0
            bool allowsAnimation() const { return mbAllowsAnimation; }
163
164
            // stripe definition has changed. The OverlayManager does have
165
            // support data to draw graphics in two colors striped. This
166
            // method notifies the OverlayObject if that change takes place.
167
            // Default implementation does nothing.
168
            virtual void stripeDefinitionHasChanged();
169
        };
170
171
        // typedefs for a vector of OverlayObjects
172
        typedef ::std::vector< OverlayObject* > OverlayObjectVector;
173
174
} // end of namespace sdr::overlay
175
176
namespace sdr::overlay
177
    {
178
        class SVXCORE_DLLPUBLIC OverlayObjectWithBasePosition : public OverlayObject
179
        {
180
        protected:
181
            // base position in logical coordinates
182
            basegfx::B2DPoint                       maBasePosition;
183
184
        public:
185
            OverlayObjectWithBasePosition(const basegfx::B2DPoint& rBasePos, Color aBaseColor);
186
            virtual ~OverlayObjectWithBasePosition() override;
187
188
            // access to basePosition
189
0
            const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; }
190
            void setBasePosition(const basegfx::B2DPoint& rNew);
191
        };
192
193
} // end of namespace sdr::overlay
194
195
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */