merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / framework / configuration / ConfigurationControllerResourceManager.hxx
blob4d99d6f30fb7c8865e9844aeb5f8a6eed92e52e3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ConfigurationControllerResourceManager.hxx,v $
11 * $Revision: 1.3 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef SD_FRAMEWORK_RESOURCE_MANAGER_HXX
33 #define SD_FRAMEWORK_RESOURCE_MANAGER_HXX
35 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
36 #include <com/sun/star/drawing/framework/XResource.hpp>
37 #include <com/sun/star/drawing/framework/XResourceFactory.hpp>
38 #include <boost/noncopyable.hpp>
39 #include <boost/shared_ptr.hpp>
40 #include <map>
41 #include <vector>
43 namespace css = ::com::sun::star;
45 namespace sd { namespace framework {
47 class ConfigurationControllerBroadcaster;
48 class ResourceFactoryManager;
50 /** Manage the set of active resources. Activate and deactivate resources.
52 class ConfigurationControllerResourceManager
53 : ::boost::noncopyable
55 public:
56 /** For every active resource both the resource itself as well as its
57 creating factory are remembered, so that on deactivation, the
58 resource can be deactivated by this factory.
60 class ResourceDescriptor
62 public:
63 css::uno::Reference<css::drawing::framework::XResource> mxResource;
64 css::uno::Reference<css::drawing::framework::XResourceFactory> mxResourceFactory;
67 /** A new ResourceManager object is created with the resource factory
68 container for creating resources and the event broadcaster for
69 notifying ConfigurationChangeListeners of activated or deactivated
70 resources.
72 ConfigurationControllerResourceManager (
73 const ::boost::shared_ptr<ResourceFactoryManager>& rpResourceFactoryContainer,
74 const ::boost::shared_ptr<ConfigurationControllerBroadcaster>& rpBroadcaster);
76 ~ConfigurationControllerResourceManager (void);
78 /** Activate all the resources that are specified by resource ids in
79 rResources. The resource ids of activated resources are added to
80 the given configuration. Activated resources are notified to all
81 interested ConfigurationChangeListeners.
83 void ActivateResources (
84 const ::std::vector<
85 css::uno::Reference<css::drawing::framework::XResourceId> >& rResources,
86 const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
88 /** Deactivate all the resources that are specified by resource ids in
89 rResources. The resource ids of deactivated resources are removed
90 from the given configuration. Activated resources are notified to all
91 interested ConfigurationChangeListeners.
93 void DeactivateResources (
94 const ::std::vector<
95 css::uno::Reference<css::drawing::framework::XResourceId> >& rResources,
96 const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
98 /** Return the descriptor for the specified resource.
99 @return
100 When there is no active resource for the given resource id then
101 an empty descriptor is returned.
103 ResourceDescriptor GetResource (
104 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId);
106 private:
107 osl::Mutex maMutex;
109 class ResourceComparator
111 public:
112 bool operator() (
113 const css::uno::Reference<css::drawing::framework::XResourceId>& rxId1,
114 const css::uno::Reference<css::drawing::framework::XResourceId>& rxId2) const;
117 typedef ::std::map<
118 css::uno::Reference<css::drawing::framework::XResourceId>,
119 ResourceDescriptor,
120 ResourceComparator> ResourceMap;
121 ResourceMap maResourceMap;
123 ::boost::shared_ptr<ResourceFactoryManager> mpResourceFactoryContainer;
125 /** This broadcaster is used to notify the activation and deactivation
126 of resources.
128 ::boost::shared_ptr<ConfigurationControllerBroadcaster> mpBroadcaster;
130 void ActivateResource (
131 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
132 const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
134 void DeactivateResource (
135 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId,
136 const css::uno::Reference<css::drawing::framework::XConfiguration>& rxConfiguration);
138 void AddResource (
139 const css::uno::Reference<css::drawing::framework::XResource>& rxResource,
140 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxFactory);
142 ResourceDescriptor RemoveResource (
143 const css::uno::Reference<css::drawing::framework::XResourceId>& rxResourceId);
147 } } // end of namespace sd::framework
149 #endif