xref: /trunk/main/sd/source/ui/sidebar/RecentlyUsedMasterPages.hxx (revision c0176e29f1b73ee9933236b76a82e2bc81761923)
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 
2302c50d82SAndre Fischer 
2402c50d82SAndre Fischer #ifndef SD_SIDEBAR_PANELS_RECENTLY_USED_MASTER_PAGES_HXX
2502c50d82SAndre Fischer #define SD_SIDEBAR_PANELS_RECENTLY_USED_MASTER_PAGES_HXX
2602c50d82SAndre Fischer 
2702c50d82SAndre Fischer #include "tools/SdGlobalResourceContainer.hxx"
2802c50d82SAndre Fischer #include <osl/mutex.hxx>
2902c50d82SAndre Fischer #include <tools/link.hxx>
3002c50d82SAndre Fischer #include <vcl/image.hxx>
3102c50d82SAndre Fischer #include <vector>
3202c50d82SAndre Fischer #include <tools/string.hxx>
3302c50d82SAndre Fischer 
3402c50d82SAndre Fischer #include "DrawDocShell.hxx"
3502c50d82SAndre Fischer #include "MasterPageContainer.hxx"
3602c50d82SAndre Fischer #include <com/sun/star/uno/XInterface.hpp>
3702c50d82SAndre Fischer 
3802c50d82SAndre Fischer class SdPage;
3902c50d82SAndre Fischer 
4002c50d82SAndre Fischer namespace sd {
4102c50d82SAndre Fischer class MasterPageObserverEvent;
4202c50d82SAndre Fischer }
4302c50d82SAndre Fischer 
4402c50d82SAndre Fischer 
4502c50d82SAndre Fischer namespace sd { namespace sidebar {
4602c50d82SAndre Fischer 
4702c50d82SAndre Fischer /** This singleton holds a list of the most recently used master pages.
4802c50d82SAndre Fischer */
4902c50d82SAndre Fischer class RecentlyUsedMasterPages
5002c50d82SAndre Fischer     : public SdGlobalResource
5102c50d82SAndre Fischer {
5202c50d82SAndre Fischer public:
5302c50d82SAndre Fischer     /** Return the single instance of this class.
5402c50d82SAndre Fischer     */
5502c50d82SAndre Fischer     static RecentlyUsedMasterPages& Instance (void);
5602c50d82SAndre Fischer 
5702c50d82SAndre Fischer     void AddEventListener (const Link& rEventListener);
5802c50d82SAndre Fischer     void RemoveEventListener (const Link& rEventListener);
5902c50d82SAndre Fischer 
6002c50d82SAndre Fischer     int GetMasterPageCount (void) const;
6102c50d82SAndre Fischer     MasterPageContainer::Token GetTokenForIndex (sal_uInt32 nIndex) const;
6202c50d82SAndre Fischer 
6302c50d82SAndre Fischer private:
6402c50d82SAndre Fischer     /** The single instance of this class. It is created on demand when
6502c50d82SAndre Fischer         Instance() is called for the first time.
6602c50d82SAndre Fischer     */
6702c50d82SAndre Fischer     static RecentlyUsedMasterPages* mpInstance;
6802c50d82SAndre Fischer 
6902c50d82SAndre Fischer     ::std::vector<Link> maListeners;
7002c50d82SAndre Fischer 
7102c50d82SAndre Fischer     class MasterPageList;
7202c50d82SAndre Fischer     ::std::auto_ptr<MasterPageList> mpMasterPages;
7302c50d82SAndre Fischer     unsigned long int mnMaxListSize;
7402c50d82SAndre Fischer     ::boost::shared_ptr<MasterPageContainer> mpContainer;
7502c50d82SAndre Fischer 
7602c50d82SAndre Fischer     RecentlyUsedMasterPages (void);
7702c50d82SAndre Fischer     virtual ~RecentlyUsedMasterPages (void);
7802c50d82SAndre Fischer 
7902c50d82SAndre Fischer     /** Call this method after a new object has been created.
8002c50d82SAndre Fischer     */
8102c50d82SAndre Fischer     void LateInit (void);
8202c50d82SAndre Fischer 
8302c50d82SAndre Fischer     /// The copy constructor is not implemented. Do not use!
8402c50d82SAndre Fischer     RecentlyUsedMasterPages (const RecentlyUsedMasterPages&);
8502c50d82SAndre Fischer 
8602c50d82SAndre Fischer     /// The assignment operator is not implemented. Do not use!
8702c50d82SAndre Fischer     RecentlyUsedMasterPages& operator= (const RecentlyUsedMasterPages&);
8802c50d82SAndre Fischer 
8902c50d82SAndre Fischer     void SendEvent (void);
9002c50d82SAndre Fischer     DECL_LINK(MasterPageChangeListener, MasterPageObserverEvent*);
9102c50d82SAndre Fischer     DECL_LINK(MasterPageContainerChangeListener, MasterPageContainerChangeEvent*);
9202c50d82SAndre Fischer 
9302c50d82SAndre Fischer     /** Add a descriptor for the specified master page to the end of the
9402c50d82SAndre Fischer         list of most recently used master pages. When the page is already a
9502c50d82SAndre Fischer         member of that list the associated descriptor is moved to the end of
9602c50d82SAndre Fischer         the list to make it the most recently used entry.
9702c50d82SAndre Fischer         @param bMakePersistent
9802c50d82SAndre Fischer             When <TRUE/> is given then the new list of recently used master
9902c50d82SAndre Fischer             pages is written back into the configuration to make it
100*c0176e29Smseidel             persistent. Giving <FALSE/> to omit this is used while loading
10102c50d82SAndre Fischer             the persistent list from the configuration.
10202c50d82SAndre Fischer     */
10302c50d82SAndre Fischer     void AddMasterPage (
10402c50d82SAndre Fischer         MasterPageContainer::Token aToken,
10502c50d82SAndre Fischer         bool bMakePersistent = true);
10602c50d82SAndre Fischer 
10702c50d82SAndre Fischer     /** Load the list of recently used master pages from the registry where
10802c50d82SAndre Fischer         it was saved to make it persistent.
10902c50d82SAndre Fischer     */
11002c50d82SAndre Fischer     void LoadPersistentValues (void);
11102c50d82SAndre Fischer 
11202c50d82SAndre Fischer     /** Save the list of recently used master pages to the registry to make
113*c0176e29Smseidel         it persistent.
11402c50d82SAndre Fischer     */
11502c50d82SAndre Fischer     void SavePersistentValues (void);
11602c50d82SAndre Fischer 
11702c50d82SAndre Fischer     void ResolveList (void);
11802c50d82SAndre Fischer };
11902c50d82SAndre Fischer 
12002c50d82SAndre Fischer 
12102c50d82SAndre Fischer 
12202c50d82SAndre Fischer } } // end of namespace sd::sidebar
12302c50d82SAndre Fischer 
12402c50d82SAndre Fischer #endif
125