14#include <com/sun/star/lang/XServiceInfo.hpp>
15#include <com/sun/star/ucb/IllegalIdentifierException.hpp>
16#include <com/sun/star/ucb/XContentProvider.hpp>
17#include <com/sun/star/uno/XComponentContext.hpp>
18#include <com/sun/star/uri/UriReferenceFactory.hpp>
22#include <rtl/ustrbuf.hxx>
40 css::lang::XServiceInfo, css::ucb::XContentProvider>
44 css::uno::Reference<css::uno::XComponentContext> context):
50 {
return "com.sun.star.comp.ucb.ImageContentProvider"; }
57 return css::uno::Sequence<OUString>{
58 "com.sun.star.ucb.ImageContentProvider"};
61 css::uno::Reference<css::ucb::XContent> SAL_CALL queryContent(
62 css::uno::Reference<css::ucb::XContentIdentifier>
const & Identifier)
65 css::uno::Reference<css::uno::XComponentContext> context;
71 throw css::lang::DisposedException();
74 auto uri(css::uri::UriReferenceFactory::create(context)->
parse(url));
76 && uri->getScheme().equalsIgnoreAsciiCase(
77 "vnd.libreoffice.image")))
79 throw css::ucb::IllegalIdentifierException(url);
83 uri->getAuthority(), rtl_UriDecodeStrict,
84 RTL_TEXTENCODING_UTF8));
86 throw css::ucb::IllegalIdentifierException(url);
88 auto path(uri->getPath());
90 throw css::ucb::IllegalIdentifierException(url);
93 assert(path[0] ==
'/');
94 for (sal_Int32 i = 1;;) {
95 auto j = path.indexOf(
'/', i);
101 path.copy(i, j - i), rtl_UriDecodeStrict,
102 RTL_TEXTENCODING_UTF8));
104 throw css::ucb::IllegalIdentifierException(url);
110 if (j == path.getLength()) {
115 auto decPath(buf.makeStringAndClear());
117 if (uri->hasQuery()) {
118 if (!uri->getQuery().startsWith(
"lang=", &lang)) {
119 throw css::ucb::IllegalIdentifierException(url);
121 lang = rtl::Uri::decode(
122 lang, rtl_UriDecodeStrict, RTL_TEXTENCODING_UTF8);
123 if (lang.isEmpty()) {
124 throw css::ucb::IllegalIdentifierException(url);
135 newUrl, css::uno::Reference<css::ucb::XCommandEnvironment>(),
137 ? content.
get() : css::uno::Reference<css::ucb::XContent>();
140 sal_Int32 SAL_CALL compareContentIds(
141 css::uno::Reference<css::ucb::XContentIdentifier>
const & Id1,
142 css::uno::Reference<css::ucb::XContentIdentifier>
const & Id2)
override
144 return Id1->getContentIdentifier().compareTo(
145 Id2->getContentIdentifier());
148 void disposing(std::unique_lock<std::mutex>&)
override {
152 css::uno::Reference<css::uno::XComponentContext>
context_;
157extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
159 css::uno::XComponentContext * context,
160 css::uno::Sequence<css::uno::Any>
const &)
162 return cppu::acquire(
new Provider(context));
VCL_DLLPUBLIC OUString getImageUrl(OUString const &name, OUString const &style, OUString const &lang)
static VCL_DLLPUBLIC ImageTree & get()
virtual void disposing(std::unique_lock< std::mutex > &)
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
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
bool parse(OUString const &uri, SourceProviderScannerData *data)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_ucb_ImageContentProvider_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
uno::Reference< uno::XComponentContext > context_