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 <svx/svxdllapi.h>
27 #include <o3tl/typed_flags_set.hxx>
29 namespace vcl
{ class Window
; }
35 enum class SdrEscapeDirection
48 template<> struct typed_flags
<SdrEscapeDirection
> : is_typed_flags
<SdrEscapeDirection
, 0x00ff> {};
57 HORZ_DONTCARE
= 0x0010,
61 VERT_DONTCARE
= 0x1000,
65 template<> struct typed_flags
<SdrAlign
> : is_typed_flags
<SdrAlign
, 0x1313> {};
68 class SVX_DLLPUBLIC SdrGluePoint
{
69 // Reference Point is SdrObject::GetSnapRect().Center()
70 // bNoPercent=false: position is -5000..5000 (1/100)% or 0..10000 (depending on align)
71 // bNoPercent=true : position is in log unit, relative to the reference point
73 SdrEscapeDirection nEscDir
;
77 bool bReallyAbsolute
:1; // temp for transformations on the reference object
78 bool bUserDefined
:1; // #i38892#
80 SdrGluePoint(): nEscDir(SdrEscapeDirection::SMART
),nId(0),nAlign(SdrAlign::NONE
),bNoPercent(false),bReallyAbsolute(false),bUserDefined(true) {}
81 SdrGluePoint(const Point
& rNewPos
): aPos(rNewPos
),nEscDir(SdrEscapeDirection::SMART
),nId(0),nAlign(SdrAlign::NONE
),bNoPercent(false),bReallyAbsolute(false),bUserDefined(true) {}
82 const Point
& GetPos() const { return aPos
; }
83 void SetPos(const Point
& rNewPos
) { aPos
=rNewPos
; }
84 SdrEscapeDirection
GetEscDir() const { return nEscDir
; }
85 void SetEscDir(SdrEscapeDirection nNewEsc
) { nEscDir
=nNewEsc
; }
86 sal_uInt16
GetId() const { return nId
; }
87 void SetId(sal_uInt16 nNewId
) { nId
=nNewId
; }
88 bool IsPercent() const { return !bNoPercent
; }
89 void SetPercent(bool bOn
) { bNoPercent
= !bOn
; }
90 // temp for transformations on the reference object
91 void SetReallyAbsolute(bool bOn
, const SdrObject
& rObj
);
94 bool IsUserDefined() const { return bUserDefined
; }
95 void SetUserDefined(bool bNew
) { bUserDefined
= bNew
; }
97 SdrAlign
GetAlign() const { return nAlign
; }
98 void SetAlign(SdrAlign nAlg
) { nAlign
=nAlg
; }
99 SdrAlign
GetHorzAlign() const { return nAlign
& static_cast<SdrAlign
>(0x00FF); }
100 void SetHorzAlign(SdrAlign nAlg
) { assert((nAlg
& static_cast<SdrAlign
>(0xFF00)) == SdrAlign::NONE
); nAlign
= SdrAlign(nAlign
& static_cast<SdrAlign
>(0xFF00)) | (nAlg
& static_cast<SdrAlign
>(0x00FF)); }
101 SdrAlign
GetVertAlign() const { return nAlign
& static_cast<SdrAlign
>(0xFF00); }
102 void SetVertAlign(SdrAlign nAlg
) { assert((nAlg
& static_cast<SdrAlign
>(0x00FF)) == SdrAlign::NONE
); nAlign
= SdrAlign(nAlign
& static_cast<SdrAlign
>(0x00FF)) | (nAlg
& static_cast<SdrAlign
>(0xFF00)); }
103 bool IsHit(const Point
& rPnt
, const OutputDevice
& rOut
, const SdrObject
* pObj
) const;
104 void Invalidate(vcl::Window
& rWin
, const SdrObject
* pObj
) const;
105 Point
GetAbsolutePos(const SdrObject
& rObj
) const;
106 void SetAbsolutePos(const Point
& rNewPos
, const SdrObject
& rObj
);
107 long GetAlignAngle() const;
108 void SetAlignAngle(long nAngle
);
109 static long EscDirToAngle(SdrEscapeDirection nEsc
);
110 static SdrEscapeDirection
EscAngleToDir(long nAngle
);
111 void Rotate(const Point
& rRef
, long nAngle
, double sn
, double cs
, const SdrObject
* pObj
);
112 void Mirror(const Point
& rRef1
, const Point
& rRef2
, long nAngle
, const SdrObject
* pObj
);
113 void Shear (const Point
& rRef
, double tn
, bool bVShear
, const SdrObject
* pObj
);
116 #define SDRGLUEPOINT_NOTFOUND 0xFFFF
118 class SVX_DLLPUBLIC SdrGluePointList
{
119 std::vector
<std::unique_ptr
<SdrGluePoint
>> aList
;
121 SdrGluePointList() {};
122 SdrGluePointList(const SdrGluePointList
& rSrcList
) { *this=rSrcList
; }
125 SdrGluePointList
& operator=(const SdrGluePointList
& rSrcList
);
126 sal_uInt16
GetCount() const { return sal_uInt16(aList
.size()); }
127 // At insert, the object (GluePoint) automatically gets an ID assigned.
128 // Return value is the index of the new GluePoint in the list.
129 sal_uInt16
Insert(const SdrGluePoint
& rGP
);
130 void Delete(sal_uInt16 nPos
)
132 aList
.erase(aList
.begin()+nPos
);
134 SdrGluePoint
& operator[](sal_uInt16 nPos
) { return *aList
[nPos
]; }
135 const SdrGluePoint
& operator[](sal_uInt16 nPos
) const { return *aList
[nPos
]; }
136 sal_uInt16
FindGluePoint(sal_uInt16 nId
) const;
137 sal_uInt16
HitTest(const Point
& rPnt
, const OutputDevice
& rOut
, const SdrObject
* pObj
) const;
138 void Invalidate(vcl::Window
& rWin
, const SdrObject
* pObj
) const;
139 // temp for transformations on the reference object
140 void SetReallyAbsolute(bool bOn
, const SdrObject
& rObj
);
141 void Rotate(const Point
& rRef
, long nAngle
, double sn
, double cs
, const SdrObject
* pObj
);
142 void Mirror(const Point
& rRef1
, const Point
& rRef2
, const SdrObject
* pObj
);
143 void Mirror(const Point
& rRef1
, const Point
& rRef2
, long nAngle
, const SdrObject
* pObj
);
144 void Shear (const Point
& rRef
, double tn
, bool bVShear
, const SdrObject
* pObj
);
148 #endif // INCLUDED_SVX_SVDGLUE_HXX
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */