1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
27 #include <o3tl/typed_flags_set.hxx>
29 namespace vcl
{ class Window
; }
34 enum class SdrEscapeDirection
47 template<> struct typed_flags
<SdrEscapeDirection
> : is_typed_flags
<SdrEscapeDirection
, 0x00ff> {};
56 HORZ_DONTCARE
= 0x0010,
60 VERT_DONTCARE
= 0x1000,
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
72 SdrEscapeDirection m_nEscDir
;
76 bool m_bReallyAbsolute
:1; // temp for transformations on the reference object
77 bool m_bUserDefined
:1; // #i38892#
80 : m_nEscDir(SdrEscapeDirection::SMART
)
82 , m_nAlign(SdrAlign::NONE
)
84 , m_bReallyAbsolute(false)
85 , m_bUserDefined(true)
87 SdrGluePoint(const Point
& rNewPos
)
89 , m_nEscDir(SdrEscapeDirection::SMART
)
91 , m_nAlign(SdrAlign::NONE
)
93 , m_bReallyAbsolute(false)
94 , m_bUserDefined(true)
96 const Point
& GetPos() const
100 void SetPos(const Point
& rNewPos
)
104 SdrEscapeDirection
GetEscDir() const
108 void SetEscDir(SdrEscapeDirection nNewEsc
)
112 sal_uInt16
GetId() const
116 void SetId(sal_uInt16 nNewId
)
120 bool IsPercent() const
122 return !m_bNoPercent
;
124 void SetPercent(bool bOn
)
128 // temp for transformations on the reference object
129 SAL_DLLPRIVATE
void SetReallyAbsolute(bool bOn
, const SdrObject
& rObj
);
132 bool IsUserDefined() const
134 return m_bUserDefined
;
136 void SetUserDefined(bool bNew
)
138 m_bUserDefined
= bNew
;
141 SdrAlign
GetAlign() const
145 void SetAlign(SdrAlign 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
;
187 SdrGluePointList() {};
188 SdrGluePointList(const SdrGluePointList
& 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: */