LCOV - code coverage report
Current view: top level - sd/source/ui/toolpanel/controls - AllMasterPagesSelector.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 67 0.0 %
Date: 2012-08-25 Functions: 0 13 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 45 0.0 %

           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                 :            : 
      30                 :            : #include "AllMasterPagesSelector.hxx"
      31                 :            : #include "PreviewValueSet.hxx"
      32                 :            : #include "app.hrc"
      33                 :            : #include "MasterPageContainer.hxx"
      34                 :            : #include "MasterPageDescriptor.hxx"
      35                 :            : #include <set>
      36                 :            : 
      37                 :            : namespace {
      38                 :            : 
      39                 :            : using namespace sd::toolpanel::controls;
      40                 :            : 
      41                 :          0 : int GetURLPriority (const SharedMasterPageDescriptor& rpDescriptor)
      42                 :            : {
      43                 :          0 :     int nPriority (0);
      44   [ #  #  #  #  :          0 :     switch (rpDescriptor->GetURLClassification())
                   #  # ]
      45                 :            :     {
      46                 :          0 :         case MasterPageDescriptor::URLCLASS_USER:         nPriority = 0; break;
      47                 :          0 :         case MasterPageDescriptor::URLCLASS_LAYOUT:       nPriority = 1; break;
      48                 :          0 :         case MasterPageDescriptor::URLCLASS_PRESENTATION: nPriority = 2; break;
      49                 :          0 :         case MasterPageDescriptor::URLCLASS_OTHER:        nPriority = 3; break;
      50                 :          0 :         case MasterPageDescriptor::URLCLASS_UNKNOWN:      nPriority = 4; break;
      51                 :            :         default:
      52                 :          0 :         case MasterPageDescriptor::URLCLASS_UNDETERMINED: nPriority = 5; break;
      53                 :            :     }
      54                 :          0 :     return nPriority;
      55                 :            : }
      56                 :            : 
      57                 :            : 
      58                 :            : class MasterPageDescriptorOrder
      59                 :            : {
      60                 :            : public:
      61                 :          0 :     bool operator() (const sd::toolpanel::controls::SharedMasterPageDescriptor& rp1,
      62                 :            :         const sd::toolpanel::controls::SharedMasterPageDescriptor& rp2)
      63                 :            :     {
      64         [ #  # ]:          0 :         if (rp1->meOrigin == MasterPageContainer::DEFAULT)
      65                 :          0 :             return true;
      66         [ #  # ]:          0 :         else if (rp2->meOrigin == MasterPageContainer::DEFAULT)
      67                 :          0 :             return false;
      68         [ #  # ]:          0 :         else if (rp1->GetURLClassification() == rp2->GetURLClassification())
      69                 :          0 :             return rp1->mnTemplateIndex < rp2->mnTemplateIndex;
      70                 :            :         else
      71                 :          0 :             return GetURLPriority(rp1) < GetURLPriority(rp2);
      72                 :            :     }
      73                 :            : };
      74                 :            : 
      75                 :            : } // end of anonymous namespace
      76                 :            : 
      77                 :            : 
      78                 :            : 
      79                 :            : namespace sd { namespace toolpanel { namespace controls {
      80                 :            : 
      81                 :          0 : class AllMasterPagesSelector::SortedMasterPageDescriptorList
      82                 :            :     : public ::std::set<SharedMasterPageDescriptor,MasterPageDescriptorOrder>
      83                 :            : {
      84                 :            : public:
      85                 :          0 :     SortedMasterPageDescriptorList (void) {}
      86                 :            : };
      87                 :            : 
      88                 :            : 
      89                 :            : 
      90                 :            : 
      91                 :          0 : AllMasterPagesSelector::AllMasterPagesSelector (
      92                 :            :     TreeNode* pParent,
      93                 :            :     SdDrawDocument& rDocument,
      94                 :            :     ViewShellBase& rBase,
      95                 :            :     DrawViewShell& rViewShell,
      96                 :            :     const ::boost::shared_ptr<MasterPageContainer>& rpContainer)
      97                 :            :     : MasterPagesSelector(pParent, rDocument, rBase, rpContainer),
      98                 :            :       mrViewShell(rViewShell),
      99 [ #  # ][ #  # ]:          0 :       mpSortedMasterPages(new SortedMasterPageDescriptorList())
     100                 :            : {
     101 [ #  # ][ #  # ]:          0 :     SetName (rtl::OUString("AllMasterPagesSelector"));
                 [ #  # ]
     102         [ #  # ]:          0 :     MasterPagesSelector::Fill();
     103                 :          0 : }
     104                 :            : 
     105                 :            : 
     106                 :            : 
     107                 :            : 
     108                 :          0 : AllMasterPagesSelector::~AllMasterPagesSelector (void)
     109                 :            : {
     110         [ #  # ]:          0 : }
     111                 :            : 
     112                 :            : 
     113                 :            : 
     114                 :            : 
     115                 :          0 : void AllMasterPagesSelector::Fill (ItemList& rItemList)
     116                 :            : {
     117         [ #  # ]:          0 :     if (mpSortedMasterPages->empty())
     118                 :          0 :         UpdateMasterPageList();
     119                 :          0 :     UpdatePageSet(rItemList);
     120                 :          0 : }
     121                 :            : 
     122                 :            : 
     123                 :            : 
     124                 :            : 
     125                 :          0 : void AllMasterPagesSelector::NotifyContainerChangeEvent (
     126                 :            :     const MasterPageContainerChangeEvent& rEvent)
     127                 :            : {
     128      [ #  #  # ]:          0 :     switch (rEvent.meEventType)
     129                 :            :     {
     130                 :            :         case MasterPageContainerChangeEvent::CHILD_ADDED:
     131                 :          0 :             AddItem(rEvent.maChildToken);
     132                 :          0 :             MasterPagesSelector::Fill();
     133                 :          0 :             break;
     134                 :            : 
     135                 :            :         case MasterPageContainerChangeEvent::INDEX_CHANGED:
     136                 :            :         case MasterPageContainerChangeEvent::INDEXES_CHANGED:
     137                 :          0 :             mpSortedMasterPages->clear();
     138                 :          0 :             MasterPagesSelector::Fill();
     139                 :          0 :             break;
     140                 :            : 
     141                 :            :         default:
     142                 :          0 :             MasterPagesSelector::NotifyContainerChangeEvent(rEvent);
     143                 :          0 :             break;
     144                 :            :     }
     145                 :          0 : }
     146                 :            : 
     147                 :            : 
     148                 :            : 
     149                 :            : 
     150                 :          0 : void AllMasterPagesSelector::UpdateMasterPageList (void)
     151                 :            : {
     152                 :          0 :     mpSortedMasterPages->clear();
     153                 :          0 :     int nTokenCount = mpContainer->GetTokenCount();
     154         [ #  # ]:          0 :     for (int i=0; i<nTokenCount; i++)
     155                 :          0 :         AddItem(mpContainer->GetTokenForIndex(i));
     156                 :          0 : }
     157                 :            : 
     158                 :            : 
     159                 :            : 
     160                 :            : 
     161                 :          0 : void AllMasterPagesSelector::AddItem (MasterPageContainer::Token aToken)
     162                 :            : {
     163         [ #  # ]:          0 :     switch (mpContainer->GetOriginForToken(aToken))
     164                 :            :     {
     165                 :            :         case MasterPageContainer::DEFAULT:
     166                 :            :         case MasterPageContainer::TEMPLATE:
     167                 :            :             // Templates are added only when coming from the
     168                 :            :             // MasterPageContainerFiller so that they have an id which
     169                 :            :             // defines their place in the list.  Templates (pre) loaded from
     170                 :            :             // RecentlyUsedMasterPages are ignored (they will be loaded
     171                 :            :             // later by the MasterPageContainerFiller.)
     172         [ #  # ]:          0 :             if (mpContainer->GetTemplateIndexForToken(aToken) >= 0)
     173         [ #  # ]:          0 :                 mpSortedMasterPages->insert(mpContainer->GetDescriptorForToken(aToken));
     174                 :          0 :             break;
     175                 :            : 
     176                 :            :         default:
     177                 :          0 :             break;
     178                 :            :     }
     179                 :          0 : }
     180                 :            : 
     181                 :            : 
     182                 :            : 
     183                 :            : 
     184                 :          0 : void AllMasterPagesSelector::UpdatePageSet (ItemList& rItemList)
     185                 :            : {
     186                 :          0 :     SortedMasterPageDescriptorList::const_iterator iDescriptor;
     187                 :          0 :     SortedMasterPageDescriptorList::const_iterator iEnd (mpSortedMasterPages->end());
     188         [ #  # ]:          0 :     for (iDescriptor=mpSortedMasterPages->begin(); iDescriptor!=iEnd; ++iDescriptor)
     189         [ #  # ]:          0 :         rItemList.push_back((*iDescriptor)->maToken);
     190                 :          0 : }
     191                 :            : 
     192                 :            : 
     193                 :            : 
     194                 :            : 
     195                 :          0 : void AllMasterPagesSelector::GetState (SfxItemSet& rItemSet)
     196                 :            : {
     197                 :          0 :     MasterPagesSelector::GetState(rItemSet);
     198                 :            : 
     199         [ #  # ]:          0 :     if (rItemSet.GetItemState(SID_TP_EDIT_MASTER) == SFX_ITEM_AVAILABLE)
     200                 :          0 :         rItemSet.DisableItem(SID_TP_EDIT_MASTER);
     201                 :          0 : }
     202                 :            : 
     203                 :            : 
     204                 :            : 
     205                 :            : 
     206                 :            : } } } // end of namespace ::sd::toolpanel::control
     207                 :            : 
     208                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10