20#include <config_folders.h>
21#include <com/sun/star/lang/IllegalArgumentException.hpp>
22#include <com/sun/star/ucb/SimpleFileAccess.hpp>
23#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
24#include <com/sun/star/uri/UriReferenceFactory.hpp>
26#include <osl/diagnose.h>
32namespace uno = ::com::sun::star::uno;
33namespace ucb = ::com::sun::star::ucb;
34namespace lang = ::com::sun::star::lang;
35namespace uri = ::com::sun::star::uri;
37constexpr OUStringLiteral
SHARE =
u"share";
40 u"vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE";
42constexpr OUStringLiteral
USER =
u"user";
44 u"vnd.sun.star.expand:${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER
"/" SAL_CONFIGFILE(
"bootstrap")
"::UserInstallation}";
55 catch (uno::Exception&)
57 OSL_FAIL(
"Scripting Framework error initialising XSimpleFileAccess");
64 catch (uno::Exception&)
66 OSL_FAIL(
"Scripting Framework error initialising XUriReferenceFactory");
79 if (
args.getLength() != 2 ||
83 throw uno::RuntimeException(
"ScriptingFrameworkURIHelper got invalid argument list" );
88 throw uno::RuntimeException(
"ScriptingFrameworkURIHelper error parsing args" );
95 throw uno::RuntimeException(
"ScriptingFrameworkURIHelper cannot find script directory" );
103 bool bAppendScriptsPart =
false;
109 bAppendScriptsPart =
true;
113 test =
"uno_packages";
119 uri =
"vnd.sun.star.expand:$BRAND_BASE_DIR";
120 bAppendScriptsPart =
true;
124 test =
"uno_packages";
127 else if (
m_sLocation.startsWith(
"vnd.sun.star.tdoc"))
147 auto pChild = std::find_if(children.begin(), children.end(), [&
test](
const OUString& child) {
148 sal_Int32 idx = child.lastIndexOf(test);
149 return idx != -1 && (idx + test.getLength()) == child.getLength();
151 if (pChild != children.end())
153 if ( bAppendScriptsPart )
174 if (
idx != std::u16string_view::npos )
185 OUString
result = rLanguagePart.replace(
'|',
'/');
193 "vnd.sun.star.script:" +
204 OUString sLanguagePart;
209 sLanguagePart = xURI->getName();
211 catch ( uno::Exception& )
213 throw lang::IllegalArgumentException(
214 "Script URI not valid",
231 "com.sun.star.script.provider.ScriptURIHelper";
243 return {
"com.sun.star.script.provider.ScriptURIHelper" };
246extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
248 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const&)
virtual OUString SAL_CALL getStorageURI(const OUString &rScriptURI) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &args) override
virtual OUString SAL_CALL getRootStorageURI() override
virtual OUString SAL_CALL getImplementationName() override
virtual ~ScriptingFrameworkURIHelper() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::uri::XUriReferenceFactory > m_xUriReferenceFactory
virtual OUString SAL_CALL getScriptURI(const OUString &rStorageURI) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
OUString getLanguagePart(std::u16string_view rStorageURI)
static OUString getLanguagePath(const OUString &rLanguagePart)
css::uno::Reference< css::ucb::XSimpleFileAccess3 > m_xSimpleFileAccess
ScriptingFrameworkURIHelper(const css::uno::Reference< css::uno::XComponentContext > &xContext)
#define SAL_CONFIGFILE(name)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * scripting_ScriptingFrameworkURIHelper_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral SHARE_UNO_PACKAGES_URI
constexpr OUStringLiteral USER
constexpr OUStringLiteral USER_URI
constexpr OUStringLiteral SHARE