1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef SD_VIEW_MASTER_PAGE_OBSERVER_HXX
21 #define SD_VIEW_MASTER_PAGE_OBSERVER_HXX
23 #include "tools/SdGlobalResourceContainer.hxx"
24 #include <osl/mutex.hxx>
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.
38 class MasterPageObserver
39 : public SdGlobalResource
42 typedef ::std::set
<String
> MasterPageNameSet
;
44 /** Return the single instance of this class.
46 static MasterPageObserver
& Instance (void);
48 /** The master page observer will listen to events of this document and
49 detect changes of the use of master pages.
51 void RegisterDocument (SdDrawDocument
& rDocument
);
53 /** The master page observer will stop to listen to events of this
56 void UnregisterDocument (SdDrawDocument
& rDocument
);
58 /** Add a listener that is informed of master pages that are newly
59 assigned to slides or become unassigned.
61 The event listener to call for future events. Call
62 RemoveEventListener() before the listener is destroyed.
64 void AddEventListener (const Link
& rEventListener
);
66 /** Remove the given listener from the list of listeners.
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.
72 void RemoveEventListener (const Link
& rEventListener
);
75 static ::osl::Mutex maMutex
;
78 ::std::auto_ptr
<Implementation
> mpImpl
;
80 MasterPageObserver (void);
81 virtual ~MasterPageObserver (void);
83 /// The copy constructor is not implemented. Do not use!
84 MasterPageObserver (const MasterPageObserver
&);
86 /// The assignment operator is not implemented. Do not use!
87 MasterPageObserver
& operator= (const MasterPageObserver
&);
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.
96 class MasterPageObserverEvent
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
109 SdDrawDocument
& mrDocument
;
110 const String
& mrMasterPageName
;
112 MasterPageObserverEvent (
114 SdDrawDocument
& rDocument
,
115 const String
& rMasterPageName
)
117 mrDocument(rDocument
),
118 mrMasterPageName(rMasterPageName
)
123 } // end of namespace sd
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */