LCOV - code coverage report
Current view: top level - sd/source/ui/inc - MasterPageObserver.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 3 3 100.0 %
Date: 2015-06-13 12:38:46 Functions: 1 1 100.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_INC_MASTERPAGEOBSERVER_HXX
      21             : #define INCLUDED_SD_SOURCE_UI_INC_MASTERPAGEOBSERVER_HXX
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : #include "tools/SdGlobalResourceContainer.hxx"
      25             : #include <osl/mutex.hxx>
      26             : #include <memory>
      27             : #include <set>
      28             : 
      29             : class SdDrawDocument;
      30             : 
      31             : namespace sd {
      32             : 
      33             : /** This singleton observes all registered documents for changes in the used
      34             :     master pages and in turn informs its listeners about it.  One such
      35             :     listener is the master page selector control in the tool panel that
      36             :     shows the recently used master pages.
      37             : */
      38             : class MasterPageObserver
      39             :     : public SdGlobalResource
      40             : {
      41             : public:
      42             :     typedef ::std::set<OUString> MasterPageNameSet;
      43             : 
      44             :     /** Return the single instance of this class.
      45             :     */
      46             :     static MasterPageObserver& Instance();
      47             : 
      48             :     /** The master page observer will listen to events of this document and
      49             :         detect changes of the use of master pages.
      50             :     */
      51             :     void RegisterDocument (SdDrawDocument& rDocument);
      52             : 
      53             :     /** The master page observer will stop to listen to events of this
      54             :         document.
      55             :     */
      56             :     void UnregisterDocument (SdDrawDocument& rDocument);
      57             : 
      58             :     /** Add a listener that is informed of master pages that are newly
      59             :         assigned to slides or become unassigned.
      60             :         @param rEventListener
      61             :             The event listener to call for future events.  Call
      62             :             RemoveEventListener() before the listener is destroyed.
      63             :     */
      64             :     void AddEventListener (const Link<>& rEventListener);
      65             : 
      66             :     /** Remove the given listener from the list of listeners.
      67             :         @param rEventListener
      68             :             After this method returns the given listener is not called back
      69             :             from this object.  Passing a listener that has not
      70             :             been registered before is safe and is silently ignored.
      71             :     */
      72             :     void RemoveEventListener (const Link<>& rEventListener);
      73             : 
      74             : private:
      75             :     static ::osl::Mutex maMutex;
      76             : 
      77             :     class Implementation;
      78             :     ::std::unique_ptr<Implementation> mpImpl;
      79             : 
      80             :     MasterPageObserver();
      81             :     virtual ~MasterPageObserver();
      82             : 
      83             :     MasterPageObserver (const MasterPageObserver&) SAL_DELETED_FUNCTION;
      84             : 
      85             :     MasterPageObserver& operator= (const MasterPageObserver&) SAL_DELETED_FUNCTION;
      86             : };
      87             : 
      88             : /** Objects of this class are sent to listeners of the MasterPageObserver
      89             :     singleton when the list of master pages of one document has changed.
      90             : */
      91             : class MasterPageObserverEvent
      92             : {
      93             : public:
      94             :     enum EventType {
      95             :         /// Master page already exists when document is registered.
      96             :         ET_MASTER_PAGE_EXISTS,
      97             :         /// Master page has been added to a document.
      98             :         ET_MASTER_PAGE_ADDED,
      99             :         /// Master page has been removed from to a document.
     100             :         ET_MASTER_PAGE_REMOVED
     101             :     };
     102             : 
     103             :     EventType meType;
     104             :     SdDrawDocument& mrDocument;
     105             :     const OUString& mrMasterPageName;
     106             : 
     107          27 :     MasterPageObserverEvent (
     108             :         EventType eType,
     109             :         SdDrawDocument& rDocument,
     110             :         const OUString& rMasterPageName)
     111             :         : meType(eType),
     112             :           mrDocument(rDocument),
     113          27 :           mrMasterPageName(rMasterPageName)
     114          27 :     {}
     115             : 
     116             : };
     117             : 
     118             : } // end of namespace sd
     119             : 
     120             : #endif
     121             : 
     122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11