1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdglue.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
38 }//end of namespace binfilter
39 #ifndef _CONTNR_HXX //autogen
40 #include <tools/contnr.hxx>
42 #ifndef _GEN_HXX //autogen
43 #include <tools/gen.hxx>
46 ////////////////////////////////////////////////////////////////////////////////////////////////////
48 #define SDRESC_SMART 0x0000
49 #define SDRESC_LEFT 0x0001
50 #define SDRESC_RIGHT 0x0002
51 #define SDRESC_TOP 0x0004
52 #define SDRESC_BOTTOM 0x0008
53 #define SDRESC_LO 0x0010 /* ni */
54 #define SDRESC_LU 0x0020 /* ni */
55 #define SDRESC_RO 0x0040 /* ni */
56 #define SDRESC_RU 0x0080 /* ni */
57 #define SDRESC_HORZ (SDRESC_LEFT|SDRESC_RIGHT)
58 #define SDRESC_VERT (SDRESC_TOP|SDRESC_BOTTOM)
59 #define SDRESC_ALL 0x00FF
61 #define SDRHORZALIGN_CENTER 0x0000
62 #define SDRHORZALIGN_LEFT 0x0001
63 #define SDRHORZALIGN_RIGHT 0x0002
64 #define SDRHORZALIGN_DONTCARE 0x0010
65 #define SDRVERTALIGN_CENTER 0x0000
66 #define SDRVERTALIGN_TOP 0x0100
67 #define SDRVERTALIGN_BOTTOM 0x0200
68 #define SDRVERTALIGN_DONTCARE 0x1000
71 // Bezugspunkt ist SdrObject::GetSnapRect().Center()
72 // bNoPercent=FALSE: Position ist -5000..5000 (1/100)% bzw. 0..10000 (je nach Align)
73 // bNoPercent=TRUE : Position ist in log Einh, rel zum Bezugspunkt
78 FASTBOOL bNoPercent
:1;
79 FASTBOOL bReallyAbsolute
:1; // Temporaer zu setzen fuer Transformationen am Bezugsobjekt
81 SdrGluePoint(): nEscDir(SDRESC_SMART
),nId(0),nAlign(0) { bNoPercent
=FALSE
; bReallyAbsolute
=FALSE
; }
82 SdrGluePoint(const Point
& rNewPos
, FASTBOOL bNewPercent
=TRUE
, USHORT nNewAlign
=0): aPos(rNewPos
),nEscDir(SDRESC_SMART
),nId(0),nAlign(nNewAlign
) { bNoPercent
=!bNewPercent
; bReallyAbsolute
=FALSE
; }
83 FASTBOOL
operator==(const SdrGluePoint
& rCmpGP
) const { return aPos
==rCmpGP
.aPos
&& nEscDir
==rCmpGP
.nEscDir
&& nId
==rCmpGP
.nId
&& nAlign
==rCmpGP
.nAlign
&& bNoPercent
==rCmpGP
.bNoPercent
&& bReallyAbsolute
==rCmpGP
.bReallyAbsolute
; }
84 FASTBOOL
operator!=(const SdrGluePoint
& rCmpGP
) const { return !operator==(rCmpGP
); }
85 const Point
& GetPos() const { return aPos
; }
86 void SetPos(const Point
& rNewPos
) { aPos
=rNewPos
; }
87 USHORT
GetEscDir() const { return nEscDir
; }
88 void SetEscDir(USHORT nNewEsc
) { nEscDir
=nNewEsc
; }
89 /*FASTBOOL IsEscapeSmart() const { return nEscDir==SDRESC_SMART; }
90 void SetEscapeSmart() { nEscDir=SDRESC_SMART; }
91 FASTBOOL IsEscapeLeft() const { return (nEscDir&SDRESC_LEFT)!=0; }
92 void SetEscapeLeft(FASTBOOL bOn) { nEscDir=bOn ? (nEscDir|SDRESC_LEFT) : (nEscDir&~SDRESC_LEFT); }
93 FASTBOOL IsEscapeRight() const { return (nEscDir&SDRESC_RIGHT)!=0; }
94 void SetEscapeRight(FASTBOOL bOn) { nEscDir=bOn ? (nEscDir|SDRESC_RIGHT) : (nEscDir&~SDRESC_RIGHT); }
95 FASTBOOL IsEscapeTop() const { return (nEscDir&SDRESC_TOP)!=0; }
96 void SetEscapeTop(FASTBOOL bOn) { nEscDir=bOn ? (nEscDir|SDRESC_TOP) : (nEscDir&~SDRESC_TOP); }
97 FASTBOOL IsEscapeBottom() const { return (nEscDir&SDRESC_BOTTOM)!=0; }
98 void SetEscapeBottom(FASTBOOL bOn) { nEscDir=bOn ? (nEscDir|SDRESC_BOTTOM) : (nEscDir&~SDRESC_BOTTOM); }*/
99 USHORT
GetId() const { return nId
; }
100 void SetId(USHORT nNewId
) { nId
=nNewId
; }
101 FASTBOOL
IsPercent() const { return !bNoPercent
; }
102 void SetPercent(FASTBOOL bOn
) { bNoPercent
=!bOn
; }
103 // Temporaer zu setzen fuer Transformationen am Bezugsobjekt
104 FASTBOOL
IsReallyAbsolute() const { return bReallyAbsolute
; }
105 USHORT
GetAlign() const { return nAlign
; }
106 void SetAlign(USHORT nAlg
) { nAlign
=nAlg
; }
107 USHORT
GetHorzAlign() const { return nAlign
&0x00FF; }
108 void SetHorzAlign(USHORT nAlg
) { nAlign
=(nAlign
&0xFF00)|(nAlg
&0x00FF); }
109 USHORT
GetVertAlign() const { return nAlign
&0xFF00; }
110 void SetVertAlign(USHORT nAlg
) { nAlign
=(nAlign
&0x00FF)|(nAlg
&0xFF00); }
111 Point
GetAbsolutePos(const SdrObject
& rObj
) const;
112 friend SvStream
& operator<<(SvStream
& rOut
, const SdrGluePoint
& rGP
);
113 friend SvStream
& operator>>(SvStream
& rIn
, SdrGluePoint
& rGP
);
116 #define SDRGLUEPOINT_NOTFOUND 0xFFFF
118 class SdrGluePointList
{
120 // FASTBOOL bSorted; // Muss noch implementiert werden oder?
121 // Eigentlich sollte die GluePointList stets sortiert sein (solange die
124 SdrGluePoint
* GetObject(USHORT i
) const { return (SdrGluePoint
*)(aList
.GetObject(i
)); }
126 SdrGluePointList(): aList(1024,4,4) {}
127 SdrGluePointList(const SdrGluePointList
& rSrcList
): aList(1024,4,4) { *this=rSrcList
; }
128 ~SdrGluePointList() { Clear(); }
130 USHORT
GetCount() const { return USHORT(aList
.Count()); }
131 // Beim Insert wird dem Objekt (also dem GluePoint) automatisch eine Id zugewiesen.
132 // ReturnCode ist der Index des neuen GluePoints in der Liste
133 USHORT
Insert(const SdrGluePoint
& rGP
);
134 void Delete(USHORT nPos
) { delete (SdrGluePoint
*)aList
.Remove(nPos
); }
135 SdrGluePoint
& operator[](USHORT nPos
) { return *GetObject(nPos
); }
136 const SdrGluePoint
& operator[](USHORT nPos
) const { return *GetObject(nPos
); }
137 USHORT
FindGluePoint(USHORT nId
) const;
138 // Temporaer zu setzen fuer Transformationen am Bezugsobjekt
139 friend SvStream
& operator<<(SvStream
& rOut
, const SdrGluePointList
& rGPL
);
140 friend SvStream
& operator>>(SvStream
& rIn
, SdrGluePointList
& rGPL
);
143 ////////////////////////////////////////////////////////////////////////////////////////////////////
145 }//end of namespace binfilter
146 #endif //_SVDGLUE_HXX