merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / framework / module / ResourceManager.hxx
blob55da4e3307166d873739fc52f697410d757263c6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ResourceManager.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_FRAMEWORK_RESOURCE_MANAGER_HXX
32 #define SD_FRAMEWORK_RESOURCE_MANAGER_HXX
34 #include "MutexOwner.hxx"
35 #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
36 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
37 #include <com/sun/star/frame/XController.hpp>
38 #include <cppuhelper/compbase1.hxx>
39 #include <boost/scoped_ptr.hpp>
41 namespace css = ::com::sun::star;
43 namespace {
45 typedef ::cppu::WeakComponentImplHelper1 <
46 ::com::sun::star::drawing::framework::XConfigurationChangeListener
47 > ResourceManagerInterfaceBase;
49 } // end of anonymous namespace.
52 namespace sd { namespace framework {
54 /** Manage the activation state of one resource depending on the view in the
55 center pane. The ResourceManager remembers in which configuration to
56 activate and in which to deactivate the resource. When the resource is
57 deactivated or activated manually by the user then the ResourceManager
58 detects this and remembers it for the future.
60 class ResourceManager
61 : private sd::MutexOwner,
62 public ResourceManagerInterfaceBase
64 public:
65 ResourceManager (
66 const ::com::sun::star::uno::Reference<
67 ::com::sun::star::frame::XController>& rxController,
68 const ::com::sun::star::uno::Reference<
69 ::com::sun::star::drawing::framework::XResourceId>& rxResourceId);
70 virtual ~ResourceManager (void);
72 /** Remember the given URL as one of a center pane view for which to
73 activate the resource managed by the called object.
75 void AddActiveMainView (const ::rtl::OUString& rsMainViewURL);
77 virtual void SAL_CALL disposing (void);
79 /** Allow the ResourceManager to make resource activation or
80 deactivation requests.
82 void Enable (void);
84 /** Disable the resource management. When called, the ResourceManager
85 requests the resource to be deactivated. Until enabled again it
86 does not make any further requests for resource activation or
87 deactivation.
89 Call this for example to hide resources in read-only mode.
91 void Disable (void);
93 // XConfigurationChangeListener
95 virtual void SAL_CALL notifyConfigurationChange (
96 const com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
97 throw (com::sun::star::uno::RuntimeException);
99 // XEventListener
101 virtual void SAL_CALL disposing (
102 const com::sun::star::lang::EventObject& rEvent)
103 throw (com::sun::star::uno::RuntimeException);
105 protected:
106 ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XConfigurationController>
107 mxConfigurationController;
109 private:
110 class MainViewContainer;
111 ::boost::scoped_ptr<MainViewContainer> mpActiveMainViewContainer;
113 /// The resource managed by this class.
114 css::uno::Reference<css::drawing::framework::XResourceId> mxResourceId;
116 /// The anchor of the main view.
117 css::uno::Reference<css::drawing::framework::XResourceId> mxMainViewAnchorId;
119 ::rtl::OUString msCurrentMainViewURL;
120 bool mbIsEnabled;
122 void HandleMainViewSwitch (
123 const ::rtl::OUString& rsViewURL,
124 const ::com::sun::star::uno::Reference<
125 com::sun::star::drawing::framework::XConfiguration>& rxConfiguration,
126 const bool bIsActivated);
127 void HandleResourceRequest(
128 bool bActivation,
129 const ::com::sun::star::uno::Reference<
130 com::sun::star::drawing::framework::XConfiguration>& rxConfiguration);
131 void UpdateForMainViewShell (void);
133 void Trace (void) const;
136 } } // end of namespace sd::framework
138 #endif