23#include <com/sun/star/lang/IllegalArgumentException.hpp>
24#include <com/sun/star/lang/XComponent.hpp>
25#include <com/sun/star/util/URLTransformer.hpp>
26#include <com/sun/star/drawing/framework/XControllerManager.hpp>
42 : mxControllerManager(rxManager)
45 Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext());
53 Reference<lang::XComponent> xComponent (rXInterfaceResource.second, UNO_QUERY);
54 rXInterfaceResource.second =
nullptr;
56 xComponent->dispose();
61 xComponent->dispose();
65 const OUString& rsURL,
66 const Reference<XResourceFactory>& rxFactory)
68 if ( ! rxFactory.is())
69 throw lang::IllegalArgumentException();
71 throw lang::IllegalArgumentException();
73 std::scoped_lock aGuard (
maMutex);
75 if (rsURL.indexOf(
'*') >= 0 || rsURL.indexOf(
'?') >= 0)
80#if defined VERBOSE && VERBOSE>=1
81 SAL_INFO(
"sd",
"ResourceFactoryManager::AddFactory pattern " << rsURL << std::hex << rxFactory.get());
88#if defined VERBOSE && VERBOSE>=1
89 SAL_INFO(
"sd",
"ResourceFactoryManager::AddFactory fixed " << rsURL <<
" 0x" << std::hex << rxFactory.get());
95 const OUString& rsURL)
98 throw lang::IllegalArgumentException();
100 std::scoped_lock aGuard (
maMutex);
102 FactoryMap::iterator iFactory (
maFactoryMap.find(rsURL));
111 [&rsURL](
const FactoryPatternList::value_type& rPattern) { return rPattern.first == rsURL; });
121 const Reference<XResourceFactory>& rxFactory)
123 std::scoped_lock aGuard (
maMutex);
126 ::std::vector<OUString> aKeys;
128 if (rFactory.second == rxFactory)
129 aKeys.push_back(rFactory.first);
132 for (
const auto& rKey : aKeys)
141 [&] (FactoryPatternList::value_type
const& it) { return it.second == rxFactory; }),
146 const OUString& rsCompleteURL)
148 OUString sURLBase (rsCompleteURL);
152 aURL.Complete = rsCompleteURL;
154 sURLBase =
aURL.Main;
161 Reference<XModuleController> xModuleController(
mxControllerManager->getModuleController());
162 if (xModuleController.is())
167 xModuleController->requestResource(sURLBase);
178 std::scoped_lock aGuard (
maMutex);
179 FactoryMap::const_iterator iFactory (
maFactoryMap.find(rsURLBase));
181 return iFactory->second;
186 [&rsURLBase](
const FactoryPatternList::value_type& rPattern) {
187 WildCard aWildCard (rPattern.first);
188 return aWildCard.Matches(rsURLBase);
191 return iPattern->second;
rtl::Reference<::sd::DrawController > mxControllerManager
void RemoveFactoryForReference(const css::uno::Reference< css::drawing::framework::XResourceFactory > &rxFactory)
Unregister the specified factory.
css::uno::Reference< css::drawing::framework::XResourceFactory > FindFactory(const OUString &rsURLBase)
Look up the factory for the given URL.
css::uno::Reference< css::util::XURLTransformer > mxURLTransformer
~ResourceFactoryManager()
void AddFactory(const OUString &rsURL, const css::uno::Reference< css::drawing::framework::XResourceFactory > &rxFactory)
Register a resource factory for one type of resource.
ResourceFactoryManager(const rtl::Reference<::sd::DrawController > &rxManager)
css::uno::Reference< css::drawing::framework::XResourceFactory > GetFactory(const OUString &rsURL)
Return a factory that can create resources specified by the given URL.
FactoryPatternList maFactoryPatternList
void RemoveFactoryForURL(const OUString &rsURL)
Unregister the specified factory.
Reference< XSingleServiceFactory > xFactory
#define SAL_INFO(area, stream)