tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / include / svx / svdglue.hxx
blob3fa5ab5a569edc768d3f5b209987d83743627ced
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_SVDGLUE_HXX
21 #define INCLUDED_SVX_SVDGLUE_HXX
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>
29 namespace vcl { class Window; }
30 class OutputDevice;
31 class SdrObject;
34 enum class SdrEscapeDirection
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,
45 namespace o3tl
47 template<> struct typed_flags<SdrEscapeDirection> : is_typed_flags<SdrEscapeDirection, 0x00ff> {};
50 enum class SdrAlign
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,
62 namespace o3tl
64 template<> struct typed_flags<SdrAlign> : is_typed_flags<SdrAlign, 0x1313> {};
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 : m_nEscDir(SdrEscapeDirection::SMART)
81 , m_nId(0)
82 , m_nAlign(SdrAlign::NONE)
83 , m_bNoPercent(false)
84 , m_bReallyAbsolute(false)
85 , m_bUserDefined(true)
87 SdrGluePoint(const Point& rNewPos)
88 : m_aPos(rNewPos)
89 , m_nEscDir(SdrEscapeDirection::SMART)
90 , m_nId(0)
91 , m_nAlign(SdrAlign::NONE)
92 , m_bNoPercent(false)
93 , m_bReallyAbsolute(false)
94 , m_bUserDefined(true)
96 const Point& GetPos() const
98 return m_aPos;
100 void SetPos(const Point& rNewPos)
102 m_aPos = rNewPos;
104 SdrEscapeDirection GetEscDir() const
106 return m_nEscDir;
108 void SetEscDir(SdrEscapeDirection nNewEsc)
110 m_nEscDir = nNewEsc;
112 sal_uInt16 GetId() const
114 return m_nId;
116 void SetId(sal_uInt16 nNewId)
118 m_nId = nNewId;
120 bool IsPercent() const
122 return !m_bNoPercent;
124 void SetPercent(bool bOn)
126 m_bNoPercent = !bOn;
128 // temp for transformations on the reference object
129 SAL_DLLPRIVATE void SetReallyAbsolute(bool bOn, const SdrObject& rObj);
131 // #i38892#
132 bool IsUserDefined() const
134 return m_bUserDefined;
136 void SetUserDefined(bool bNew)
138 m_bUserDefined = bNew;
141 SdrAlign GetAlign() const
143 return m_nAlign;
145 void SetAlign(SdrAlign nAlg)
147 m_nAlign = nAlg;
149 SdrAlign GetHorzAlign() const
151 return m_nAlign & static_cast<SdrAlign>(0x00FF);
153 void SetHorzAlign(SdrAlign nAlg)
155 assert((nAlg & static_cast<SdrAlign>(0xFF00)) == SdrAlign::NONE);
156 m_nAlign = SdrAlign(m_nAlign & static_cast<SdrAlign>(0xFF00)) | (nAlg & static_cast<SdrAlign>(0x00FF));
158 SdrAlign GetVertAlign() const
160 return m_nAlign & static_cast<SdrAlign>(0xFF00);
162 void SetVertAlign(SdrAlign nAlg)
164 assert((nAlg & static_cast<SdrAlign>(0x00FF)) == SdrAlign::NONE);
165 m_nAlign = SdrAlign(m_nAlign & static_cast<SdrAlign>(0x00FF)) | (nAlg & static_cast<SdrAlign>(0xFF00));
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);
181 #define SDRGLUEPOINT_NOTFOUND 0xFFFF
183 class SVXCORE_DLLPUBLIC SdrGluePointList
185 std::vector<SdrGluePoint> m_aList;
186 public:
187 SdrGluePointList() {};
188 SdrGluePointList(const SdrGluePointList& rSrcList)
190 *this = rSrcList;
193 SdrGluePointList& operator=(const SdrGluePointList& rSrcList);
194 sal_uInt16 GetCount() const
196 return sal_uInt16(m_aList.size());
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)
203 m_aList.erase(m_aList.begin() + nPos);
205 SdrGluePoint& operator[](sal_uInt16 nPos)
207 return m_aList[nPos];
209 const SdrGluePoint& operator[](sal_uInt16 nPos) const
211 return m_aList[nPos];
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;
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);
226 #endif // INCLUDED_SVX_SVDGLUE_HXX
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */