22#include <com/sun/star/lang/XServiceInfo.hpp>
23#include <com/sun/star/uno/Reference.hxx>
24#include <com/sun/star/uno/RuntimeException.hpp>
25#include <com/sun/star/uno/Sequence.hxx>
26#include <com/sun/star/uri/XUriSchemeParser.hpp>
27#include <com/sun/star/uri/XVndSunStarExpandUrlReference.hpp>
28#include <com/sun/star/util/XMacroExpander.hpp>
32#include <rtl/textenc.h>
35#include <rtl/ustring.hxx>
46bool parseSchemeSpecificPart(OUString
const & part) {
50 || (!::rtl::Uri::decode(part, ::rtl_UriDecodeStrict, RTL_TEXTENCODING_UTF8).isEmpty());
54 public ::cppu::WeakImplHelper<css::uri::XVndSunStarExpandUrlReference>
57 UrlReference(OUString
const & scheme, OUString
const & path):
59 scheme, false, OUString(), path, false,
63 UrlReference(
const UrlReference&) =
delete;
64 UrlReference& operator=(
const UrlReference&) =
delete;
66 virtual OUString SAL_CALL getUriReference()
override
67 {
return base_.getUriReference(); }
69 virtual sal_Bool SAL_CALL isAbsolute()
override
70 {
return base_.isAbsolute(); }
72 virtual OUString SAL_CALL getScheme()
override
73 {
return base_.getScheme(); }
75 virtual OUString SAL_CALL getSchemeSpecificPart()
override
76 {
return base_.getSchemeSpecificPart(); }
78 virtual sal_Bool SAL_CALL isHierarchical()
override
79 {
return base_.isHierarchical(); }
81 virtual sal_Bool SAL_CALL hasAuthority()
override
82 {
return base_.hasAuthority(); }
84 virtual OUString SAL_CALL getAuthority()
override
85 {
return base_.getAuthority(); }
87 virtual OUString SAL_CALL getPath()
override
88 {
return base_.getPath(); }
90 virtual sal_Bool SAL_CALL hasRelativePath()
override
91 {
return base_.hasRelativePath(); }
93 virtual ::sal_Int32 SAL_CALL getPathSegmentCount()
override
94 {
return base_.getPathSegmentCount(); }
96 virtual OUString SAL_CALL getPathSegment(sal_Int32 index)
override
97 {
return base_.getPathSegment(index); }
99 virtual sal_Bool SAL_CALL hasQuery()
override
100 {
return base_.hasQuery(); }
102 virtual OUString SAL_CALL getQuery()
override
103 {
return base_.getQuery(); }
105 virtual sal_Bool SAL_CALL hasFragment()
override
106 {
return base_.hasFragment(); }
108 virtual OUString SAL_CALL getFragment()
override
109 {
return base_.getFragment(); }
111 virtual void SAL_CALL setFragment(OUString
const & fragment)
override
112 { base_.setFragment(fragment); }
114 virtual void SAL_CALL clearFragment()
override
115 { base_.clearFragment(); }
117 virtual OUString SAL_CALL expand(
118 css::uno::Reference< css::util::XMacroExpander >
const & expander)
override;
121 virtual ~UrlReference()
override {}
126OUString UrlReference::expand(
127 css::uno::Reference< css::util::XMacroExpander >
const & expander)
129 if (!expander.is()) {
130 throw css::uno::RuntimeException(
"null expander passed to XVndSunStarExpandUrl.expand");
132 return expander->expandMacros(
134 getPath(), ::rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8));
138 public ::cppu::WeakImplHelper<
139 css::lang::XServiceInfo, css::uri::XUriSchemeParser>
144 Parser(
const Parser&) =
delete;
145 Parser& operator=(
const Parser&) =
delete;
150 OUString
const & serviceName)
override;
152 virtual css::uno::Sequence< OUString > SAL_CALL
155 virtual css::uno::Reference< css::uri::XUriReference > SAL_CALL
157 OUString
const & scheme,
158 OUString
const & schemeSpecificPart)
override;
161 virtual ~Parser()
override {}
164OUString Parser::getImplementationName()
166 return "com.sun.star.comp.uri.UriSchemeParser_vndDOTsunDOTstarDOTexpand";
169sal_Bool Parser::supportsService(OUString
const & serviceName)
174css::uno::Sequence< OUString > Parser::getSupportedServiceNames()
176 return {
"com.sun.star.uri.UriSchemeParser_vndDOTsunDOTstarDOTexpand" };
179css::uno::Reference< css::uri::XUriReference > Parser::parse(
180 OUString
const & scheme, OUString
const & schemeSpecificPart)
182 if (!parseSchemeSpecificPart(schemeSpecificPart)) {
183 return css::uno::Reference< css::uri::XUriReference >();
185 return new UrlReference(scheme, schemeSpecificPart);
190extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
192 css::uno::Sequence<css::uno::Any>
const &)
195 return ::cppu::acquire(
new Parser());
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_uri_UriSchemeParser_vndDOTsunDOTstarDOTexpand_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > 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)