xref: /trunk/main/sd/source/ui/sidebar/RecentlyUsedMasterPages.hxx (revision 6c3f46008062a6f976c36b489e4ef55c817e828c)
102c50d82SAndre Fischer /**************************************************************
202c50d82SAndre Fischer  *
302c50d82SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
402c50d82SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
502c50d82SAndre Fischer  * distributed with this work for additional information
602c50d82SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
702c50d82SAndre Fischer  * to you under the Apache License, Version 2.0 (the
802c50d82SAndre Fischer  * "License"); you may not use this file except in compliance
902c50d82SAndre Fischer  * with the License.  You may obtain a copy of the License at
1002c50d82SAndre Fischer  *
1102c50d82SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
1202c50d82SAndre Fischer  *
1302c50d82SAndre Fischer  * Unless required by applicable law or agreed to in writing,
1402c50d82SAndre Fischer  * software distributed under the License is distributed on an
1502c50d82SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1602c50d82SAndre Fischer  * KIND, either express or implied.  See the License for the
1702c50d82SAndre Fischer  * specific language governing permissions and limitations
1802c50d82SAndre Fischer  * under the License.
1902c50d82SAndre Fischer  *
2002c50d82SAndre Fischer  *************************************************************/
2102c50d82SAndre Fischer 
2202c50d82SAndre Fischer #ifndef SD_SIDEBAR_PANELS_RECENTLY_USED_MASTER_PAGES_HXX
2302c50d82SAndre Fischer #define SD_SIDEBAR_PANELS_RECENTLY_USED_MASTER_PAGES_HXX
2402c50d82SAndre Fischer 
2502c50d82SAndre Fischer #include "tools/SdGlobalResourceContainer.hxx"
2602c50d82SAndre Fischer #include <osl/mutex.hxx>
2702c50d82SAndre Fischer #include <tools/link.hxx>
2802c50d82SAndre Fischer #include <vcl/image.hxx>
2902c50d82SAndre Fischer #include <vector>
3002c50d82SAndre Fischer #include <tools/string.hxx>
3102c50d82SAndre Fischer 
3202c50d82SAndre Fischer #include "DrawDocShell.hxx"
3302c50d82SAndre Fischer #include "MasterPageContainer.hxx"
3402c50d82SAndre Fischer #include <com/sun/star/uno/XInterface.hpp>
3502c50d82SAndre Fischer 
3602c50d82SAndre Fischer class SdPage;
3702c50d82SAndre Fischer 
3802c50d82SAndre Fischer namespace sd {
3902c50d82SAndre Fischer class MasterPageObserverEvent;
4002c50d82SAndre Fischer }
4102c50d82SAndre Fischer 
4202c50d82SAndre Fischer namespace sd { namespace sidebar {
4302c50d82SAndre Fischer 
4402c50d82SAndre Fischer /** This singleton holds a list of the most recently used master pages.
4502c50d82SAndre Fischer  */
4602c50d82SAndre Fischer class RecentlyUsedMasterPages
4702c50d82SAndre Fischer     : public SdGlobalResource
4802c50d82SAndre Fischer {
4902c50d82SAndre Fischer public:
5002c50d82SAndre Fischer     /** Return the single instance of this class.
5102c50d82SAndre Fischer      */
5202c50d82SAndre Fischer     static RecentlyUsedMasterPages& Instance (void);
5302c50d82SAndre Fischer 
5402c50d82SAndre Fischer     void AddEventListener (const Link& rEventListener);
5502c50d82SAndre Fischer     void RemoveEventListener (const Link& rEventListener);
5602c50d82SAndre Fischer 
5702c50d82SAndre Fischer     int GetMasterPageCount (void) const;
5802c50d82SAndre Fischer     MasterPageContainer::Token GetTokenForIndex (sal_uInt32 nIndex) const;
5902c50d82SAndre Fischer 
6002c50d82SAndre Fischer private:
6102c50d82SAndre Fischer     /** The single instance of this class. It is created on demand when
6202c50d82SAndre Fischer         Instance() is called for the first time.
6302c50d82SAndre Fischer      */
6402c50d82SAndre Fischer     static RecentlyUsedMasterPages* mpInstance;
6502c50d82SAndre Fischer 
6602c50d82SAndre Fischer     ::std::vector<Link> maListeners;
6702c50d82SAndre Fischer 
6802c50d82SAndre Fischer     class MasterPageList;
6902c50d82SAndre Fischer     ::std::auto_ptr<MasterPageList> mpMasterPages;
7002c50d82SAndre Fischer     unsigned long int mnMaxListSize;
7102c50d82SAndre Fischer     ::boost::shared_ptr<MasterPageContainer> mpContainer;
7202c50d82SAndre Fischer 
7302c50d82SAndre Fischer     RecentlyUsedMasterPages (void);
7402c50d82SAndre Fischer     virtual ~RecentlyUsedMasterPages (void);
7502c50d82SAndre Fischer 
7602c50d82SAndre Fischer     /** Call this method after a new object has been created.
7702c50d82SAndre Fischer      */
7802c50d82SAndre Fischer     void LateInit (void);
7902c50d82SAndre Fischer 
80*6c3f4600Smseidel     // The copy constructor is not implemented. Do not use!
8102c50d82SAndre Fischer     RecentlyUsedMasterPages (const RecentlyUsedMasterPages&);
8202c50d82SAndre Fischer 
83*6c3f4600Smseidel     // The assignment operator is not implemented. Do not use!
8402c50d82SAndre Fischer     RecentlyUsedMasterPages& operator= (const RecentlyUsedMasterPages&);
8502c50d82SAndre Fischer 
8602c50d82SAndre Fischer     void SendEvent (void);
8702c50d82SAndre Fischer     DECL_LINK(MasterPageChangeListener, MasterPageObserverEvent*);
8802c50d82SAndre Fischer     DECL_LINK(MasterPageContainerChangeListener, MasterPageContainerChangeEvent*);
8902c50d82SAndre Fischer 
9002c50d82SAndre Fischer     /** Add a descriptor for the specified master page to the end of the
9102c50d82SAndre Fischer         list of most recently used master pages. When the page is already a
9202c50d82SAndre Fischer         member of that list the associated descriptor is moved to the end of
9302c50d82SAndre Fischer         the list to make it the most recently used entry.
9402c50d82SAndre Fischer         @param bMakePersistent
9502c50d82SAndre Fischer             When <TRUE/> is given then the new list of recently used master
9602c50d82SAndre Fischer             pages is written back into the configuration to make it
97c0176e29Smseidel             persistent. Giving <FALSE/> to omit this is used while loading
9802c50d82SAndre Fischer             the persistent list from the configuration.
9902c50d82SAndre Fischer      */
10002c50d82SAndre Fischer     void AddMasterPage (
10102c50d82SAndre Fischer         MasterPageContainer::Token aToken,
10202c50d82SAndre Fischer         bool bMakePersistent = true);
10302c50d82SAndre Fischer 
10402c50d82SAndre Fischer     /** Load the list of recently used master pages from the registry where
10502c50d82SAndre Fischer         it was saved to make it persistent.
10602c50d82SAndre Fischer      */
10702c50d82SAndre Fischer     void LoadPersistentValues (void);
10802c50d82SAndre Fischer 
10902c50d82SAndre Fischer     /** Save the list of recently used master pages to the registry to make
110c0176e29Smseidel         it persistent.
11102c50d82SAndre Fischer      */
11202c50d82SAndre Fischer     void SavePersistentValues (void);
11302c50d82SAndre Fischer 
11402c50d82SAndre Fischer     void ResolveList (void);
11502c50d82SAndre Fischer };
11602c50d82SAndre Fischer 
11702c50d82SAndre Fischer } } // end of namespace sd::sidebar
11802c50d82SAndre Fischer 
11902c50d82SAndre Fischer #endif
120*6c3f4600Smseidel 
121*6c3f4600Smseidel /* vim: set noet sw=4 ts=4: */
122