1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #ifndef SD_SIDEBAR_PANELS_RECENTLY_USED_MASTER_PAGES_HXX 23 #define SD_SIDEBAR_PANELS_RECENTLY_USED_MASTER_PAGES_HXX 24 25 #include "tools/SdGlobalResourceContainer.hxx" 26 #include <osl/mutex.hxx> 27 #include <tools/link.hxx> 28 #include <vcl/image.hxx> 29 #include <vector> 30 #include <tools/string.hxx> 31 32 #include "DrawDocShell.hxx" 33 #include "MasterPageContainer.hxx" 34 #include <com/sun/star/uno/XInterface.hpp> 35 36 class SdPage; 37 38 namespace sd { 39 class MasterPageObserverEvent; 40 } 41 42 namespace sd { namespace sidebar { 43 44 /** This singleton holds a list of the most recently used master pages. 45 */ 46 class RecentlyUsedMasterPages 47 : public SdGlobalResource 48 { 49 public: 50 /** Return the single instance of this class. 51 */ 52 static RecentlyUsedMasterPages& Instance (void); 53 54 void AddEventListener (const Link& rEventListener); 55 void RemoveEventListener (const Link& rEventListener); 56 57 int GetMasterPageCount (void) const; 58 MasterPageContainer::Token GetTokenForIndex (sal_uInt32 nIndex) const; 59 60 private: 61 /** The single instance of this class. It is created on demand when 62 Instance() is called for the first time. 63 */ 64 static RecentlyUsedMasterPages* mpInstance; 65 66 ::std::vector<Link> maListeners; 67 68 class MasterPageList; 69 ::std::auto_ptr<MasterPageList> mpMasterPages; 70 unsigned long int mnMaxListSize; 71 ::boost::shared_ptr<MasterPageContainer> mpContainer; 72 73 RecentlyUsedMasterPages (void); 74 virtual ~RecentlyUsedMasterPages (void); 75 76 /** Call this method after a new object has been created. 77 */ 78 void LateInit (void); 79 80 // The copy constructor is not implemented. Do not use! 81 RecentlyUsedMasterPages (const RecentlyUsedMasterPages&); 82 83 // The assignment operator is not implemented. Do not use! 84 RecentlyUsedMasterPages& operator= (const RecentlyUsedMasterPages&); 85 86 void SendEvent (void); 87 DECL_LINK(MasterPageChangeListener, MasterPageObserverEvent*); 88 DECL_LINK(MasterPageContainerChangeListener, MasterPageContainerChangeEvent*); 89 90 /** Add a descriptor for the specified master page to the end of the 91 list of most recently used master pages. When the page is already a 92 member of that list the associated descriptor is moved to the end of 93 the list to make it the most recently used entry. 94 @param bMakePersistent 95 When <TRUE/> is given then the new list of recently used master 96 pages is written back into the configuration to make it 97 persistent. Giving <FALSE/> to omit this is used while loading 98 the persistent list from the configuration. 99 */ 100 void AddMasterPage ( 101 MasterPageContainer::Token aToken, 102 bool bMakePersistent = true); 103 104 /** Load the list of recently used master pages from the registry where 105 it was saved to make it persistent. 106 */ 107 void LoadPersistentValues (void); 108 109 /** Save the list of recently used master pages to the registry to make 110 it persistent. 111 */ 112 void SavePersistentValues (void); 113 114 void ResolveList (void); 115 }; 116 117 } } // end of namespace sd::sidebar 118 119 #endif 120 121 /* vim: set noet sw=4 ts=4: */ 122