1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: RecentlyUsedMasterPages.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_TOOLPANEL_CONTROLS_RECENTLY_USED_MASTER_PAGES_HXX
32 #define SD_TOOLPANEL_CONTROLS_RECENTLY_USED_MASTER_PAGES_HXX
34 #include "tools/SdGlobalResourceContainer.hxx"
35 #include <osl/mutex.hxx>
36 #include <tools/link.hxx>
37 #include <vcl/image.hxx>
39 #include <tools/string.hxx>
41 #include "DrawDocShell.hxx"
42 #include "MasterPageContainer.hxx"
43 #include <com/sun/star/uno/XInterface.hpp>
48 class MasterPageObserverEvent
;
52 namespace sd
{ namespace toolpanel
{ namespace controls
{
54 /** This singleton holds a list of the most recently used master pages.
56 class RecentlyUsedMasterPages
57 : public SdGlobalResource
60 /** Return the single instance of this class.
62 static RecentlyUsedMasterPages
& Instance (void);
64 void AddEventListener (const Link
& rEventListener
);
65 void RemoveEventListener (const Link
& rEventListener
);
67 int GetMasterPageCount (void) const;
68 MasterPageContainer::Token
GetTokenForIndex (sal_uInt32 nIndex
) const;
71 /** The single instance of this class. It is created on demand when
72 Instance() is called for the first time.
74 static RecentlyUsedMasterPages
* mpInstance
;
76 ::std::vector
<Link
> maListeners
;
79 ::std::auto_ptr
<MasterPageList
> mpMasterPages
;
80 unsigned long int mnMaxListSize
;
81 ::boost::shared_ptr
<MasterPageContainer
> mpContainer
;
83 RecentlyUsedMasterPages (void);
84 virtual ~RecentlyUsedMasterPages (void);
86 /** Call this method after a new object has been created.
90 /// The copy constructor is not implemented. Do not use!
91 RecentlyUsedMasterPages (const RecentlyUsedMasterPages
&);
93 /// The assignment operator is not implemented. Do not use!
94 RecentlyUsedMasterPages
& operator= (const RecentlyUsedMasterPages
&);
96 void SendEvent (void);
97 DECL_LINK(MasterPageChangeListener
, MasterPageObserverEvent
*);
98 DECL_LINK(MasterPageContainerChangeListener
, MasterPageContainerChangeEvent
*);
100 /** Add a descriptor for the specified master page to the end of the
101 list of most recently used master pages. When the page is already a
102 member of that list the associated descriptor is moved to the end of
103 the list to make it the most recently used entry.
104 @param bMakePersistent
105 When <TRUE/> is given then the new list of recently used master
106 pages is written back into the configuration to make it
107 persistent. Giving <FALSE/> to ommit this is used while loading
108 the persistent list from the configuration.
111 MasterPageContainer::Token aToken
,
112 bool bMakePersistent
= true);
114 /** Load the list of recently used master pages from the registry where
115 it was saved to make it persistent.
117 void LoadPersistentValues (void);
119 /** Save the list of recently used master pages to the registry to make
122 void SavePersistentValues (void);
124 void ResolveList (void);
129 } } } // end of namespace ::sd::toolpanel::controls