25#include <com/sun/star/uno/XComponentContext.hpp>
26#include <com/sun/star/lang/DisposedException.hpp>
27#include <com/sun/star/lang/XServiceInfo.hpp>
28#include <com/sun/star/util/theMacroExpander.hpp>
29#include <com/sun/star/ucb/IllegalIdentifierException.hpp>
30#include <com/sun/star/ucb/XContentProvider.hpp>
40 lang::XServiceInfo, ucb::XContentProvider > t_impl_helper;
43class ExpandContentProviderImpl :
public t_impl_helper
46 uno::Reference< util::XMacroExpander > m_xMacroExpander;
48 uno::Reference< ucb::XContentIdentifier >
const & xIdentifier )
const;
54 explicit ExpandContentProviderImpl(
55 uno::Reference< uno::XComponentContext >
const & xComponentContext )
57 m_xMacroExpander( util::theMacroExpander::
get(xComponentContext) )
66 virtual uno::Reference< ucb::XContent > SAL_CALL queryContent(
67 uno::Reference< ucb::XContentIdentifier >
const & xIdentifier )
override;
68 virtual sal_Int32 SAL_CALL compareContentIds(
69 uno::Reference< ucb::XContentIdentifier >
const & xId1,
70 uno::Reference< ucb::XContentIdentifier >
const & xId2 )
override;
74void ExpandContentProviderImpl::check()
const
80 throw lang::DisposedException(
81 "expand content provider instance has "
82 "already been disposed!",
83 const_cast< ExpandContentProviderImpl *
>(
this)->getXWeak() );
89OUString ExpandContentProviderImpl::getImplementationName()
92 return "com.sun.star.comp.ucb.ExpandContentProvider";
96uno::Sequence< OUString > ExpandContentProviderImpl::getSupportedServiceNames()
100 "com.sun.star.ucb.ExpandContentProvider",
101 "com.sun.star.ucb.ContentProvider"
105sal_Bool ExpandContentProviderImpl::supportsService(OUString
const & serviceName )
110OUString ExpandContentProviderImpl::expandUri(
111 uno::Reference< ucb::XContentIdentifier >
const & xIdentifier )
const
113 OUString uri( xIdentifier->getContentIdentifier() );
114 if (!uri.startsWithIgnoreAsciiCase(
"vnd.sun.star.expand:", &uri))
116 throw ucb::IllegalIdentifierException(
117 "expected protocol vnd.sun.star.expand!",
118 const_cast< ExpandContentProviderImpl *
>(
this)->getXWeak() );
121 OUString str = ::rtl::Uri::decode(uri, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
123 return m_xMacroExpander->expandMacros( str );
128uno::Reference< ucb::XContent > ExpandContentProviderImpl::queryContent(
129 uno::Reference< ucb::XContentIdentifier >
const & xIdentifier )
132 OUString uri(
expandUri( xIdentifier ) );
136 uri, uno::Reference< ucb::XCommandEnvironment >(),
137 m_xComponentContext, ucb_content ))
139 return ucb_content.
get();
143 return uno::Reference< ucb::XContent >();
148sal_Int32 ExpandContentProviderImpl::compareContentIds(
149 uno::Reference< ucb::XContentIdentifier >
const & xId1,
150 uno::Reference< ucb::XContentIdentifier >
const & xId2 )
157 return uri1.compareTo( uri2 );
159 catch (
const ucb::IllegalIdentifierException &)
169extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
171 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const&)
173 return cppu::acquire(
new ExpandContentProviderImpl(context));
static bool create(const OUString &rURL, const css::uno::Reference< css::ucb::XCommandEnvironment > &rEnv, const css::uno::Reference< css::uno::XComponentContext > &rCtx, Content &rContent)
css::uno::Reference< css::ucb::XContent > get() const
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< XComponentContext > const m_xComponentContext
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > check(dp_misc::DescriptionInfoset const &infoset)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ucb_expand_ExpandContentProviderImpl_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)