summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-10-12 08:57:24 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-10-23 11:45:47 +0200
commit5aa2cd1d3f85958917f47523ee430af11ac1751d (patch)
tree0a5e62c012841e51410500c5b6a52db1938c5ed3 /scripting
parentf4776bf465ee682f65d1e978b031c928d9d310a5 (diff)
fdo#46808, use service constructor for uri::UriReferenceFactory
Change-Id: I4e72bf5880fa28cb96d93ede7730a63220af7fa6
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/basprov/basprov.cxx65
-rw-r--r--scripting/source/dlgprov/dlgprov.cxx21
-rw-r--r--scripting/source/protocolhandler/scripthandler.cxx19
-rw-r--r--scripting/source/provider/MasterScriptProvider.cxx14
-rw-r--r--scripting/source/provider/URIHelper.cxx7
5 files changed, 36 insertions, 90 deletions
diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx
index bf4a449e1a13..750394524161 100644
--- a/scripting/source/basprov/basprov.cxx
+++ b/scripting/source/basprov/basprov.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
#include <com/sun/star/script/provider/ScriptFrameworkErrorType.hpp>
#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <cppuhelper/implementationentry.hxx>
#include <rtl/uri.hxx>
@@ -135,40 +136,31 @@ namespace basprov
::rtl::OUString aFileURL;
if ( m_xContext.is() )
{
- Reference< uri::XUriReferenceFactory > xUriFac;
- Reference< lang::XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
- if ( xSMgr.is() )
- {
- xUriFac.set( xSMgr->createInstanceWithContext( ::rtl::OUString(
- "com.sun.star.uri.UriReferenceFactory" ), m_xContext ), UNO_QUERY );
- }
+ Reference< uri::XUriReferenceFactory > xUriFac( uri::UriReferenceFactory::create( m_xContext ) );
- if ( xUriFac.is() )
- {
- ::rtl::OUString aLinkURL( xLibContainer->getLibraryLinkURL( rLibName ) );
- Reference< uri::XUriReference > xUriRef( xUriFac->parse( aLinkURL ), UNO_QUERY );
+ ::rtl::OUString aLinkURL( xLibContainer->getLibraryLinkURL( rLibName ) );
+ Reference< uri::XUriReference > xUriRef( xUriFac->parse( aLinkURL ), UNO_QUERY );
- if ( xUriRef.is() )
+ if ( xUriRef.is() )
+ {
+ ::rtl::OUString aScheme = xUriRef->getScheme();
+ if ( aScheme.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("file")) )
{
- ::rtl::OUString aScheme = xUriRef->getScheme();
- if ( aScheme.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("file")) )
+ aFileURL = aLinkURL;
+ }
+ else if ( aScheme.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.pkg")) )
+ {
+ ::rtl::OUString aAuthority = xUriRef->getAuthority();
+ if ( aAuthority.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.expand:" ) ) )
{
- aFileURL = aLinkURL;
- }
- else if ( aScheme.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.pkg")) )
- {
- ::rtl::OUString aAuthority = xUriRef->getAuthority();
- if ( aAuthority.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.expand:" ) ) )
- {
- ::rtl::OUString aDecodedURL( aAuthority.copy( sizeof ( "vnd.sun.star.expand:" ) - 1 ) );
- aDecodedURL = ::rtl::Uri::decode( aDecodedURL, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
- Reference<util::XMacroExpander> xMacroExpander(
- m_xContext->getValueByName(
- ::rtl::OUString("/singletons/com.sun.star.util.theMacroExpander") ),
- UNO_QUERY );
- if ( xMacroExpander.is() )
- aFileURL = xMacroExpander->expandMacros( aDecodedURL );
- }
+ ::rtl::OUString aDecodedURL( aAuthority.copy( sizeof ( "vnd.sun.star.expand:" ) - 1 ) );
+ aDecodedURL = ::rtl::Uri::decode( aDecodedURL, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
+ Reference<util::XMacroExpander> xMacroExpander(
+ m_xContext->getValueByName(
+ ::rtl::OUString("/singletons/com.sun.star.util.theMacroExpander") ),
+ UNO_QUERY );
+ if ( xMacroExpander.is() )
+ aFileURL = xMacroExpander->expandMacros( aDecodedURL );
}
}
}
@@ -325,18 +317,7 @@ namespace basprov
SolarMutexGuard aGuard;
Reference< provider::XScript > xScript;
- Reference< lang::XMultiComponentFactory > xMcFac ( m_xContext->getServiceManager() );
- Reference< uri::XUriReferenceFactory > xFac (
- xMcFac->createInstanceWithContext( rtl::OUString(
- "com.sun.star.uri.UriReferenceFactory"), m_xContext ) , UNO_QUERY );
-
- if ( !xFac.is() )
- {
- throw provider::ScriptFrameworkErrorException(
- OUSTR( "Failed to instantiate UriReferenceFactory" ), Reference< XInterface >(),
- scriptURI, OUSTR("Basic"),
- provider::ScriptFrameworkErrorType::UNKNOWN );
- }
+ Reference< uri::XUriReferenceFactory > xFac ( uri::UriReferenceFactory::create( m_xContext ) );
Reference< uri::XUriReference > uriRef(
xFac->parse( scriptURI ), UNO_QUERY );
diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx
index 2c55c323fa8e..e1703f47665c 100644
--- a/scripting/source/dlgprov/dlgprov.cxx
+++ b/scripting/source/dlgprov/dlgprov.cxx
@@ -44,7 +44,7 @@
#include <comphelper/namedvaluecollection.hxx>
#include <com/sun/star/uri/XUriReference.hpp>
-#include <com/sun/star/uri/XUriReferenceFactory.hpp>
+#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
#include <com/sun/star/uri/XVndSunStarExpandUrl.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
@@ -285,25 +285,8 @@ static ::rtl::OUString aResourceResolverPropName("ResourceResolver");
// parse URL
// TODO: use URL parsing class
// TODO: decoding of location
- Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager(), UNO_QUERY );
- if ( !xSMgr.is() )
- {
- throw RuntimeException(
- ::rtl::OUString( "DialogProviderImpl::getDialogModel: Couldn't instantiate MultiComponent factory" ),
- Reference< XInterface >() );
- }
-
- Reference< uri::XUriReferenceFactory > xFac (
- xSMgr->createInstanceWithContext( rtl::OUString(
- "com.sun.star.uri.UriReferenceFactory"), m_xContext ) , UNO_QUERY );
-
- if ( !xFac.is() )
- {
- throw RuntimeException(
- ::rtl::OUString("DialogProviderImpl::getDialogModel(), could not instatiate UriReferenceFactory."),
- Reference< XInterface >() );
- }
+ Reference< uri::XUriReferenceFactory > xFac ( uri::UriReferenceFactory::create( m_xContext ) );
// i75778: Support non-script URLs
Reference< io::XInputStream > xInput;
diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx
index 4151a56c4179..faa25bb3613e 100644
--- a/scripting/source/protocolhandler/scripthandler.cxx
+++ b/scripting/source/protocolhandler/scripthandler.cxx
@@ -49,7 +49,7 @@
#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/uri/XUriReference.hpp"
-#include "com/sun/star/uri/XUriReferenceFactory.hpp"
+#include "com/sun/star/uri/UriReferenceFactory.hpp"
#include "com/sun/star/uri/XVndSunStarScriptUrl.hpp"
using namespace ::com::sun::star;
@@ -102,19 +102,14 @@ Reference< XDispatch > SAL_CALL ScriptProtocolHandler::queryDispatch(
Reference< XDispatch > xDispatcher;
// get scheme of url
- Reference< uri::XUriReferenceFactory > xFac (
- m_xFactory->createInstance( rtl::OUString(
- "com.sun.star.uri.UriReferenceFactory") ) , UNO_QUERY );
- if ( xFac.is() )
+ Reference< uri::XUriReferenceFactory > xFac = uri::UriReferenceFactory::create( comphelper::getComponentContext(m_xFactory) );
+ Reference< uri::XUriReference > uriRef(
+ xFac->parse( aURL.Complete ), UNO_QUERY );
+ if ( uriRef.is() )
{
- Reference< uri::XUriReference > uriRef(
- xFac->parse( aURL.Complete ), UNO_QUERY );
- if ( uriRef.is() )
+ if ( uriRef->getScheme().equals( ::rtl::OUString::createFromAscii( ::scripting_protocolhandler::MYSCHEME ) ) )
{
- if ( uriRef->getScheme().equals( ::rtl::OUString::createFromAscii( ::scripting_protocolhandler::MYSCHEME ) ) )
- {
- xDispatcher = this;
- }
+ xDispatcher = this;
}
}
diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx
index ff034699700d..4362330c7b6b 100644
--- a/scripting/source/provider/MasterScriptProvider.cxx
+++ b/scripting/source/provider/MasterScriptProvider.cxx
@@ -31,7 +31,7 @@
#include <com/sun/star/document/XScriptInvocationContext.hpp>
#include <com/sun/star/uri/XUriReference.hpp>
-#include <com/sun/star/uri/XUriReferenceFactory.hpp>
+#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
#include <com/sun/star/deployment/XPackage.hpp>
@@ -259,17 +259,7 @@ throw ( provider::ScriptFrameworkErrorException,
// need to get the language from the string
- Reference< uri::XUriReferenceFactory > xFac (
- m_xMgr->createInstanceWithContext( rtl::OUString(
- "com.sun.star.uri.UriReferenceFactory"), m_xContext ) , UNO_QUERY );
- if ( !xFac.is() )
- {
- ::rtl::OUString message("Failed to instantiate UriReferenceFactory");
- throw provider::ScriptFrameworkErrorException(
- message, Reference< XInterface >(),
- scriptURI, ::rtl::OUString(),
- provider::ScriptFrameworkErrorType::UNKNOWN );
- }
+ Reference< uri::XUriReferenceFactory > xFac ( uri::UriReferenceFactory::create( m_xContext ) );
Reference< uri::XUriReference > uriRef(
xFac->parse( scriptURI ), UNO_QUERY );
diff --git a/scripting/source/provider/URIHelper.cxx b/scripting/source/provider/URIHelper.cxx
index 7ef545fe6c2b..ec7ba77551ac 100644
--- a/scripting/source/provider/URIHelper.cxx
+++ b/scripting/source/provider/URIHelper.cxx
@@ -19,6 +19,7 @@
#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
+#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <rtl/ustrbuf.hxx>
#include "URIHelper.hxx"
@@ -67,11 +68,7 @@ ScriptingFrameworkURIHelper::ScriptingFrameworkURIHelper(
try
{
- m_xUriReferenceFactory = uno::Reference< uri::XUriReferenceFactory >(
- xContext->getServiceManager()->createInstanceWithContext(
- OUString(
- "com.sun.star.uri.UriReferenceFactory"),
- xContext ), uno::UNO_QUERY_THROW );
+ m_xUriReferenceFactory = uri::UriReferenceFactory::create( xContext );
}
catch (uno::Exception&)
{