21#include <com/sun/star/lang/IllegalArgumentException.hpp>
22#include <com/sun/star/ucb/DuplicateProviderException.hpp>
23#include <com/sun/star/ucb/XContentProviderManager.hpp>
24#include <com/sun/star/ucb/XParameterizedContentProvider.hpp>
25#include <com/sun/star/ucb/ContentProviderProxyFactory.hpp>
26#include <com/sun/star/ucb/XContentProviderFactory.hpp>
27#include <com/sun/star/uno/XComponentContext.hpp>
28#include <com/sun/star/uno/RuntimeException.hpp>
30#include <osl/diagnose.h>
38 uno::Reference< ucb::XContentProviderManager >
const & rManager,
39 uno::Reference< uno::XComponentContext >
const & rxContext,
40 OUString
const & rName,
41 OUString
const & rArguments,
42 OUString
const & rTemplate)
44 OSL_ENSURE(rxContext.is(),
45 "ucb::registerAtUcb(): No service factory");
47 bool bNoProxy = rArguments.startsWith(
"{noproxy}");
49 aProviderArguments(bNoProxy ?
51 copy(RTL_CONSTASCII_LENGTH(
"{noproxy}")) :
54 uno::Reference< ucb::XContentProvider > xProvider;
61 uno::Reference< ucb::XContentProviderFactory > xProxyFactory;
64 xProxyFactory = ucb::ContentProviderProxyFactory::create( rxContext );
66 catch (uno::Exception
const &) {}
67 OSL_ENSURE(xProxyFactory.is(),
"No ContentProviderProxyFactory");
68 if (xProxyFactory.is())
69 xProvider = xProxyFactory->createContentProvider(rName);
77 rxContext->getServiceManager()->createInstanceWithContext(rName, rxContext),
80 catch (uno::RuntimeException
const &) {
throw; }
81 catch (uno::Exception
const &) {}
84 uno::Reference< ucb::XParameterizedContentProvider >
85 xParameterized(xProvider, uno::UNO_QUERY);
86 if (xParameterized.is())
88 uno::Reference< ucb::XContentProvider > xInstance;
91 xInstance = xParameterized->registerInstance(rTemplate,
97 catch (lang::IllegalArgumentException
const &) {}
100 xProvider = xInstance;
103 bool bSuccess =
false;
104 if (rManager.is() && (rName.isEmpty() || xProvider.is()))
108 rManager->registerContentProvider(xProvider, rTemplate,
true);
111 catch (ucb::DuplicateProviderException
const &)
113 if (xParameterized.is())
116 xParameterized->deregisterInstance(rTemplate,
119 catch (lang::IllegalArgumentException
const &) {}
123 if (xParameterized.is())
126 xParameterized->deregisterInstance(rTemplate,
129 catch (lang::IllegalArgumentException
const &) {}
130 catch (uno::RuntimeException
const &) {}
void copy(const fs::path &src, const fs::path &dest)
bool registerAtUcb(uno::Reference< ucb::XContentProviderManager > const &rManager, uno::Reference< uno::XComponentContext > const &rxContext, OUString const &rName, OUString const &rArguments, OUString const &rTemplate)