cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / framework / ConfigurationController.hxx
blob1975b5fa2257968c865ba12f4bd80ff4b1428341
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <sddllapi.h>
23 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
24 #include <com/sun/star/lang/XInitialization.hpp>
26 #include <cppuhelper/basemutex.hxx>
27 #include <cppuhelper/compbase.hxx>
28 #include <rtl/ref.hxx>
30 #include <memory>
33 namespace com::sun::star::drawing::framework { class XConfiguration; }
34 namespace com::sun::star::drawing::framework { class XConfigurationChangeRequest; }
35 namespace com::sun::star::drawing::framework { class XResourceId; }
36 namespace com::sun::star::drawing::framework { struct ConfigurationChangeEvent; }
37 namespace com::sun::star::frame { class XController; }
38 namespace sd { class DrawController; }
40 namespace sd::framework {
42 typedef ::cppu::WeakComponentImplHelper <
43 css::drawing::framework::XConfigurationController
44 > ConfigurationControllerInterfaceBase;
46 /** The configuration controller is responsible for maintaining the current
47 configuration.
49 @see css::drawing::framework::XConfigurationController
50 for an extended documentation.
52 class SD_DLLPUBLIC ConfigurationController final
53 : private cppu::BaseMutex,
54 public ConfigurationControllerInterfaceBase
56 public:
57 ConfigurationController(const rtl::Reference<::sd::DrawController>& rxController);
58 virtual ~ConfigurationController() noexcept override;
59 ConfigurationController(const ConfigurationController&) = delete;
60 ConfigurationController& operator=(const ConfigurationController&) = delete;
62 virtual void SAL_CALL disposing() override;
64 void ProcessEvent();
66 /** Normally the requested changes of the configuration are executed
67 asynchronously. However, there is at least one situation (searching
68 with the Outliner) where the surrounding code does not cope with
69 this. So, instead of calling Reschedule until the global event loop
70 executes the configuration update, this method does (almost) the
71 same without the reschedules.
73 Do not use this method until there is absolutely no other way.
75 void RequestSynchronousUpdate();
77 // XConfigurationController
79 virtual void SAL_CALL lock() override;
81 virtual void SAL_CALL unlock() override;
83 virtual void SAL_CALL requestResourceActivation (
84 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
85 css::drawing::framework::ResourceActivationMode eMode) override;
87 virtual void SAL_CALL requestResourceDeactivation (
88 const css::uno::Reference<css::drawing::framework::XResourceId>&
89 rxResourceId) override;
91 virtual css::uno::Reference<css::drawing::framework::XResource>
92 SAL_CALL getResource (
93 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId) override;
95 virtual void SAL_CALL update() override;
97 virtual css::uno::Reference<
98 css::drawing::framework::XConfiguration>
99 SAL_CALL getRequestedConfiguration() override;
101 virtual css::uno::Reference<
102 css::drawing::framework::XConfiguration>
103 SAL_CALL getCurrentConfiguration() override;
105 virtual void SAL_CALL restoreConfiguration (
106 const css::uno::Reference<css::drawing::framework::XConfiguration>&
107 rxConfiguration) override;
109 // XConfigurationControllerBroadcaster
111 virtual void SAL_CALL addConfigurationChangeListener (
112 const css::uno::Reference<
113 css::drawing::framework::XConfigurationChangeListener>& rxListener,
114 const OUString& rsEventType,
115 const css::uno::Any& rUserData) override;
117 virtual void SAL_CALL removeConfigurationChangeListener (
118 const css::uno::Reference<
119 css::drawing::framework::XConfigurationChangeListener>& rxListener) override;
121 virtual void SAL_CALL notifyEvent (
122 const css::drawing::framework::ConfigurationChangeEvent& rEvent) override;
124 // XConfigurationRequestQueue
126 virtual sal_Bool SAL_CALL hasPendingRequests() override;
128 virtual void SAL_CALL postChangeRequest (
129 const css::uno::Reference<
130 css::drawing::framework::XConfigurationChangeRequest>& rxRequest) override;
132 // XResourceFactoryManager
134 virtual void SAL_CALL addResourceFactory(
135 const OUString& sResourceURL,
136 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxResourceFactory) override;
138 virtual void SAL_CALL removeResourceFactoryForURL(
139 const OUString& sResourceURL) override;
141 virtual void SAL_CALL removeResourceFactoryForReference(
142 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxResourceFactory) override;
144 virtual css::uno::Reference<css::drawing::framework::XResourceFactory>
145 SAL_CALL getResourceFactory (
146 const OUString& sResourceURL) override;
148 /** Use this class instead of calling lock() and unlock() directly in
149 order to be exception safe.
151 class Lock
153 public:
154 Lock (const css::uno::Reference<
155 css::drawing::framework::XConfigurationController>& rxController);
156 ~Lock();
157 private:
158 css::uno::Reference<
159 css::drawing::framework::XConfigurationController> mxController;
162 private:
163 class Implementation;
164 std::unique_ptr<Implementation> mpImplementation;
165 bool mbIsDisposed;
167 /** When the called object has already been disposed this method throws
168 an exception and does not return.
170 @throws css::lang::DisposedException
171 @throws css::uno::RuntimeException
173 void ThrowIfDisposed () const;
176 } // end of namespace sd::framework
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */