diff options
Diffstat (limited to 'desktop/source/deployment/registry/script/dp_script.cxx')
-rw-r--r-- | desktop/source/deployment/registry/script/dp_script.cxx | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index c0adcf069484..c4567230456b 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -21,6 +21,7 @@ #include <strings.hrc> #include "dp_lib_container.h" #include <dp_backend.h> +#include <dp_misc.h> #include <dp_ucb.h> #include <ucbhelper/content.hxx> #include <cppuhelper/implbase.hxx> @@ -144,25 +145,22 @@ BackendImpl::BackendImpl( Reference<XComponentContext> const & xComponentContext ) : t_helper( args, xComponentContext ), m_xBasicLibTypeInfo( new Package::TypeInfo( - "application/vnd.sun.star.basic-library", + u"application/vnd.sun.star.basic-library"_ustr, OUString() /* no file filter */, DpResId(RID_STR_BASIC_LIB) ) ), m_xDialogLibTypeInfo( new Package::TypeInfo( - "application/vnd.sun.star.dialog-library", + u"application/vnd.sun.star.dialog-library"_ustr, OUString() /* no file filter */, DpResId(RID_STR_DIALOG_LIB) ) ), - m_typeInfos( 2 ) + m_typeInfos{ m_xBasicLibTypeInfo, m_xDialogLibTypeInfo } { - m_typeInfos[ 0 ] = m_xBasicLibTypeInfo; - m_typeInfos[ 1 ] = m_xDialogLibTypeInfo; - OSL_ASSERT( ! transientMode() ); if (!transientMode()) { - OUString dbFile = makeURL(getCachePath(), "backenddb.xml"); + OUString dbFile = makeURL(getCachePath(), u"backenddb.xml"_ustr); m_backendDb.reset( new ScriptBackendDb(getComponentContext(), dbFile)); } @@ -172,7 +170,7 @@ BackendImpl::BackendImpl( // XServiceInfo OUString BackendImpl::getImplementationName() { - return "com.sun.star.comp.deployment.script.PackageRegistryBackend"; + return u"com.sun.star.comp.deployment.script.PackageRegistryBackend"_ustr; } sal_Bool BackendImpl::supportsService( const OUString& ServiceName ) @@ -241,12 +239,12 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( { // probe for script.xlb: if (create_ucb_content( - nullptr, makeURL( url, "script.xlb" ), + nullptr, makeURL( url, u"script.xlb"_ustr ), xCmdEnv, false /* no throw */ )) mediaType = "application/vnd.sun.star.basic-library"; // probe for dialog.xlb: else if (create_ucb_content( - nullptr, makeURL( url, "dialog.xlb" ), + nullptr, makeURL( url, u"dialog.xlb"_ustr ), xCmdEnv, false /* no throw */ )) mediaType = "application/vnd.sun.star.dialog-library"; } @@ -262,7 +260,7 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( { if (type.equalsIgnoreAsciiCase("application")) { - OUString dialogURL( makeURL( url, "dialog.xlb" ) ); + OUString dialogURL( makeURL( url, u"dialog.xlb"_ustr ) ); if (! create_ucb_content( nullptr, dialogURL, xCmdEnv, false /* no throw */ )) { dialogURL.clear(); @@ -270,7 +268,7 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_( if (subType.equalsIgnoreAsciiCase("vnd.sun.star.basic-library")) { - OUString scriptURL( makeURL( url, "script.xlb")); + OUString scriptURL( makeURL( url, u"script.xlb"_ustr)); if (! create_ucb_content( nullptr, scriptURL, xCmdEnv, false /* no throw */ )) { scriptURL.clear(); @@ -307,7 +305,7 @@ BackendImpl * BackendImpl::PackageImpl::getMyBackend() const check(); //We should never get here... throw RuntimeException( - "Failed to get the BackendImpl", + u"Failed to get the BackendImpl"_ustr, static_cast<OWeakObject*>(const_cast<PackageImpl *>(this))); } return pBackend; @@ -350,36 +348,36 @@ lcl_maybeAddScript( OUString const& rScriptURL, Reference<css::script::XLibraryContainer3> const& xScriptLibs) { - if (bExists && xScriptLibs.is()) + if (!bExists || !xScriptLibs) + return false; + + bool bCanAdd = true; + if (xScriptLibs->hasByName(rName)) { - bool bCanAdd = true; - if (xScriptLibs->hasByName(rName)) + const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(rName); + //We assume here that library names in extensions are unique, which may not be the case + //ToDo: If the script exist in another extension, then both extensions must have the + //same id + if (sOriginalUrl.match("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE") + || sOriginalUrl.match("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE") + || sOriginalUrl.match("vnd.sun.star.expand:$BUNDLED_EXTENSIONS") + || sOriginalUrl.match("$(INST)/share/basic/Access2Base/")) { - const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(rName); - //We assume here that library names in extensions are unique, which may not be the case - //ToDo: If the script exist in another extension, then both extensions must have the - //same id - if (sOriginalUrl.match("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE") - || sOriginalUrl.match("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE") - || sOriginalUrl.match("vnd.sun.star.expand:$BUNDLED_EXTENSIONS") - || sOriginalUrl.match("$(INST)/share/basic/Access2Base/")) - { - xScriptLibs->removeLibrary(rName); - bCanAdd = true; - } - else - { - bCanAdd = false; - } + xScriptLibs->removeLibrary(rName); + bCanAdd = true; } - - if (bCanAdd) + else { - xScriptLibs->createLibraryLink(rName, rScriptURL, false); - return xScriptLibs->hasByName(rName); + bCanAdd = false; } } + if (bCanAdd) + { + xScriptLibs->createLibraryLink(rName, rScriptURL, false); + return xScriptLibs->hasByName(rName); + } + return false; } @@ -408,7 +406,7 @@ void BackendImpl::PackageImpl::processPackage_( { xScriptLibs.set( xComponentContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.script.ApplicationScriptLibraryContainer", + u"com.sun.star.script.ApplicationScriptLibraryContainer"_ustr, xComponentContext ), UNO_QUERY_THROW ); } @@ -416,7 +414,7 @@ void BackendImpl::PackageImpl::processPackage_( { xDialogLibs.set( xComponentContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.script.ApplicationDialogLibraryContainer", + u"com.sun.star.script.ApplicationDialogLibraryContainer"_ustr, xComponentContext ), UNO_QUERY_THROW ); } } |