Kaydet (Commit) 5aa2cd1d authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Stephan Bergmann

fdo#46808, use service constructor for uri::UriReferenceFactory

Change-Id: I4e72bf5880fa28cb96d93ede7730a63220af7fa6
üst f4776bf4
......@@ -25,7 +25,7 @@
#include "doceventnotifier.hxx"
#include "documentenumeration.hxx"
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
#include <com/sun/star/document/MacroExecMode.hpp>
#include <com/sun/star/frame/XStorable.hpp>
......@@ -88,6 +88,7 @@ namespace basctl
using ::com::sun::star::uno::makeAny;
using ::com::sun::star::script::XLibraryContainer2;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::uri::UriReferenceFactory;
using ::com::sun::star::uri::XUriReferenceFactory;
using ::com::sun::star::uri::XUriReference;
using ::com::sun::star::uno::XComponentContext;
......@@ -934,14 +935,8 @@ namespace basctl
if ( !xLibContainer->hasByName( _rLibName ) || !xLibContainer->isLibraryLink( _rLibName ) )
return false;
OUString aFileURL;
Reference< XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
Reference< XUriReferenceFactory > xUriFac;
if ( xMSF.is() )
{
xUriFac.set(
xMSF->createInstance( "com.sun.star.uri.UriReferenceFactory" ),
UNO_QUERY_THROW );
}
Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
Reference< XUriReferenceFactory > xUriFac = UriReferenceFactory::create(xContext);
OUString aLinkURL( xLibContainer->getLibraryLinkURL( _rLibName ) );
Reference< XUriReference > xUriRef( xUriFac->parse( aLinkURL ), UNO_QUERY_THROW );
......@@ -958,8 +953,6 @@ namespace basctl
{
OUString aDecodedURL( aAuthority.copy( sizeof ( "vnd.sun.star.expand:" ) - 1 ) );
aDecodedURL = ::rtl::Uri::decode( aDecodedURL, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
Reference< XComponentContext > xContext(
comphelper::getComponentContext( xMSF ) );
Reference< XMacroExpander > xMacroExpander(
xContext->getValueByName(
"/singletons/com.sun.star.util.theMacroExpander" ),
......
......@@ -34,7 +34,7 @@
#include <com/sun/star/ucb/UnsupportedDataSinkException.hpp>
#include <com/sun/star/ucb/CommandFailedException.hpp>
#include <com/sun/star/task/XInteractionAbort.hpp>
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <com/sun/star/uri/XUriReference.hpp>
#include <com/sun/star/ucb/PostCommandArgument2.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
......@@ -705,13 +705,12 @@ sal_Bool MediaDescriptor::impl_openStreamWithURL( const ::rtl::OUString& sURL, s
it parses the URL in another way. It's main part isnt enough
and it's complete part contains the jumpmark (fragment) parameter ...
*/
static ::rtl::OUString SERVICENAME_URIREFERENCEFACTORY( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.uri.UriReferenceFactory" ));
try
{
css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
css::uno::Reference< css::uri::XUriReferenceFactory > xUriFactory(xSMGR->createInstance(SERVICENAME_URIREFERENCEFACTORY), css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::uri::XUriReference > xUriRef = xUriFactory->parse(sURL);
css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
css::uno::Reference< css::uri::XUriReferenceFactory > xUriFactory = css::uri::UriReferenceFactory::create(xContext);;
css::uno::Reference< css::uri::XUriReference > xUriRef = xUriFactory->parse(sURL);
if (xUriRef.is())
{
xUriRef->clearFragment();
......
......@@ -94,7 +94,7 @@ class PopupMenuDispatcher : // interfaces
public:
// constructor / destructor
PopupMenuDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
PopupMenuDispatcher( const css::uno::Reference< css::uno::XComponentContext >& xContext );
// XInterface, XTypeProvider, XServiceInfo
FWK_DECLARE_XINTERFACE
......@@ -146,7 +146,7 @@ class PopupMenuDispatcher : // interfaces
css::uno::WeakReference< css::frame::XFrame > m_xWeakFrame ; /// css::uno::WeakReference to frame (Don't use a hard css::uno::Reference. Owner can't delete us then!)
css::uno::Reference< css::container::XNameAccess > m_xPopupCtrlQuery ; /// reference to query for popup controller
css::uno::Reference< css::uri::XUriReferenceFactory > m_xUriRefFactory ; /// reference to the uri reference factory
css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// factory shared with our owner to create new services!
css::uno::Reference< css::uno::XComponentContext > m_xContext ; /// factory shared with our owner to create new services!
IMPL_ListenerHashContainer m_aListenerContainer; /// hash table for listener at specified URLs
sal_Bool m_bAlreadyDisposed ; /// Protection against multiple disposing calls.
sal_Bool m_bActivateListener ; /// dispatcher is listener for frame activation
......
......@@ -43,7 +43,9 @@
#include <com/sun/star/lang/WrappedTargetException.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <comphelper/componentcontext.hxx>
#include <ucbhelper/content.hxx>
#include <osl/mutex.hxx>
#include <rtl/ustrbuf.hxx>
......@@ -70,12 +72,12 @@ const sal_Int32 PROTOCOL_LENGTH = 19;
// constructor
//*****************************************************************************************************************
PopupMenuDispatcher::PopupMenuDispatcher(
const uno::Reference< XMultiServiceFactory >& xFactory )
const uno::Reference< XComponentContext >& xContext )
// Init baseclasses first
: ThreadHelpBase ( &Application::GetSolarMutex() )
, OWeakObject ( )
// Init member
, m_xFactory ( xFactory )
, m_xContext ( xContext )
, m_aListenerContainer ( m_aLock.getShareableOslMutex() )
, m_bAlreadyDisposed ( sal_False )
, m_bActivateListener ( sal_False )
......@@ -116,10 +118,61 @@ DEFINE_XTYPEPROVIDER_7 ( PopupMenuDispatcher ,
XFrameActionListener
)
DEFINE_XSERVICEINFO_MULTISERVICE( PopupMenuDispatcher ,
::cppu::OWeakObject ,
SERVICENAME_PROTOCOLHANDLER ,
IMPLEMENTATIONNAME_POPUPMENUDISPATCHER )
::rtl::OUString SAL_CALL PopupMenuDispatcher::getImplementationName() throw( css::uno::RuntimeException )
{
return impl_getStaticImplementationName();
}
sal_Bool SAL_CALL PopupMenuDispatcher::supportsService( const ::rtl::OUString& sServiceName )
throw( css::uno::RuntimeException )
{
return ::comphelper::findValue(getSupportedServiceNames(), sServiceName, sal_True).getLength() != 0;
}
css::uno::Sequence< ::rtl::OUString > SAL_CALL PopupMenuDispatcher::getSupportedServiceNames()
throw( css::uno::RuntimeException )
{
return impl_getStaticSupportedServiceNames();
}
css::uno::Sequence< ::rtl::OUString > PopupMenuDispatcher::impl_getStaticSupportedServiceNames()
{
css::uno::Sequence< ::rtl::OUString > seqServiceNames( 1 );
seqServiceNames.getArray() [0] = SERVICENAME_PROTOCOLHANDLER;
return seqServiceNames;
}
::rtl::OUString PopupMenuDispatcher::impl_getStaticImplementationName()
{
return IMPLEMENTATIONNAME_POPUPMENUDISPATCHER;
}
css::uno::Reference< css::uno::XInterface >
SAL_CALL PopupMenuDispatcher::impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager )
throw( css::uno::Exception )
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework","Ocke.Janssen@sun.com",U2B(IMPLEMENTATIONNAME_POPUPMENUDISPATCHER).getStr());
/* create new instance of service */
PopupMenuDispatcher* pClass = new PopupMenuDispatcher( comphelper::getComponentContext(xServiceManager) );
/* hold it alive by increasing his ref count!!! */
css::uno::Reference< css::uno::XInterface > xService( static_cast< ::cppu::OWeakObject* >(pClass), css::uno::UNO_QUERY );
/* initialize new service instance ... he can use his own refcount ... we hold it! */
pClass->impl_initService();
/* return new created service as reference */
return xService;
}
css::uno::Reference< css::lang::XSingleServiceFactory >
PopupMenuDispatcher::impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager )
{
css::uno::Reference< css::lang::XSingleServiceFactory > xReturn (
cppu::createSingleFactory ( xServiceManager,
PopupMenuDispatcher::impl_getStaticImplementationName() ,
PopupMenuDispatcher::impl_createInstance ,
PopupMenuDispatcher::impl_getStaticSupportedServiceNames() )
);
return xReturn;
}
DEFINE_INIT_SERVICE(PopupMenuDispatcher,
{
......@@ -333,7 +386,7 @@ SAL_CALL PopupMenuDispatcher::disposing( const EventObject& ) throw( RuntimeExce
}
// Forget our factory.
m_xFactory = uno::Reference< XMultiServiceFactory >();
m_xContext = uno::Reference< XComponentContext >();
}
}
......@@ -379,13 +432,7 @@ void PopupMenuDispatcher::impl_CreateUriRefFactory()
{
if ( !m_xUriRefFactory.is() )
{
rtl::OUString aUriRefFactoryService(
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.uri.UriReferenceFactory" ));
m_xUriRefFactory = css::uno::Reference< css::uri::XUriReferenceFactory >(
m_xFactory->createInstance( aUriRefFactoryService ),
css::uno::UNO_QUERY);
m_xUriRefFactory = css::uri::UriReferenceFactory::create( m_xContext );
}
}
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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;
}
}
......
......@@ -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 );
......
......@@ -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&)
{
......
......@@ -56,7 +56,7 @@
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
#include <basic/basmgr.hxx>
#include <toolkit/helper/vclunohelper.hxx>
......@@ -527,35 +527,29 @@ sal_Bool SfxApplication::IsXScriptURL( const String& rScriptURL )
(void) rScriptURL;
#else
::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory > xSMgr =
::comphelper::getProcessServiceFactory();
< ::com::sun::star::uno::XComponentContext > xContext =
::comphelper::getProcessComponentContext();
::com::sun::star::uno::Reference
< ::com::sun::star::uri::XUriReferenceFactory >
xFactory( xSMgr->createInstance(
::rtl::OUString(
"com.sun.star.uri.UriReferenceFactory" ) ),
::com::sun::star::uno::UNO_QUERY );
xFactory = ::com::sun::star::uri::UriReferenceFactory::create( xContext );
if ( xFactory.is() )
try
{
try
{
::com::sun::star::uno::Reference
< ::com::sun::star::uri::XVndSunStarScriptUrl >
xUrl( xFactory->parse( rScriptURL ),
::com::sun::star::uno::UNO_QUERY );
::com::sun::star::uno::Reference
< ::com::sun::star::uri::XVndSunStarScriptUrl >
xUrl( xFactory->parse( rScriptURL ),
::com::sun::star::uno::UNO_QUERY );
if ( xUrl.is() )
{
result = sal_True;
}
}
catch (const ::com::sun::star::uno::RuntimeException&)
if ( xUrl.is() )
{
// ignore, will just return FALSE
result = sal_True;
}
}
catch (const ::com::sun::star::uno::RuntimeException&)
{
// ignore, will just return FALSE
}
#endif
return result;
}
......
......@@ -61,7 +61,7 @@
#include <unotools/ucbhelper.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/XVndSunStarPkgUrlReferenceFactory.hpp>
......@@ -147,13 +147,8 @@ uno::Reference<rdf::XURI> createBaseURI(
}
}
const uno::Reference<lang::XMultiComponentFactory> xServiceFactory(
i_xContext->getServiceManager(), uno::UNO_SET_THROW);
const uno::Reference<uri::XUriReferenceFactory> xUriFactory(
xServiceFactory->createInstanceWithContext(
::rtl::OUString(
"com.sun.star.uri.UriReferenceFactory"), i_xContext),
uno::UNO_QUERY_THROW);
const uno::Reference<uri::XUriReferenceFactory> xUriFactory =
uri::UriReferenceFactory::create( i_xContext);
uno::Reference< uri::XUriReference > xBaseURI;
const uno::Reference< uri::XUriReference > xPkgURI(
......
......@@ -56,7 +56,7 @@
#include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
#include <com/sun/star/document/UpdateDocMode.hpp>
#include <com/sun/star/beans/XPropertySet.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/embed/XStorage.hpp>
#include <com/sun/star/embed/EmbedStates.hpp>
......@@ -2620,29 +2620,26 @@ void SfxViewFrame::AddDispatchMacroToBasic_Impl( const ::rtl::OUString& sMacro )
String aModuleName;
String aMacroName;
String aLocation;
Reference< XMultiServiceFactory > xSMgr = ::comphelper::getProcessServiceFactory();
Reference< com::sun::star::uri::XUriReferenceFactory > xFactory( xSMgr->createInstance(
::rtl::OUString("com.sun.star.uri.UriReferenceFactory") ), UNO_QUERY );
if ( xFactory.is() )
{
Reference< com::sun::star::uri::XVndSunStarScriptUrl > xUrl( xFactory->parse( aScriptURL ), UNO_QUERY );
if ( xUrl.is() )
{
// get name
::rtl::OUString aName = xUrl->getName();
sal_Unicode cTok = '.';
sal_Int32 nIndex = 0;
aLibName = aName.getToken( 0, cTok, nIndex );
if ( nIndex != -1 )
aModuleName = aName.getToken( 0, cTok, nIndex );
if ( nIndex != -1 )
aMacroName = aName.getToken( 0, cTok, nIndex );
// get location
::rtl::OUString aLocKey("location");
if ( xUrl->hasParameter( aLocKey ) )
aLocation = xUrl->getParameter( aLocKey );
}
Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
Reference< com::sun::star::uri::XUriReferenceFactory > xFactory =
com::sun::star::uri::UriReferenceFactory::create( xContext );
Reference< com::sun::star::uri::XVndSunStarScriptUrl > xUrl( xFactory->parse( aScriptURL ), UNO_QUERY );
if ( xUrl.is() )
{
// get name
::rtl::OUString aName = xUrl->getName();
sal_Unicode cTok = '.';
sal_Int32 nIndex = 0;
aLibName = aName.getToken( 0, cTok, nIndex );
if ( nIndex != -1 )
aModuleName = aName.getToken( 0, cTok, nIndex );
if ( nIndex != -1 )
aMacroName = aName.getToken( 0, cTok, nIndex );
// get location
::rtl::OUString aLocKey("location");
if ( xUrl->hasParameter( aLocKey ) )
aLocation = xUrl->getParameter( aLocKey );
}
BasicManager* pBasMgr = 0;
......
......@@ -32,7 +32,7 @@
#include <docufld.hxx>
#include <unofldmid.h>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
#include <comphelper/processfactory.hxx>
......@@ -235,23 +235,18 @@ void SwMacroField::CreateMacroString(
sal_Bool SwMacroField::isScriptURL( const String& str )
{
uno::Reference< lang::XMultiServiceFactory > xSMgr =
::comphelper::getProcessServiceFactory();
uno::Reference< uno::XComponentContext > xContext =
::comphelper::getProcessComponentContext();
uno::Reference< uri::XUriReferenceFactory >
xFactory( xSMgr->createInstance(
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.uri.UriReferenceFactory")) ), uno::UNO_QUERY );
xFactory = uri::UriReferenceFactory::create( xContext );
if ( xFactory.is() )
{
uno::Reference< uri::XVndSunStarScriptUrl >
xUrl( xFactory->parse( str ), uno::UNO_QUERY );
uno::Reference< uri::XVndSunStarScriptUrl >
xUrl( xFactory->parse( str ), uno::UNO_QUERY );
if ( xUrl.is() )
{
return sal_True;
}
if ( xUrl.is() )
{
return sal_True;
}
return sal_False;
}
......
......@@ -39,7 +39,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdbc/XDataSource.hpp>
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
......@@ -1695,22 +1695,18 @@ void SwFldMgr::SetMacroPath(const String& rPath)
// try to set sMacroName member variable by parsing the macro path
// using the new URI parsing services
Reference< XMultiServiceFactory > xSMgr =
::comphelper::getProcessServiceFactory();
Reference< XComponentContext > xContext =
::comphelper::getProcessComponentContext();
Reference< uri::XUriReferenceFactory >
xFactory( xSMgr->createInstance(
::rtl::OUString( "com.sun.star.uri.UriReferenceFactory" ) ), UNO_QUERY );
xFactory = uri::UriReferenceFactory::create( xContext );
if ( xFactory.is() )
{
Reference< uri::XVndSunStarScriptUrl >
xUrl( xFactory->parse( sMacroPath ), UNO_QUERY );
Reference< uri::XVndSunStarScriptUrl >
xUrl( xFactory->parse( sMacroPath ), UNO_QUERY );
if ( xUrl.is() )
{
sMacroName = xUrl->getName();
}
if ( xUrl.is() )
{
sMacroName = xUrl->getName();
}
}
......
......@@ -53,7 +53,7 @@
#include <com/sun/star/frame/XConfigManager.hpp>
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <com/sun/star/uri/XVndSunStarExpandUrl.hpp>
#include <com/sun/star/script/XInvocation.hpp>
#include <comphelper/locale.hxx>
......@@ -94,22 +94,9 @@ rtl::OUString Databases::expandURL( const rtl::OUString& aURL, Reference< uno::X
static Reference< util::XMacroExpander > xMacroExpander;
static Reference< uri::XUriReferenceFactory > xFac;
if( !xContext.is() )
return rtl::OUString();
if( !xMacroExpander.is() || !xFac.is() )
{
Reference< XMultiComponentFactory > xSMgr( xContext->getServiceManager(), UNO_QUERY );
xFac = Reference< uri::XUriReferenceFactory >(
xSMgr->createInstanceWithContext( rtl::OUString(
"com.sun.star.uri.UriReferenceFactory"), xContext ) , UNO_QUERY );
if( !xFac.is() )
{
throw RuntimeException(
::rtl::OUString( "Databases::expand(), could not instatiate UriReferenceFactory." ),
Reference< XInterface >() );
}
xFac = uri::UriReferenceFactory::create( xContext );
xMacroExpander = Reference< util::XMacroExpander >(
xContext->getValueByName(
......
......@@ -40,7 +40,7 @@
#include <comphelper/processfactory.hxx>
#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
#include <com/sun/star/util/XMacroExpander.hpp>
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <com/sun/star/uri/XVndSunStarExpandUrl.hpp>
#include <comphelper/locale.hxx>
#include <comphelper/string.hxx>
......@@ -1292,17 +1292,7 @@ rtl::OUString TreeFileIterator::expandURL( const rtl::OUString& aURL )
if( !xMacroExpander.is() || !xFac.is() )
{
Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager(), UNO_QUERY );
xFac = Reference< uri::XUriReferenceFactory >(
xSMgr->createInstanceWithContext( rtl::OUString(
"com.sun.star.uri.UriReferenceFactory"), m_xContext ) , UNO_QUERY );
if( !xFac.is() )
{
throw RuntimeException(
::rtl::OUString( "Databases::expand(), could not instatiate UriReferenceFactory." ),