Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_SVX_SVDGLUE_HXX
21 : #define INCLUDED_SVX_SVDGLUE_HXX
22 :
23 : namespace vcl { class Window; }
24 : class OutputDevice;
25 : class SvStream;
26 : class SdrObject;
27 :
28 : #include <tools/gen.hxx>
29 : #include <svx/svxdllapi.h>
30 : #include <vector>
31 :
32 :
33 :
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
46 :
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
55 :
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=true : Position ist in log Einh, rel zum Bezugspunkt
60 : Point aPos;
61 : sal_uInt16 nEscDir;
62 : sal_uInt16 nId;
63 : sal_uInt16 nAlign;
64 : bool bNoPercent:1;
65 : bool bReallyAbsolute:1; // Temporaer zu setzen fuer Transformationen am Bezugsobjekt
66 : bool bUserDefined:1; // #i38892#
67 : public:
68 384 : SdrGluePoint(): nEscDir(SDRESC_SMART),nId(0),nAlign(0),bNoPercent(false),bReallyAbsolute(false),bUserDefined(true) {}
69 520 : SdrGluePoint(const Point& rNewPos, bool bNewPercent=true, sal_uInt16 nNewAlign=0): aPos(rNewPos),nEscDir(SDRESC_SMART),nId(0),nAlign(nNewAlign),bNoPercent(!bNewPercent),bReallyAbsolute(false),bUserDefined(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 1452 : const Point& GetPos() const { return aPos; }
73 572 : void SetPos(const Point& rNewPos) { aPos=rNewPos; }
74 520 : sal_uInt16 GetEscDir() const { return nEscDir; }
75 160 : void SetEscDir(sal_uInt16 nNewEsc) { nEscDir=nNewEsc; }
76 5268 : sal_uInt16 GetId() const { return nId; }
77 160 : void SetId(sal_uInt16 nNewId) { nId=nNewId; }
78 520 : bool IsPercent() const { return !bNoPercent; }
79 680 : void SetPercent(bool bOn) { bNoPercent = !bOn; }
80 : // Temporaer zu setzen fuer Transformationen am Bezugsobjekt
81 : bool IsReallyAbsolute() const { return bReallyAbsolute; }
82 : void SetReallyAbsolute(bool bOn, const SdrObject& rObj);
83 :
84 : // #i38892#
85 1262 : bool IsUserDefined() const { return bUserDefined; }
86 1352 : void SetUserDefined(bool bNew) { bUserDefined = bNew; }
87 :
88 520 : sal_uInt16 GetAlign() const { return nAlign; }
89 160 : void SetAlign(sal_uInt16 nAlg) { nAlign=nAlg; }
90 612 : sal_uInt16 GetHorzAlign() const { return nAlign&0x00FF; }
91 0 : void SetHorzAlign(sal_uInt16 nAlg) { nAlign=(nAlign&0xFF00)|(nAlg&0x00FF); }
92 612 : sal_uInt16 GetVertAlign() const { return nAlign&0xFF00; }
93 0 : 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(vcl::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);
105 : };
106 :
107 : #define SDRGLUEPOINT_NOTFOUND 0xFFFF
108 :
109 : class SVX_DLLPUBLIC SdrGluePointList {
110 : std::vector<SdrGluePoint*> aList;
111 : protected:
112 10258 : SdrGluePoint* GetObject(sal_uInt16 i) const { return aList[i]; }
113 : public:
114 274 : SdrGluePointList(): aList() {}
115 0 : SdrGluePointList(const SdrGluePointList& rSrcList): aList() { *this=rSrcList; }
116 274 : ~SdrGluePointList() { Clear(); }
117 : void Clear();
118 : void operator=(const SdrGluePointList& rSrcList);
119 7742 : 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 0 : void Delete(sal_uInt16 nPos)
124 : {
125 0 : SdrGluePoint* p = aList[nPos];
126 0 : aList.erase(aList.begin()+nPos);
127 0 : delete p;
128 0 : }
129 420 : SdrGluePoint& operator[](sal_uInt16 nPos) { return *GetObject(nPos); }
130 3966 : 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(vcl::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);
140 : };
141 :
142 :
143 :
144 :
145 : #endif // INCLUDED_SVX_SVDGLUE_HXX
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|