sync master with lastest vba changes
[ooovba.git] / binfilter / inc / bf_svx / svdmark.hxx
blobf99ad9bc181a6a36437d0fda73aa217fa290092b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdmark.hxx,v $
10 * $Revision: 1.5 $
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 ************************************************************************/
31 #ifndef _SVDMARK_HXX
32 #define _SVDMARK_HXX
34 #ifndef _CONTNR_HXX //autogen
35 #include <tools/contnr.hxx>
36 #endif
38 #ifndef _STRING_HXX //autogen
39 #include <tools/string.hxx>
40 #endif
41 class Rectangle;
42 namespace binfilter {
44 class SdrPage;
45 class SdrObjList;
46 class SdrObject;
47 class SdrPageView;
49 // Ein Container fuer USHORTs (im Prinzip ein dynamisches Array)
50 class SdrUShortCont {
51 Container aArr;
52 FASTBOOL bSorted;
53 FASTBOOL bDelDups;
54 private:
55 public:
56 SdrUShortCont(USHORT nBlock, USHORT nInit, USHORT nResize): aArr(nBlock,nInit,nResize), bSorted(TRUE), bDelDups(TRUE) {}
57 SdrUShortCont(const SdrUShortCont& rCont): aArr(rCont.aArr), bSorted(rCont.bSorted), bDelDups(rCont.bDelDups) {}
58 SdrUShortCont& operator=(const SdrUShortCont& rCont) { aArr=rCont.aArr; bSorted=rCont.bSorted; bDelDups=rCont.bDelDups; return *this; }
59 FASTBOOL operator==(const SdrUShortCont& rCont) const { return aArr==rCont.aArr; }
60 FASTBOOL operator!=(const SdrUShortCont& rCont) const { return aArr!=rCont.aArr; }
61 void Clear() { aArr.Clear(); bSorted=TRUE; }
62 void Remove(ULONG nPos) { aArr.Remove(nPos); }
63 USHORT GetObject(ULONG nPos) const { return USHORT(ULONG(aArr.GetObject(nPos))); }
64 ULONG GetPos(USHORT nElem) const { return aArr.GetPos((void*)(ULONG)nElem); }
65 ULONG GetCount() const { return aArr.Count(); }
66 FASTBOOL Exist(USHORT nElem) const { return aArr.GetPos((void*)(ULONG)nElem)!=CONTAINER_ENTRY_NOTFOUND; }
69 class SdrMark { // Alles was eine View ueber ein markiertes Objekt wissen muss
70 protected:
71 SdrObject* pObj;
72 SdrPageView* pPageView;
73 SdrUShortCont* pPoints; // Markierte Punkte
74 SdrUShortCont* pLines; // Markierte Linienabschnitte
75 SdrUShortCont* pGluePoints; // Markierte Klebepunkte (deren Id's)
76 FASTBOOL bCon1; // fuer Connectoren
77 FASTBOOL bCon2; // fuer Connectoren
78 USHORT nUser; // z.B. fuer CopyObjects, mitkopieren von Edges
79 public:
80 SdrMark(SdrObject* pNewObj=NULL, SdrPageView* pNewPageView=NULL): pObj(pNewObj), pPageView(pNewPageView), pPoints(NULL), pLines(NULL), pGluePoints(NULL), bCon1(FALSE), bCon2(FALSE), nUser(0) {}
81 SdrMark(const SdrMark& rMark): pObj(NULL), pPageView(NULL), pPoints(NULL), pLines(NULL), pGluePoints(NULL), bCon1(FALSE), bCon2(FALSE), nUser(0) { *this=rMark; }
82 ~SdrMark() { if (pPoints!=NULL) delete pPoints; if (pLines!=NULL) delete pLines; if (pGluePoints!=NULL) delete pGluePoints; }
83 SdrObject* GetObj() const { return pObj; }
84 SdrPageView* GetPageView() const { return pPageView; }
85 void SetObj(SdrObject* pNewObj) { pObj =pNewObj; }
86 void SetPageView(SdrPageView* pNewPageView) { pPageView=pNewPageView; }
87 void SetCon1(FASTBOOL bOn) { bCon1=bOn; }
88 FASTBOOL IsCon1() const { return bCon1; }
89 void SetCon2(FASTBOOL bOn) { bCon2=bOn; }
90 FASTBOOL IsCon2() const { return bCon2; }
91 void SetUser(USHORT nVal) { nUser=nVal; }
92 USHORT GetUser() const { return nUser; }
93 const SdrUShortCont* GetMarkedPoints() const { return pPoints; }
94 const SdrUShortCont* GetMarkedLines() const { return pLines; }
95 const SdrUShortCont* GetMarkedGluePoints() const { return pGluePoints; }
96 SdrUShortCont* GetMarkedPoints() { return pPoints; }
97 SdrUShortCont* GetMarkedLines() { return pLines; }
98 SdrUShortCont* GetMarkedGluePoints() { return pGluePoints; }
99 SdrUShortCont* ForceMarkedPoints() { if (pPoints==NULL) pPoints=new SdrUShortCont(1024,32,32); return pPoints; }
100 SdrUShortCont* ForceMarkedLines() { if (pLines==NULL) pLines=new SdrUShortCont(1024,32,32); return pLines; }
101 SdrUShortCont* ForceMarkedGluePoints() { if (pGluePoints==NULL) pGluePoints=new SdrUShortCont(1024,32,32); return pGluePoints; }
104 class SdrMarkList {
105 protected:
106 Container aList;
107 String aMarkName;
108 String aPointName;
109 String aGluePointName;
110 FASTBOOL bPointNameOk;
111 FASTBOOL bGluePointNameOk;
112 FASTBOOL bNameOk;
113 FASTBOOL bSorted;
114 private:
115 // Nicht implementiert:
116 FASTBOOL operator==(const SdrMarkList& rCmpMarkList) const;
117 private:
118 const XubString& GetPointMarkDescription(FASTBOOL bGlue) const;
119 protected:
120 public:
121 SdrMarkList() : aList(1024,64,64),bPointNameOk(FALSE),bGluePointNameOk(FALSE),bNameOk(FALSE),bSorted(TRUE) { }
122 SdrMarkList(const SdrMarkList& rLst) : aList(1024,64,64) { *this=rLst; }
123 ~SdrMarkList() { Clear(); }
124 void Clear();
125 // Sicherstellen, das die Liste sortiert ist:
126 void ForceSort();
127 void SetUnsorted() { bSorted=FALSE; }
128 ULONG GetMarkCount() const { return aList.Count(); }
129 SdrMark* GetMark(ULONG nNum) const { return (SdrMark*)(aList.GetObject(nNum)); }
131 // FindObject() sucht nach einer Markierung eines SdrObject.
132 // Die Methode ist nicht const, da ein ForceSort gerufen wird!
133 // Rueckgabewert ist der Index der gefundenen Mark-Entry bzw.
134 // CONTAINER_ENTRY_NOTFOUND.
135 ULONG FindObject(const SdrObject* pObj);
137 void InsertEntry(const SdrMark& rMark, FASTBOOL bChkSort=TRUE);
139 // bReverse kann einen Performancevorteil bringen, wenn sicher ist,
140 // dass die SrcList genau verkehrt herum ist.
142 // Alle Entrys einer bestimmten PageView rauswerfen inkl delete
143 FASTBOOL DeletePageView (const SdrPageView& rPV);
144 // Alle Objekte einer Seiteansicht markieren
146 void SetNameDirty() { bNameOk=FALSE; bPointNameOk=FALSE; bGluePointNameOk=FALSE; }
148 // Eine verbale Beschreibung der markierten Objekte z.B.:
149 // "27 Linien", "12 Objekte", "Polygon" oder auch "Kein Objekt"
150 const String& GetGluePointMarkDescription() const { return GetPointMarkDescription(TRUE); }
152 // Schliesslich kann sich eine Mehrfach-Markierung
153 // ueber mehrere Seiten erstrecken ...
154 // pPage=NULL: Die Markierungen aller! Seiten beruecksichtigen
155 FASTBOOL TakeBoundRect(SdrPageView* pPageView, Rectangle& rRect) const;
156 FASTBOOL TakeSnapRect(SdrPageView* pPageView, Rectangle& rRect) const;
158 // Es werden saemtliche Entries kopiert!
159 void operator=(const SdrMarkList& rLst);
162 // Die Klasse kopiert alle eingefuegten MarkEntrys auf den Heap. Die Verwendung
163 // ist z.B. wie folgt gedacht:
164 // InsertEntry(SdrMark(pObj,pPage));
166 }//end of namespace binfilter
167 #endif //_SVDMARK_HXX