update dev300-m58
[ooovba.git] / sd / source / ui / inc / MasterPageObserver.hxx
blob32b95802ae2f4aee9239214dad46a3268b3181fc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MasterPageObserver.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_VIEW_MASTER_PAGE_OBSERVER_HXX
32 #define SD_VIEW_MASTER_PAGE_OBSERVER_HXX
34 #include "tools/SdGlobalResourceContainer.hxx"
35 #include <osl/mutex.hxx>
36 #include <tools/link.hxx>
37 #include <memory>
38 #include <set>
40 class SdDrawDocument;
41 class String;
43 namespace sd {
45 /** This singleton observes all registered documents for changes in the used
46 master pages and in turn informs its listeners about it. One such
47 listener is the master page selector control in the tool panel that
48 shows the recently used master pages.
50 class MasterPageObserver
51 : public SdGlobalResource
53 public:
54 typedef ::std::set<String> MasterPageNameSet;
56 /** Return the single instance of this class.
58 static MasterPageObserver& Instance (void);
60 /** The master page observer will listen to events of this document and
61 detect changes of the use of master pages.
63 void RegisterDocument (SdDrawDocument& rDocument);
65 /** The master page observer will stop to listen to events of this
66 document.
68 void UnregisterDocument (SdDrawDocument& rDocument);
70 /** Add a listener that is informed of master pages that are newly
71 assigned to slides or become unassigned.
72 @param rEventListener
73 The event listener to call for future events. Call
74 RemoveEventListener() before the listener is destroyed.
76 void AddEventListener (const Link& rEventListener);
78 /** Remove the given listener from the list of listeners.
79 @param rEventListener
80 After this method returns the given listener is not called back
81 from this object. Passing a listener that has not
82 been registered before is safe and is silently ignored.
84 void RemoveEventListener (const Link& rEventListener);
86 /** Return a set of the names of master pages for the given document.
87 This convenience method exists because this set is part of the
88 internal data structure and thus takes no time to create.
90 MasterPageNameSet GetMasterPageNames (SdDrawDocument& rDocument);
92 private:
93 static ::osl::Mutex maMutex;
95 class Implementation;
96 ::std::auto_ptr<Implementation> mpImpl;
98 MasterPageObserver (void);
99 virtual ~MasterPageObserver (void);
101 /// The copy constructor is not implemented. Do not use!
102 MasterPageObserver (const MasterPageObserver&);
104 /// The assignment operator is not implemented. Do not use!
105 MasterPageObserver& operator= (const MasterPageObserver&);
111 /** Objects of this class are sent to listeners of the MasterPageObserver
112 singleton when the list of master pages of one document has changed.
114 class MasterPageObserverEvent
116 public:
117 enum EventType {
118 /// Master page already exists when document is registered.
119 ET_MASTER_PAGE_EXISTS,
120 /// Master page has been added to a document.
121 ET_MASTER_PAGE_ADDED,
122 /// Master page has been removed from to a document.
123 ET_MASTER_PAGE_REMOVED
126 EventType meType;
127 SdDrawDocument& mrDocument;
128 const String& mrMasterPageName;
130 MasterPageObserverEvent (
131 EventType eType,
132 SdDrawDocument& rDocument,
133 const String& rMasterPageName)
134 : meType(eType),
135 mrDocument(rDocument),
136 mrMasterPageName(rMasterPageName)
141 } // end of namespace sd
143 #endif