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>
26 #include <o3tl/typed_flags_set.hxx>
28 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 SVX_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#
79 SdrGluePoint(): nEscDir(SdrEscapeDirection::SMART
),nId(0),nAlign(SdrAlign::NONE
),bNoPercent(false),bReallyAbsolute(false),bUserDefined(true) {}
80 SdrGluePoint(const Point
& rNewPos
): aPos(rNewPos
),nEscDir(SdrEscapeDirection::SMART
),nId(0),nAlign(SdrAlign::NONE
),bNoPercent(false),bReallyAbsolute(false),bUserDefined(true) {}
81 const Point
& GetPos() const { return aPos
; }
82 void SetPos(const Point
& rNewPos
) { aPos
=rNewPos
; }
83 SdrEscapeDirection
GetEscDir() const { return nEscDir
; }
84 void SetEscDir(SdrEscapeDirection nNewEsc
) { nEscDir
=nNewEsc
; }
85 sal_uInt16
GetId() const { return nId
; }
86 void SetId(sal_uInt16 nNewId
) { nId
=nNewId
; }
87 bool IsPercent() const { return !bNoPercent
; }
88 void SetPercent(bool bOn
) { bNoPercent
= !bOn
; }
89 // temp for transformations on the reference object
90 void SetReallyAbsolute(bool bOn
, const SdrObject
& rObj
);
93 bool IsUserDefined() const { return bUserDefined
; }
94 void SetUserDefined(bool bNew
) { bUserDefined
= bNew
; }
96 SdrAlign
GetAlign() const { return nAlign
; }
97 void SetAlign(SdrAlign nAlg
) { nAlign
=nAlg
; }
98 SdrAlign
GetHorzAlign() const { return nAlign
& static_cast<SdrAlign
>(0x00FF); }
99 void SetHorzAlign(SdrAlign nAlg
) { assert((nAlg
& static_cast<SdrAlign
>(0xff)) == SdrAlign::NONE
); nAlign
= SdrAlign(nAlign
& static_cast<SdrAlign
>(0xFF00)) | (nAlg
& static_cast<SdrAlign
>(0x00FF)); }
100 SdrAlign
GetVertAlign() const { return nAlign
& static_cast<SdrAlign
>(0xFF00); }
101 void SetVertAlign(SdrAlign nAlg
) { assert((nAlg
& static_cast<SdrAlign
>(0xff00)) == SdrAlign::NONE
); nAlign
= SdrAlign(nAlign
& static_cast<SdrAlign
>(0x00FF)) | (nAlg
& static_cast<SdrAlign
>(0xFF00)); }
102 bool IsHit(const Point
& rPnt
, const OutputDevice
& rOut
, const SdrObject
* pObj
) const;
103 void Invalidate(vcl::Window
& rWin
, const SdrObject
* pObj
) const;
104 Point
GetAbsolutePos(const SdrObject
& rObj
) const;
105 void SetAbsolutePos(const Point
& rNewPos
, const SdrObject
& rObj
);
106 long GetAlignAngle() const;
107 void SetAlignAngle(long nAngle
);
108 static long EscDirToAngle(SdrEscapeDirection nEsc
);
109 static SdrEscapeDirection
EscAngleToDir(long nAngle
);
110 void Rotate(const Point
& rRef
, long nAngle
, double sn
, double cs
, const SdrObject
* pObj
);
111 void Mirror(const Point
& rRef1
, const Point
& rRef2
, long nAngle
, const SdrObject
* pObj
);
112 void Shear (const Point
& rRef
, double tn
, bool bVShear
, const SdrObject
* pObj
);
115 #define SDRGLUEPOINT_NOTFOUND 0xFFFF
117 class SVX_DLLPUBLIC SdrGluePointList
{
118 std::vector
<SdrGluePoint
*> aList
;
120 SdrGluePoint
* GetObject(sal_uInt16 i
) const { return aList
[i
]; }
122 SdrGluePointList(): aList() {}
123 SdrGluePointList(const SdrGluePointList
& rSrcList
): aList() { *this=rSrcList
; }
124 ~SdrGluePointList() { Clear(); }
126 SdrGluePointList
& operator=(const SdrGluePointList
& rSrcList
);
127 sal_uInt16
GetCount() const { return sal_uInt16(aList
.size()); }
128 // At insert, the object (GluePoint) automatically gets an ID assigned.
129 // Return value is the index of the new GluePoint in the list.
130 sal_uInt16
Insert(const SdrGluePoint
& rGP
);
131 void Delete(sal_uInt16 nPos
)
133 SdrGluePoint
* p
= aList
[nPos
];
134 aList
.erase(aList
.begin()+nPos
);
137 SdrGluePoint
& operator[](sal_uInt16 nPos
) { return *GetObject(nPos
); }
138 const SdrGluePoint
& operator[](sal_uInt16 nPos
) const { return *GetObject(nPos
); }
139 sal_uInt16
FindGluePoint(sal_uInt16 nId
) const;
140 sal_uInt16
HitTest(const Point
& rPnt
, const OutputDevice
& rOut
, const SdrObject
* pObj
) const;
141 void Invalidate(vcl::Window
& rWin
, const SdrObject
* pObj
) const;
142 // temp for transformations on the reference object
143 void SetReallyAbsolute(bool bOn
, const SdrObject
& rObj
);
144 void Rotate(const Point
& rRef
, long nAngle
, double sn
, double cs
, const SdrObject
* pObj
);
145 void Mirror(const Point
& rRef1
, const Point
& rRef2
, const SdrObject
* pObj
);
146 void Mirror(const Point
& rRef1
, const Point
& rRef2
, long nAngle
, const SdrObject
* pObj
);
147 void Shear (const Point
& rRef
, double tn
, bool bVShear
, const SdrObject
* pObj
);
151 #endif // INCLUDED_SVX_SVDGLUE_HXX
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */