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 .
22 #include <rtl/ustring.hxx>
23 #include <tools/link.hxx>
24 #include "tools/SdGlobalResourceContainer.hxx"
37 class MasterPageObserverEvent
;
39 /** This singleton observes all registered documents for changes in the used
40 master pages and in turn informs its listeners about it. One such
41 listener is the master page selector control in the tool panel that
42 shows the recently used master pages.
44 class MasterPageObserver final
: public SdGlobalResource
47 typedef ::std::set
<OUString
> MasterPageNameSet
;
49 /** Return the single instance of this class.
51 static MasterPageObserver
& Instance();
53 /** The master page observer will listen to events of this document and
54 detect changes of the use of master pages.
56 void RegisterDocument(SdDrawDocument
& rDocument
);
58 /** The master page observer will stop to listen to events of this
61 void UnregisterDocument(SdDrawDocument
& rDocument
);
63 /** Add a listener that is informed of master pages that are newly
64 assigned to slides or become unassigned.
66 The event listener to call for future events. Call
67 RemoveEventListener() before the listener is destroyed.
69 void AddEventListener(const Link
<MasterPageObserverEvent
&, void>& rEventListener
);
71 /** Remove the given listener from the list of listeners.
73 After this method returns the given listener is not called back
74 from this object. Passing a listener that has not
75 been registered before is safe and is silently ignored.
77 void RemoveEventListener(const Link
<MasterPageObserverEvent
&, void>& rEventListener
);
81 ::std::unique_ptr
<Implementation
> mpImpl
;
84 virtual ~MasterPageObserver() override
;
86 MasterPageObserver(const MasterPageObserver
&) = delete;
88 MasterPageObserver
& operator=(const MasterPageObserver
&) = delete;
91 /** Objects of this class are sent to listeners of the MasterPageObserver
92 singleton when the list of master pages of one document has changed.
94 class MasterPageObserverEvent
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
108 const OUString
& mrMasterPageName
;
110 MasterPageObserverEvent(EventType eType
, const OUString
& rMasterPageName
)
112 , mrMasterPageName(rMasterPageName
)
117 } // end of namespace sd
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */