bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / framework / configuration / ConfigurationControllerResourceManager.hxx
blob727365574207f1ca51c5e5e2ecf4f122fe81b46d
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 #ifndef INCLUDED_SD_SOURCE_UI_FRAMEWORK_CONFIGURATION_CONFIGURATIONCONTROLLERRESOURCEMANAGER_HXX
21 #define INCLUDED_SD_SOURCE_UI_FRAMEWORK_CONFIGURATION_CONFIGURATIONCONTROLLERRESOURCEMANAGER_HXX
23 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
24 #include <com/sun/star/drawing/framework/XResource.hpp>
25 #include <com/sun/star/drawing/framework/XResourceFactory.hpp>
26 #include <osl/mutex.hxx>
28 #include <boost/noncopyable.hpp>
29 #include <boost/shared_ptr.hpp>
30 #include <map>
31 #include <vector>
33 namespace sd { namespace framework {
35 class ConfigurationControllerBroadcaster;
36 class ResourceFactoryManager;
38 /** Manage the set of active resources. Activate and deactivate resources.
40 class ConfigurationControllerResourceManager
41 : ::boost::noncopyable
43 public:
44 /** For every active resource both the resource itself as well as its
45 creating factory are remembered, so that on deactivation, the
46 resource can be deactivated by this factory.
48 class ResourceDescriptor
50 public:
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
58 resources.
60 ConfigurationControllerResourceManager (
61 const ::boost::shared_ptr<ResourceFactoryManager>& rpResourceFactoryContainer,
62 const ::boost::shared_ptr<ConfigurationControllerBroadcaster>& rpBroadcaster);
64 ~ConfigurationControllerResourceManager();
66 /** Activate all the resources that are specified by resource ids in
67 rResources. The resource ids of activated resources are added to
68 the given configuration. Activated resources are notified to all
69 interested ConfigurationChangeListeners.
71 void ActivateResources (
72 const ::std::vector<
73 css::uno::Reference<css::drawing::framework::XResourceId> >& rResources,
74 const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
76 /** Deactivate all the resources that are specified by resource ids in
77 rResources. The resource ids of deactivated resources are removed
78 from the given configuration. Activated resources are notified to all
79 interested ConfigurationChangeListeners.
81 void DeactivateResources (
82 const ::std::vector<
83 css::uno::Reference<css::drawing::framework::XResourceId> >& rResources,
84 const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
86 /** Return the descriptor for the specified resource.
87 @return
88 When there is no active resource for the given resource id then
89 an empty descriptor is returned.
91 ResourceDescriptor GetResource (
92 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId);
94 private:
95 osl::Mutex maMutex;
97 class ResourceComparator
99 public:
100 bool operator() (
101 const css::uno::Reference<css::drawing::framework::XResourceId>& rxId1,
102 const css::uno::Reference<css::drawing::framework::XResourceId>& rxId2) const;
105 typedef ::std::map<
106 css::uno::Reference<css::drawing::framework::XResourceId>,
107 ResourceDescriptor,
108 ResourceComparator> ResourceMap;
109 ResourceMap maResourceMap;
111 ::boost::shared_ptr<ResourceFactoryManager> mpResourceFactoryContainer;
113 /** This broadcaster is used to notify the activation and deactivation
114 of resources.
116 ::boost::shared_ptr<ConfigurationControllerBroadcaster> mpBroadcaster;
118 void ActivateResource (
119 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
120 const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
122 void DeactivateResource (
123 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
124 const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
126 void AddResource (
127 const css::uno::Reference<css::drawing::framework::XResource>& rxResource,
128 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxFactory);
130 ResourceDescriptor RemoveResource (
131 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId);
134 } } // end of namespace sd::framework
136 #endif
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */