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