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

Generated by: LCOV version 1.10