merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / framework / configuration / ResourceFactoryManager.hxx
blob1ff2bcada47205ca2a8a3cd7a86100ef94cc1ec2
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: ResourceFactoryManager.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_FACTORY_MANAGER_HXX
33 #define SD_FRAMEWORK_RESOURCE_FACTORY_MANAGER_HXX
35 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
36 #include <com/sun/star/drawing/framework/XModuleController.hpp>
37 #include <com/sun/star/drawing/framework/XResourceFactoryManager.hpp>
38 #include <com/sun/star/util/XURLTransformer.hpp>
39 #include <osl/mutex.hxx>
40 #include <comphelper/stl_types.hxx>
41 #include <hash_map>
43 namespace css = ::com::sun::star;
45 namespace sd { namespace framework {
47 /** Container of resource factories of the drawing framework.
49 class ResourceFactoryManager
51 public:
52 ResourceFactoryManager (
53 const css::uno::Reference<css::drawing::framework::XControllerManager>& rxManager);
55 ~ResourceFactoryManager (void);
57 /** Register a resource factory for one type of resource.
58 @param rsURL
59 The type of the resource that will be created by the factory.
60 @param rxFactory
61 The factory that will create resource objects of the specfied type.
63 void AddFactory (
64 const ::rtl::OUString& rsURL,
65 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxFactory)
66 throw (css::uno::RuntimeException);
68 /** Unregister the specifed factory.
69 @param rsURL
70 Unregister only the factory for this URL. When the same factory
71 is registered for other URLs then these remain registered.
73 void RemoveFactoryForURL(
74 const ::rtl::OUString& rsURL)
75 throw (css::uno::RuntimeException);
77 /** Unregister the specified factory.
78 @param rxFactory
79 Unregister the this factory for all URLs that it has been
80 registered for.
82 void RemoveFactoryForReference(
83 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxFactory)
84 throw (css::uno::RuntimeException);
86 /** Return a factory that can create resources specified by the given URL.
87 @param rsCompleteURL
88 This URL specifies the type of the resource. It may contain arguments.
89 @return
90 When a factory for the specified URL has been registered by a
91 previous call to AddFactory() then a reference to that factory
92 is returned. Otherwise an empty reference is returned.
94 css::uno::Reference<css::drawing::framework::XResourceFactory> GetFactory (
95 const ::rtl::OUString& rsURL)
96 throw (css::uno::RuntimeException);
98 private:
99 ::osl::Mutex maMutex;
100 typedef ::std::hash_map<
101 ::rtl::OUString,
102 css::uno::Reference<css::drawing::framework::XResourceFactory>,
103 ::comphelper::UStringHash,
104 ::comphelper::UStringEqual> FactoryMap;
105 FactoryMap maFactoryMap;
107 typedef ::std::vector<
108 ::std::pair<
109 rtl::OUString,
110 css::uno::Reference<css::drawing::framework::XResourceFactory> > >
111 FactoryPatternList;
112 FactoryPatternList maFactoryPatternList;
114 css::uno::Reference<css::drawing::framework::XControllerManager> mxControllerManager;
115 css::uno::Reference<css::util::XURLTransformer> mxURLTransformer;
117 /** Look up the factory for the given URL.
118 @param rsURLBase
119 The css::tools::URL.Main part of a URL. Arguments have to be
120 stripped off by the caller.
121 @return
122 When the factory has not yet been added then return NULL.
124 css::uno::Reference<css::drawing::framework::XResourceFactory> FindFactory (
125 const ::rtl::OUString& rsURLBase)
126 throw (css::uno::RuntimeException);
130 } } // end of namespace sd::framework
132 #endif