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 nEscDir
;
76 bool bReallyAbsolute
:1; // temp for transformations on the reference object
77 bool bUserDefined
:1; // #i38892#
80 : nEscDir(SdrEscapeDirection::SMART
)
82 , nAlign(SdrAlign::NONE
)
84 , bReallyAbsolute(false)
87 SdrGluePoint(const Point
& rNewPos
)
89 , nEscDir(SdrEscapeDirection::SMART
)
91 , nAlign(SdrAlign::NONE
)
93 , bReallyAbsolute(false)
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
124 void SetPercent(bool bOn
)
128 // temp for transformations on the reference object
129 void SetReallyAbsolute(bool bOn
, const SdrObject
& rObj
);
132 bool IsUserDefined() const
136 void SetUserDefined(bool bNew
)
141 SdrAlign
GetAlign() const
145 void SetAlign(SdrAlign nAlg
)
149 SdrAlign
GetHorzAlign() const
151 return nAlign
& static_cast<SdrAlign
>(0x00FF);
153 void SetHorzAlign(SdrAlign nAlg
)
155 assert((nAlg
& static_cast<SdrAlign
>(0xFF00)) == SdrAlign::NONE
);
156 nAlign
= SdrAlign(nAlign
& static_cast<SdrAlign
>(0xFF00)) | (nAlg
& static_cast<SdrAlign
>(0x00FF));
158 SdrAlign
GetVertAlign() const
160 return nAlign
& static_cast<SdrAlign
>(0xFF00);
162 void SetVertAlign(SdrAlign nAlg
)
164 assert((nAlg
& static_cast<SdrAlign
>(0x00FF)) == SdrAlign::NONE
);
165 nAlign
= SdrAlign(nAlign
& static_cast<SdrAlign
>(0x00FF)) | (nAlg
& static_cast<SdrAlign
>(0xFF00));
168 bool IsHit(const Point
& rPnt
, const OutputDevice
& rOut
, const SdrObject
* pObj
) const;
169 void Invalidate(vcl::Window
& rWin
, const SdrObject
* pObj
) const;
170 Point
GetAbsolutePos(const SdrObject
& rObj
) const;
171 void SetAbsolutePos(const Point
& rNewPos
, const SdrObject
& rObj
);
172 Degree100
GetAlignAngle() const;
173 void SetAlignAngle(Degree100 nAngle
);
174 static Degree100
EscDirToAngle(SdrEscapeDirection nEsc
);
175 static SdrEscapeDirection
EscAngleToDir(Degree100 nAngle
);
176 void Rotate(const Point
& rRef
, Degree100 nAngle
, double sn
, double cs
, const SdrObject
* pObj
);
177 void Mirror(const Point
& rRef1
, const Point
& rRef2
, Degree100 nAngle
, const SdrObject
* pObj
);
178 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
> aList
;
187 SdrGluePointList() {};
188 SdrGluePointList(const SdrGluePointList
& rSrcList
)
193 SdrGluePointList
& operator=(const SdrGluePointList
& rSrcList
);
194 sal_uInt16
GetCount() const
196 return sal_uInt16(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 aList
.erase(aList
.begin() + nPos
);
205 SdrGluePoint
& operator[](sal_uInt16 nPos
)
209 const SdrGluePoint
& operator[](sal_uInt16 nPos
) const
213 sal_uInt16
FindGluePoint(sal_uInt16 nId
) const;
214 sal_uInt16
HitTest(const Point
& rPnt
, const OutputDevice
& rOut
, const SdrObject
* pObj
) const;
215 void Invalidate(vcl::Window
& rWin
, const SdrObject
* pObj
) const;
217 // temp for transformations on the reference object
218 void SetReallyAbsolute(bool bOn
, const SdrObject
& rObj
);
219 void Rotate(const Point
& rRef
, Degree100 nAngle
, double sn
, double cs
, const SdrObject
* pObj
);
220 void Mirror(const Point
& rRef1
, const Point
& rRef2
, const SdrObject
* pObj
);
221 void Mirror(const Point
& rRef1
, const Point
& rRef2
, Degree100 nAngle
, const SdrObject
* pObj
);
222 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: */