bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / inc / MasterPageObserver.hxx
blob927cfbf4cda4581ef29a2fa7adaaa07ba7933db9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/link.hxx>
25 #include "tools/SdGlobalResourceContainer.hxx"
26 #include <memory>
27 #include <set>
29 namespace osl { class Mutex; }
31 class SdDrawDocument;
33 namespace sd {
35 class MasterPageObserverEvent;
37 /** This singleton observes all registered documents for changes in the used
38 master pages and in turn informs its listeners about it. One such
39 listener is the master page selector control in the tool panel that
40 shows the recently used master pages.
42 class MasterPageObserver
43 : public SdGlobalResource
45 public:
46 typedef ::std::set<OUString> MasterPageNameSet;
48 /** Return the single instance of this class.
50 static MasterPageObserver& Instance();
52 /** The master page observer will listen to events of this document and
53 detect changes of the use of master pages.
55 void RegisterDocument (SdDrawDocument& rDocument);
57 /** The master page observer will stop to listen to events of this
58 document.
60 void UnregisterDocument (SdDrawDocument& rDocument);
62 /** Add a listener that is informed of master pages that are newly
63 assigned to slides or become unassigned.
64 @param rEventListener
65 The event listener to call for future events. Call
66 RemoveEventListener() before the listener is destroyed.
68 void AddEventListener (const Link<MasterPageObserverEvent&,void>& rEventListener);
70 /** Remove the given listener from the list of listeners.
71 @param rEventListener
72 After this method returns the given listener is not called back
73 from this object. Passing a listener that has not
74 been registered before is safe and is silently ignored.
76 void RemoveEventListener (const Link<MasterPageObserverEvent&,void>& rEventListener);
78 private:
79 static ::osl::Mutex maMutex;
81 class Implementation;
82 ::std::unique_ptr<Implementation> mpImpl;
84 MasterPageObserver();
85 virtual ~MasterPageObserver() override;
87 MasterPageObserver (const MasterPageObserver&) = delete;
89 MasterPageObserver& operator= (const MasterPageObserver&) = delete;
92 /** Objects of this class are sent to listeners of the MasterPageObserver
93 singleton when the list of master pages of one document has changed.
95 class MasterPageObserverEvent
97 public:
98 enum EventType {
99 /// Master page already exists when document is registered.
100 ET_MASTER_PAGE_EXISTS,
101 /// Master page has been added to a document.
102 ET_MASTER_PAGE_ADDED,
103 /// Master page has been removed from to a document.
104 ET_MASTER_PAGE_REMOVED
107 EventType const meType;
108 const OUString& mrMasterPageName;
110 MasterPageObserverEvent (
111 EventType eType,
112 const OUString& rMasterPageName)
113 : meType(eType),
114 mrMasterPageName(rMasterPageName)
119 } // end of namespace sd
121 #endif
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */