LCOV - code coverage report
Current view: top level - libreoffice/svx/inc/svx - svdmark.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 30 66 45.5 %
Date: 2012-12-17 Functions: 12 25 48.0 %
Legend: Lines: hit not hit

          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 _SVDMARK_HXX
      21             : #define _SVDMARK_HXX
      22             : 
      23             : #include <vector>
      24             : 
      25             : #include <tools/string.hxx>
      26             : #include "svx/svxdllapi.h"
      27             : #include <svx/sdrobjectuser.hxx>
      28             : 
      29             : #include <set>
      30             : 
      31             : class Rectangle;
      32             : class SdrPage;
      33             : class SdrObjList;
      34             : class SdrObject;
      35             : class SdrPageView;
      36             : 
      37             : typedef std::set<sal_uInt16> SdrUShortCont;
      38             : 
      39             : 
      40             : // Alles was eine View ueber ein markiertes Objekt wissen muss
      41             : class SVX_DLLPUBLIC SdrMark : public sdr::ObjectUser
      42             : {
      43             : protected:
      44             :     SdrObject*                                          mpSelectedSdrObject;    // the seleceted object
      45             :     SdrPageView*                                        mpPageView;
      46             :     SdrUShortCont*                                      mpPoints;     // Markierte Punkte
      47             :     SdrUShortCont*                                      mpLines;      // Markierte Linienabschnitte
      48             :     SdrUShortCont*                                      mpGluePoints; // Markierte Klebepunkte (deren Id's)
      49             :     sal_Bool                                            mbCon1;       // fuer Connectoren
      50             :     sal_Bool                                            mbCon2;       // fuer Connectoren
      51             :     sal_uInt16                                          mnUser;       // z.B. fuer CopyObjects, mitkopieren von Edges
      52             : 
      53             : public:
      54             :     explicit SdrMark(SdrObject* pNewObj = 0L, SdrPageView* pNewPageView = 0L);
      55             :     SdrMark(const SdrMark& rMark);
      56             :     virtual ~SdrMark();
      57             : 
      58             :     // derived from ObjectUser
      59             :     virtual void ObjectInDestruction(const SdrObject& rObject);
      60             : 
      61             :     SdrMark& operator=(const SdrMark& rMark);
      62             :     sal_Bool operator==(const SdrMark& rMark) const;
      63             :     sal_Bool operator!=(const SdrMark& rMark) const
      64             :     {
      65             :         return !(operator==(rMark));
      66             :     }
      67             : 
      68             :     void SetMarkedSdrObj(SdrObject* pNewObj);
      69             :     SdrObject* GetMarkedSdrObj() const;
      70             : 
      71          66 :     SdrPageView* GetPageView() const
      72             :     {
      73          66 :         return mpPageView;
      74             :     }
      75             : 
      76           0 :     void SetPageView(SdrPageView* pNewPageView)
      77             :     {
      78           0 :         mpPageView = pNewPageView;
      79           0 :     }
      80             : 
      81           0 :     void SetCon1(sal_Bool bOn)
      82             :     {
      83           0 :         mbCon1 = bOn;
      84           0 :     }
      85             : 
      86           0 :     sal_Bool IsCon1() const
      87             :     {
      88           0 :         return mbCon1;
      89             :     }
      90             : 
      91           0 :     void SetCon2(sal_Bool bOn)
      92             :     {
      93           0 :         mbCon2 = bOn;
      94           0 :     }
      95             : 
      96           0 :     sal_Bool IsCon2() const
      97             :     {
      98           0 :         return mbCon2;
      99             :     }
     100             : 
     101           0 :     void SetUser(sal_uInt16 nVal)
     102             :     {
     103           0 :         mnUser = nVal;
     104           0 :     }
     105             : 
     106           0 :     sal_uInt16 GetUser() const
     107             :     {
     108           0 :         return mnUser;
     109             :     }
     110             : 
     111          22 :     const SdrUShortCont* GetMarkedPoints() const
     112             :     {
     113          22 :         return mpPoints;
     114             :     }
     115             : 
     116             :     const SdrUShortCont* GetMarkedLines() const
     117             :     {
     118             :         return mpLines;
     119             :     }
     120             : 
     121          22 :     const SdrUShortCont* GetMarkedGluePoints() const
     122             :     {
     123          22 :         return mpGluePoints;
     124             :     }
     125             : 
     126           0 :     SdrUShortCont* GetMarkedPoints()
     127             :     {
     128           0 :         return mpPoints;
     129             :     }
     130             : 
     131             :     SdrUShortCont* GetMarkedLines()
     132             :     {
     133             :         return mpLines;
     134             :     }
     135             : 
     136          22 :     SdrUShortCont* GetMarkedGluePoints()
     137             :     {
     138          22 :         return mpGluePoints;
     139             :     }
     140             : 
     141           0 :     SdrUShortCont* ForceMarkedPoints()
     142             :     {
     143           0 :         if(!mpPoints)
     144           0 :             mpPoints = new SdrUShortCont;
     145             : 
     146           0 :         return mpPoints;
     147             :     }
     148             : 
     149             :     SdrUShortCont* ForceMarkedLines()
     150             :     {
     151             :         if(!mpLines)
     152             :             mpLines = new SdrUShortCont;
     153             : 
     154             :         return mpLines;
     155             :     }
     156             : 
     157           0 :     SdrUShortCont* ForceMarkedGluePoints()
     158             :     {
     159           0 :         if(!mpGluePoints)
     160           0 :             mpGluePoints = new SdrUShortCont;
     161             : 
     162           0 :         return mpGluePoints;
     163             :     }
     164             : };
     165             : 
     166             : class SVX_DLLPUBLIC SdrMarkList
     167             : {
     168             : protected:
     169             :     std::vector<SdrMark*>                               maList;
     170             : 
     171             :     String                                              maMarkName;
     172             :     String                                              maPointName;
     173             :     String                                              maGluePointName;
     174             : 
     175             :     sal_Bool                                            mbPointNameOk;
     176             :     sal_Bool                                            mbGluePointNameOk;
     177             :     sal_Bool                                            mbNameOk;
     178             :     sal_Bool                                            mbSorted;
     179             : 
     180             : private:
     181             :     SVX_DLLPRIVATE sal_Bool operator==(const SdrMarkList& rCmpMarkList) const;
     182             :     SVX_DLLPRIVATE void ImpForceSort();
     183             : 
     184             : private:
     185             :     SVX_DLLPRIVATE const XubString& GetPointMarkDescription(sal_Bool bGlue) const;
     186             : 
     187             : public:
     188        6347 :     SdrMarkList()
     189             :     :   maList(),
     190             :         mbPointNameOk(sal_False),
     191             :         mbGluePointNameOk(sal_False),
     192             :         mbNameOk(sal_False),
     193        6347 :         mbSorted(sal_True)
     194             :     {
     195        6347 :     }
     196             : 
     197           0 :     SdrMarkList(const SdrMarkList& rLst)
     198           0 :     :   maList()
     199             :     {
     200           0 :         *this = rLst;
     201           0 :     }
     202             : 
     203        2593 :     ~SdrMarkList()
     204        2593 :     {
     205        2593 :         Clear();
     206        2593 :     }
     207             : 
     208             :     void Clear();
     209             :     void ForceSort() const;
     210         408 :     void SetUnsorted()
     211             :     {
     212         408 :         mbSorted = sal_False;
     213         408 :     }
     214             : 
     215       35469 :     sal_uLong GetMarkCount() const
     216             :     {
     217       35469 :         return maList.size();
     218             :     }
     219             : 
     220             :     SdrMark* GetMark(sal_uLong nNum) const;
     221             :     sal_uLong FindObject(const SdrObject* pObj) const;
     222             :     void InsertEntry(const SdrMark& rMark, sal_Bool bChkSort = sal_True);
     223             :     void DeleteMark(sal_uLong nNum);
     224             :     void ReplaceMark(const SdrMark& rNewMark, sal_uLong nNum);
     225             :     void Merge(const SdrMarkList& rSrcList, sal_Bool bReverse = sal_False);
     226             :     sal_Bool DeletePageView(const SdrPageView& rPV);
     227             :     sal_Bool InsertPageView(const SdrPageView& rPV);
     228             : 
     229        5678 :     void SetNameDirty()
     230             :     {
     231        5678 :         mbNameOk = sal_False;
     232        5678 :         mbPointNameOk = sal_False;
     233        5678 :         mbGluePointNameOk = sal_False;
     234        5678 :     }
     235             : 
     236             :     // Eine verbale Beschreibung der markierten Objekte z.B.:
     237             :     // "27 Linien", "12 Objekte", "Polygon" oder auch "Kein Objekt"
     238             :     const String& GetMarkDescription() const;
     239           0 :     const String& GetPointMarkDescription() const
     240             :     {
     241           0 :         return GetPointMarkDescription(sal_False);
     242             :     }
     243             : 
     244           0 :     const String& GetGluePointMarkDescription() const
     245             :     {
     246           0 :         return GetPointMarkDescription(sal_True);
     247             :     }
     248             : 
     249             :     // pPage=0L: Die Markierungen aller! Seiten beruecksichtigen
     250             :     sal_Bool TakeBoundRect(SdrPageView* pPageView, Rectangle& rRect) const;
     251             :     sal_Bool TakeSnapRect(SdrPageView* pPageView, Rectangle& rRect) const;
     252             : 
     253             :     // Es werden saemtliche Entries kopiert!
     254             :     void operator=(const SdrMarkList& rLst);
     255             : };
     256             : 
     257             : ////////////////////////////////////////////////////////////////////////////////////////////////////
     258             : // migrate selections
     259             : 
     260             : namespace sdr
     261             : {
     262         508 :     class SVX_DLLPUBLIC ViewSelection
     263             :     {
     264             :         SdrMarkList                 maMarkedObjectList;
     265             :         SdrMarkList                 maEdgesOfMarkedNodes;
     266             :         SdrMarkList                 maMarkedEdgesOfMarkedNodes;
     267             :         std::vector<SdrObject*>     maAllMarkedObjects;
     268             : 
     269             :         // bitfield
     270             :         unsigned                    mbEdgesOfMarkedNodesDirty : 1;
     271             : 
     272             :         SVX_DLLPRIVATE void ImpForceEdgesOfMarkedNodes();
     273             :         SVX_DLLPRIVATE void ImplCollectCompleteSelection(SdrObject* pObj);
     274             : 
     275             :     public:
     276             :         ViewSelection();
     277             : 
     278             :         void SetEdgesOfMarkedNodesDirty();
     279             : 
     280       30958 :         const SdrMarkList& GetMarkedObjectList() const
     281             :         {
     282       30958 :             return maMarkedObjectList;
     283             :         }
     284             : 
     285             :         const SdrMarkList& GetEdgesOfMarkedNodes() const;
     286             :         const SdrMarkList& GetMarkedEdgesOfMarkedNodes() const;
     287             :         const std::vector<SdrObject*>& GetAllMarkedObjects() const;
     288             : 
     289        1572 :         SdrMarkList& GetMarkedObjectListWriteAccess()
     290             :         {
     291        1572 :             return maMarkedObjectList;
     292             :         }
     293             :     };
     294             : } // end of namespace sdr
     295             : 
     296             : #endif //_SVDMARK_HXX
     297             : 
     298             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10