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