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 INCLUDED_SD_SOURCE_UI_INC_MASTERPAGEOBSERVER_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_MASTERPAGEOBSERVER_HXX
23 #include <rtl/ustring.hxx>
24 #include "tools/SdGlobalResourceContainer.hxx"
25 #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
<OUString
> MasterPageNameSet
;
44 /** Return the single instance of this class.
46 static MasterPageObserver
& Instance();
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::unique_ptr
<Implementation
> mpImpl
;
81 virtual ~MasterPageObserver();
83 MasterPageObserver (const MasterPageObserver
&) SAL_DELETED_FUNCTION
;
85 MasterPageObserver
& operator= (const MasterPageObserver
&) SAL_DELETED_FUNCTION
;
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.
91 class MasterPageObserverEvent
95 /// Master page already exists when document is registered.
96 ET_MASTER_PAGE_EXISTS
,
97 /// Master page has been added to a document.
99 /// Master page has been removed from to a document.
100 ET_MASTER_PAGE_REMOVED
104 SdDrawDocument
& mrDocument
;
105 const OUString
& mrMasterPageName
;
107 MasterPageObserverEvent (
109 SdDrawDocument
& rDocument
,
110 const OUString
& rMasterPageName
)
112 mrDocument(rDocument
),
113 mrMasterPageName(rMasterPageName
)
118 } // end of namespace sd
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */