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_CONFIGURATION_CONTROLLER_HXX 25 #define SD_FRAMEWORK_CONFIGURATION_CONTROLLER_HXX 26 27 #include "MutexOwner.hxx" 28 29 #include <com/sun/star/drawing/framework/XConfigurationController.hpp> 30 #include <com/sun/star/drawing/framework/XConfigurationChangeRequest.hpp> 31 #include <com/sun/star/drawing/framework/XConfiguration.hpp> 32 #include <com/sun/star/drawing/framework/XControllerManager.hpp> 33 #include <com/sun/star/drawing/framework/XResourceFactoryManager.hpp> 34 #include <com/sun/star/drawing/framework/XResourceId.hpp> 35 #include <com/sun/star/drawing/framework/ConfigurationChangeEvent.hpp> 36 #include <com/sun/star/lang/XInitialization.hpp> 37 #include <com/sun/star/uno/XComponentContext.hpp> 38 39 #include <cppuhelper/compbase2.hxx> 40 #include <tools/link.hxx> 41 #include <rtl/ref.hxx> 42 43 #include <boost/scoped_ptr.hpp> 44 #include <boost/shared_ptr.hpp> 45 #include <boost/noncopyable.hpp> 46 47 namespace css = ::com::sun::star; 48 49 namespace { 50 51 typedef ::cppu::WeakComponentImplHelper2 < 52 ::css::drawing::framework::XConfigurationController, 53 ::css::lang::XInitialization 54 > ConfigurationControllerInterfaceBase; 55 56 } // end of anonymous namespace. 57 58 59 namespace sd { class ViewShellBase; } 60 61 62 namespace sd { namespace framework { 63 64 class ChangeRequestQueueProcessor; 65 class ConfigurationControllerBroadcaster; 66 class ConfigurationUpdater; 67 class ConfigurationUpdaterLock; 68 69 /** The configuration controller is responsible for maintaining the current 70 configuration. 71 72 @see css::drawing::framework::XConfigurationController 73 for an extended documentation. 74 */ 75 class ConfigurationController 76 : private sd::MutexOwner, 77 private boost::noncopyable, 78 public ConfigurationControllerInterfaceBase 79 { 80 public: 81 ConfigurationController (void) throw(); 82 virtual ~ConfigurationController (void) throw(); 83 84 virtual void SAL_CALL disposing (void); 85 86 void ProcessEvent (void); 87 88 /** Normally the requested changes of the configuration are executed 89 asynchronously. However, there is at least one situation (searching 90 with the Outliner) where the surrounding code does not cope with 91 this. So, instead of calling Reschedule until the global event loop 92 executes the configuration update, this method does (almost) the 93 same without the reschedules. 94 95 Do not use this method until there is absolutely no other way. 96 */ 97 void RequestSynchronousUpdate (void); 98 99 // XConfigurationController 100 101 virtual void SAL_CALL lock (void); 102 103 virtual void SAL_CALL unlock (void); 104 105 virtual void SAL_CALL requestResourceActivation ( 106 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId, 107 css::drawing::framework::ResourceActivationMode eMode); 108 109 virtual void SAL_CALL requestResourceDeactivation ( 110 const css::uno::Reference<css::drawing::framework::XResourceId>& 111 rxResourceId); 112 113 virtual css::uno::Reference<css::drawing::framework::XResource> 114 SAL_CALL getResource ( 115 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId); 116 117 virtual void SAL_CALL update (void); 118 119 virtual css::uno::Reference< 120 css::drawing::framework::XConfiguration> 121 SAL_CALL getRequestedConfiguration (void); 122 123 virtual css::uno::Reference< 124 css::drawing::framework::XConfiguration> 125 SAL_CALL getCurrentConfiguration (void); 126 127 virtual void SAL_CALL restoreConfiguration ( 128 const css::uno::Reference<css::drawing::framework::XConfiguration>& 129 rxConfiguration); 130 131 132 // XConfigurationControllerBroadcaster 133 134 virtual void SAL_CALL addConfigurationChangeListener ( 135 const css::uno::Reference< 136 css::drawing::framework::XConfigurationChangeListener>& rxListener, 137 const ::rtl::OUString& rsEventType, 138 const css::uno::Any& rUserData); 139 140 virtual void SAL_CALL removeConfigurationChangeListener ( 141 const css::uno::Reference< 142 css::drawing::framework::XConfigurationChangeListener>& rxListener); 143 144 virtual void SAL_CALL notifyEvent ( 145 const css::drawing::framework::ConfigurationChangeEvent& rEvent); 146 147 148 // XConfigurationRequestQueue 149 150 virtual sal_Bool SAL_CALL hasPendingRequests (void); 151 152 virtual void SAL_CALL postChangeRequest ( 153 const css::uno::Reference< 154 css::drawing::framework::XConfigurationChangeRequest>& rxRequest); 155 156 157 // XResourceFactoryManager 158 159 virtual void SAL_CALL addResourceFactory( 160 const ::rtl::OUString& sResourceURL, 161 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxResourceFactory); 162 163 virtual void SAL_CALL removeResourceFactoryForURL( 164 const ::rtl::OUString& sResourceURL); 165 166 virtual void SAL_CALL removeResourceFactoryForReference( 167 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxResourceFactory); 168 169 virtual css::uno::Reference<css::drawing::framework::XResourceFactory> 170 SAL_CALL getResourceFactory ( 171 const ::rtl::OUString& sResourceURL); 172 173 174 // XInitialization 175 176 virtual void SAL_CALL initialize( 177 const css::uno::Sequence<css::uno::Any>& rArguments); 178 179 180 /** Use this class instead of calling lock() and unlock() directly in 181 order to be exception safe. 182 */ 183 class Lock 184 { 185 public: 186 Lock (const css::uno::Reference< 187 css::drawing::framework::XConfigurationController>& rxController); 188 ~Lock (void); 189 private: 190 css::uno::Reference< 191 css::drawing::framework::XConfigurationController> mxController; 192 }; 193 194 private: 195 class Implementation; 196 ::boost::scoped_ptr<Implementation> mpImplementation; 197 bool mbIsDisposed; 198 199 /** When the called object has already been disposed this method throws 200 an exception and does not return. 201 */ 202 void ThrowIfDisposed (void) const; 203 }; 204 205 } } // end of namespace sd::framework 206 207 #endif 208