LCOV - code coverage report
Current view: top level - include/svx - svdmark.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 36 66 54.5 %
Date: 2014-04-11 Functions: 14 25 56.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 INCLUDED_SVX_SVDMARK_HXX
      21             : #define INCLUDED_SVX_SVDMARK_HXX
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : #include <svx/svxdllapi.h>
      25             : #include <svx/sdrobjectuser.hxx>
      26             : #include <tools/solar.h>
      27             : 
      28             : #include <set>
      29             : #include <vector>
      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             : // Everything a View needs to know about a selected object
      41             : class SVX_DLLPUBLIC SdrMark : public sdr::ObjectUser
      42             : {
      43             : protected:
      44             :     SdrObject*                                          mpSelectedSdrObject; // the selected object
      45             :     SdrPageView*                                        mpPageView;
      46             :     SdrUShortCont*                                      mpPoints;     // Selected Points
      47             :     SdrUShortCont*                                      mpLines;      // Selected Line
      48             :     SdrUShortCont*                                      mpGluePoints; // Selected Gluepoints (their Id's)
      49             :     bool                                                mbCon1;       // for Connectors
      50             :     bool                                                mbCon2;       // for Connectors
      51             :     sal_uInt16                                          mnUser;       // E.g. for CopyObjects, also copy 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) SAL_OVERRIDE;
      60             : 
      61             :     SdrMark& operator=(const SdrMark& rMark);
      62             :     bool operator==(const SdrMark& rMark) const;
      63             :     bool operator!=(const SdrMark& rMark) const
      64             :     {
      65             :         return !(operator==(rMark));
      66             :     }
      67             : 
      68             :     void SetMarkedSdrObj(SdrObject* pNewObj);
      69             :     SdrObject* GetMarkedSdrObj() const;
      70             : 
      71        1754 :     SdrPageView* GetPageView() const
      72             :     {
      73        1754 :         return mpPageView;
      74             :     }
      75             : 
      76           0 :     void SetPageView(SdrPageView* pNewPageView)
      77             :     {
      78           0 :         mpPageView = pNewPageView;
      79           0 :     }
      80             : 
      81           0 :     void SetCon1(bool bOn)
      82             :     {
      83           0 :         mbCon1 = bOn;
      84           0 :     }
      85             : 
      86           0 :     bool IsCon1() const
      87             :     {
      88           0 :         return mbCon1;
      89             :     }
      90             : 
      91           0 :     void SetCon2(bool bOn)
      92             :     {
      93           0 :         mbCon2 = bOn;
      94           0 :     }
      95             : 
      96           0 :     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         232 :     const SdrUShortCont* GetMarkedPoints() const
     112             :     {
     113         232 :         return mpPoints;
     114             :     }
     115             : 
     116             :     const SdrUShortCont* GetMarkedLines() const
     117             :     {
     118             :         return mpLines;
     119             :     }
     120             : 
     121         336 :     const SdrUShortCont* GetMarkedGluePoints() const
     122             :     {
     123         336 :         return mpGluePoints;
     124             :     }
     125             : 
     126          49 :     SdrUShortCont* GetMarkedPoints()
     127             :     {
     128          49 :         return mpPoints;
     129             :     }
     130             : 
     131             :     SdrUShortCont* GetMarkedLines()
     132             :     {
     133             :         return mpLines;
     134             :     }
     135             : 
     136         393 :     SdrUShortCont* GetMarkedGluePoints()
     137             :     {
     138         393 :         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             :     OUString                                            maMarkName;
     172             :     OUString                                            maPointName;
     173             :     OUString                                            maGluePointName;
     174             : 
     175             :     bool                                                mbPointNameOk;
     176             :     bool                                                mbGluePointNameOk;
     177             :     bool                                                mbNameOk;
     178             :     bool                                                mbSorted;
     179             : 
     180             : private:
     181             :     SVX_DLLPRIVATE bool operator==(const SdrMarkList& rCmpMarkList) const;
     182             :     SVX_DLLPRIVATE void ImpForceSort();
     183             : 
     184             : private:
     185             :     SVX_DLLPRIVATE const OUString& GetPointMarkDescription(bool bGlue) const;
     186             : 
     187             : public:
     188       27543 :     SdrMarkList()
     189             :     :   maList(),
     190             :         mbPointNameOk(false),
     191             :         mbGluePointNameOk(false),
     192             :         mbNameOk(false),
     193       27543 :         mbSorted(true)
     194             :     {
     195       27543 :     }
     196             : 
     197          41 :     SdrMarkList(const SdrMarkList& rLst)
     198          41 :     :   maList()
     199             :     {
     200          41 :         *this = rLst;
     201          41 :     }
     202             : 
     203       26715 :     ~SdrMarkList()
     204       26715 :     {
     205       26715 :         Clear();
     206       26715 :     }
     207             : 
     208             :     void Clear();
     209             :     void ForceSort() const;
     210        3462 :     void SetUnsorted()
     211             :     {
     212        3462 :         mbSorted = false;
     213        3462 :     }
     214             : 
     215      419244 :     sal_uLong GetMarkCount() const
     216             :     {
     217      419244 :         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, bool bChkSort = true);
     223             :     void DeleteMark(sal_uLong nNum);
     224             :     void ReplaceMark(const SdrMark& rNewMark, sal_uLong nNum);
     225             :     void Merge(const SdrMarkList& rSrcList, bool bReverse = false);
     226             :     bool DeletePageView(const SdrPageView& rPV);
     227             :     bool InsertPageView(const SdrPageView& rPV);
     228             : 
     229       42310 :     void SetNameDirty()
     230             :     {
     231       42310 :         mbNameOk = false;
     232       42310 :         mbPointNameOk = false;
     233       42310 :         mbGluePointNameOk = false;
     234       42310 :     }
     235             : 
     236             :     // A verbal description of selected objects e.g.:
     237             :     // "27 Lines", "12 Objects", "Polygon" or even "Not an object"
     238             :     const OUString& GetMarkDescription() const;
     239           0 :     const OUString& GetPointMarkDescription() const
     240             :     {
     241           0 :         return GetPointMarkDescription(false);
     242             :     }
     243             : 
     244           0 :     const OUString& GetGluePointMarkDescription() const
     245             :     {
     246           0 :         return GetPointMarkDescription(true);
     247             :     }
     248             : 
     249             :     // pPage=0L: Selection of everything! Respect Pages
     250             :     bool TakeBoundRect(SdrPageView* pPageView, Rectangle& rRect) const;
     251             :     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        5585 :     class SVX_DLLPUBLIC ViewSelection
     263             :     {
     264             :         SdrMarkList                 maMarkedObjectList;
     265             :         SdrMarkList                 maEdgesOfMarkedNodes;
     266             :         SdrMarkList                 maMarkedEdgesOfMarkedNodes;
     267             :         std::vector<SdrObject*>     maAllMarkedObjects;
     268             : 
     269             :         // bitfield
     270             :         bool                        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      392714 :         const SdrMarkList& GetMarkedObjectList() const
     281             :         {
     282      392714 :             return maMarkedObjectList;
     283             :         }
     284             : 
     285             :         const SdrMarkList& GetEdgesOfMarkedNodes() const;
     286             :         const SdrMarkList& GetMarkedEdgesOfMarkedNodes() const;
     287             :         const std::vector<SdrObject*>& GetAllMarkedObjects() const;
     288             : 
     289       12874 :         SdrMarkList& GetMarkedObjectListWriteAccess()
     290             :         {
     291       12874 :             return maMarkedObjectList;
     292             :         }
     293             :     };
     294             : } // end of namespace sdr
     295             : 
     296             : #endif // INCLUDED_SVX_SVDMARK_HXX
     297             : 
     298             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10