LCOV - code coverage report
Current view: top level - sd/source/ui/sidebar - RecentlyUsedMasterPages.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 8 0.0 %
Date: 2014-11-03 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 (void);
      48             : 
      49             :     void AddEventListener (const Link& rEventListener);
      50             :     void RemoveEventListener (const Link& rEventListener);
      51             : 
      52             :     int GetMasterPageCount (void) 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 :             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 (void);
      95             :     virtual ~RecentlyUsedMasterPages (void);
      96             : 
      97             :     /** Call this method after a new object has been created.
      98             :     */
      99             :     void LateInit (void);
     100             : 
     101             :     /// The copy constructor is not implemented.  Do not use!
     102             :     RecentlyUsedMasterPages (const RecentlyUsedMasterPages&);
     103             : 
     104             :     /// The assignment operator is not implemented.  Do not use!
     105             :     RecentlyUsedMasterPages& operator= (const RecentlyUsedMasterPages&);
     106             : 
     107             :     void SendEvent (void);
     108             :     DECL_LINK(MasterPageChangeListener, MasterPageObserverEvent*);
     109             :     DECL_LINK(MasterPageContainerChangeListener, MasterPageContainerChangeEvent*);
     110             : 
     111             :     /** Add a descriptor for the specified master page to the end of the
     112             :         list of most recently used master pages.  When the page is already a
     113             :         member of that list the associated descriptor is moved to the end of
     114             :         the list to make it the most recently used entry.
     115             :         @param bMakePersistent
     116             :             When <TRUE/> is given then the new list of recently used master
     117             :             pages is written back into the configuration to make it
     118             :             persistent.  Giving <FALSE/> to omit this is used while loading
     119             :             the persistent list from the configuration.
     120             :     */
     121             :     void AddMasterPage (
     122             :         MasterPageContainer::Token aToken,
     123             :         bool bMakePersistent = true);
     124             : 
     125             :     /** Load the list of recently used master pages from the registry where
     126             :         it was saved to make it persistent.
     127             :     */
     128             :     void LoadPersistentValues (void);
     129             : 
     130             :     /** Save the list of recently used master pages to the registry to make
     131             :         it presistent.
     132             :     */
     133             :     void SavePersistentValues (void);
     134             : 
     135             :     void ResolveList (void);
     136             : };
     137             : 
     138             : } } // end of namespace sd::sidebar
     139             : 
     140             : #endif
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10