cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / framework / ModuleController.hxx
blobea1de664cc9f83cc2866957ef31aa38d6b0bd16c
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 <com/sun/star/drawing/framework/XModuleController.hpp>
23 #include <com/sun/star/lang/XInitialization.hpp>
24 #include <comphelper/compbase.hxx>
25 #include <cppuhelper/weakref.hxx>
26 #include <rtl/ref.hxx>
28 #include <unordered_map>
30 namespace com::sun::star::frame { class XController; }
31 namespace com::sun::star::uno { class XComponentContext; }
32 namespace sd { class DrawController; }
34 namespace sd::framework {
36 typedef comphelper::WeakComponentImplHelper <
37 css::drawing::framework::XModuleController
38 > ModuleControllerInterfaceBase;
40 /** The ModuleController has two tasks:
42 1. It reads the
43 org.openoffice.Office.Impress/MultiPaneGUI/Framework/ResourceFactories
44 configuration data that maps from resource URLs to service names of
45 factories that can create resources for the URLs. When the
46 configuration controller wants to create a resource for which it does
47 not have a factory, it asks the ModuleController to provide one. The
48 ModuleController looks up the service name registered for the URL of the
49 resource and instantiates this service. The service is expected to
50 register on its creation a factory for the resource in question.
52 2. The ModuleController instantiates PresentationFactoryProvider.
53 This service
54 can then register as listeners at the ConfigurationController or do
55 whatever they like.
57 class ModuleController final
58 : public ModuleControllerInterfaceBase
60 public:
61 /// @throws std::exception
62 ModuleController(const rtl::Reference<::sd::DrawController>& rxController);
64 virtual void disposing(std::unique_lock<std::mutex>&) override;
66 // XModuleController
68 virtual void SAL_CALL requestResource(const OUString& rsResourceURL) override;
70 private:
71 rtl::Reference<::sd::DrawController> mxController;
73 std::unordered_map<OUString, OUString> maResourceToFactoryMap;
74 std::unordered_map<OUString, css::uno::WeakReference<css::uno::XInterface>> maLoadedFactories;
76 ModuleController (const ModuleController&) = delete;
77 virtual ~ModuleController() noexcept override;
79 /** Called for every entry in the ResourceFactories configuration entry.
81 void ProcessFactory (const OUString& ServiceName, ::std::vector<OUString> aURLs);
83 /** Instantiate startup services. This method is called once when a new
84 ModuleController object is created.
86 void InstantiateStartupServices();
89 } // end of namespace sd::framework
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */