summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-05-14 09:52:58 +0200
committerNoel Grandin <noel@peralex.com>2013-05-14 13:39:29 +0200
commit8bf8a2f3493273cb408ef86c5d971e18fa8fc40b (patch)
tree1b963951e586f7e60dd212febb0985213330421a
parentsal_Int*/sal_uInt* to bool (diff)
downloadcore-8bf8a2f3493273cb408ef86c5d971e18fa8fc40b.tar.gz
core-8bf8a2f3493273cb408ef86c5d971e18fa8fc40b.zip
fdo#46808, Convert script::InvocationAdapterFactory to new style
Change-Id: I2fe24c863f4c43471f46032ed15fcd5b98863fc1
-rw-r--r--basic/source/classes/sbunoobj.cxx64
-rw-r--r--eventattacher/source/eventattacher.cxx43
-rw-r--r--pyuno/source/module/pyuno_runtime.cxx11
-rw-r--r--udkapi/UnoApi_udkapi.mk2
-rw-r--r--udkapi/com/sun/star/script/InvocationAdapterFactory.idl18
-rw-r--r--udkapi/type_reference/udkapi.rdbbin715264 -> 716288 bytes
6 files changed, 53 insertions, 85 deletions
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index f16fc449c88c..001df2aa0b58 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -49,6 +49,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/Introspection.hpp>
#include <com/sun/star/script/BasicErrorException.hpp>
+#include <com/sun/star/script/InvocationAdapterFactory.hpp>
#include <com/sun/star/script/XAllListener.hpp>
#include <com/sun/star/script/XInvocationAdapterFactory.hpp>
#include <com/sun/star/script/Converter.hpp>
@@ -3028,16 +3029,13 @@ void RTL_Impl_CreateUnoService( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWri
// search for the service and instatiate it
Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() );
Reference< XInterface > xInterface;
- if ( xFactory.is() )
+ try
{
- try
- {
- xInterface = xFactory->createInstance( aServiceName );
- }
- catch( const Exception& )
- {
- implHandleAnyException( ::cppu::getCaughtException() );
- }
+ xInterface = xFactory->createInstance( aServiceName );
+ }
+ catch( const Exception& )
+ {
+ implHandleAnyException( ::cppu::getCaughtException() );
}
SbxVariableRef refVar = rPar.Get(0);
@@ -3086,16 +3084,13 @@ void RTL_Impl_CreateUnoServiceWithArguments( StarBASIC* pBasic, SbxArray& rPar,
// search for the service and instatiate it
Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() );
Reference< XInterface > xInterface;
- if ( xFactory.is() )
+ try
{
- try
- {
- xInterface = xFactory->createInstanceWithArguments( aServiceName, aArgs );
- }
- catch( const Exception& )
- {
- implHandleAnyException( ::cppu::getCaughtException() );
- }
+ xInterface = xFactory->createInstanceWithArguments( aServiceName, aArgs );
+ }
+ catch( const Exception& )
+ {
+ implHandleAnyException( ::cppu::getCaughtException() );
}
SbxVariableRef refVar = rPar.Get(0);
@@ -3131,19 +3126,12 @@ void RTL_Impl_GetProcessServiceManager( StarBASIC* pBasic, SbxArray& rPar, sal_B
// get the global service manager
Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() );
- if( xFactory.is() )
- {
- Any aAny;
- aAny <<= xFactory;
+ Any aAny;
+ aAny <<= xFactory;
- // Create a SbUnoObject out of it and return it
- SbUnoObjectRef xUnoObj = new SbUnoObject( OUString( "ProcessServiceManager" ), aAny );
- refVar->PutObject( (SbUnoObject*)xUnoObj );
- }
- else
- {
- refVar->PutObject( NULL );
- }
+ // Create a SbUnoObject out of it and return it
+ SbUnoObjectRef xUnoObj = new SbUnoObject( OUString( "ProcessServiceManager" ), aAny );
+ refVar->PutObject( (SbUnoObject*)xUnoObj );
}
void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
@@ -4060,7 +4048,7 @@ private:
// Function to replace AllListenerAdapterService::createAllListerAdapter
Reference< XInterface > createAllListenerAdapter
(
- const Reference< XInvocationAdapterFactory >& xInvocationAdapterFactory,
+ const Reference< XInvocationAdapterFactory2 >& xInvocationAdapterFactory,
const Reference< XIdlClass >& xListenerType,
const Reference< XAllListener >& xListener,
const Any& Helper
@@ -4069,10 +4057,12 @@ Reference< XInterface > createAllListenerAdapter
Reference< XInterface > xAdapter;
if( xInvocationAdapterFactory.is() && xListenerType.is() && xListener.is() )
{
- Reference< XInvocation > xInvocationToAllListenerMapper =
+ Reference< XInvocation > xInvocationToAllListenerMapper =
(XInvocation*)new InvocationToAllListenerMapper( xListenerType, xListener, Helper );
Type aListenerType( xListenerType->getTypeClass(), xListenerType->getName() );
- xAdapter = xInvocationAdapterFactory->createAdapter( xInvocationToAllListenerMapper, aListenerType );
+ Sequence<Type> arg2(1);
+ arg2[0] = aListenerType;
+ xAdapter = xInvocationAdapterFactory->createAdapter( xInvocationToAllListenerMapper, arg2 );
}
return xAdapter;
}
@@ -4209,9 +4199,7 @@ void SbRtl_CreateUnoListener( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite
return;
// get the AllListenerAdapterService
- Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() );
- if( !xFactory.is() )
- return;
+ Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
// search the class
Reference< XIdlClass > xClass = xCoreReflection->forName( aListenerClassName );
@@ -4219,8 +4207,8 @@ void SbRtl_CreateUnoListener( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite
return;
// From 1999-11-30: get the InvocationAdapterFactory
- Reference< XInvocationAdapterFactory > xInvocationAdapterFactory = Reference< XInvocationAdapterFactory >(
- xFactory->createInstance( OUString("com.sun.star.script.InvocationAdapterFactory") ), UNO_QUERY );
+ Reference< XInvocationAdapterFactory2 > xInvocationAdapterFactory =
+ InvocationAdapterFactory::create( xContext );
BasicAllListener_Impl * p;
Reference< XAllListener > xAllLst = p = new BasicAllListener_Impl( aPrefixName );
diff --git a/eventattacher/source/eventattacher.cxx b/eventattacher/source/eventattacher.cxx
index 24697881fc1b..09275b0dae4d 100644
--- a/eventattacher/source/eventattacher.cxx
+++ b/eventattacher/source/eventattacher.cxx
@@ -27,7 +27,7 @@
#include <com/sun/star/script/XEventAttacher2.hpp>
#include <com/sun/star/script/Converter.hpp>
#include <com/sun/star/script/XAllListener.hpp>
-#include <com/sun/star/script/XInvocationAdapterFactory.hpp>
+#include <com/sun/star/script/InvocationAdapterFactory.hpp>
#include <com/sun/star/reflection/theCoreReflection.hpp>
#include <com/sun/star/reflection/XIdlReflection.hpp>
@@ -86,7 +86,7 @@ private:
// Function to replace AllListenerAdapterService::createAllListerAdapter
Reference< XInterface > createAllListenerAdapter
(
- const Reference< XInvocationAdapterFactory >& xInvocationAdapterFactory,
+ const Reference< XInvocationAdapterFactory2 >& xInvocationAdapterFactory,
const Reference< XIdlClass >& xListenerType,
const Reference< XAllListener >& xListener,
const Any& Helper
@@ -98,7 +98,9 @@ Reference< XInterface > createAllListenerAdapter
Reference< XInvocation > xInvocationToAllListenerMapper =
(XInvocation*)new InvocationToAllListenerMapper( xListenerType, xListener, Helper );
Type aListenerType( xListenerType->getTypeClass(), xListenerType->getName());
- xAdapter = xInvocationAdapterFactory->createAdapter( xInvocationToAllListenerMapper, aListenerType );
+ Sequence<Type> arg2(1);
+ arg2[0] = aListenerType;
+ xAdapter = xInvocationAdapterFactory->createAdapter( xInvocationToAllListenerMapper, arg2 );
}
return xAdapter;
}
@@ -209,7 +211,7 @@ sal_Bool SAL_CALL InvocationToAllListenerMapper::hasProperty(const OUString& Nam
class EventAttacherImpl : public WeakImplHelper3 < XEventAttacher2, XInitialization, XServiceInfo >
{
public:
- EventAttacherImpl( const Reference< XMultiServiceFactory >& );
+ EventAttacherImpl( const Reference< XComponentContext >& );
~EventAttacherImpl();
// XServiceInfo
@@ -251,7 +253,7 @@ public:
private:
Reference<XEventListener> attachListenerForTarget(
const Reference<XIntrospectionAccess>& xAccess,
- const Reference<XInvocationAdapterFactory>& xInvocationAdapterFactory,
+ const Reference<XInvocationAdapterFactory2>& xInvocationAdapterFactory,
const Reference<XAllListener>& xAllListener,
const Any& aObject,
const Any& aHelper,
@@ -265,24 +267,24 @@ private:
private:
Mutex m_aMutex;
- Reference< XMultiServiceFactory > m_xSMgr;
+ Reference< XComponentContext > m_xContext;
// Save Services
Reference< XIntrospection > m_xIntrospection;
Reference< XIdlReflection > m_xReflection;
Reference< XTypeConverter > m_xConverter;
- Reference< XInvocationAdapterFactory > m_xInvocationAdapterFactory;
+ Reference< XInvocationAdapterFactory2 > m_xInvocationAdapterFactory;
// needed services
Reference< XIntrospection > getIntrospection() throw( Exception );
Reference< XIdlReflection > getReflection() throw( Exception );
- Reference< XInvocationAdapterFactory > getInvocationAdapterService() throw( Exception );
+ Reference< XInvocationAdapterFactory2 > getInvocationAdapterService() throw( Exception );
};
//*************************************************************************
-EventAttacherImpl::EventAttacherImpl( const Reference< XMultiServiceFactory >& rSMgr )
- : m_xSMgr( rSMgr )
+EventAttacherImpl::EventAttacherImpl( const Reference< XComponentContext >& rxContext )
+ : m_xContext( rxContext )
{
}
@@ -295,7 +297,7 @@ EventAttacherImpl::~EventAttacherImpl()
Reference< XInterface > SAL_CALL EventAttacherImpl_CreateInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( Exception )
{
Reference< XInterface > xRet;
- XEventAttacher *pEventAttacher = (XEventAttacher*) new EventAttacherImpl(rSMgr);
+ XEventAttacher *pEventAttacher = (XEventAttacher*) new EventAttacherImpl( comphelper::getComponentContext(rSMgr) );
if (pEventAttacher)
{
@@ -349,7 +351,7 @@ void SAL_CALL EventAttacherImpl::initialize(const Sequence< Any >& Arguments) th
throw IllegalArgumentException();
// InvocationAdapter service ?
- Reference< XInvocationAdapterFactory > xALAS;
+ Reference< XInvocationAdapterFactory2 > xALAS;
pArray[i] >>= xALAS;
if( xALAS.is() )
{
@@ -394,7 +396,7 @@ Reference< XIntrospection > EventAttacherImpl::getIntrospection() throw( Excepti
Guard< Mutex > aGuard( m_aMutex );
if( !m_xIntrospection.is() )
{
- m_xIntrospection = Introspection::create( comphelper::getComponentContext(m_xSMgr) );
+ m_xIntrospection = Introspection::create( m_xContext );
}
return m_xIntrospection;
}
@@ -406,20 +408,19 @@ Reference< XIdlReflection > EventAttacherImpl::getReflection() throw( Exception
Guard< Mutex > aGuard( m_aMutex );
if( !m_xReflection.is() )
{
- m_xReflection = theCoreReflection::get(comphelper::getComponentContext(m_xSMgr));
+ m_xReflection = theCoreReflection::get(m_xContext);
}
return m_xReflection;
}
//*************************************************************************
//*** Private helper methods ***
-Reference< XInvocationAdapterFactory > EventAttacherImpl::getInvocationAdapterService() throw( Exception )
+Reference< XInvocationAdapterFactory2 > EventAttacherImpl::getInvocationAdapterService() throw( Exception )
{
Guard< Mutex > aGuard( m_aMutex );
if( !m_xInvocationAdapterFactory.is() )
{
- Reference< XInterface > xIFace( m_xSMgr->createInstance( OUString("com.sun.star.script.InvocationAdapterFactory") ) );
- m_xInvocationAdapterFactory = Reference< XInvocationAdapterFactory >( xIFace, UNO_QUERY );
+ m_xInvocationAdapterFactory = InvocationAdapterFactory::create(m_xContext);
}
return m_xInvocationAdapterFactory;
}
@@ -432,7 +433,7 @@ Reference< XTypeConverter > EventAttacherImpl::getConverter() throw( Exception )
Guard< Mutex > aGuard( m_aMutex );
if( !m_xConverter.is() )
{
- m_xConverter = Converter::create(comphelper::getComponentContext(m_xSMgr));
+ m_xConverter = Converter::create(m_xContext);
}
return m_xConverter;
}
@@ -582,7 +583,7 @@ Reference< XEventListener > EventAttacherImpl::attachListener
if( !xObject.is() || !AllListener.is() )
throw IllegalArgumentException();
- Reference< XInvocationAdapterFactory > xInvocationAdapterFactory = getInvocationAdapterService();
+ Reference< XInvocationAdapterFactory2 > xInvocationAdapterFactory = getInvocationAdapterService();
if( !xInvocationAdapterFactory.is() )
throw ServiceNotRegisteredException();
@@ -612,7 +613,7 @@ Reference< XEventListener > EventAttacherImpl::attachListener
Reference<XEventListener> EventAttacherImpl::attachListenerForTarget(
const Reference<XIntrospectionAccess>& xAccess,
- const Reference<XInvocationAdapterFactory>& xInvocationAdapterFactory,
+ const Reference<XInvocationAdapterFactory2>& xInvocationAdapterFactory,
const Reference<XAllListener>& xAllListener,
const Any& aObject,
const Any& aHelper,
@@ -725,7 +726,7 @@ Sequence< Reference<XEventListener> > EventAttacherImpl::attachListeners(
if (!xObject.is())
throw IllegalArgumentException();
- Reference< XInvocationAdapterFactory > xInvocationAdapterFactory = getInvocationAdapterService();
+ Reference< XInvocationAdapterFactory2 > xInvocationAdapterFactory = getInvocationAdapterService();
if( !xInvocationAdapterFactory.is() )
throw ServiceNotRegisteredException();
diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx
index 15615ba48dcb..96d8c15fc795 100644
--- a/pyuno/source/module/pyuno_runtime.cxx
+++ b/pyuno/source/module/pyuno_runtime.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/beans/XMaterialHolder.hpp>
#include <com/sun/star/beans/Introspection.hpp>
#include <com/sun/star/script/Converter.hpp>
+#include <com/sun/star/script/InvocationAdapterFactory.hpp>
#include <com/sun/star/reflection/theCoreReflection.hpp>
@@ -267,15 +268,7 @@ PyRef stRuntimeImpl::create( const Reference< XComponentContext > &ctx )
c->xCoreReflection = theCoreReflection::get(ctx);
- c->xAdapterFactory = Reference< XInvocationAdapterFactory2 > (
- ctx->getServiceManager()->createInstanceWithContext(
- OUString( "com.sun.star.script.InvocationAdapterFactory" ),
- ctx ),
- UNO_QUERY );
- if( ! c->xAdapterFactory.is() )
- throw RuntimeException(
- OUString( "pyuno: couldn't instantiate invocation adapter factory service" ),
- Reference< XInterface > () );
+ c->xAdapterFactory = css::script::InvocationAdapterFactory::create(ctx);
c->xIntrospection = Introspection::create(ctx);
diff --git a/udkapi/UnoApi_udkapi.mk b/udkapi/UnoApi_udkapi.mk
index 011e4872933f..5e723a17ad59 100644
--- a/udkapi/UnoApi_udkapi.mk
+++ b/udkapi/UnoApi_udkapi.mk
@@ -88,7 +88,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,udkapi,udkapi/com/sun/star/registr
))
$(eval $(call gb_UnoApi_add_idlfiles_noheader,udkapi,udkapi/com/sun/star/script,\
Engine \
- InvocationAdapterFactory \
JavaScript \
))
$(eval $(call gb_UnoApi_add_idlfiles_noheader,udkapi,udkapi/com/sun/star/util,\
@@ -137,6 +136,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,udkapi,udkapi/com/sun/star/script,\
AllListenerAdapter \
Converter \
Invocation \
+ InvocationAdapterFactory \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,udkapi,udkapi/com/sun/star/uno,\
NamingService \
diff --git a/udkapi/com/sun/star/script/InvocationAdapterFactory.idl b/udkapi/com/sun/star/script/InvocationAdapterFactory.idl
index 200872843a38..766a2d04ee94 100644
--- a/udkapi/com/sun/star/script/InvocationAdapterFactory.idl
+++ b/udkapi/com/sun/star/script/InvocationAdapterFactory.idl
@@ -19,12 +19,9 @@
#ifndef __com_sun_star_script_InvocationAdapterFactory_idl__
#define __com_sun_star_script_InvocationAdapterFactory_idl__
-#include <com/sun/star/script/XInvocationAdapterFactory.idl>
#include <com/sun/star/script/XInvocationAdapterFactory2.idl>
-
-
- module com { module sun { module star { module script {
+module com { module sun { module star { module script {
/** Provides functionality to create an adapter that supports (a)
special interface type(s) and maps calls to the interface's
@@ -43,18 +40,7 @@
<type scope="com::sun::star::script">XInvocationAdapterFactory2</type>.
</p>
*/
-published service InvocationAdapterFactory
-{
- /** Interface for creating adapter objects.
- This interface is deprecated. Use <type>XInvocationAdapterFactory2</type>.
- @deprecated
- */
- interface com::sun::star::script::XInvocationAdapterFactory;
-
- /** Interface for creating adapter objects.
- */
- interface com::sun::star::script::XInvocationAdapterFactory2;
-};
+published service InvocationAdapterFactory : XInvocationAdapterFactory2;
}; }; }; };
diff --git a/udkapi/type_reference/udkapi.rdb b/udkapi/type_reference/udkapi.rdb
index 469512a5700f..f1f890b456e3 100644
--- a/udkapi/type_reference/udkapi.rdb
+++ b/udkapi/type_reference/udkapi.rdb
Binary files differ