xref: /AOO41X/main/svx/inc/svx/svdglue.hxx (revision 5876ddcaa727000da06189fba3a2f4ebb924ef74)
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:
SdrGluePoint()72     SdrGluePoint(): nEscDir(SDRESC_SMART),nId(0),nAlign(0) { bNoPercent=sal_False; bReallyAbsolute=sal_False; bUserDefined=sal_True; }
SdrGluePoint(const Point & rNewPos,FASTBOOL bNewPercent=sal_True,sal_uInt16 nNewAlign=0)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; }
operator ==(const SdrGluePoint & rCmpGP) const74     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; }
operator !=(const SdrGluePoint & rCmpGP) const75     bool operator!=(const SdrGluePoint& rCmpGP) const   { return !operator==(rCmpGP); }
GetPos() const76     const Point& GetPos() const                             { return aPos; }
SetPos(const Point & rNewPos)77     void         SetPos(const Point& rNewPos)               { aPos=rNewPos; }
GetEscDir() const78     sal_uInt16       GetEscDir() const                          { return nEscDir; }
SetEscDir(sal_uInt16 nNewEsc)79     void         SetEscDir(sal_uInt16 nNewEsc)                  { nEscDir=nNewEsc; }
GetId() const80     sal_uInt16       GetId() const                              { return nId; }
SetId(sal_uInt16 nNewId)81     void         SetId(sal_uInt16 nNewId)                       { nId=nNewId; }
IsPercent() const82     bool         IsPercent() const                          { return !bNoPercent; }
SetPercent(FASTBOOL bOn)83     void         SetPercent(FASTBOOL bOn)                   { bNoPercent=!bOn; }
84     // Temporaer zu setzen fuer Transformationen am Bezugsobjekt
IsReallyAbsolute() const85     FASTBOOL     IsReallyAbsolute() const                   { return bReallyAbsolute; }
86     void         SetReallyAbsolute(FASTBOOL bOn, const SdrObject& rObj);
87 
88     // #i38892#
IsUserDefined() const89     FASTBOOL     IsUserDefined() const                   { return bUserDefined; }
SetUserDefined(FASTBOOL bNew)90     void         SetUserDefined(FASTBOOL bNew)           { bUserDefined = bNew; }
91 
GetAlign() const92     sal_uInt16       GetAlign() const                           { return nAlign; }
SetAlign(sal_uInt16 nAlg)93     void         SetAlign(sal_uInt16 nAlg)                      { nAlign=nAlg; }
GetHorzAlign() const94     sal_uInt16       GetHorzAlign() const                       { return nAlign&0x00FF; }
SetHorzAlign(sal_uInt16 nAlg)95     void         SetHorzAlign(sal_uInt16 nAlg)                  { nAlign=(nAlign&0xFF00)|(nAlg&0x00FF); }
GetVertAlign() const96     sal_uInt16       GetVertAlign() const                       { return nAlign&0xFF00; }
SetVertAlign(sal_uInt16 nAlg)97     void         SetVertAlign(sal_uInt16 nAlg)                  { nAlign=(nAlign&0x00FF)|(nAlg&0xFF00); }
98     FASTBOOL     IsHit(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
99     void         Invalidate(Window& rWin, const SdrObject* pObj) const;
100     Point        GetAbsolutePos(const SdrObject& rObj) const;
101     void         SetAbsolutePos(const Point& rNewPos, const SdrObject& rObj);
102     long         GetAlignAngle() const;
103     void         SetAlignAngle(long nWink);
104     long         EscDirToAngle(sal_uInt16 nEsc) const;
105     sal_uInt16       EscAngleToDir(long nWink) const;
106     void         Rotate(const Point& rRef, long nWink, double sn, double cs, const SdrObject* pObj);
107     void         Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj);
108     void         Mirror(const Point& rRef1, const Point& rRef2, long nWink, const SdrObject* pObj);
109     void         Shear (const Point& rRef, long nWink, double tn, FASTBOOL bVShear, const SdrObject* pObj);
110 };
111 
112 #define SDRGLUEPOINT_NOTFOUND 0xFFFF
113 
114 class SVX_DLLPUBLIC SdrGluePointList {
115     Container aList;
116 protected:
GetObject(sal_uInt16 i) const117     SdrGluePoint* GetObject(sal_uInt16 i) const { return (SdrGluePoint*)(aList.GetObject(i)); }
118 public:
SdrGluePointList()119     SdrGluePointList(): aList(1024,4,4) {}
SdrGluePointList(const SdrGluePointList & rSrcList)120     SdrGluePointList(const SdrGluePointList& rSrcList): aList(1024,4,4)     { *this=rSrcList; }
~SdrGluePointList()121     ~SdrGluePointList()                                                     { Clear(); }
122     void                Clear();
123     void                operator=(const SdrGluePointList& rSrcList);
GetCount() const124     sal_uInt16              GetCount() const                                    { return sal_uInt16(aList.Count()); }
125     // Beim Insert wird dem Objekt (also dem GluePoint) automatisch eine Id zugewiesen.
126     // ReturnCode ist der Index des neuen GluePoints in der Liste
127     sal_uInt16              Insert(const SdrGluePoint& rGP);
Delete(sal_uInt16 nPos)128     void                Delete(sal_uInt16 nPos)                                 { delete (SdrGluePoint*)aList.Remove(nPos); }
operator [](sal_uInt16 nPos)129     SdrGluePoint&       operator[](sal_uInt16 nPos)                             { return *GetObject(nPos); }
operator [](sal_uInt16 nPos) const130     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, FASTBOOL bBack=sal_False, FASTBOOL bNext=sal_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(FASTBOOL 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, FASTBOOL bVShear, const SdrObject* pObj);
140 };
141 
142 
143 ////////////////////////////////////////////////////////////////////////////////////////////////////
144 
145 #endif //_SVDGLUE_HXX
146 
147