bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / sidebar / RecentlyUsedMasterPages.hxx
blobc4da8a3986e32f714026fa610fbec5439900ca6b
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_SIDEBAR_RECENTLYUSEDMASTERPAGES_HXX
21 #define INCLUDED_SD_SOURCE_UI_SIDEBAR_RECENTLYUSEDMASTERPAGES_HXX
23 #include "tools/SdGlobalResourceContainer.hxx"
24 #include <osl/mutex.hxx>
25 #include <tools/link.hxx>
26 #include <vcl/image.hxx>
27 #include <vector>
29 #include "DrawDocShell.hxx"
30 #include "MasterPageContainer.hxx"
31 #include <com/sun/star/uno/XInterface.hpp>
33 namespace sd {
34 class MasterPageObserverEvent;
37 namespace sd { namespace sidebar {
39 /** This singleton holds a list of the most recently used master pages.
41 class RecentlyUsedMasterPages
42 : public SdGlobalResource
44 public:
45 /** Return the single instance of this class.
47 static RecentlyUsedMasterPages& Instance();
49 void AddEventListener (const Link<>& rEventListener);
50 void RemoveEventListener (const Link<>& rEventListener);
52 int GetMasterPageCount() const;
53 MasterPageContainer::Token GetTokenForIndex (sal_uInt32 nIndex) const;
55 private:
56 class Descriptor
58 public:
59 OUString msURL;
60 OUString msName;
61 ::sd::sidebar::MasterPageContainer::Token maToken;
62 Descriptor (::sd::sidebar::MasterPageContainer::Token aToken,
63 const OUString& rsURL, const OUString& rsName)
64 : msURL(rsURL),
65 msName(rsName),
66 maToken(aToken)
69 class TokenComparator
71 public:
72 explicit TokenComparator(::sd::sidebar::MasterPageContainer::Token aToken)
73 : maToken(aToken) {}
74 bool operator () (const Descriptor& rDescriptor)
75 { return maToken==rDescriptor.maToken; }
77 private:
78 ::sd::sidebar::MasterPageContainer::Token maToken;
82 /** The single instance of this class. It is created on demand when
83 Instance() is called for the first time.
85 static RecentlyUsedMasterPages* mpInstance;
87 ::std::vector<Link<>> maListeners;
89 typedef ::std::vector<Descriptor> MasterPageList;
90 MasterPageList mvMasterPages;
91 unsigned long int mnMaxListSize;
92 ::boost::shared_ptr<MasterPageContainer> mpContainer;
94 RecentlyUsedMasterPages();
95 virtual ~RecentlyUsedMasterPages();
97 /** Call this method after a new object has been created.
99 void LateInit();
101 RecentlyUsedMasterPages (const RecentlyUsedMasterPages&) SAL_DELETED_FUNCTION;
103 RecentlyUsedMasterPages& operator= (const RecentlyUsedMasterPages&) SAL_DELETED_FUNCTION;
105 void SendEvent();
106 DECL_LINK(MasterPageChangeListener, MasterPageObserverEvent*);
107 DECL_LINK(MasterPageContainerChangeListener, MasterPageContainerChangeEvent*);
109 /** Add a descriptor for the specified master page to the end of the
110 list of most recently used master pages. When the page is already a
111 member of that list the associated descriptor is moved to the end of
112 the list to make it the most recently used entry.
113 @param bMakePersistent
114 When <TRUE/> is given then the new list of recently used master
115 pages is written back into the configuration to make it
116 persistent. Giving <FALSE/> to omit this is used while loading
117 the persistent list from the configuration.
119 void AddMasterPage (
120 MasterPageContainer::Token aToken,
121 bool bMakePersistent = true);
123 /** Load the list of recently used master pages from the registry where
124 it was saved to make it persistent.
126 void LoadPersistentValues();
128 /** Save the list of recently used master pages to the registry to make
129 it presistent.
131 void SavePersistentValues();
133 void ResolveList();
136 } } // end of namespace sd::sidebar
138 #endif
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */