1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MasterPageObserver.hxx,v $
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>
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
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
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.
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.
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
);
93 static ::osl::Mutex maMutex
;
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
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
127 SdDrawDocument
& mrDocument
;
128 const String
& mrMasterPageName
;
130 MasterPageObserverEvent (
132 SdDrawDocument
& rDocument
,
133 const String
& rMasterPageName
)
135 mrDocument(rDocument
),
136 mrMasterPageName(rMasterPageName
)
141 } // end of namespace sd