1*3334a7e6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*3334a7e6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*3334a7e6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*3334a7e6SAndrew Rist * distributed with this work for additional information 6*3334a7e6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*3334a7e6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*3334a7e6SAndrew Rist * "License"); you may not use this file except in compliance 9*3334a7e6SAndrew Rist * with the License. You may obtain a copy of the License at 10*3334a7e6SAndrew Rist * 11*3334a7e6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*3334a7e6SAndrew Rist * 13*3334a7e6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*3334a7e6SAndrew Rist * software distributed under the License is distributed on an 15*3334a7e6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*3334a7e6SAndrew Rist * KIND, either express or implied. See the License for the 17*3334a7e6SAndrew Rist * specific language governing permissions and limitations 18*3334a7e6SAndrew Rist * under the License. 19*3334a7e6SAndrew Rist * 20*3334a7e6SAndrew Rist *************************************************************/ 21*3334a7e6SAndrew Rist 22*3334a7e6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SVDMARK_HXX 25cdf0e10cSrcweir #define _SVDMARK_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <tools/contnr.hxx> 28cdf0e10cSrcweir #include <tools/string.hxx> 29cdf0e10cSrcweir #include <tools/list.hxx> 30cdf0e10cSrcweir #include "svx/svxdllapi.h" 31cdf0e10cSrcweir #include <svx/sdrobjectuser.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <set> 34cdf0e10cSrcweir 35cdf0e10cSrcweir class Rectangle; 36cdf0e10cSrcweir class SdrPage; 37cdf0e10cSrcweir class SdrObjList; 38cdf0e10cSrcweir class SdrObject; 39cdf0e10cSrcweir class SdrPageView; 40cdf0e10cSrcweir 41cdf0e10cSrcweir // Ein Container fuer USHORTs (im Prinzip ein dynamisches Array) 42cdf0e10cSrcweir class SVX_DLLPUBLIC SdrUShortCont 43cdf0e10cSrcweir { 44cdf0e10cSrcweir Container maArray; 45cdf0e10cSrcweir sal_Bool mbSorted; 46cdf0e10cSrcweir 47cdf0e10cSrcweir private: 48cdf0e10cSrcweir void CheckSort(sal_uLong nPos); 49cdf0e10cSrcweir 50cdf0e10cSrcweir public: SdrUShortCont(sal_uInt16 nBlock,sal_uInt16 nInit,sal_uInt16 nResize)51cdf0e10cSrcweir SdrUShortCont(sal_uInt16 nBlock, sal_uInt16 nInit, sal_uInt16 nResize) 52cdf0e10cSrcweir : maArray(nBlock, nInit, nResize), 53cdf0e10cSrcweir mbSorted(sal_True) 54cdf0e10cSrcweir {} 55cdf0e10cSrcweir SdrUShortCont(const SdrUShortCont & rCont)56cdf0e10cSrcweir SdrUShortCont(const SdrUShortCont& rCont) 57cdf0e10cSrcweir : maArray(rCont.maArray), 58cdf0e10cSrcweir mbSorted(rCont.mbSorted) 59cdf0e10cSrcweir {} 60cdf0e10cSrcweir 61cdf0e10cSrcweir /** helper to migrate to stl containers */ 62cdf0e10cSrcweir std::set< sal_uInt16 > getContainer(); 63cdf0e10cSrcweir operator =(const SdrUShortCont & rCont)64cdf0e10cSrcweir SdrUShortCont& operator=(const SdrUShortCont& rCont) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir maArray = rCont.maArray; 67cdf0e10cSrcweir mbSorted = rCont.mbSorted; 68cdf0e10cSrcweir return *this; 69cdf0e10cSrcweir } 70cdf0e10cSrcweir operator ==(const SdrUShortCont & rCont) const71cdf0e10cSrcweir sal_Bool operator==(const SdrUShortCont& rCont) const 72cdf0e10cSrcweir { 73cdf0e10cSrcweir return maArray == rCont.maArray; 74cdf0e10cSrcweir } 75cdf0e10cSrcweir operator !=(const SdrUShortCont & rCont) const76cdf0e10cSrcweir sal_Bool operator!=(const SdrUShortCont& rCont) const 77cdf0e10cSrcweir { 78cdf0e10cSrcweir return maArray != rCont.maArray; 79cdf0e10cSrcweir } 80cdf0e10cSrcweir Clear()81cdf0e10cSrcweir void Clear() 82cdf0e10cSrcweir { 83cdf0e10cSrcweir maArray.Clear(); 84cdf0e10cSrcweir mbSorted = sal_True; 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir void Sort() const; 88cdf0e10cSrcweir ForceSort() const89cdf0e10cSrcweir void ForceSort() const 90cdf0e10cSrcweir { 91cdf0e10cSrcweir if(!mbSorted) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir Sort(); 94cdf0e10cSrcweir } 95cdf0e10cSrcweir } 96cdf0e10cSrcweir Insert(sal_uInt16 nElem,sal_uLong nPos=CONTAINER_APPEND)97cdf0e10cSrcweir void Insert(sal_uInt16 nElem, sal_uLong nPos = CONTAINER_APPEND) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir maArray.Insert((void*)sal_uLong(nElem),nPos); 100cdf0e10cSrcweir 101cdf0e10cSrcweir if(mbSorted) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir CheckSort(nPos); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir } 106cdf0e10cSrcweir Remove(sal_uLong nPos)107cdf0e10cSrcweir void Remove(sal_uLong nPos) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir maArray.Remove(nPos); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir Replace(sal_uInt16 nElem,sal_uLong nPos)112cdf0e10cSrcweir void Replace(sal_uInt16 nElem, sal_uLong nPos) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir maArray.Replace((void*)sal_uLong(nElem), nPos); 115cdf0e10cSrcweir 116cdf0e10cSrcweir if(mbSorted) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir CheckSort(nPos); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir } 121cdf0e10cSrcweir GetObject(sal_uLong nPos) const122cdf0e10cSrcweir sal_uInt16 GetObject(sal_uLong nPos) const 123cdf0e10cSrcweir { 124cdf0e10cSrcweir return sal_uInt16(sal_uIntPtr(maArray.GetObject(nPos))); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir GetPos(sal_uInt16 nElem) const127cdf0e10cSrcweir sal_uLong GetPos(sal_uInt16 nElem) const 128cdf0e10cSrcweir { 129cdf0e10cSrcweir return maArray.GetPos((void*)(sal_uLong)nElem); 130cdf0e10cSrcweir } 131cdf0e10cSrcweir GetCount() const132cdf0e10cSrcweir sal_uLong GetCount() const 133cdf0e10cSrcweir { 134cdf0e10cSrcweir return maArray.Count(); 135cdf0e10cSrcweir } 136cdf0e10cSrcweir Exist(sal_uInt16 nElem) const137cdf0e10cSrcweir sal_Bool Exist(sal_uInt16 nElem) const 138cdf0e10cSrcweir { 139cdf0e10cSrcweir return (CONTAINER_ENTRY_NOTFOUND != maArray.GetPos((void*)(sal_uLong)nElem)); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir }; 142cdf0e10cSrcweir 143cdf0e10cSrcweir // Alles was eine View ueber ein markiertes Objekt wissen muss 144cdf0e10cSrcweir class SVX_DLLPUBLIC SdrMark : public sdr::ObjectUser 145cdf0e10cSrcweir { 146cdf0e10cSrcweir protected: 147cdf0e10cSrcweir SdrObject* mpSelectedSdrObject; // the seleceted object 148cdf0e10cSrcweir SdrPageView* mpPageView; 149cdf0e10cSrcweir SdrUShortCont* mpPoints; // Markierte Punkte 150cdf0e10cSrcweir SdrUShortCont* mpLines; // Markierte Linienabschnitte 151cdf0e10cSrcweir SdrUShortCont* mpGluePoints; // Markierte Klebepunkte (deren Id's) 152cdf0e10cSrcweir sal_Bool mbCon1; // fuer Connectoren 153cdf0e10cSrcweir sal_Bool mbCon2; // fuer Connectoren 154cdf0e10cSrcweir sal_uInt16 mnUser; // z.B. fuer CopyObjects, mitkopieren von Edges 155cdf0e10cSrcweir 156cdf0e10cSrcweir public: 157cdf0e10cSrcweir SdrMark(SdrObject* pNewObj = 0L, SdrPageView* pNewPageView = 0L); 158cdf0e10cSrcweir SdrMark(const SdrMark& rMark); 159cdf0e10cSrcweir virtual ~SdrMark(); 160cdf0e10cSrcweir 161cdf0e10cSrcweir // derived from ObjectUser 162cdf0e10cSrcweir virtual void ObjectInDestruction(const SdrObject& rObject); 163cdf0e10cSrcweir 164cdf0e10cSrcweir SdrMark& operator=(const SdrMark& rMark); 165cdf0e10cSrcweir sal_Bool operator==(const SdrMark& rMark) const; operator !=(const SdrMark & rMark) const166cdf0e10cSrcweir sal_Bool operator!=(const SdrMark& rMark) const 167cdf0e10cSrcweir { 168cdf0e10cSrcweir return !(operator==(rMark)); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir void SetMarkedSdrObj(SdrObject* pNewObj); 172cdf0e10cSrcweir SdrObject* GetMarkedSdrObj() const; 173cdf0e10cSrcweir 174cdf0e10cSrcweir SdrPage* GetPage() const; 175cdf0e10cSrcweir SdrObjList* GetObjList() const; GetPageView() const176cdf0e10cSrcweir SdrPageView* GetPageView() const 177cdf0e10cSrcweir { 178cdf0e10cSrcweir return mpPageView; 179cdf0e10cSrcweir } 180cdf0e10cSrcweir SetPageView(SdrPageView * pNewPageView)181cdf0e10cSrcweir void SetPageView(SdrPageView* pNewPageView) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir mpPageView = pNewPageView; 184cdf0e10cSrcweir } 185cdf0e10cSrcweir SetCon1(sal_Bool bOn)186cdf0e10cSrcweir void SetCon1(sal_Bool bOn) 187cdf0e10cSrcweir { 188cdf0e10cSrcweir mbCon1 = bOn; 189cdf0e10cSrcweir } 190cdf0e10cSrcweir IsCon1() const191cdf0e10cSrcweir sal_Bool IsCon1() const 192cdf0e10cSrcweir { 193cdf0e10cSrcweir return mbCon1; 194cdf0e10cSrcweir } 195cdf0e10cSrcweir SetCon2(sal_Bool bOn)196cdf0e10cSrcweir void SetCon2(sal_Bool bOn) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir mbCon2 = bOn; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir IsCon2() const201cdf0e10cSrcweir sal_Bool IsCon2() const 202cdf0e10cSrcweir { 203cdf0e10cSrcweir return mbCon2; 204cdf0e10cSrcweir } 205cdf0e10cSrcweir SetUser(sal_uInt16 nVal)206cdf0e10cSrcweir void SetUser(sal_uInt16 nVal) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir mnUser = nVal; 209cdf0e10cSrcweir } 210cdf0e10cSrcweir GetUser() const211cdf0e10cSrcweir sal_uInt16 GetUser() const 212cdf0e10cSrcweir { 213cdf0e10cSrcweir return mnUser; 214cdf0e10cSrcweir } 215cdf0e10cSrcweir GetMarkedPoints() const216cdf0e10cSrcweir const SdrUShortCont* GetMarkedPoints() const 217cdf0e10cSrcweir { 218cdf0e10cSrcweir return mpPoints; 219cdf0e10cSrcweir } 220cdf0e10cSrcweir GetMarkedLines() const221cdf0e10cSrcweir const SdrUShortCont* GetMarkedLines() const 222cdf0e10cSrcweir { 223cdf0e10cSrcweir return mpLines; 224cdf0e10cSrcweir } 225cdf0e10cSrcweir GetMarkedGluePoints() const226cdf0e10cSrcweir const SdrUShortCont* GetMarkedGluePoints() const 227cdf0e10cSrcweir { 228cdf0e10cSrcweir return mpGluePoints; 229cdf0e10cSrcweir } 230cdf0e10cSrcweir GetMarkedPoints()231cdf0e10cSrcweir SdrUShortCont* GetMarkedPoints() 232cdf0e10cSrcweir { 233cdf0e10cSrcweir return mpPoints; 234cdf0e10cSrcweir } 235cdf0e10cSrcweir GetMarkedLines()236cdf0e10cSrcweir SdrUShortCont* GetMarkedLines() 237cdf0e10cSrcweir { 238cdf0e10cSrcweir return mpLines; 239cdf0e10cSrcweir } 240cdf0e10cSrcweir GetMarkedGluePoints()241cdf0e10cSrcweir SdrUShortCont* GetMarkedGluePoints() 242cdf0e10cSrcweir { 243cdf0e10cSrcweir return mpGluePoints; 244cdf0e10cSrcweir } 245cdf0e10cSrcweir ForceMarkedPoints()246cdf0e10cSrcweir SdrUShortCont* ForceMarkedPoints() 247cdf0e10cSrcweir { 248cdf0e10cSrcweir if(!mpPoints) 249cdf0e10cSrcweir mpPoints = new SdrUShortCont(1024, 32, 32); 250cdf0e10cSrcweir 251cdf0e10cSrcweir return mpPoints; 252cdf0e10cSrcweir } 253cdf0e10cSrcweir ForceMarkedLines()254cdf0e10cSrcweir SdrUShortCont* ForceMarkedLines() 255cdf0e10cSrcweir { 256cdf0e10cSrcweir if(!mpLines) 257cdf0e10cSrcweir mpLines = new SdrUShortCont(1024, 32, 32); 258cdf0e10cSrcweir 259cdf0e10cSrcweir return mpLines; 260cdf0e10cSrcweir } 261cdf0e10cSrcweir ForceMarkedGluePoints()262cdf0e10cSrcweir SdrUShortCont* ForceMarkedGluePoints() 263cdf0e10cSrcweir { 264cdf0e10cSrcweir if(!mpGluePoints) 265cdf0e10cSrcweir mpGluePoints = new SdrUShortCont(1024, 32, 32); 266cdf0e10cSrcweir 267cdf0e10cSrcweir return mpGluePoints; 268cdf0e10cSrcweir } 269cdf0e10cSrcweir }; 270cdf0e10cSrcweir 271cdf0e10cSrcweir class SVX_DLLPUBLIC SdrMarkList 272cdf0e10cSrcweir { 273cdf0e10cSrcweir protected: 274cdf0e10cSrcweir Container maList; 275cdf0e10cSrcweir 276cdf0e10cSrcweir String maMarkName; 277cdf0e10cSrcweir String maPointName; 278cdf0e10cSrcweir String maGluePointName; 279cdf0e10cSrcweir 280cdf0e10cSrcweir sal_Bool mbPointNameOk; 281cdf0e10cSrcweir sal_Bool mbGluePointNameOk; 282cdf0e10cSrcweir sal_Bool mbNameOk; 283cdf0e10cSrcweir sal_Bool mbSorted; 284cdf0e10cSrcweir 285cdf0e10cSrcweir private: 286cdf0e10cSrcweir SVX_DLLPRIVATE sal_Bool operator==(const SdrMarkList& rCmpMarkList) const; 287cdf0e10cSrcweir SVX_DLLPRIVATE void ImpForceSort(); 288cdf0e10cSrcweir 289cdf0e10cSrcweir private: 290cdf0e10cSrcweir SVX_DLLPRIVATE const XubString& GetPointMarkDescription(sal_Bool bGlue) const; 291cdf0e10cSrcweir 292cdf0e10cSrcweir public: SdrMarkList()293cdf0e10cSrcweir SdrMarkList() 294cdf0e10cSrcweir : maList(1024, 64, 64), 295cdf0e10cSrcweir mbPointNameOk(sal_False), 296cdf0e10cSrcweir mbGluePointNameOk(sal_False), 297cdf0e10cSrcweir mbNameOk(sal_False), 298cdf0e10cSrcweir mbSorted(sal_True) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir } 301cdf0e10cSrcweir SdrMarkList(const SdrMarkList & rLst)302cdf0e10cSrcweir SdrMarkList(const SdrMarkList& rLst) 303cdf0e10cSrcweir : maList(1024, 64, 64) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir *this = rLst; 306cdf0e10cSrcweir } 307cdf0e10cSrcweir ~SdrMarkList()308cdf0e10cSrcweir ~SdrMarkList() 309cdf0e10cSrcweir { 310cdf0e10cSrcweir Clear(); 311cdf0e10cSrcweir } 312cdf0e10cSrcweir 313cdf0e10cSrcweir void Clear(); 314cdf0e10cSrcweir void ForceSort() const; SetUnsorted()315cdf0e10cSrcweir void SetUnsorted() 316cdf0e10cSrcweir { 317cdf0e10cSrcweir mbSorted = sal_False; 318cdf0e10cSrcweir } 319cdf0e10cSrcweir GetMarkCount() const320cdf0e10cSrcweir sal_uLong GetMarkCount() const 321cdf0e10cSrcweir { 322cdf0e10cSrcweir return maList.Count(); 323cdf0e10cSrcweir } 324cdf0e10cSrcweir GetMark(sal_uLong nNum) const325cdf0e10cSrcweir SdrMark* GetMark(sal_uLong nNum) const 326cdf0e10cSrcweir { 327cdf0e10cSrcweir return (SdrMark*)(maList.GetObject(nNum)); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir sal_uLong FindObject(const SdrObject* pObj) const; 331cdf0e10cSrcweir void InsertEntry(const SdrMark& rMark, sal_Bool bChkSort = sal_True); 332cdf0e10cSrcweir void DeleteMark(sal_uLong nNum); 333cdf0e10cSrcweir void ReplaceMark(const SdrMark& rNewMark, sal_uLong nNum); 334cdf0e10cSrcweir void Merge(const SdrMarkList& rSrcList, sal_Bool bReverse = sal_False); 335cdf0e10cSrcweir sal_Bool DeletePageView(const SdrPageView& rPV); 336cdf0e10cSrcweir sal_Bool InsertPageView(const SdrPageView& rPV); 337cdf0e10cSrcweir SetNameDirty()338cdf0e10cSrcweir void SetNameDirty() 339cdf0e10cSrcweir { 340cdf0e10cSrcweir mbNameOk = sal_False; 341cdf0e10cSrcweir mbPointNameOk = sal_False; 342cdf0e10cSrcweir mbGluePointNameOk = sal_False; 343cdf0e10cSrcweir } 344cdf0e10cSrcweir 345cdf0e10cSrcweir // Eine verbale Beschreibung der markierten Objekte z.B.: 346cdf0e10cSrcweir // "27 Linien", "12 Objekte", "Polygon" oder auch "Kein Objekt" 347cdf0e10cSrcweir const String& GetMarkDescription() const; GetPointMarkDescription() const348cdf0e10cSrcweir const String& GetPointMarkDescription() const 349cdf0e10cSrcweir { 350cdf0e10cSrcweir return GetPointMarkDescription(sal_False); 351cdf0e10cSrcweir } 352cdf0e10cSrcweir GetGluePointMarkDescription() const353cdf0e10cSrcweir const String& GetGluePointMarkDescription() const 354cdf0e10cSrcweir { 355cdf0e10cSrcweir return GetPointMarkDescription(sal_True); 356cdf0e10cSrcweir } 357cdf0e10cSrcweir 358cdf0e10cSrcweir // pPage=0L: Die Markierungen aller! Seiten beruecksichtigen 359cdf0e10cSrcweir sal_Bool TakeBoundRect(SdrPageView* pPageView, Rectangle& rRect) const; 360cdf0e10cSrcweir sal_Bool TakeSnapRect(SdrPageView* pPageView, Rectangle& rRect) const; 361cdf0e10cSrcweir 362cdf0e10cSrcweir // Es werden saemtliche Entries kopiert! 363cdf0e10cSrcweir void operator=(const SdrMarkList& rLst); 364cdf0e10cSrcweir }; 365cdf0e10cSrcweir 366cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 367cdf0e10cSrcweir // migrate selections 368cdf0e10cSrcweir 369cdf0e10cSrcweir namespace sdr 370cdf0e10cSrcweir { 371cdf0e10cSrcweir class SVX_DLLPUBLIC ViewSelection 372cdf0e10cSrcweir { 373cdf0e10cSrcweir SdrMarkList maMarkedObjectList; 374cdf0e10cSrcweir SdrMarkList maEdgesOfMarkedNodes; 375cdf0e10cSrcweir SdrMarkList maMarkedEdgesOfMarkedNodes; 376cdf0e10cSrcweir List maAllMarkedObjects; 377cdf0e10cSrcweir 378cdf0e10cSrcweir // bitfield 379cdf0e10cSrcweir unsigned mbEdgesOfMarkedNodesDirty : 1; 380cdf0e10cSrcweir 381cdf0e10cSrcweir SVX_DLLPRIVATE void ImpForceEdgesOfMarkedNodes(); 382cdf0e10cSrcweir SVX_DLLPRIVATE void ImplCollectCompleteSelection(SdrObject* pObj); 383cdf0e10cSrcweir 384cdf0e10cSrcweir public: 385cdf0e10cSrcweir ViewSelection(); 386cdf0e10cSrcweir 387cdf0e10cSrcweir void SetEdgesOfMarkedNodesDirty(); 388cdf0e10cSrcweir GetMarkedObjectList() const389cdf0e10cSrcweir const SdrMarkList& GetMarkedObjectList() const 390cdf0e10cSrcweir { 391cdf0e10cSrcweir return maMarkedObjectList; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir 394cdf0e10cSrcweir const SdrMarkList& GetEdgesOfMarkedNodes() const; 395cdf0e10cSrcweir const SdrMarkList& GetMarkedEdgesOfMarkedNodes() const; 396cdf0e10cSrcweir const List& GetAllMarkedObjects() const; 397cdf0e10cSrcweir GetMarkedObjectListWriteAccess()398cdf0e10cSrcweir SdrMarkList& GetMarkedObjectListWriteAccess() 399cdf0e10cSrcweir { 400cdf0e10cSrcweir return maMarkedObjectList; 401cdf0e10cSrcweir } 402cdf0e10cSrcweir }; 403cdf0e10cSrcweir } // end of namespace sdr 404cdf0e10cSrcweir 405cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 406cdf0e10cSrcweir 407cdf0e10cSrcweir #endif //_SVDMARK_HXX 408cdf0e10cSrcweir // eof 409