1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ResourceFactoryManager.hxx,v $
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>
43 namespace css
= ::com::sun::star
;
45 namespace sd
{ namespace framework
{
47 /** Container of resource factories of the drawing framework.
49 class ResourceFactoryManager
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.
59 The type of the resource that will be created by the factory.
61 The factory that will create resource objects of the specfied type.
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.
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.
79 Unregister the this factory for all URLs that it has been
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.
88 This URL specifies the type of the resource. It may contain arguments.
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
);
100 typedef ::std::hash_map
<
102 css::uno::Reference
<css::drawing::framework::XResourceFactory
>,
103 ::comphelper::UStringHash
,
104 ::comphelper::UStringEqual
> FactoryMap
;
105 FactoryMap maFactoryMap
;
107 typedef ::std::vector
<
110 css::uno::Reference
<css::drawing::framework::XResourceFactory
> > >
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.
119 The css::tools::URL.Main part of a URL. Arguments have to be
120 stripped off by the caller.
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