xref: /trunk/main/svx/inc/svx/svdglue.hxx (revision b5da552ccefc4034e06a43bfae43fb8a8b64a7ad)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVDGLUE_HXX
25 #define _SVDGLUE_HXX
26 
27 class Window;
28 class OutputDevice;
29 class SvStream;
30 class SdrObject;
31 
32 #include <tools/contnr.hxx>
33 #include <tools/gen.hxx>
34 #include "svx/svxdllapi.h"
35 
36 ////////////////////////////////////////////////////////////////////////////////////////////////////
37 
38 #define SDRESC_SMART  0x0000
39 #define SDRESC_LEFT   0x0001
40 #define SDRESC_RIGHT  0x0002
41 #define SDRESC_TOP    0x0004
42 #define SDRESC_BOTTOM 0x0008
43 #define SDRESC_LO    0x0010 /* ni */
44 #define SDRESC_LU    0x0020 /* ni */
45 #define SDRESC_RO    0x0040 /* ni */
46 #define SDRESC_RU    0x0080 /* ni */
47 #define SDRESC_HORZ  (SDRESC_LEFT|SDRESC_RIGHT)
48 #define SDRESC_VERT  (SDRESC_TOP|SDRESC_BOTTOM)
49 #define SDRESC_ALL   0x00FF
50 
51 #define SDRHORZALIGN_CENTER   0x0000
52 #define SDRHORZALIGN_LEFT     0x0001
53 #define SDRHORZALIGN_RIGHT    0x0002
54 #define SDRHORZALIGN_DONTCARE 0x0010
55 #define SDRVERTALIGN_CENTER   0x0000
56 #define SDRVERTALIGN_TOP      0x0100
57 #define SDRVERTALIGN_BOTTOM   0x0200
58 #define SDRVERTALIGN_DONTCARE 0x1000
59 
60 class SVX_DLLPUBLIC SdrGluePoint {
61     // Bezugspunkt ist SdrObject::GetSnapRect().Center()
62     // bNoPercent=FALSE: Position ist -5000..5000 (1/100)% bzw. 0..10000 (je nach Align)
63     // bNoPercent=sal_True : Position ist in log Einh, rel zum Bezugspunkt
64     Point    aPos;
65     sal_uInt16   nEscDir;
66     sal_uInt16   nId;
67     sal_uInt16   nAlign;
68     FASTBOOL bNoPercent:1;
69     FASTBOOL bReallyAbsolute:1; // Temporaer zu setzen fuer Transformationen am Bezugsobjekt
70     FASTBOOL bUserDefined:1; // #i38892#
71 public:
72     SdrGluePoint(): nEscDir(SDRESC_SMART),nId(0),nAlign(0) { bNoPercent=sal_False; bReallyAbsolute=sal_False; bUserDefined=sal_True; }
73     SdrGluePoint(const Point& rNewPos, FASTBOOL bNewPercent=sal_True, sal_uInt16 nNewAlign=0): aPos(rNewPos),nEscDir(SDRESC_SMART),nId(0),nAlign(nNewAlign) { bNoPercent=!bNewPercent; bReallyAbsolute=sal_False; bUserDefined=sal_True; }
74     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; }
75     bool operator!=(const SdrGluePoint& rCmpGP) const   { return !operator==(rCmpGP); }
76     const Point& GetPos() const                             { return aPos; }
77     void         SetPos(const Point& rNewPos)               { aPos=rNewPos; }
78     sal_uInt16       GetEscDir() const                          { return nEscDir; }
79     void         SetEscDir(sal_uInt16 nNewEsc)                  { nEscDir=nNewEsc; }
80     sal_uInt16       GetId() const                              { return nId; }
81     void         SetId(sal_uInt16 nNewId)                       { nId=nNewId; }
82     bool         IsPercent() const                          { return !bNoPercent; }
83     void         SetPercent(FASTBOOL bOn)                   { bNoPercent=!bOn; }
84     // Temporaer zu setzen fuer Transformationen am Bezugsobjekt
85     FASTBOOL     IsReallyAbsolute() const                   { return bReallyAbsolute; }
86     void         SetReallyAbsolute(FASTBOOL bOn, const SdrObject& rObj);
87 
88     // #i38892#
89     FASTBOOL     IsUserDefined() const                   { return bUserDefined; }
90     void         SetUserDefined(FASTBOOL bNew)           { bUserDefined = bNew; }
91 
92     sal_uInt16       GetAlign() const                           { return nAlign; }
93     void         SetAlign(sal_uInt16 nAlg)                      { nAlign=nAlg; }
94     sal_uInt16       GetHorzAlign() const                       { return nAlign&0x00FF; }
95     void         SetHorzAlign(sal_uInt16 nAlg)                  { nAlign=(nAlign&0xFF00)|(nAlg&0x00FF); }
96     sal_uInt16       GetVertAlign() const                       { return nAlign&0xFF00; }
97     void         SetVertAlign(sal_uInt16 nAlg)                  { nAlign=(nAlign&0x00FF)|(nAlg&0xFF00); }
98     void         Draw(OutputDevice& rOut, const SdrObject* pObj) const;
99     FASTBOOL     IsHit(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
100     void         Invalidate(Window& rWin, const SdrObject* pObj) const;
101     Point        GetAbsolutePos(const SdrObject& rObj) const;
102     void         SetAbsolutePos(const Point& rNewPos, const SdrObject& rObj);
103     long         GetAlignAngle() const;
104     void         SetAlignAngle(long nWink);
105     long         EscDirToAngle(sal_uInt16 nEsc) const;
106     sal_uInt16       EscAngleToDir(long nWink) const;
107     void         Rotate(const Point& rRef, long nWink, double sn, double cs, const SdrObject* pObj);
108     void         Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj);
109     void         Mirror(const Point& rRef1, const Point& rRef2, long nWink, const SdrObject* pObj);
110     void         Shear (const Point& rRef, long nWink, double tn, FASTBOOL bVShear, const SdrObject* pObj);
111 };
112 
113 #define SDRGLUEPOINT_NOTFOUND 0xFFFF
114 
115 class SVX_DLLPUBLIC SdrGluePointList {
116     Container aList;
117 protected:
118     SdrGluePoint* GetObject(sal_uInt16 i) const { return (SdrGluePoint*)(aList.GetObject(i)); }
119 public:
120     SdrGluePointList(): aList(1024,4,4) {}
121     SdrGluePointList(const SdrGluePointList& rSrcList): aList(1024,4,4)     { *this=rSrcList; }
122     ~SdrGluePointList()                                                     { Clear(); }
123     void                Clear();
124     void                operator=(const SdrGluePointList& rSrcList);
125     sal_uInt16              GetCount() const                                    { return sal_uInt16(aList.Count()); }
126     // Beim Insert wird dem Objekt (also dem GluePoint) automatisch eine Id zugewiesen.
127     // ReturnCode ist der Index des neuen GluePoints in der Liste
128     sal_uInt16              Insert(const SdrGluePoint& rGP);
129     void                Delete(sal_uInt16 nPos)                                 { delete (SdrGluePoint*)aList.Remove(nPos); }
130     SdrGluePoint&       operator[](sal_uInt16 nPos)                             { return *GetObject(nPos); }
131     const SdrGluePoint& operator[](sal_uInt16 nPos) const                       { return *GetObject(nPos); }
132     sal_uInt16              FindGluePoint(sal_uInt16 nId) const;
133     sal_uInt16              HitTest(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj, FASTBOOL bBack=sal_False, FASTBOOL bNext=sal_False, sal_uInt16 nId0=0) const;
134     void                Invalidate(Window& rWin, const SdrObject* pObj) const;
135     // Temporaer zu setzen fuer Transformationen am Bezugsobjekt
136     void                SetReallyAbsolute(FASTBOOL bOn, const SdrObject& rObj);
137     void                Rotate(const Point& rRef, long nWink, double sn, double cs, const SdrObject* pObj);
138     void                Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj);
139     void                Mirror(const Point& rRef1, const Point& rRef2, long nWink, const SdrObject* pObj);
140     void                Shear (const Point& rRef, long nWink, double tn, FASTBOOL bVShear, const SdrObject* pObj);
141 };
142 
143 
144 ////////////////////////////////////////////////////////////////////////////////////////////////////
145 
146 #endif //_SVDGLUE_HXX
147 
148