Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/svdglue.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_SVDGLUE_HXX
21
#define INCLUDED_SVX_SVDGLUE_HXX
22
23
#include <tools/gen.hxx>
24
#include <tools/degree.hxx>
25
#include <svx/svxdllapi.h>
26
#include <vector>
27
#include <o3tl/typed_flags_set.hxx>
28
29
namespace vcl { class Window; }
30
class OutputDevice;
31
class SdrObject;
32
33
34
enum class SdrEscapeDirection
35
{
36
    SMART  = 0x0000,
37
    LEFT   = 0x0001,
38
    RIGHT  = 0x0002,
39
    TOP    = 0x0004,
40
    BOTTOM = 0x0008,
41
    HORZ   = LEFT | RIGHT,
42
    VERT   = TOP | BOTTOM,
43
    ALL    = 0x00ff,
44
};
45
namespace o3tl
46
{
47
    template<> struct typed_flags<SdrEscapeDirection> : is_typed_flags<SdrEscapeDirection, 0x00ff> {};
48
}
49
50
enum class SdrAlign
51
{
52
    NONE          = 0x0000,
53
    HORZ_CENTER   = 0x0000,
54
    HORZ_LEFT     = 0x0001,
55
    HORZ_RIGHT    = 0x0002,
56
    HORZ_DONTCARE = 0x0010,
57
    VERT_CENTER   = 0x0000,
58
    VERT_TOP      = 0x0100,
59
    VERT_BOTTOM   = 0x0200,
60
    VERT_DONTCARE = 0x1000,
61
};
62
namespace o3tl
63
{
64
    template<> struct typed_flags<SdrAlign> : is_typed_flags<SdrAlign, 0x1313> {};
65
}
66
67
class SVXCORE_DLLPUBLIC SdrGluePoint {
68
    // Reference Point is SdrObject::GetSnapRect().Center()
69
    // bNoPercent=false: position is -5000..5000 (1/100)% or 0..10000 (depending on align)
70
    // bNoPercent=true : position is in log unit, relative to the reference point
71
    Point    m_aPos;
72
    SdrEscapeDirection m_nEscDir;
73
    sal_uInt16   m_nId;
74
    SdrAlign     m_nAlign;
75
    bool m_bNoPercent:1;
76
    bool m_bReallyAbsolute:1; // temp for transformations on the reference object
77
    bool m_bUserDefined:1; // #i38892#
78
public:
79
    SdrGluePoint()
80
204k
        : m_nEscDir(SdrEscapeDirection::SMART)
81
204k
        , m_nId(0)
82
204k
        , m_nAlign(SdrAlign::NONE)
83
204k
        , m_bNoPercent(false)
84
204k
        , m_bReallyAbsolute(false)
85
204k
        , m_bUserDefined(true)
86
204k
    {}
87
    SdrGluePoint(const Point& rNewPos)
88
3.31k
        : m_aPos(rNewPos)
89
3.31k
        , m_nEscDir(SdrEscapeDirection::SMART)
90
3.31k
        , m_nId(0)
91
3.31k
        , m_nAlign(SdrAlign::NONE)
92
3.31k
        , m_bNoPercent(false)
93
3.31k
        , m_bReallyAbsolute(false)
94
3.31k
        , m_bUserDefined(true)
95
3.31k
    {}
96
    const Point& GetPos() const
97
950k
    {
98
950k
        return m_aPos;
99
950k
    }
100
    void SetPos(const Point& rNewPos)
101
1.13M
    {
102
1.13M
        m_aPos = rNewPos;
103
1.13M
    }
104
    SdrEscapeDirection GetEscDir() const
105
3.31k
    {
106
3.31k
        return m_nEscDir;
107
3.31k
    }
108
    void SetEscDir(SdrEscapeDirection nNewEsc)
109
186k
    {
110
186k
        m_nEscDir = nNewEsc;
111
186k
    }
112
    sal_uInt16   GetId() const
113
8.88M
    {
114
8.88M
        return m_nId;
115
8.88M
    }
116
    void SetId(sal_uInt16 nNewId)
117
186k
    {
118
186k
        m_nId = nNewId;
119
186k
    }
120
    bool IsPercent() const
121
3.04k
    {
122
3.04k
        return !m_bNoPercent;
123
3.04k
    }
124
    void SetPercent(bool bOn)
125
189k
    {
126
189k
        m_bNoPercent  = !bOn;
127
189k
    }
128
    // temp for transformations on the reference object
129
    SAL_DLLPRIVATE void SetReallyAbsolute(bool bOn, const SdrObject& rObj);
130
131
    // #i38892#
132
    bool IsUserDefined() const
133
2.05M
    {
134
2.05M
        return m_bUserDefined;
135
2.05M
    }
136
    void SetUserDefined(bool bNew)
137
2.14M
    {
138
2.14M
        m_bUserDefined = bNew;
139
2.14M
    }
140
141
    SdrAlign GetAlign() const
142
3.04k
    {
143
3.04k
        return m_nAlign;
144
3.04k
    }
145
    void SetAlign(SdrAlign nAlg)
146
186k
    {
147
186k
        m_nAlign = nAlg;
148
186k
    }
149
    SdrAlign GetHorzAlign() const
150
1.07M
    {
151
1.07M
        return m_nAlign & static_cast<SdrAlign>(0x00FF);
152
1.07M
    }
153
    void SetHorzAlign(SdrAlign nAlg)
154
0
    {
155
0
        assert((nAlg & static_cast<SdrAlign>(0xFF00)) == SdrAlign::NONE);
156
0
        m_nAlign = SdrAlign(m_nAlign & static_cast<SdrAlign>(0xFF00)) | (nAlg & static_cast<SdrAlign>(0x00FF));
157
0
    }
158
    SdrAlign GetVertAlign() const
159
1.07M
    {
160
1.07M
        return m_nAlign & static_cast<SdrAlign>(0xFF00);
161
1.07M
    }
162
    void SetVertAlign(SdrAlign nAlg)
163
0
    {
164
0
        assert((nAlg & static_cast<SdrAlign>(0x00FF)) == SdrAlign::NONE);
165
0
        m_nAlign = SdrAlign(m_nAlign & static_cast<SdrAlign>(0x00FF)) | (nAlg & static_cast<SdrAlign>(0xFF00));
166
0
    }
167
168
    SAL_DLLPRIVATE bool IsHit(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
169
    SAL_DLLPRIVATE void Invalidate(vcl::Window& rWin, const SdrObject* pObj) const;
170
    Point GetAbsolutePos(const SdrObject& rObj) const;
171
    SAL_DLLPRIVATE void SetAbsolutePos(const Point& rNewPos, const SdrObject& rObj);
172
    SAL_DLLPRIVATE Degree100 GetAlignAngle() const;
173
    SAL_DLLPRIVATE void SetAlignAngle(Degree100 nAngle);
174
    SAL_DLLPRIVATE static Degree100 EscDirToAngle(SdrEscapeDirection nEsc);
175
    SAL_DLLPRIVATE static SdrEscapeDirection EscAngleToDir(Degree100 nAngle);
176
    SAL_DLLPRIVATE void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs, const SdrObject* pObj);
177
    SAL_DLLPRIVATE void Mirror(const Point& rRef1, const Point& rRef2, Degree100 nAngle, const SdrObject* pObj);
178
    SAL_DLLPRIVATE void Shear (const Point& rRef, double tn, bool bVShear, const SdrObject* pObj);
179
};
180
181
1.49k
#define SDRGLUEPOINT_NOTFOUND 0xFFFF
182
183
class SVXCORE_DLLPUBLIC SdrGluePointList
184
{
185
    std::vector<SdrGluePoint> m_aList;
186
public:
187
54.0k
    SdrGluePointList() {};
188
    SdrGluePointList(const SdrGluePointList& rSrcList)
189
3
    {
190
3
        *this = rSrcList;
191
3
    }
192
193
    SdrGluePointList& operator=(const SdrGluePointList& rSrcList);
194
    sal_uInt16 GetCount() const
195
9.87M
    {
196
9.87M
        return sal_uInt16(m_aList.size());
197
9.87M
    }
198
    // At insert, the object (GluePoint) automatically gets an ID assigned.
199
    // Return value is the index of the new GluePoint in the list.
200
    sal_uInt16 Insert(const SdrGluePoint& rGP);
201
    void Delete(sal_uInt16 nPos)
202
0
    {
203
0
        m_aList.erase(m_aList.begin() + nPos);
204
0
    }
205
    SdrGluePoint& operator[](sal_uInt16 nPos)
206
944k
    {
207
944k
        return m_aList[nPos];
208
944k
    }
209
    const SdrGluePoint& operator[](sal_uInt16 nPos) const
210
6.35M
    {
211
6.35M
        return m_aList[nPos];
212
6.35M
    }
213
    sal_uInt16 FindGluePoint(sal_uInt16 nId) const;
214
    SAL_DLLPRIVATE sal_uInt16 HitTest(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
215
    SAL_DLLPRIVATE void Invalidate(vcl::Window& rWin, const SdrObject* pObj) const;
216
217
    // temp for transformations on the reference object
218
    SAL_DLLPRIVATE void SetReallyAbsolute(bool bOn, const SdrObject& rObj);
219
    SAL_DLLPRIVATE void Rotate(const Point& rRef, Degree100 nAngle, double sn, double cs, const SdrObject* pObj);
220
    SAL_DLLPRIVATE void Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj);
221
    SAL_DLLPRIVATE void Mirror(const Point& rRef1, const Point& rRef2, Degree100 nAngle, const SdrObject* pObj);
222
    SAL_DLLPRIVATE void Shear(const Point& rRef, double tn, bool bVShear, const SdrObject* pObj);
223
};
224
225
226
#endif // INCLUDED_SVX_SVDGLUE_HXX
227
228
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */