bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / framework / configuration / ConfigurationControllerResourceManager.hxx
blobf9945892f8726efd35e9b3ab9927eacd80b7b17e
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 SD_FRAMEWORK_RESOURCE_MANAGER_HXX
21 #define SD_FRAMEWORK_RESOURCE_MANAGER_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 <boost/noncopyable.hpp>
27 #include <boost/shared_ptr.hpp>
28 #include <map>
29 #include <vector>
31 namespace sd { namespace framework {
33 class ConfigurationControllerBroadcaster;
34 class ResourceFactoryManager;
36 /** Manage the set of active resources. Activate and deactivate resources.
38 class ConfigurationControllerResourceManager
39 : ::boost::noncopyable
41 public:
42 /** For every active resource both the resource itself as well as its
43 creating factory are remembered, so that on deactivation, the
44 resource can be deactivated by this factory.
46 class ResourceDescriptor
48 public:
49 css::uno::Reference<css::drawing::framework::XResource> mxResource;
50 css::uno::Reference<css::drawing::framework::XResourceFactory> mxResourceFactory;
53 /** A new ResourceManager object is created with the resource factory
54 container for creating resources and the event broadcaster for
55 notifying ConfigurationChangeListeners of activated or deactivated
56 resources.
58 ConfigurationControllerResourceManager (
59 const ::boost::shared_ptr<ResourceFactoryManager>& rpResourceFactoryContainer,
60 const ::boost::shared_ptr<ConfigurationControllerBroadcaster>& rpBroadcaster);
62 ~ConfigurationControllerResourceManager (void);
64 /** Activate all the resources that are specified by resource ids in
65 rResources. The resource ids of activated resources are added to
66 the given configuration. Activated resources are notified to all
67 interested ConfigurationChangeListeners.
69 void ActivateResources (
70 const ::std::vector<
71 css::uno::Reference<css::drawing::framework::XResourceId> >& rResources,
72 const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
74 /** Deactivate all the resources that are specified by resource ids in
75 rResources. The resource ids of deactivated resources are removed
76 from the given configuration. Activated resources are notified to all
77 interested ConfigurationChangeListeners.
79 void DeactivateResources (
80 const ::std::vector<
81 css::uno::Reference<css::drawing::framework::XResourceId> >& rResources,
82 const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
84 /** Return the descriptor for the specified resource.
85 @return
86 When there is no active resource for the given resource id then
87 an empty descriptor is returned.
89 ResourceDescriptor GetResource (
90 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId);
92 private:
93 osl::Mutex maMutex;
95 class ResourceComparator
97 public:
98 bool operator() (
99 const css::uno::Reference<css::drawing::framework::XResourceId>& rxId1,
100 const css::uno::Reference<css::drawing::framework::XResourceId>& rxId2) const;
103 typedef ::std::map<
104 css::uno::Reference<css::drawing::framework::XResourceId>,
105 ResourceDescriptor,
106 ResourceComparator> ResourceMap;
107 ResourceMap maResourceMap;
109 ::boost::shared_ptr<ResourceFactoryManager> mpResourceFactoryContainer;
111 /** This broadcaster is used to notify the activation and deactivation
112 of resources.
114 ::boost::shared_ptr<ConfigurationControllerBroadcaster> mpBroadcaster;
116 void ActivateResource (
117 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
118 const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
120 void DeactivateResource (
121 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
122 const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
124 void AddResource (
125 const css::uno::Reference<css::drawing::framework::XResource>& rxResource,
126 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxFactory);
128 ResourceDescriptor RemoveResource (
129 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId);
133 } } // end of namespace sd::framework
135 #endif
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */