LCOV - code coverage report
Current view: top level - svx/inc/svx - svdmark.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 32 68 47.1 %
Date: 2012-08-25 Functions: 13 26 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 9 34 26.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _SVDMARK_HXX
      30                 :            : #define _SVDMARK_HXX
      31                 :            : 
      32                 :            : #include <vector>
      33                 :            : 
      34                 :            : #include <tools/string.hxx>
      35                 :            : #include "svx/svxdllapi.h"
      36                 :            : #include <svx/sdrobjectuser.hxx>
      37                 :            : 
      38                 :            : #include <set>
      39                 :            : 
      40                 :            : class Rectangle;
      41                 :            : class SdrPage;
      42                 :            : class SdrObjList;
      43                 :            : class SdrObject;
      44                 :            : class SdrPageView;
      45                 :            : 
      46                 :            : typedef std::set<sal_uInt16> SdrUShortCont;
      47                 :            : 
      48                 :            : 
      49                 :            : // Alles was eine View ueber ein markiertes Objekt wissen muss
      50                 :            : class SVX_DLLPUBLIC SdrMark : public sdr::ObjectUser
      51                 :            : {
      52                 :            : protected:
      53                 :            :     SdrObject*                                          mpSelectedSdrObject;    // the seleceted object
      54                 :            :     SdrPageView*                                        mpPageView;
      55                 :            :     SdrUShortCont*                                      mpPoints;     // Markierte Punkte
      56                 :            :     SdrUShortCont*                                      mpLines;      // Markierte Linienabschnitte
      57                 :            :     SdrUShortCont*                                      mpGluePoints; // Markierte Klebepunkte (deren Id's)
      58                 :            :     sal_Bool                                            mbCon1;       // fuer Connectoren
      59                 :            :     sal_Bool                                            mbCon2;       // fuer Connectoren
      60                 :            :     sal_uInt16                                          mnUser;       // z.B. fuer CopyObjects, mitkopieren von Edges
      61                 :            : 
      62                 :            : public:
      63                 :            :     explicit SdrMark(SdrObject* pNewObj = 0L, SdrPageView* pNewPageView = 0L);
      64                 :            :     SdrMark(const SdrMark& rMark);
      65                 :            :     virtual ~SdrMark();
      66                 :            : 
      67                 :            :     // derived from ObjectUser
      68                 :            :     virtual void ObjectInDestruction(const SdrObject& rObject);
      69                 :            : 
      70                 :            :     SdrMark& operator=(const SdrMark& rMark);
      71                 :            :     sal_Bool operator==(const SdrMark& rMark) const;
      72                 :            :     sal_Bool operator!=(const SdrMark& rMark) const
      73                 :            :     {
      74                 :            :         return !(operator==(rMark));
      75                 :            :     }
      76                 :            : 
      77                 :            :     void SetMarkedSdrObj(SdrObject* pNewObj);
      78                 :            :     SdrObject* GetMarkedSdrObj() const;
      79                 :            : 
      80                 :       6445 :     SdrPageView* GetPageView() const
      81                 :            :     {
      82                 :       6445 :         return mpPageView;
      83                 :            :     }
      84                 :            : 
      85                 :          0 :     void SetPageView(SdrPageView* pNewPageView)
      86                 :            :     {
      87                 :          0 :         mpPageView = pNewPageView;
      88                 :          0 :     }
      89                 :            : 
      90                 :          0 :     void SetCon1(sal_Bool bOn)
      91                 :            :     {
      92                 :          0 :         mbCon1 = bOn;
      93                 :          0 :     }
      94                 :            : 
      95                 :          0 :     sal_Bool IsCon1() const
      96                 :            :     {
      97                 :          0 :         return mbCon1;
      98                 :            :     }
      99                 :            : 
     100                 :          0 :     void SetCon2(sal_Bool bOn)
     101                 :            :     {
     102                 :          0 :         mbCon2 = bOn;
     103                 :          0 :     }
     104                 :            : 
     105                 :          0 :     sal_Bool IsCon2() const
     106                 :            :     {
     107                 :          0 :         return mbCon2;
     108                 :            :     }
     109                 :            : 
     110                 :          0 :     void SetUser(sal_uInt16 nVal)
     111                 :            :     {
     112                 :          0 :         mnUser = nVal;
     113                 :          0 :     }
     114                 :            : 
     115                 :          0 :     sal_uInt16 GetUser() const
     116                 :            :     {
     117                 :          0 :         return mnUser;
     118                 :            :     }
     119                 :            : 
     120                 :        210 :     const SdrUShortCont* GetMarkedPoints() const
     121                 :            :     {
     122                 :        210 :         return mpPoints;
     123                 :            :     }
     124                 :            : 
     125                 :            :     const SdrUShortCont* GetMarkedLines() const
     126                 :            :     {
     127                 :            :         return mpLines;
     128                 :            :     }
     129                 :            : 
     130                 :       1728 :     const SdrUShortCont* GetMarkedGluePoints() const
     131                 :            :     {
     132                 :       1728 :         return mpGluePoints;
     133                 :            :     }
     134                 :            : 
     135                 :          0 :     SdrUShortCont* GetMarkedPoints()
     136                 :            :     {
     137                 :          0 :         return mpPoints;
     138                 :            :     }
     139                 :            : 
     140                 :            :     SdrUShortCont* GetMarkedLines()
     141                 :            :     {
     142                 :            :         return mpLines;
     143                 :            :     }
     144                 :            : 
     145                 :       1006 :     SdrUShortCont* GetMarkedGluePoints()
     146                 :            :     {
     147                 :       1006 :         return mpGluePoints;
     148                 :            :     }
     149                 :            : 
     150                 :          0 :     SdrUShortCont* ForceMarkedPoints()
     151                 :            :     {
     152         [ #  # ]:          0 :         if(!mpPoints)
     153         [ #  # ]:          0 :             mpPoints = new SdrUShortCont;
     154                 :            : 
     155                 :          0 :         return mpPoints;
     156                 :            :     }
     157                 :            : 
     158                 :            :     SdrUShortCont* ForceMarkedLines()
     159                 :            :     {
     160                 :            :         if(!mpLines)
     161                 :            :             mpLines = new SdrUShortCont;
     162                 :            : 
     163                 :            :         return mpLines;
     164                 :            :     }
     165                 :            : 
     166                 :          0 :     SdrUShortCont* ForceMarkedGluePoints()
     167                 :            :     {
     168         [ #  # ]:          0 :         if(!mpGluePoints)
     169         [ #  # ]:          0 :             mpGluePoints = new SdrUShortCont;
     170                 :            : 
     171                 :          0 :         return mpGluePoints;
     172                 :            :     }
     173                 :            : };
     174                 :            : 
     175                 :            : class SVX_DLLPUBLIC SdrMarkList
     176                 :            : {
     177                 :            : protected:
     178                 :            :     std::vector<SdrMark*>                               maList;
     179                 :            : 
     180                 :            :     String                                              maMarkName;
     181                 :            :     String                                              maPointName;
     182                 :            :     String                                              maGluePointName;
     183                 :            : 
     184                 :            :     sal_Bool                                            mbPointNameOk;
     185                 :            :     sal_Bool                                            mbGluePointNameOk;
     186                 :            :     sal_Bool                                            mbNameOk;
     187                 :            :     sal_Bool                                            mbSorted;
     188                 :            : 
     189                 :            : private:
     190                 :            :     SVX_DLLPRIVATE sal_Bool operator==(const SdrMarkList& rCmpMarkList) const;
     191                 :            :     SVX_DLLPRIVATE void ImpForceSort();
     192                 :            : 
     193                 :            : private:
     194                 :            :     SVX_DLLPRIVATE const XubString& GetPointMarkDescription(sal_Bool bGlue) const;
     195                 :            : 
     196                 :            : public:
     197                 :      22418 :     SdrMarkList()
     198                 :            :     :   maList(),
     199                 :            :         mbPointNameOk(sal_False),
     200                 :            :         mbGluePointNameOk(sal_False),
     201                 :            :         mbNameOk(sal_False),
     202 [ +  - ][ +  - ]:      22418 :         mbSorted(sal_True)
                 [ +  - ]
     203                 :            :     {
     204                 :      22418 :     }
     205                 :            : 
     206                 :          0 :     SdrMarkList(const SdrMarkList& rLst)
     207 [ #  # ][ #  # ]:          0 :     :   maList()
                 [ #  # ]
     208                 :            :     {
     209         [ #  # ]:          0 :         *this = rLst;
     210                 :          0 :     }
     211                 :            : 
     212                 :      21563 :     ~SdrMarkList()
     213 [ +  - ][ +  - ]:      21563 :     {
                 [ +  - ]
     214         [ +  - ]:      21563 :         Clear();
     215                 :      21563 :     }
     216                 :            : 
     217                 :            :     void Clear();
     218                 :            :     void ForceSort() const;
     219                 :       4384 :     void SetUnsorted()
     220                 :            :     {
     221                 :       4384 :         mbSorted = sal_False;
     222                 :       4384 :     }
     223                 :            : 
     224                 :     218170 :     sal_uLong GetMarkCount() const
     225                 :            :     {
     226                 :     218170 :         return maList.size();
     227                 :            :     }
     228                 :            : 
     229                 :      13568 :     SdrMark* GetMark(sal_uLong nNum) const
     230                 :            :     {
     231                 :      13568 :         return maList[nNum];
     232                 :            :     }
     233                 :            : 
     234                 :            :     sal_uLong FindObject(const SdrObject* pObj) const;
     235                 :            :     void InsertEntry(const SdrMark& rMark, sal_Bool bChkSort = sal_True);
     236                 :            :     void DeleteMark(sal_uLong nNum);
     237                 :            :     void ReplaceMark(const SdrMark& rNewMark, sal_uLong nNum);
     238                 :            :     void Merge(const SdrMarkList& rSrcList, sal_Bool bReverse = sal_False);
     239                 :            :     sal_Bool DeletePageView(const SdrPageView& rPV);
     240                 :            :     sal_Bool InsertPageView(const SdrPageView& rPV);
     241                 :            : 
     242                 :      39503 :     void SetNameDirty()
     243                 :            :     {
     244                 :      39503 :         mbNameOk = sal_False;
     245                 :      39503 :         mbPointNameOk = sal_False;
     246                 :      39503 :         mbGluePointNameOk = sal_False;
     247                 :      39503 :     }
     248                 :            : 
     249                 :            :     // Eine verbale Beschreibung der markierten Objekte z.B.:
     250                 :            :     // "27 Linien", "12 Objekte", "Polygon" oder auch "Kein Objekt"
     251                 :            :     const String& GetMarkDescription() const;
     252                 :          0 :     const String& GetPointMarkDescription() const
     253                 :            :     {
     254                 :          0 :         return GetPointMarkDescription(sal_False);
     255                 :            :     }
     256                 :            : 
     257                 :          0 :     const String& GetGluePointMarkDescription() const
     258                 :            :     {
     259                 :          0 :         return GetPointMarkDescription(sal_True);
     260                 :            :     }
     261                 :            : 
     262                 :            :     // pPage=0L: Die Markierungen aller! Seiten beruecksichtigen
     263                 :            :     sal_Bool TakeBoundRect(SdrPageView* pPageView, Rectangle& rRect) const;
     264                 :            :     sal_Bool TakeSnapRect(SdrPageView* pPageView, Rectangle& rRect) const;
     265                 :            : 
     266                 :            :     // Es werden saemtliche Entries kopiert!
     267                 :            :     void operator=(const SdrMarkList& rLst);
     268                 :            : };
     269                 :            : 
     270                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     271                 :            : // migrate selections
     272                 :            : 
     273                 :            : namespace sdr
     274                 :            : {
     275 [ +  - ][ +  - ]:       4508 :     class SVX_DLLPUBLIC ViewSelection
     276                 :            :     {
     277                 :            :         SdrMarkList                 maMarkedObjectList;
     278                 :            :         SdrMarkList                 maEdgesOfMarkedNodes;
     279                 :            :         SdrMarkList                 maMarkedEdgesOfMarkedNodes;
     280                 :            :         std::vector<SdrObject*>     maAllMarkedObjects;
     281                 :            : 
     282                 :            :         // bitfield
     283                 :            :         unsigned                    mbEdgesOfMarkedNodesDirty : 1;
     284                 :            : 
     285                 :            :         SVX_DLLPRIVATE void ImpForceEdgesOfMarkedNodes();
     286                 :            :         SVX_DLLPRIVATE void ImplCollectCompleteSelection(SdrObject* pObj);
     287                 :            : 
     288                 :            :     public:
     289                 :            :         ViewSelection();
     290                 :            : 
     291                 :            :         void SetEdgesOfMarkedNodesDirty();
     292                 :            : 
     293                 :     206832 :         const SdrMarkList& GetMarkedObjectList() const
     294                 :            :         {
     295                 :     206832 :             return maMarkedObjectList;
     296                 :            :         }
     297                 :            : 
     298                 :            :         const SdrMarkList& GetEdgesOfMarkedNodes() const;
     299                 :            :         const SdrMarkList& GetMarkedEdgesOfMarkedNodes() const;
     300                 :            :         const std::vector<SdrObject*>& GetAllMarkedObjects() const;
     301                 :            : 
     302                 :      17356 :         SdrMarkList& GetMarkedObjectListWriteAccess()
     303                 :            :         {
     304                 :      17356 :             return maMarkedObjectList;
     305                 :            :         }
     306                 :            :     };
     307                 :            : } // end of namespace sdr
     308                 :            : 
     309                 :            : #endif //_SVDMARK_HXX
     310                 :            : 
     311                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10