LCOV - code coverage report
Current view: top level - sd/source/ui/sidebar - RecentlyUsedMasterPages.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 8 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 7 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             : #ifndef INCLUDED_SD_SOURCE_UI_SIDEBAR_RECENTLYUSEDMASTERPAGES_HXX
      21             : #define INCLUDED_SD_SOURCE_UI_SIDEBAR_RECENTLYUSEDMASTERPAGES_HXX
      22             : 
      23             : #include "tools/SdGlobalResourceContainer.hxx"
      24             : #include <osl/mutex.hxx>
      25             : #include <tools/link.hxx>
      26             : #include <vcl/image.hxx>
      27             : #include <vector>
      28             : 
      29             : #include "DrawDocShell.hxx"
      30             : #include "MasterPageContainer.hxx"
      31             : #include <com/sun/star/uno/XInterface.hpp>
      32             : 
      33             : namespace sd {
      34             : class MasterPageObserverEvent;
      35             : }
      36             : 
      37             : namespace sd { namespace sidebar {
      38             : 
      39             : /** This singleton holds a list of the most recently used master pages.
      40             : */
      41             : class RecentlyUsedMasterPages
      42             :     : public SdGlobalResource
      43             : {
      44             : public:
      45             :     /** Return the single instance of this class.
      46             :     */
      47             :     static RecentlyUsedMasterPages& Instance();
      48             : 
      49             :     void AddEventListener (const Link<>& rEventListener);
      50             :     void RemoveEventListener (const Link<>& rEventListener);
      51             : 
      52             :     int GetMasterPageCount() const;
      53             :     MasterPageContainer::Token GetTokenForIndex (sal_uInt32 nIndex) const;
      54             : 
      55             : private:
      56           0 :     class Descriptor
      57             :     {
      58             :     public:
      59             :         OUString msURL;
      60             :         OUString msName;
      61             :         ::sd::sidebar::MasterPageContainer::Token maToken;
      62           0 :         Descriptor (::sd::sidebar::MasterPageContainer::Token aToken,
      63             :                     const OUString& rsURL, const OUString& rsName)
      64             :             : msURL(rsURL),
      65             :               msName(rsName),
      66           0 :               maToken(aToken)
      67           0 :         {}
      68             : 
      69             :         class TokenComparator
      70             :         {
      71             :         public:
      72           0 :             explicit TokenComparator(::sd::sidebar::MasterPageContainer::Token aToken)
      73           0 :                 : maToken(aToken) {}
      74           0 :             bool operator () (const Descriptor& rDescriptor)
      75           0 :             { return maToken==rDescriptor.maToken; }
      76             : 
      77             :         private:
      78             :             ::sd::sidebar::MasterPageContainer::Token maToken;
      79             :         };
      80             :     };
      81             : 
      82             :     /** The single instance of this class.  It is created on demand when
      83             :         Instance() is called for the first time.
      84             :     */
      85             :     static RecentlyUsedMasterPages* mpInstance;
      86             : 
      87             :     ::std::vector<Link<>> maListeners;
      88             : 
      89             :     typedef ::std::vector<Descriptor> MasterPageList;
      90             :     MasterPageList mvMasterPages;
      91             :     unsigned long int mnMaxListSize;
      92             :     ::boost::shared_ptr<MasterPageContainer> mpContainer;
      93             : 
      94             :     RecentlyUsedMasterPages();
      95             :     virtual ~RecentlyUsedMasterPages();
      96             : 
      97             :     /** Call this method after a new object has been created.
      98             :     */
      99             :     void LateInit();
     100             : 
     101             :     RecentlyUsedMasterPages (const RecentlyUsedMasterPages&) SAL_DELETED_FUNCTION;
     102             : 
     103             :     RecentlyUsedMasterPages& operator= (const RecentlyUsedMasterPages&) SAL_DELETED_FUNCTION;
     104             : 
     105             :     void SendEvent();
     106             :     DECL_LINK(MasterPageChangeListener, MasterPageObserverEvent*);
     107             :     DECL_LINK(MasterPageContainerChangeListener, MasterPageContainerChangeEvent*);
     108             : 
     109             :     /** Add a descriptor for the specified master page to the end of the
     110             :         list of most recently used master pages.  When the page is already a
     111             :         member of that list the associated descriptor is moved to the end of
     112             :         the list to make it the most recently used entry.
     113             :         @param bMakePersistent
     114             :             When <TRUE/> is given then the new list of recently used master
     115             :             pages is written back into the configuration to make it
     116             :             persistent.  Giving <FALSE/> to omit this is used while loading
     117             :             the persistent list from the configuration.
     118             :     */
     119             :     void AddMasterPage (
     120             :         MasterPageContainer::Token aToken,
     121             :         bool bMakePersistent = true);
     122             : 
     123             :     /** Load the list of recently used master pages from the registry where
     124             :         it was saved to make it persistent.
     125             :     */
     126             :     void LoadPersistentValues();
     127             : 
     128             :     /** Save the list of recently used master pages to the registry to make
     129             :         it presistent.
     130             :     */
     131             :     void SavePersistentValues();
     132             : 
     133             :     void ResolveList();
     134             : };
     135             : 
     136             : } } // end of namespace sd::sidebar
     137             : 
     138             : #endif
     139             : 
     140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11