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 91 // XEventListener 92 93 virtual void SAL_CALL disposing ( 94 const com::sun::star::lang::EventObject& rEvent); 95 96 protected: 97 ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XConfigurationController> 98 mxConfigurationController; 99 100 private: 101 class MainViewContainer; 102 ::boost::scoped_ptr<MainViewContainer> mpActiveMainViewContainer; 103 104 /// The resource managed by this class. 105 css::uno::Reference<css::drawing::framework::XResourceId> mxResourceId; 106 107 /// The anchor of the main view. 108 css::uno::Reference<css::drawing::framework::XResourceId> mxMainViewAnchorId; 109 110 ::rtl::OUString msCurrentMainViewURL; 111 bool mbIsEnabled; 112 113 void HandleMainViewSwitch ( 114 const ::rtl::OUString& rsViewURL, 115 const ::com::sun::star::uno::Reference< 116 com::sun::star::drawing::framework::XConfiguration>& rxConfiguration, 117 const bool bIsActivated); 118 void HandleResourceRequest( 119 bool bActivation, 120 const ::com::sun::star::uno::Reference< 121 com::sun::star::drawing::framework::XConfiguration>& rxConfiguration); 122 void UpdateForMainViewShell (void); 123 }; 124 125 } } // end of namespace sd::framework 126 127 #endif 128