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
28 #include <tools/gen.hxx>
29 #include <svx/svxdllapi.h>
32 ////////////////////////////////////////////////////////////////////////////////////////////////////
34 #define SDRESC_SMART 0x0000
35 #define SDRESC_LEFT 0x0001
36 #define SDRESC_RIGHT 0x0002
37 #define SDRESC_TOP 0x0004
38 #define SDRESC_BOTTOM 0x0008
39 #define SDRESC_LO 0x0010 /* ni */
40 #define SDRESC_LU 0x0020 /* ni */
41 #define SDRESC_RO 0x0040 /* ni */
42 #define SDRESC_RU 0x0080 /* ni */
43 #define SDRESC_HORZ (SDRESC_LEFT|SDRESC_RIGHT)
44 #define SDRESC_VERT (SDRESC_TOP|SDRESC_BOTTOM)
45 #define SDRESC_ALL 0x00FF
47 #define SDRHORZALIGN_CENTER 0x0000
48 #define SDRHORZALIGN_LEFT 0x0001
49 #define SDRHORZALIGN_RIGHT 0x0002
50 #define SDRHORZALIGN_DONTCARE 0x0010
51 #define SDRVERTALIGN_CENTER 0x0000
52 #define SDRVERTALIGN_TOP 0x0100
53 #define SDRVERTALIGN_BOTTOM 0x0200
54 #define SDRVERTALIGN_DONTCARE 0x1000
56 class SVX_DLLPUBLIC SdrGluePoint
{
57 // Bezugspunkt ist SdrObject::GetSnapRect().Center()
58 // bNoPercent=FALSE: Position ist -5000..5000 (1/100)% bzw. 0..10000 (je nach Align)
59 // bNoPercent=sal_True : Position ist in log Einh, rel zum Bezugspunkt
64 sal_uInt8 bNoPercent
:1;
65 sal_uInt8 bReallyAbsolute
:1; // Temporaer zu setzen fuer Transformationen am Bezugsobjekt
66 sal_uInt8 bUserDefined
:1; // #i38892#
68 SdrGluePoint(): nEscDir(SDRESC_SMART
),nId(0),nAlign(0) { bNoPercent
=sal_False
; bReallyAbsolute
=sal_False
; bUserDefined
=sal_True
; }
69 SdrGluePoint(const Point
& rNewPos
, bool bNewPercent
= sal_True
, sal_uInt16 nNewAlign
=0): aPos(rNewPos
),nEscDir(SDRESC_SMART
),nId(0),nAlign(nNewAlign
) { bNoPercent
=!bNewPercent
; bReallyAbsolute
= sal_False
; bUserDefined
= sal_True
; }
70 bool operator==(const SdrGluePoint
& rCmpGP
) const { return aPos
==rCmpGP
.aPos
&& nEscDir
==rCmpGP
.nEscDir
&& nId
==rCmpGP
.nId
&& nAlign
==rCmpGP
.nAlign
&& bNoPercent
==rCmpGP
.bNoPercent
&& bReallyAbsolute
==rCmpGP
.bReallyAbsolute
&& bUserDefined
==rCmpGP
.bUserDefined
; }
71 bool operator!=(const SdrGluePoint
& rCmpGP
) const { return !operator==(rCmpGP
); }
72 const Point
& GetPos() const { return aPos
; }
73 void SetPos(const Point
& rNewPos
) { aPos
=rNewPos
; }
74 sal_uInt16
GetEscDir() const { return nEscDir
; }
75 void SetEscDir(sal_uInt16 nNewEsc
) { nEscDir
=nNewEsc
; }
76 sal_uInt16
GetId() const { return nId
; }
77 void SetId(sal_uInt16 nNewId
) { nId
=nNewId
; }
78 bool IsPercent() const { return bNoPercent
? false : true; }
79 void SetPercent(bool bOn
) { bNoPercent
= !bOn
; }
80 // Temporaer zu setzen fuer Transformationen am Bezugsobjekt
81 bool IsReallyAbsolute() const { return bReallyAbsolute
? true : false; }
82 void SetReallyAbsolute(bool bOn
, const SdrObject
& rObj
);
85 bool IsUserDefined() const { return bUserDefined
? true : false; }
86 void SetUserDefined(bool bNew
) { bUserDefined
= bNew
? true : false; }
88 sal_uInt16
GetAlign() const { return nAlign
; }
89 void SetAlign(sal_uInt16 nAlg
) { nAlign
=nAlg
; }
90 sal_uInt16
GetHorzAlign() const { return nAlign
&0x00FF; }
91 void SetHorzAlign(sal_uInt16 nAlg
) { nAlign
=(nAlign
&0xFF00)|(nAlg
&0x00FF); }
92 sal_uInt16
GetVertAlign() const { return nAlign
&0xFF00; }
93 void SetVertAlign(sal_uInt16 nAlg
) { nAlign
=(nAlign
&0x00FF)|(nAlg
&0xFF00); }
94 bool IsHit(const Point
& rPnt
, const OutputDevice
& rOut
, const SdrObject
* pObj
) const;
95 void Invalidate(Window
& rWin
, const SdrObject
* pObj
) const;
96 Point
GetAbsolutePos(const SdrObject
& rObj
) const;
97 void SetAbsolutePos(const Point
& rNewPos
, const SdrObject
& rObj
);
98 long GetAlignAngle() const;
99 void SetAlignAngle(long nWink
);
100 long EscDirToAngle(sal_uInt16 nEsc
) const;
101 sal_uInt16
EscAngleToDir(long nWink
) const;
102 void Rotate(const Point
& rRef
, long nWink
, double sn
, double cs
, const SdrObject
* pObj
);
103 void Mirror(const Point
& rRef1
, const Point
& rRef2
, long nWink
, const SdrObject
* pObj
);
104 void Shear (const Point
& rRef
, long nWink
, double tn
, bool bVShear
, const SdrObject
* pObj
);
107 #define SDRGLUEPOINT_NOTFOUND 0xFFFF
109 class SVX_DLLPUBLIC SdrGluePointList
{
110 std::vector
<SdrGluePoint
*> aList
;
112 SdrGluePoint
* GetObject(sal_uInt16 i
) const { return aList
[i
]; }
114 SdrGluePointList(): aList() {}
115 SdrGluePointList(const SdrGluePointList
& rSrcList
): aList() { *this=rSrcList
; }
116 ~SdrGluePointList() { Clear(); }
118 void operator=(const SdrGluePointList
& rSrcList
);
119 sal_uInt16
GetCount() const { return sal_uInt16(aList
.size()); }
120 // Beim Insert wird dem Objekt (also dem GluePoint) automatisch eine Id zugewiesen.
121 // ReturnCode ist der Index des neuen GluePoints in der Liste
122 sal_uInt16
Insert(const SdrGluePoint
& rGP
);
123 void Delete(sal_uInt16 nPos
)
125 SdrGluePoint
* p
= aList
[nPos
];
126 aList
.erase(aList
.begin()+nPos
);
129 SdrGluePoint
& operator[](sal_uInt16 nPos
) { return *GetObject(nPos
); }
130 const SdrGluePoint
& operator[](sal_uInt16 nPos
) const { return *GetObject(nPos
); }
131 sal_uInt16
FindGluePoint(sal_uInt16 nId
) const;
132 sal_uInt16
HitTest(const Point
& rPnt
, const OutputDevice
& rOut
, const SdrObject
* pObj
, bool bBack
= false, bool bNext
= false, sal_uInt16 nId0
=0) const;
133 void Invalidate(Window
& rWin
, const SdrObject
* pObj
) const;
134 // Temporaer zu setzen fuer Transformationen am Bezugsobjekt
135 void SetReallyAbsolute(bool bOn
, const SdrObject
& rObj
);
136 void Rotate(const Point
& rRef
, long nWink
, double sn
, double cs
, const SdrObject
* pObj
);
137 void Mirror(const Point
& rRef1
, const Point
& rRef2
, const SdrObject
* pObj
);
138 void Mirror(const Point
& rRef1
, const Point
& rRef2
, long nWink
, const SdrObject
* pObj
);
139 void Shear (const Point
& rRef
, long nWink
, double tn
, bool bVShear
, const SdrObject
* pObj
);
143 ////////////////////////////////////////////////////////////////////////////////////////////////////
145 #endif // INCLUDED_SVX_SVDGLUE_HXX
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */