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