LCOV - code coverage report
Current view: top level - include/svx - svdlayer.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 13 21 61.9 %
Date: 2015-06-13 12:38:46 Functions: 14 16 87.5 %
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_SVDLAYER_HXX
      21             : #define INCLUDED_SVX_SVDLAYER_HXX
      22             : 
      23             : #include <tools/stream.hxx>
      24             : #include <svx/svdsob.hxx>
      25             : #include <svx/svdtypes.hxx>
      26             : #include <svx/svxdllapi.h>
      27             : #include <algorithm>
      28             : 
      29             : class SdrModel;
      30             : 
      31       21983 : class SVX_DLLPUBLIC SdrLayer
      32             : {
      33             :     friend class SdrLayerAdmin;
      34             : 
      35             :     OUString maName;
      36             :     OUString maTitle;
      37             :     OUString maDescription;
      38             :     SdrModel*  pModel; // zum Broadcasten
      39             :     sal_uInt16     nType;  // 0=Userdefined,1=Standardlayer
      40             :     SdrLayerID nID;
      41             : 
      42             :     SdrLayer(SdrLayerID nNewID, const OUString& rNewName);
      43             : 
      44             : public:
      45             :     bool      operator==(const SdrLayer& rCmpLayer) const;
      46             :     bool      operator!=(const SdrLayer& rCmpLayer) const { return !operator==(rCmpLayer); }
      47             : 
      48             :     void SetName(const OUString& rNewName);
      49      286038 :     const OUString& GetName() const { return maName; }
      50             : 
      51         233 :     void SetTitle(const OUString& rTitle) { maTitle = rTitle; }
      52          75 :     const OUString& GetTitle() const { return maTitle; }
      53             : 
      54         233 :     void SetDescription(const OUString& rDesc) { maDescription = rDesc; }
      55          75 :     const OUString& GetDescription() const { return maDescription; }
      56             : 
      57      173685 :     SdrLayerID    GetID() const                               { return nID; }
      58       22097 :     void          SetModel(SdrModel* pNewModel)               { pModel=pNewModel; }
      59             :     SdrModel*     GetModel() const                            { return pModel; }
      60             :     // A SdrLayer should be considered the standard Layer. It shall then set the
      61             :     // appropriate country-specific name. SetName() sets the "StandardLayer" flag
      62             :     // and if necessary returns "Userdefined".
      63             :     void          SetStandardLayer(bool bStd = true);
      64             :     bool          IsStandardLayer() const                     { return nType==1; }
      65             : };
      66             : 
      67             : // When Changing the layer data you currently have to set the Modify-Flag
      68             : // manually
      69             : #define SDRLAYER_MAXCOUNT 255
      70             : class SVX_DLLPUBLIC SdrLayerAdmin {
      71             : friend class SdrView;
      72             : friend class SdrModel;
      73             : friend class SdrPage;
      74             : 
      75             : protected:
      76             :     std::vector<SdrLayer*> aLayer;
      77             :     SdrLayerAdmin* pParent; // Der Admin der Seite kennt den Admin des Docs
      78             :     SdrModel*      pModel; // for broadcasting
      79             :     OUString       maControlLayerName;
      80             : protected:
      81             :     // Eine noch nicht verwendete LayerID raussuchen. Sind bereits alle
      82             :     // verbraucht, so gibt's 'ne 0. Wer sicher gehen will, muss vorher
      83             :     // GetLayerCount()<SDRLAYER_MAXCOUNT abfragen, denn sonst sind alle
      84             :     // vergeben.
      85             :     SdrLayerID           GetUniqueLayerID() const;
      86             :     void                 Broadcast() const;
      87             : public:
      88             :     explicit SdrLayerAdmin(SdrLayerAdmin* pNewParent=NULL);
      89             :     SdrLayerAdmin(const SdrLayerAdmin& rSrcLayerAdmin);
      90             :     ~SdrLayerAdmin();
      91             :     const SdrLayerAdmin& operator=(const SdrLayerAdmin& rSrcLayerAdmin);
      92             :     bool             operator==(const SdrLayerAdmin& rCmpLayerAdmin) const;
      93             :     bool             operator!=(const SdrLayerAdmin& rCmpLayerAdmin) const       { return !operator==(rCmpLayerAdmin); }
      94             :     SdrLayerAdmin*       GetParent() const                                           { return pParent; }
      95           0 :     void                 SetParent(SdrLayerAdmin* pNewParent)                        { pParent=pNewParent; }
      96             :     void                 SetModel(SdrModel* pNewModel);
      97             :     SdrModel*            GetModel() const                                            { return pModel; }
      98             :     void                 InsertLayer(SdrLayer* pLayer)
      99             :     {
     100             :         aLayer.push_back(pLayer);
     101             :         pLayer->SetModel(pModel);
     102             :         Broadcast();
     103             :     }
     104           0 :     void                 InsertLayer(SdrLayer* pLayer, sal_uInt16 nPos)
     105             :     {
     106           0 :         if(nPos==0xFFFF)
     107           0 :             aLayer.push_back(pLayer);
     108             :         else
     109           0 :             aLayer.insert(aLayer.begin() + nPos, pLayer);
     110           0 :         pLayer->SetModel(pModel);
     111           0 :         Broadcast();
     112           0 :     }
     113             :     SdrLayer*            RemoveLayer(sal_uInt16 nPos);
     114             :     // Delete the entire layer
     115             :     void               ClearLayer();
     116             :     // New layer is created and inserted
     117             :     SdrLayer*          NewLayer(const OUString& rName, sal_uInt16 nPos=0xFFFF);
     118             :     void               DeleteLayer(SdrLayer* pLayer)
     119             :     {
     120             :         std::vector<SdrLayer*>::iterator it = std::find(aLayer.begin(), aLayer.end(), pLayer);
     121             :         if( it == aLayer.end() )
     122             :             return;
     123             :         aLayer.erase(it);
     124             :         delete pLayer;
     125             :         Broadcast();
     126             :     }
     127             :     // New layer, name is retrieved from the resource
     128             :     SdrLayer*          NewStandardLayer(sal_uInt16 nPos=0xFFFF);
     129             : 
     130             :     // Iterate over all layers
     131      493820 :     sal_uInt16             GetLayerCount() const                                         { return sal_uInt16(aLayer.size()); }
     132        1669 :     SdrLayer*          GetLayer(sal_uInt16 i)                                            { return aLayer[i]; }
     133      439477 :     const SdrLayer*    GetLayer(sal_uInt16 i) const                                      { return aLayer[i]; }
     134             : 
     135             :     sal_uInt16             GetLayerPos(SdrLayer* pLayer) const;
     136             : 
     137             :     SdrLayer* GetLayer(const OUString& rName, bool bInherited);
     138             :     const SdrLayer* GetLayer(const OUString& rName, bool bInherited) const;
     139             :     SdrLayerID GetLayerID(const OUString& rName, bool bInherited) const;
     140        5367 :           SdrLayer*    GetLayerPerID(sal_uInt16 nID)                                     { return const_cast<SdrLayer*>(const_cast<const SdrLayerAdmin*>(this)->GetLayerPerID(nID)); }
     141             :     const SdrLayer*    GetLayerPerID(sal_uInt16 nID) const;
     142             : 
     143             :     void SetControlLayerName(const OUString& rNewName);
     144       55429 :     const OUString& GetControlLayerName() const { return maControlLayerName; }
     145             : };
     146             : 
     147             : /*
     148             : Anmerkung zu den Layer - Gemischt symbolisch/ID-basierendes Interface
     149             :     Einen neuen Layer macht man sich mit:
     150             :       pLayerAdmin->NewLayer("Der neue Layer");
     151             :     Der Layer wird dann automatisch an das Ende der Liste angehaengt.
     152             :     Entsprechdes gilt fuer Layersets gleichermassen.
     153             :     Das Interface am SdrLayerSet basiert auf LayerID's. Die App muss sich
     154             :     dafuer am SdrLayerAdmin eine ID abholen:
     155             :         SdrLayerID nLayerID=pLayerAdmin->GetLayerID("Der neue Layer");
     156             :     Wird der Layer nicht gefunden, so liefert die Methode SDRLAYER_NOTFOUND
     157             :     zurueck. Die Methoden mit ID-Interface fangen diesen Wert jedoch i.d.R
     158             :     sinnvoll ab.
     159             :     Hat man nicht nur den Namen, sondern gar einen SdrLayer*, so kann man
     160             :     sich die ID natuerlich wesentlich schneller direkt vom Layer abholen.
     161             : bInherited:
     162             :     TRUE: Wird der Layer/LayerSet nicht gefunden, so wird im Parent-LayerAdmin
     163             :           nachgesehen, ob es dort einen entsprechende Definition gibt.
     164             :     FALSE: Es wird nur dieser LayerAdmin durchsucht.
     165             :     Jeder LayerAdmin einer Seite hat einen Parent-LayerAdmin, n?mlich den des
     166             :     Model. Das Model selbst hat keinen Parent.
     167             : */
     168             : 
     169             : #endif // INCLUDED_SVX_SVDLAYER_HXX
     170             : 
     171             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11