1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #pragma once 21 22 #include <MutexOwner.hxx> 23 24 #include <com/sun/star/drawing/framework/XConfigurationController.hpp> 25 #include <com/sun/star/lang/XInitialization.hpp> 26 27 #include <cppuhelper/compbase.hxx> 28 29 #include <memory> 30 31 32 namespace com::sun::star::drawing::framework { class XConfiguration; } 33 namespace com::sun::star::drawing::framework { class XConfigurationChangeRequest; } 34 namespace com::sun::star::drawing::framework { class XResourceId; } 35 namespace com::sun::star::drawing::framework { struct ConfigurationChangeEvent; } 36 37 namespace sd::framework { 38 39 typedef ::cppu::WeakComponentImplHelper < 40 css::drawing::framework::XConfigurationController, 41 css::lang::XInitialization 42 > ConfigurationControllerInterfaceBase; 43 44 /** The configuration controller is responsible for maintaining the current 45 configuration. 46 47 @see css::drawing::framework::XConfigurationController 48 for an extended documentation. 49 */ 50 class ConfigurationController 51 : private sd::MutexOwner, 52 public ConfigurationControllerInterfaceBase 53 { 54 public: 55 ConfigurationController() noexcept; 56 virtual ~ConfigurationController() noexcept override; 57 ConfigurationController(const ConfigurationController&) = delete; 58 ConfigurationController& operator=(const ConfigurationController&) = delete; 59 60 virtual void SAL_CALL disposing() override; 61 62 void ProcessEvent(); 63 64 /** Normally the requested changes of the configuration are executed 65 asynchronously. However, there is at least one situation (searching 66 with the Outliner) where the surrounding code does not cope with 67 this. So, instead of calling Reschedule until the global event loop 68 executes the configuration update, this method does (almost) the 69 same without the reschedules. 70 71 Do not use this method until there is absolutely no other way. 72 */ 73 void RequestSynchronousUpdate(); 74 75 // XConfigurationController 76 77 virtual void SAL_CALL lock() override; 78 79 virtual void SAL_CALL unlock() override; 80 81 virtual void SAL_CALL requestResourceActivation ( 82 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId, 83 css::drawing::framework::ResourceActivationMode eMode) override; 84 85 virtual void SAL_CALL requestResourceDeactivation ( 86 const css::uno::Reference<css::drawing::framework::XResourceId>& 87 rxResourceId) override; 88 89 virtual css::uno::Reference<css::drawing::framework::XResource> 90 SAL_CALL getResource ( 91 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId) override; 92 93 virtual void SAL_CALL update() override; 94 95 virtual css::uno::Reference< 96 css::drawing::framework::XConfiguration> 97 SAL_CALL getRequestedConfiguration() override; 98 99 virtual css::uno::Reference< 100 css::drawing::framework::XConfiguration> 101 SAL_CALL getCurrentConfiguration() override; 102 103 virtual void SAL_CALL restoreConfiguration ( 104 const css::uno::Reference<css::drawing::framework::XConfiguration>& 105 rxConfiguration) override; 106 107 // XConfigurationControllerBroadcaster 108 109 virtual void SAL_CALL addConfigurationChangeListener ( 110 const css::uno::Reference< 111 css::drawing::framework::XConfigurationChangeListener>& rxListener, 112 const OUString& rsEventType, 113 const css::uno::Any& rUserData) override; 114 115 virtual void SAL_CALL removeConfigurationChangeListener ( 116 const css::uno::Reference< 117 css::drawing::framework::XConfigurationChangeListener>& rxListener) override; 118 119 virtual void SAL_CALL notifyEvent ( 120 const css::drawing::framework::ConfigurationChangeEvent& rEvent) override; 121 122 // XConfigurationRequestQueue 123 124 virtual sal_Bool SAL_CALL hasPendingRequests() override; 125 126 virtual void SAL_CALL postChangeRequest ( 127 const css::uno::Reference< 128 css::drawing::framework::XConfigurationChangeRequest>& rxRequest) override; 129 130 // XResourceFactoryManager 131 132 virtual void SAL_CALL addResourceFactory( 133 const OUString& sResourceURL, 134 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxResourceFactory) override; 135 136 virtual void SAL_CALL removeResourceFactoryForURL( 137 const OUString& sResourceURL) override; 138 139 virtual void SAL_CALL removeResourceFactoryForReference( 140 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxResourceFactory) override; 141 142 virtual css::uno::Reference<css::drawing::framework::XResourceFactory> 143 SAL_CALL getResourceFactory ( 144 const OUString& sResourceURL) override; 145 146 // XInitialization 147 148 virtual void SAL_CALL initialize( 149 const css::uno::Sequence<css::uno::Any>& rArguments) override; 150 151 /** Use this class instead of calling lock() and unlock() directly in 152 order to be exception safe. 153 */ 154 class Lock 155 { 156 public: 157 Lock (const css::uno::Reference< 158 css::drawing::framework::XConfigurationController>& rxController); 159 ~Lock(); 160 private: 161 css::uno::Reference< 162 css::drawing::framework::XConfigurationController> mxController; 163 }; 164 165 private: 166 class Implementation; 167 std::unique_ptr<Implementation> mpImplementation; 168 bool mbIsDisposed; 169 170 /** When the called object has already been disposed this method throws 171 an exception and does not return. 172 173 @throws css::lang::DisposedException 174 @throws css::uno::RuntimeException 175 */ 176 void ThrowIfDisposed () const; 177 }; 178 179 } // end of namespace sd::framework 180 181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 182