bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / framework / configuration / ResourceFactoryManager.hxx
blobdcb24835f1fcf9a0a6a3830ec9604a5aba8f14c2
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_RESOURCEFACTORYMANAGER_HXX
21 #define INCLUDED_SD_SOURCE_UI_FRAMEWORK_CONFIGURATION_RESOURCEFACTORYMANAGER_HXX
23 #include <sal/config.h>
25 #include <unordered_map>
26 #include <utility>
27 #include <vector>
29 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
30 #include <com/sun/star/drawing/framework/XModuleController.hpp>
31 #include <com/sun/star/drawing/framework/XResourceFactoryManager.hpp>
32 #include <com/sun/star/util/XURLTransformer.hpp>
33 #include <osl/mutex.hxx>
35 namespace sd { namespace framework {
37 /** Container of resource factories of the drawing framework.
39 class ResourceFactoryManager
41 public:
42 ResourceFactoryManager (
43 const css::uno::Reference<css::drawing::framework::XControllerManager>& rxManager);
45 ~ResourceFactoryManager();
47 /** Register a resource factory for one type of resource.
48 @param rsURL
49 The type of the resource that will be created by the factory.
50 @param rxFactory
51 The factory that will create resource objects of the specified type.
53 void AddFactory (
54 const OUString& rsURL,
55 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxFactory)
56 throw (css::uno::RuntimeException);
58 /** Unregister the specifed factory.
59 @param rsURL
60 Unregister only the factory for this URL. When the same factory
61 is registered for other URLs then these remain registered.
63 void RemoveFactoryForURL(
64 const OUString& rsURL)
65 throw (css::uno::RuntimeException);
67 /** Unregister the specified factory.
68 @param rxFactory
69 Unregister the this factory for all URLs that it has been
70 registered for.
72 void RemoveFactoryForReference(
73 const css::uno::Reference<css::drawing::framework::XResourceFactory>& rxFactory)
74 throw (css::uno::RuntimeException);
76 /** Return a factory that can create resources specified by the given URL.
77 @param rsCompleteURL
78 This URL specifies the type of the resource. It may contain arguments.
79 @return
80 When a factory for the specified URL has been registered by a
81 previous call to AddFactory() then a reference to that factory
82 is returned. Otherwise an empty reference is returned.
84 css::uno::Reference<css::drawing::framework::XResourceFactory> GetFactory (
85 const OUString& rsURL)
86 throw (css::uno::RuntimeException);
88 private:
89 ::osl::Mutex maMutex;
90 typedef std::unordered_map<
91 OUString,
92 css::uno::Reference<css::drawing::framework::XResourceFactory>,
93 OUStringHash> FactoryMap;
94 FactoryMap maFactoryMap;
96 typedef ::std::vector<
97 ::std::pair<
98 OUString,
99 css::uno::Reference<css::drawing::framework::XResourceFactory> > >
100 FactoryPatternList;
101 FactoryPatternList maFactoryPatternList;
103 css::uno::Reference<css::drawing::framework::XControllerManager> mxControllerManager;
104 css::uno::Reference<css::util::XURLTransformer> mxURLTransformer;
106 /** Look up the factory for the given URL.
107 @param rsURLBase
108 The css::tools::URL.Main part of a URL. Arguments have to be
109 stripped off by the caller.
110 @return
111 When the factory has not yet been added then return NULL.
113 css::uno::Reference<css::drawing::framework::XResourceFactory> FindFactory (
114 const OUString& rsURLBase)
115 throw (css::uno::RuntimeException);
118 } } // end of namespace sd::framework
120 #endif
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */