LCOV - code coverage report
Current view: top level - sd/source/ui/inc - MasterPageObserver.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 3 100.0 %
Date: 2012-08-25 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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 SD_VIEW_MASTER_PAGE_OBSERVER_HXX
      21                 :            : #define SD_VIEW_MASTER_PAGE_OBSERVER_HXX
      22                 :            : 
      23                 :            : #include "tools/SdGlobalResourceContainer.hxx"
      24                 :            : #include <osl/mutex.hxx>
      25                 :            : #include <memory>
      26                 :            : #include <set>
      27                 :            : 
      28                 :            : class SdDrawDocument;
      29                 :            : class String;
      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<String> MasterPageNameSet;
      43                 :            : 
      44                 :            :     /** Return the single instance of this class.
      45                 :            :     */
      46                 :            :     static MasterPageObserver& Instance (void);
      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::auto_ptr<Implementation> mpImpl;
      79                 :            : 
      80                 :            :     MasterPageObserver (void);
      81                 :            :     virtual ~MasterPageObserver (void);
      82                 :            : 
      83                 :            :     /// The copy constructor is not implemented.  Do not use!
      84                 :            :     MasterPageObserver (const MasterPageObserver&);
      85                 :            : 
      86                 :            :     /// The assignment operator is not implemented.  Do not use!
      87                 :            :     MasterPageObserver& operator= (const MasterPageObserver&);
      88                 :            : };
      89                 :            : 
      90                 :            : 
      91                 :            : 
      92                 :            : 
      93                 :            : /** Objects of this class are sent to listeners of the MasterPageObserver
      94                 :            :     singleton when the list of master pages of one document has changed.
      95                 :            : */
      96                 :            : class MasterPageObserverEvent
      97                 :            : {
      98                 :            : public:
      99                 :            :     enum EventType {
     100                 :            :         /// Master page already exists when document is registered.
     101                 :            :         ET_MASTER_PAGE_EXISTS,
     102                 :            :         /// Master page has been added to a document.
     103                 :            :         ET_MASTER_PAGE_ADDED,
     104                 :            :         /// Master page has been removed from to a document.
     105                 :            :         ET_MASTER_PAGE_REMOVED
     106                 :            :     };
     107                 :            : 
     108                 :            :     EventType meType;
     109                 :            :     SdDrawDocument& mrDocument;
     110                 :            :     const String& mrMasterPageName;
     111                 :            : 
     112                 :         22 :     MasterPageObserverEvent (
     113                 :            :         EventType eType,
     114                 :            :         SdDrawDocument& rDocument,
     115                 :            :         const String& rMasterPageName)
     116                 :            :         : meType(eType),
     117                 :            :           mrDocument(rDocument),
     118                 :         22 :           mrMasterPageName(rMasterPageName)
     119                 :         22 :     {}
     120                 :            : 
     121                 :            : };
     122                 :            : 
     123                 :            : } // end of namespace sd
     124                 :            : 
     125                 :            : #endif
     126                 :            : 
     127                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10