LCOV - code coverage report
Current view: top level - sd/source/ui/toolpanel/controls - RecentMasterPagesSelector.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 50 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 74 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 "RecentMasterPagesSelector.hxx"
      31                 :            : #include "PreviewValueSet.hxx"
      32                 :            : 
      33                 :            : #include "RecentlyUsedMasterPages.hxx"
      34                 :            : #include "MasterPageContainerProviders.hxx"
      35                 :            : #include "MasterPageObserver.hxx"
      36                 :            : #include "sdpage.hxx"
      37                 :            : #include "drawdoc.hxx"
      38                 :            : #include "app.hrc"
      39                 :            : #include <vcl/bitmap.hxx>
      40                 :            : 
      41                 :            : namespace sd { namespace toolpanel { namespace controls {
      42                 :            : 
      43                 :            : 
      44                 :          0 : RecentMasterPagesSelector::RecentMasterPagesSelector (
      45                 :            :     TreeNode* pParent,
      46                 :            :     SdDrawDocument& rDocument,
      47                 :            :     ViewShellBase& rBase,
      48                 :            :     const ::boost::shared_ptr<MasterPageContainer>& rpContainer)
      49                 :          0 :     : MasterPagesSelector (pParent, rDocument, rBase, rpContainer)
      50                 :            : {
      51 [ #  # ][ #  # ]:          0 :     SetName (rtl::OUString("RecentMasterPagesSelector"));
                 [ #  # ]
      52                 :          0 : }
      53                 :            : 
      54                 :            : 
      55                 :            : 
      56                 :            : 
      57                 :          0 : RecentMasterPagesSelector::~RecentMasterPagesSelector (void)
      58                 :            : {
      59         [ #  # ]:          0 :     RecentlyUsedMasterPages::Instance().RemoveEventListener (
      60 [ #  # ][ #  # ]:          0 :         LINK(this,RecentMasterPagesSelector,MasterPageListListener));
      61         [ #  # ]:          0 : }
      62                 :            : 
      63                 :            : 
      64                 :            : 
      65                 :            : 
      66                 :          0 : void RecentMasterPagesSelector::LateInit (void)
      67                 :            : {
      68                 :          0 :     MasterPagesSelector::LateInit();
      69                 :            : 
      70                 :          0 :     MasterPagesSelector::Fill();
      71         [ #  # ]:          0 :     RecentlyUsedMasterPages::Instance().AddEventListener (
      72         [ #  # ]:          0 :         LINK(this,RecentMasterPagesSelector,MasterPageListListener));
      73                 :          0 : }
      74                 :            : 
      75                 :            : 
      76                 :            : 
      77                 :            : 
      78                 :          0 : IMPL_LINK_NOARG(RecentMasterPagesSelector, MasterPageListListener)
      79                 :            : {
      80                 :          0 :     MasterPagesSelector::Fill();
      81                 :          0 :     return 0;
      82                 :            : }
      83                 :            : 
      84                 :            : 
      85                 :            : 
      86                 :            : 
      87                 :          0 : void RecentMasterPagesSelector::Fill (ItemList& rItemList)
      88                 :            : {
      89                 :            :     // Create a set of names of the master pages used by the document.
      90         [ #  # ]:          0 :     MasterPageObserver::MasterPageNameSet aCurrentNames;
      91         [ #  # ]:          0 :     sal_uInt16 nMasterPageCount = mrDocument.GetMasterSdPageCount(PK_STANDARD);
      92                 :            :     sal_uInt16 nIndex;
      93         [ #  # ]:          0 :     for (nIndex=0; nIndex<nMasterPageCount; nIndex++)
      94                 :            :     {
      95         [ #  # ]:          0 :         SdPage* pMasterPage = mrDocument.GetMasterSdPage (nIndex, PK_STANDARD);
      96         [ #  # ]:          0 :         if (pMasterPage != NULL)
      97 [ #  # ][ #  # ]:          0 :             aCurrentNames.insert (pMasterPage->GetName());
      98                 :            :     }
      99         [ #  # ]:          0 :     MasterPageObserver::MasterPageNameSet::iterator aI;
     100                 :            : 
     101                 :            :     // Insert the recently used master pages that are currently not used.
     102         [ #  # ]:          0 :     RecentlyUsedMasterPages& rInstance (RecentlyUsedMasterPages::Instance());
     103         [ #  # ]:          0 :     int nPageCount = rInstance.GetMasterPageCount();
     104         [ #  # ]:          0 :     for (nIndex=0; nIndex<nPageCount; nIndex++)
     105                 :            :     {
     106                 :            :         // Add an entry when a) the page is already known to the
     107                 :            :         // MasterPageContainer, b) the style name is empty, i.e. it has not yet
     108                 :            :         // been loaded (and thus can not be in use) or otherwise c) the
     109                 :            :         // style name is not currently in use.
     110         [ #  # ]:          0 :         MasterPageContainer::Token aToken (rInstance.GetTokenForIndex(nIndex));
     111         [ #  # ]:          0 :         if (aToken != MasterPageContainer::NIL_TOKEN)
     112                 :            :         {
     113         [ #  # ]:          0 :             String sStyleName (mpContainer->GetStyleNameForToken(aToken));
     114 [ #  # ][ #  # ]:          0 :             if (sStyleName.Len()==0
                 [ #  # ]
     115 [ #  # ][ #  # ]:          0 :                 || aCurrentNames.find(sStyleName) == aCurrentNames.end())
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     116                 :            :             {
     117         [ #  # ]:          0 :                 rItemList.push_back(aToken);
     118         [ #  # ]:          0 :             }
     119                 :            :         }
     120                 :          0 :     }
     121                 :          0 : }
     122                 :            : 
     123                 :            : 
     124                 :            : 
     125                 :            : 
     126                 :          0 : void RecentMasterPagesSelector::AssignMasterPageToPageList (
     127                 :            :     SdPage* pMasterPage,
     128                 :            :     const ::boost::shared_ptr<std::vector<SdPage*> >& rpPageList)
     129                 :            : {
     130                 :          0 :     sal_uInt16 nSelectedItemId = mpPageSet->GetSelectItemId();
     131                 :            : 
     132                 :          0 :     MasterPagesSelector::AssignMasterPageToPageList(pMasterPage, rpPageList);
     133                 :            : 
     134                 :            :     // Restore the selection.
     135         [ #  # ]:          0 :     if (mpPageSet->GetItemCount() > 0)
     136                 :            :     {
     137         [ #  # ]:          0 :         if (mpPageSet->GetItemCount() >= nSelectedItemId)
     138                 :          0 :             mpPageSet->SelectItem(nSelectedItemId);
     139                 :            :         else
     140                 :          0 :             mpPageSet->SelectItem(mpPageSet->GetItemCount());
     141                 :            :     }
     142                 :          0 : }
     143                 :            : 
     144                 :            : 
     145                 :            : 
     146                 :            : 
     147                 :          0 : void RecentMasterPagesSelector::GetState (SfxItemSet& rItemSet)
     148                 :            : {
     149                 :          0 :     MasterPagesSelector::GetState (rItemSet);
     150         [ #  # ]:          0 :     if (rItemSet.GetItemState(SID_TP_EDIT_MASTER) == SFX_ITEM_AVAILABLE)
     151                 :          0 :         rItemSet.DisableItem (SID_TP_EDIT_MASTER);
     152                 :          0 : }
     153                 :            : 
     154                 :            : 
     155                 :            : 
     156                 :            : 
     157                 :            : } } } // end of namespace ::sd::toolpanel::controls
     158                 :            : 
     159                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10