1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <osl/mutex.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
30 namespace com::sun::star::drawing::framework
{ class XConfiguration
; }
31 namespace com::sun::star::drawing::framework
{ class XResourceFactory
; }
32 namespace com::sun::star::drawing::framework
{ class XResource
; }
33 namespace com::sun::star::drawing::framework
{ class XResourceId
; }
35 namespace sd::framework
{
37 class ConfigurationControllerBroadcaster
;
38 class ResourceFactoryManager
;
40 /** Manage the set of active resources. Activate and deactivate resources.
42 class ConfigurationControllerResourceManager
45 /** For every active resource both the resource itself as well as its
46 creating factory are remembered, so that on deactivation, the
47 resource can be deactivated by this factory.
49 struct ResourceDescriptor
51 css::uno::Reference
<css::drawing::framework::XResource
> mxResource
;
52 css::uno::Reference
<css::drawing::framework::XResourceFactory
> mxResourceFactory
;
55 /** A new ResourceManager object is created with the resource factory
56 container for creating resources and the event broadcaster for
57 notifying ConfigurationChangeListeners of activated or deactivated
60 ConfigurationControllerResourceManager (
61 std::shared_ptr
<ResourceFactoryManager
> pResourceFactoryContainer
,
62 std::shared_ptr
<ConfigurationControllerBroadcaster
> pBroadcaster
);
64 ~ConfigurationControllerResourceManager();
66 /// Forbid copy construction and copy assignment
67 ConfigurationControllerResourceManager(const ConfigurationControllerResourceManager
&) = delete;
68 ConfigurationControllerResourceManager
& operator=(const ConfigurationControllerResourceManager
&) = delete;
70 /** Activate all the resources that are specified by resource ids in
71 rResources. The resource ids of activated resources are added to
72 the given configuration. Activated resources are notified to all
73 interested ConfigurationChangeListeners.
75 void ActivateResources (
77 css::uno::Reference
<css::drawing::framework::XResourceId
> >& rResources
,
78 const css::uno::Reference
<css::drawing::framework::XConfiguration
>& rxConfiguration
);
80 /** Deactivate all the resources that are specified by resource ids in
81 rResources. The resource ids of deactivated resources are removed
82 from the given configuration. Activated resources are notified to all
83 interested ConfigurationChangeListeners.
85 void DeactivateResources (
87 css::uno::Reference
<css::drawing::framework::XResourceId
> >& rResources
,
88 const css::uno::Reference
<css::drawing::framework::XConfiguration
>& rxConfiguration
);
90 /** Return the descriptor for the specified resource.
92 When there is no active resource for the given resource id then
93 an empty descriptor is returned.
95 ResourceDescriptor
GetResource (
96 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxResourceId
);
101 class ResourceComparator
105 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxId1
,
106 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxId2
) const;
110 css::uno::Reference
<css::drawing::framework::XResourceId
>,
112 ResourceComparator
> ResourceMap
;
113 ResourceMap maResourceMap
;
115 std::shared_ptr
<ResourceFactoryManager
> mpResourceFactoryContainer
;
117 /** This broadcaster is used to notify the activation and deactivation
120 std::shared_ptr
<ConfigurationControllerBroadcaster
> mpBroadcaster
;
122 void ActivateResource (
123 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxResourceId
,
124 const css::uno::Reference
<css::drawing::framework::XConfiguration
>& rxConfiguration
);
126 void DeactivateResource (
127 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxResourceId
,
128 const css::uno::Reference
<css::drawing::framework::XConfiguration
>& rxConfiguration
);
131 const css::uno::Reference
<css::drawing::framework::XResource
>& rxResource
,
132 const css::uno::Reference
<css::drawing::framework::XResourceFactory
>& rxFactory
);
134 ResourceDescriptor
RemoveResource (
135 const css::uno::Reference
<css::drawing::framework::XResourceId
>& rxResourceId
);
138 } // end of namespace sd::framework
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */