Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/inc/sdr/overlay/overlaytools.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
#ifndef INCLUDED_SVX_INC_SDR_OVERLAY_OVERLAYTOOLS_HXX
21
#define INCLUDED_SVX_INC_SDR_OVERLAY_OVERLAYTOOLS_HXX
22
23
#include <basegfx/color/bcolor.hxx>
24
#include <drawinglayer/primitive2d/primitivetools2d.hxx>
25
#include <vcl/bitmap.hxx>
26
#include <basegfx/vector/b2dsize.hxx>
27
28
namespace drawinglayer::primitive2d {
29
30
class OverlayStaticRectanglePrimitive final : public DiscreteMetricDependentPrimitive2D
31
{
32
private:
33
    basegfx::B2DPoint maPosition;
34
    basegfx::B2DSize maSize;
35
36
    // the graphic definition
37
    basegfx::BColor maStrokeColor;
38
    basegfx::BColor maFillColor;
39
    double mfTransparence;
40
41
    // the rotation of the primitive itself
42
    double mfRotation;
43
44
    virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override;
45
46
public:
47
    OverlayStaticRectanglePrimitive(
48
        const basegfx::B2DPoint& rPosition,
49
        const basegfx::B2DSize& rSize,
50
        const basegfx::BColor& rStrokeColor,
51
        const basegfx::BColor& rFillColor,
52
        double fTransparence,
53
        double fRotation);
54
55
    // compare operator
56
    virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override;
57
58
    virtual sal_uInt32 getPrimitive2DID() const override;
59
};
60
61
} // end of namespace drawinglayer::primitive2d
62
63
// Overlay helper class which holds a BotmapEx which is to be visualized
64
// at the given logic position with the Bitmap's pixel size, unscaled and
65
// unrotated (like a marker). The discrete pixel on the bitmap associated
66
// with the target position is given in discrete X,Y coordinates
67
namespace drawinglayer::primitive2d
68
    {
69
        class OverlayBitmapPrimitive final : public DiscreteMetricDependentPrimitive2D
70
        {
71
        private:
72
            // The Bitmap to use, PixelSize is used
73
            Bitmap                                  maBitmap;
74
75
            // The logic position
76
            basegfx::B2DPoint                       maBasePosition;
77
78
            // The pixel inside the Bitmap which is associated with
79
            // the target position (offset in the bitmap)
80
            sal_uInt16                              mnCenterX;
81
            sal_uInt16                              mnCenterY;
82
83
            // evtl. rotation and shear around center
84
            double                                  mfShearX;
85
            double                                  mfRotation;
86
87
            virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override;
88
89
        public:
90
            OverlayBitmapPrimitive(
91
                const Bitmap& rBitmap,
92
                const basegfx::B2DPoint& rBasePosition,
93
                sal_uInt16 nCenterX,
94
                sal_uInt16 nCenterY,
95
                double fShearX,
96
                double fRotation);
97
98
            // data access
99
0
            const Bitmap& getBitmap() const { return maBitmap; }
100
0
            const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; }
101
0
            sal_uInt16 getCenterX() const { return mnCenterX; }
102
0
            sal_uInt16 getCenterY() const { return mnCenterY; }
103
0
            double getShearX() const { return mfShearX; }
104
0
            double getRotation() const { return mfRotation; }
105
106
            // compare operator
107
            virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override;
108
109
            virtual sal_uInt32 getPrimitive2DID() const override;
110
        };
111
} // end of namespace drawinglayer::primitive2d
112
113
114
// Overlay helper class for a crosshair
115
namespace drawinglayer::primitive2d
116
    {
117
        class OverlayCrosshairPrimitive final : public ViewportDependentPrimitive2D
118
        {
119
        private:
120
            // The logic position
121
            basegfx::B2DPoint                       maBasePosition;
122
123
            // The stripe colors and length
124
            basegfx::BColor                          maRGBColorA;
125
            basegfx::BColor                          maRGBColorB;
126
            double                                   mfDiscreteDashLength;
127
128
            virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override;
129
130
        public:
131
            OverlayCrosshairPrimitive(
132
                const basegfx::B2DPoint& rBasePosition,
133
                const basegfx::BColor& rRGBColorA,
134
                const basegfx::BColor& rRGBColorB,
135
                double fDiscreteDashLength);
136
137
            // data access
138
0
            const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; }
139
0
            const basegfx::BColor& getRGBColorA() const { return maRGBColorA; }
140
0
            const basegfx::BColor& getRGBColorB() const { return maRGBColorB; }
141
0
            double getDiscreteDashLength() const { return mfDiscreteDashLength; }
142
143
            // compare operator
144
            virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override;
145
146
            virtual sal_uInt32 getPrimitive2DID() const override;
147
        };
148
} // end of namespace drawinglayer::primitive2d
149
150
151
// Overlay helper class for a hatch rectangle as used e.g. for text object
152
// selection highlighting
153
namespace drawinglayer::primitive2d
154
    {
155
        class OverlayRectanglePrimitive final : public DiscreteMetricDependentPrimitive2D
156
        {
157
        private:
158
            // the logic rectangle definition
159
            basegfx::B2DRange               maObjectRange;
160
161
            // the graphic definition
162
            basegfx::BColor                 maColor;
163
            double                          mfTransparence;
164
165
            // the discrete grow and shrink of the box
166
            double                          mfDiscreteGrow;
167
            double                          mfDiscreteShrink;
168
169
            // the rotation of the primitive itself
170
            double                          mfRotation;
171
172
            virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override;
173
174
        public:
175
            OverlayRectanglePrimitive(
176
                const basegfx::B2DRange& rObjectRange,
177
                const basegfx::BColor& rColor,
178
                double fTransparence,
179
                double fDiscreteGrow,
180
                double fDiscreteShrink,
181
                double fRotation);
182
183
            // data access
184
0
            const basegfx::B2DRange& getObjectRange() const { return maObjectRange; }
185
0
            const basegfx::BColor& getColor() const { return maColor; }
186
0
            double getTransparence() const { return mfTransparence; }
187
0
            double getDiscreteGrow() const { return mfDiscreteGrow; }
188
0
            double getDiscreteShrink() const { return mfDiscreteShrink; }
189
0
            double getRotation() const { return mfRotation; }
190
191
            // compare operator
192
            virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override;
193
194
            virtual sal_uInt32 getPrimitive2DID() const override;
195
        };
196
} // end of namespace drawinglayer::primitive2d
197
198
199
// Overlay helper class for a striped helpline
200
201
namespace drawinglayer::primitive2d
202
    {
203
        enum HelplineStyle
204
        {
205
            HELPLINESTYLE_POINT,
206
            HELPLINESTYLE_VERTICAL,
207
            HELPLINESTYLE_HORIZONTAL
208
        };
209
210
        class OverlayHelplineStripedPrimitive final : public ViewportDependentPrimitive2D
211
        {
212
        private:
213
            // The logic position
214
            basegfx::B2DPoint                       maBasePosition;
215
216
            // the style
217
            HelplineStyle                           meStyle;
218
219
            // The stripe colors and length
220
            basegfx::BColor                         maRGBColorA;
221
            basegfx::BColor                         maRGBColorB;
222
            double                                  mfDiscreteDashLength;
223
224
            virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override;
225
226
        public:
227
            OverlayHelplineStripedPrimitive(
228
                const basegfx::B2DPoint& rBasePosition,
229
                HelplineStyle eStyle,
230
                const basegfx::BColor& rRGBColorA,
231
                const basegfx::BColor& rRGBColorB,
232
                double fDiscreteDashLength);
233
234
            // data access
235
0
            const basegfx::B2DPoint& getBasePosition() const { return maBasePosition; }
236
0
            HelplineStyle getStyle() const { return meStyle; }
237
0
            const basegfx::BColor& getRGBColorA() const { return maRGBColorA; }
238
0
            const basegfx::BColor& getRGBColorB() const { return maRGBColorB; }
239
0
            double getDiscreteDashLength() const { return mfDiscreteDashLength; }
240
241
            // compare operator
242
            virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override;
243
244
            virtual sal_uInt32 getPrimitive2DID() const override;
245
        };
246
} // end of namespace drawinglayer::primitive2d
247
248
249
// Overlay helper class for rolling rectangle helplines. This primitive is
250
// only for the extended lines to the ends of the view
251
252
namespace drawinglayer::primitive2d
253
    {
254
        class OverlayRollingRectanglePrimitive final : public ViewportDependentPrimitive2D
255
        {
256
        private:
257
            // The logic range
258
            basegfx::B2DRange                       maRollingRectangle;
259
260
            // The stripe colors and length
261
            basegfx::BColor                         maRGBColorA;
262
            basegfx::BColor                         maRGBColorB;
263
            double                                  mfDiscreteDashLength;
264
265
            virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override;
266
267
        public:
268
            OverlayRollingRectanglePrimitive(
269
                const basegfx::B2DRange& aRollingRectangle,
270
                const basegfx::BColor& rRGBColorA,
271
                const basegfx::BColor& rRGBColorB,
272
                double fDiscreteDashLength);
273
274
            // data access
275
0
            const basegfx::B2DRange& getRollingRectangle() const { return maRollingRectangle; }
276
0
            const basegfx::BColor& getRGBColorA() const { return maRGBColorA; }
277
0
            const basegfx::BColor& getRGBColorB() const { return maRGBColorB; }
278
0
            double getDiscreteDashLength() const { return mfDiscreteDashLength; }
279
280
            // compare operator
281
            virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override;
282
283
            virtual sal_uInt32 getPrimitive2DID() const override;
284
        };
285
} // end of namespace drawinglayer::primitive2d
286
287
288
#endif // INCLUDED_SVX_INC_SDR_OVERLAY_OVERLAYTOOLS_HXX
289
290
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */