1*c45d927aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*c45d927aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*c45d927aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*c45d927aSAndrew Rist * distributed with this work for additional information 6*c45d927aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*c45d927aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*c45d927aSAndrew Rist * "License"); you may not use this file except in compliance 9*c45d927aSAndrew Rist * with the License. You may obtain a copy of the License at 10*c45d927aSAndrew Rist * 11*c45d927aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*c45d927aSAndrew Rist * 13*c45d927aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*c45d927aSAndrew Rist * software distributed under the License is distributed on an 15*c45d927aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*c45d927aSAndrew Rist * KIND, either express or implied. See the License for the 17*c45d927aSAndrew Rist * specific language governing permissions and limitations 18*c45d927aSAndrew Rist * under the License. 19*c45d927aSAndrew Rist * 20*c45d927aSAndrew Rist *************************************************************/ 21*c45d927aSAndrew Rist 22*c45d927aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SD_FRAMEWORK_RESOURCE_MANAGER_HXX 25cdf0e10cSrcweir #define SD_FRAMEWORK_RESOURCE_MANAGER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "MutexOwner.hxx" 28cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp> 29cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XConfigurationController.hpp> 30cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 31cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx> 32cdf0e10cSrcweir #include <boost/scoped_ptr.hpp> 33cdf0e10cSrcweir 34cdf0e10cSrcweir namespace css = ::com::sun::star; 35cdf0e10cSrcweir 36cdf0e10cSrcweir namespace { 37cdf0e10cSrcweir 38cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1 < 39cdf0e10cSrcweir ::com::sun::star::drawing::framework::XConfigurationChangeListener 40cdf0e10cSrcweir > ResourceManagerInterfaceBase; 41cdf0e10cSrcweir 42cdf0e10cSrcweir } // end of anonymous namespace. 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir namespace sd { namespace framework { 46cdf0e10cSrcweir 47cdf0e10cSrcweir /** Manage the activation state of one resource depending on the view in the 48cdf0e10cSrcweir center pane. The ResourceManager remembers in which configuration to 49cdf0e10cSrcweir activate and in which to deactivate the resource. When the resource is 50cdf0e10cSrcweir deactivated or activated manually by the user then the ResourceManager 51cdf0e10cSrcweir detects this and remembers it for the future. 52cdf0e10cSrcweir */ 53cdf0e10cSrcweir class ResourceManager 54cdf0e10cSrcweir : private sd::MutexOwner, 55cdf0e10cSrcweir public ResourceManagerInterfaceBase 56cdf0e10cSrcweir { 57cdf0e10cSrcweir public: 58cdf0e10cSrcweir ResourceManager ( 59cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 60cdf0e10cSrcweir ::com::sun::star::frame::XController>& rxController, 61cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 62cdf0e10cSrcweir ::com::sun::star::drawing::framework::XResourceId>& rxResourceId); 63cdf0e10cSrcweir virtual ~ResourceManager (void); 64cdf0e10cSrcweir 65cdf0e10cSrcweir /** Remember the given URL as one of a center pane view for which to 66cdf0e10cSrcweir activate the resource managed by the called object. 67cdf0e10cSrcweir */ 68cdf0e10cSrcweir void AddActiveMainView (const ::rtl::OUString& rsMainViewURL); 69cdf0e10cSrcweir 70cdf0e10cSrcweir virtual void SAL_CALL disposing (void); 71cdf0e10cSrcweir 72cdf0e10cSrcweir /** Allow the ResourceManager to make resource activation or 73cdf0e10cSrcweir deactivation requests. 74cdf0e10cSrcweir */ 75cdf0e10cSrcweir void Enable (void); 76cdf0e10cSrcweir 77cdf0e10cSrcweir /** Disable the resource management. When called, the ResourceManager 78cdf0e10cSrcweir requests the resource to be deactivated. Until enabled again it 79cdf0e10cSrcweir does not make any further requests for resource activation or 80cdf0e10cSrcweir deactivation. 81cdf0e10cSrcweir 82cdf0e10cSrcweir Call this for example to hide resources in read-only mode. 83cdf0e10cSrcweir */ 84cdf0e10cSrcweir void Disable (void); 85cdf0e10cSrcweir 86cdf0e10cSrcweir // XConfigurationChangeListener 87cdf0e10cSrcweir 88cdf0e10cSrcweir virtual void SAL_CALL notifyConfigurationChange ( 89cdf0e10cSrcweir const com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent) 90cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException); 91cdf0e10cSrcweir 92cdf0e10cSrcweir // XEventListener 93cdf0e10cSrcweir 94cdf0e10cSrcweir virtual void SAL_CALL disposing ( 95cdf0e10cSrcweir const com::sun::star::lang::EventObject& rEvent) 96cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException); 97cdf0e10cSrcweir 98cdf0e10cSrcweir protected: 99cdf0e10cSrcweir ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XConfigurationController> 100cdf0e10cSrcweir mxConfigurationController; 101cdf0e10cSrcweir 102cdf0e10cSrcweir private: 103cdf0e10cSrcweir class MainViewContainer; 104cdf0e10cSrcweir ::boost::scoped_ptr<MainViewContainer> mpActiveMainViewContainer; 105cdf0e10cSrcweir 106cdf0e10cSrcweir /// The resource managed by this class. 107cdf0e10cSrcweir css::uno::Reference<css::drawing::framework::XResourceId> mxResourceId; 108cdf0e10cSrcweir 109cdf0e10cSrcweir /// The anchor of the main view. 110cdf0e10cSrcweir css::uno::Reference<css::drawing::framework::XResourceId> mxMainViewAnchorId; 111cdf0e10cSrcweir 112cdf0e10cSrcweir ::rtl::OUString msCurrentMainViewURL; 113cdf0e10cSrcweir bool mbIsEnabled; 114cdf0e10cSrcweir 115cdf0e10cSrcweir void HandleMainViewSwitch ( 116cdf0e10cSrcweir const ::rtl::OUString& rsViewURL, 117cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 118cdf0e10cSrcweir com::sun::star::drawing::framework::XConfiguration>& rxConfiguration, 119cdf0e10cSrcweir const bool bIsActivated); 120cdf0e10cSrcweir void HandleResourceRequest( 121cdf0e10cSrcweir bool bActivation, 122cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 123cdf0e10cSrcweir com::sun::star::drawing::framework::XConfiguration>& rxConfiguration); 124cdf0e10cSrcweir void UpdateForMainViewShell (void); 125cdf0e10cSrcweir }; 126cdf0e10cSrcweir 127cdf0e10cSrcweir } } // end of namespace sd::framework 128cdf0e10cSrcweir 129cdf0e10cSrcweir #endif 130