LibreOffice Module sd (master) 1
RecentlyUsedMasterPages.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
23#include <tools/link.hxx>
24#include <utility>
25#include <vector>
26
28
29namespace sd {
30class MasterPageObserverEvent;
31}
32
33namespace sd::sidebar {
34
38 : public SdGlobalResource
39{
40public:
44
45 void AddEventListener (const Link<LinkParamNone*,void>& rEventListener);
46 void RemoveEventListener (const Link<LinkParamNone*,void>& rEventListener);
47
48 int GetMasterPageCount() const;
50
51private:
53 {
54 public:
55 OUString msURL;
56 OUString msName;
59 OUString sURL, OUString sName)
60 : msURL(std::move(sURL)),
61 msName(std::move(sName)),
62 maToken(aToken)
63 {}
64
66 {
67 public:
69 : maToken(aToken) {}
70 bool operator () (const Descriptor& rDescriptor)
71 { return maToken==rDescriptor.maToken; }
72
73 private:
75 };
76 };
77
82
83 ::std::vector<Link<LinkParamNone*,void>> maListeners;
84
85 typedef ::std::vector<Descriptor> MasterPageList;
87 std::shared_ptr<MasterPageContainer> mpContainer;
88
90 virtual ~RecentlyUsedMasterPages() override;
91
94 void LateInit();
95
97
99
100 void SendEvent();
101 DECL_LINK(MasterPageChangeListener, MasterPageObserverEvent&, void);
102 DECL_LINK(MasterPageContainerChangeListener, MasterPageContainerChangeEvent&, void);
103
110
115
120
121 void ResolveList();
122};
123
124} // end of namespace sd::sidebar
125
126/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Objects of this class are sent to listeners of the MasterPageObserver singleton when the list of mast...
For some changes to the set of master pages in a MasterPageContainer or to the data stored for each m...
TokenComparator(::sd::sidebar::MasterPageContainer::Token aToken)
Descriptor(::sd::sidebar::MasterPageContainer::Token aToken, OUString sURL, OUString sName)
::sd::sidebar::MasterPageContainer::Token maToken
This singleton holds a list of the most recently used master pages.
DECL_LINK(MasterPageChangeListener, MasterPageObserverEvent &, void)
void LoadPersistentValues()
Load the list of recently used master pages from the registry where it was saved to make it persisten...
RecentlyUsedMasterPages & operator=(const RecentlyUsedMasterPages &)=delete
void SavePersistentValues()
Save the list of recently used master pages to the registry to make it persistent.
void RemoveEventListener(const Link< LinkParamNone *, void > &rEventListener)
void AddMasterPage(MasterPageContainer::Token aToken)
Add a descriptor for the specified master page to the end of the list of most recently used master pa...
std::shared_ptr< MasterPageContainer > mpContainer
static RecentlyUsedMasterPages * mpInstance
The single instance of this class.
static RecentlyUsedMasterPages & Instance()
Return the single instance of this class.
void AddEventListener(const Link< LinkParamNone *, void > &rEventListener)
void LateInit()
Call this method after a new object has been created.
::std::vector< Link< LinkParamNone *, void > > maListeners
MasterPageContainer::Token GetTokenForIndex(sal_uInt32 nIndex) const
DECL_LINK(MasterPageContainerChangeListener, MasterPageContainerChangeEvent &, void)
RecentlyUsedMasterPages(const RecentlyUsedMasterPages &)=delete
OUString sName
sal_Int32 nIndex