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 23 24 #ifndef SD_SIDEBAR_PANELS_RECENTLY_USED_MASTER_PAGES_HXX 25 #define SD_SIDEBAR_PANELS_RECENTLY_USED_MASTER_PAGES_HXX 26 27 #include "tools/SdGlobalResourceContainer.hxx" 28 #include <osl/mutex.hxx> 29 #include <tools/link.hxx> 30 #include <vcl/image.hxx> 31 #include <vector> 32 #include <tools/string.hxx> 33 34 #include "DrawDocShell.hxx" 35 #include "MasterPageContainer.hxx" 36 #include <com/sun/star/uno/XInterface.hpp> 37 38 class SdPage; 39 40 namespace sd { 41 class MasterPageObserverEvent; 42 } 43 44 45 namespace sd { namespace sidebar { 46 47 /** This singleton holds a list of the most recently used master pages. 48 */ 49 class RecentlyUsedMasterPages 50 : public SdGlobalResource 51 { 52 public: 53 /** Return the single instance of this class. 54 */ 55 static RecentlyUsedMasterPages& Instance (void); 56 57 void AddEventListener (const Link& rEventListener); 58 void RemoveEventListener (const Link& rEventListener); 59 60 int GetMasterPageCount (void) const; 61 MasterPageContainer::Token GetTokenForIndex (sal_uInt32 nIndex) const; 62 63 private: 64 /** The single instance of this class. It is created on demand when 65 Instance() is called for the first time. 66 */ 67 static RecentlyUsedMasterPages* mpInstance; 68 69 ::std::vector<Link> maListeners; 70 71 class MasterPageList; 72 ::std::auto_ptr<MasterPageList> mpMasterPages; 73 unsigned long int mnMaxListSize; 74 ::boost::shared_ptr<MasterPageContainer> mpContainer; 75 76 RecentlyUsedMasterPages (void); 77 virtual ~RecentlyUsedMasterPages (void); 78 79 /** Call this method after a new object has been created. 80 */ 81 void LateInit (void); 82 83 /// The copy constructor is not implemented. Do not use! 84 RecentlyUsedMasterPages (const RecentlyUsedMasterPages&); 85 86 /// The assignment operator is not implemented. Do not use! 87 RecentlyUsedMasterPages& operator= (const RecentlyUsedMasterPages&); 88 89 void SendEvent (void); 90 DECL_LINK(MasterPageChangeListener, MasterPageObserverEvent*); 91 DECL_LINK(MasterPageContainerChangeListener, MasterPageContainerChangeEvent*); 92 93 /** Add a descriptor for the specified master page to the end of the 94 list of most recently used master pages. When the page is already a 95 member of that list the associated descriptor is moved to the end of 96 the list to make it the most recently used entry. 97 @param bMakePersistent 98 When <TRUE/> is given then the new list of recently used master 99 pages is written back into the configuration to make it 100 persistent. Giving <FALSE/> to ommit this is used while loading 101 the persistent list from the configuration. 102 */ 103 void AddMasterPage ( 104 MasterPageContainer::Token aToken, 105 bool bMakePersistent = true); 106 107 /** Load the list of recently used master pages from the registry where 108 it was saved to make it persistent. 109 */ 110 void LoadPersistentValues (void); 111 112 /** Save the list of recently used master pages to the registry to make 113 it presistent. 114 */ 115 void SavePersistentValues (void); 116 117 void ResolveList (void); 118 }; 119 120 121 122 } } // end of namespace sd::sidebar 123 124 #endif 125