bump product version to 4.1.6.2
[LibreOffice.git] / pyuno / source / module / pyuno.cxx
blob36f7c9221e92e00cf35084709fd6a3027c07a3d1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "pyuno_impl.hxx"
22 #include <rtl/strbuf.hxx>
23 #include <rtl/ustrbuf.hxx>
25 #include <osl/thread.h>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/lang/XTypeProvider.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/beans/XMaterialHolder.hpp>
32 using com::sun::star::uno::Sequence;
33 using com::sun::star::uno::Reference;
34 using com::sun::star::uno::XInterface;
35 using com::sun::star::uno::Any;
36 using com::sun::star::uno::makeAny;
37 using com::sun::star::uno::UNO_QUERY;
38 using com::sun::star::uno::Type;
39 using com::sun::star::uno::TypeClass;
40 using com::sun::star::uno::RuntimeException;
41 using com::sun::star::uno::Exception;
42 using com::sun::star::uno::XComponentContext;
43 using com::sun::star::lang::XSingleServiceFactory;
44 using com::sun::star::lang::XServiceInfo;
45 using com::sun::star::lang::XTypeProvider;
46 using com::sun::star::script::XTypeConverter;
47 using com::sun::star::script::XInvocation2;
48 using com::sun::star::beans::XMaterialHolder;
50 namespace pyuno
53 PyObject *PyUNO_str( PyObject * self );
55 void PyUNO_del (PyObject* self)
57 PyUNO* me = reinterpret_cast< PyUNO* > (self);
59 PyThreadDetach antiguard;
60 delete me->members;
62 PyObject_Del (self);
67 OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef , sal_Int32 mode ) SAL_THROW(())
69 OSL_ASSERT( pVal );
70 if (pTypeRef->eTypeClass == typelib_TypeClass_VOID)
71 return OUString("void");
73 OUStringBuffer buf( 64 );
74 buf.append( (sal_Unicode)'(' );
75 buf.append( pTypeRef->pTypeName );
76 buf.append( (sal_Unicode)')' );
78 switch (pTypeRef->eTypeClass)
80 case typelib_TypeClass_INTERFACE:
82 buf.append( "0x" );
83 buf.append( reinterpret_cast< sal_IntPtr >(*(void **)pVal), 16 );
84 if( VAL2STR_MODE_DEEP == mode )
86 buf.append( "{" ); Reference< XInterface > r = *( Reference< XInterface > * ) pVal;
87 Reference< XServiceInfo > serviceInfo( r, UNO_QUERY);
88 Reference< XTypeProvider > typeProvider(r,UNO_QUERY);
89 if( serviceInfo.is() )
91 buf.append("implementationName=" );
92 buf.append(serviceInfo->getImplementationName() );
93 buf.append(", supportedServices={" );
94 Sequence< OUString > seq = serviceInfo->getSupportedServiceNames();
95 for( int i = 0 ; i < seq.getLength() ; i ++ )
97 buf.append( seq[i] );
98 if( i +1 != seq.getLength() )
99 buf.append( "," );
101 buf.append("}");
104 if( typeProvider.is() )
106 buf.append(", supportedInterfaces={" );
107 Sequence< Type > seq (typeProvider->getTypes());
108 for( int i = 0 ; i < seq.getLength() ; i ++ )
110 buf.append(seq[i].getTypeName());
111 if( i +1 != seq.getLength() )
112 buf.append( "," );
114 buf.append("}");
116 buf.append( "}" );
119 break;
121 case typelib_TypeClass_UNION:
123 break;
125 case typelib_TypeClass_STRUCT:
126 case typelib_TypeClass_EXCEPTION:
128 buf.append( "{ " );
129 typelib_TypeDescription * pTypeDescr = 0;
130 TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
131 OSL_ASSERT( pTypeDescr );
133 typelib_CompoundTypeDescription * pCompType = (typelib_CompoundTypeDescription *)pTypeDescr;
134 sal_Int32 nDescr = pCompType->nMembers;
136 if (pCompType->pBaseTypeDescription)
138 buf.append( val2str( pVal, ((typelib_TypeDescription *)pCompType->pBaseTypeDescription)->pWeakRef,mode ) );
139 if (nDescr)
140 buf.append( ", " );
143 typelib_TypeDescriptionReference ** ppTypeRefs = pCompType->ppTypeRefs;
144 sal_Int32 * pMemberOffsets = pCompType->pMemberOffsets;
145 rtl_uString ** ppMemberNames = pCompType->ppMemberNames;
147 for ( sal_Int32 nPos = 0; nPos < nDescr; ++nPos )
149 buf.append( ppMemberNames[nPos] );
150 buf.append( " = " );
151 typelib_TypeDescription * pMemberType = 0;
152 TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[nPos] );
153 buf.append( val2str( (char *)pVal + pMemberOffsets[nPos], pMemberType->pWeakRef, mode ) );
154 TYPELIB_DANGER_RELEASE( pMemberType );
155 if (nPos < (nDescr -1))
156 buf.append( ", " );
159 TYPELIB_DANGER_RELEASE( pTypeDescr );
161 buf.append( " }" );
162 break;
164 case typelib_TypeClass_SEQUENCE:
166 typelib_TypeDescription * pTypeDescr = 0;
167 TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
169 uno_Sequence * pSequence = *(uno_Sequence **)pVal;
170 typelib_TypeDescription * pElementTypeDescr = 0;
171 TYPELIB_DANGER_GET( &pElementTypeDescr, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType );
173 sal_Int32 nElementSize = pElementTypeDescr->nSize;
174 sal_Int32 nElements = pSequence->nElements;
176 if (nElements)
178 buf.append( "{ " );
179 char * pElements = pSequence->elements;
180 for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos )
182 buf.append( val2str( pElements + (nElementSize * nPos), pElementTypeDescr->pWeakRef, mode ) );
183 if (nPos < (nElements -1))
184 buf.append( ", " );
186 buf.append( " }" );
188 else
190 buf.append( "{}" );
192 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
193 TYPELIB_DANGER_RELEASE( pTypeDescr );
194 break;
196 case typelib_TypeClass_ANY:
197 buf.append( "{ " );
198 buf.append( val2str( ((uno_Any *)pVal)->pData,
199 ((uno_Any *)pVal)->pType ,
200 mode) );
201 buf.append( " }" );
202 break;
203 case typelib_TypeClass_TYPE:
204 buf.append( (*(typelib_TypeDescriptionReference **)pVal)->pTypeName );
205 break;
206 case typelib_TypeClass_STRING:
207 buf.append( (sal_Unicode)'\"' );
208 buf.append( *(rtl_uString **)pVal );
209 buf.append( (sal_Unicode)'\"' );
210 break;
211 case typelib_TypeClass_ENUM:
213 typelib_TypeDescription * pTypeDescr = 0;
214 TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
216 sal_Int32 * pValues = ((typelib_EnumTypeDescription *)pTypeDescr)->pEnumValues;
217 sal_Int32 nPos = ((typelib_EnumTypeDescription *)pTypeDescr)->nEnumValues;
218 while (nPos--)
220 if (pValues[nPos] == *(int *)pVal)
221 break;
223 if (nPos >= 0)
224 buf.append( ((typelib_EnumTypeDescription *)pTypeDescr)->ppEnumNames[nPos] );
225 else
226 buf.append( (sal_Unicode)'?' );
228 TYPELIB_DANGER_RELEASE( pTypeDescr );
229 break;
231 case typelib_TypeClass_BOOLEAN:
232 if (*(sal_Bool *)pVal)
233 buf.append( "true" );
234 else
235 buf.append( "false" );
236 break;
237 case typelib_TypeClass_CHAR:
238 buf.append( (sal_Unicode)'\'' );
239 buf.append( *(sal_Unicode *)pVal );
240 buf.append( (sal_Unicode)'\'' );
241 break;
242 case typelib_TypeClass_FLOAT:
243 buf.append( *(float *)pVal );
244 break;
245 case typelib_TypeClass_DOUBLE:
246 buf.append( *(double *)pVal );
247 break;
248 case typelib_TypeClass_BYTE:
249 buf.append( "0x" );
250 buf.append( (sal_Int32)*(sal_Int8 *)pVal, 16 );
251 break;
252 case typelib_TypeClass_SHORT:
253 buf.append( "0x" );
254 buf.append( (sal_Int32)*(sal_Int16 *)pVal, 16 );
255 break;
256 case typelib_TypeClass_UNSIGNED_SHORT:
257 buf.append( "0x" );
258 buf.append( (sal_Int32)*(sal_uInt16 *)pVal, 16 );
259 break;
260 case typelib_TypeClass_LONG:
261 buf.append( "0x" );
262 buf.append( *(sal_Int32 *)pVal, 16 );
263 break;
264 case typelib_TypeClass_UNSIGNED_LONG:
265 buf.append( "0x" );
266 buf.append( (sal_Int64)*(sal_uInt32 *)pVal, 16 );
267 break;
268 case typelib_TypeClass_HYPER:
269 case typelib_TypeClass_UNSIGNED_HYPER:
270 buf.append( "0x" );
271 #if defined(__GNUC__) && defined(SPARC)
272 // I guess this really should check if there are strict alignment
273 // requirements, not just "GCC on SPARC".
275 sal_Int64 aVal;
276 *(sal_Int32 *)&aVal = *(sal_Int32 *)pVal;
277 *((sal_Int32 *)&aVal +1)= *((sal_Int32 *)pVal +1);
278 buf.append( aVal, 16 );
280 #else
281 buf.append( *(sal_Int64 *)pVal, 16 );
282 #endif
283 break;
285 case typelib_TypeClass_VOID:
286 case typelib_TypeClass_ARRAY:
287 case typelib_TypeClass_UNKNOWN:
288 case typelib_TypeClass_SERVICE:
289 case typelib_TypeClass_MODULE:
290 default:
291 buf.append( (sal_Unicode)'?' );
294 return buf.makeStringAndClear();
298 PyObject *PyUNO_repr( PyObject * self )
300 PyUNO *me = (PyUNO * ) self;
301 PyObject * ret = 0;
303 if( me->members->wrappedObject.getValueType().getTypeClass()
304 == com::sun::star::uno::TypeClass_EXCEPTION )
306 Reference< XMaterialHolder > rHolder(me->members->xInvocation,UNO_QUERY);
307 if( rHolder.is() )
309 Any a = rHolder->getMaterial();
310 Exception e;
311 a >>= e;
312 ret = ustring2PyUnicode(e.Message ).getAcquired();
315 else
317 ret = PyUNO_str( self );
319 return ret;
322 PyObject *PyUNO_invoke( PyObject *object, const char *name , PyObject *args )
324 PyRef ret;
327 Runtime runtime;
329 PyRef paras,callable;
330 if( PyObject_IsInstance( object, getPyUnoClass().get() ) )
332 PyUNO* me = (PyUNO*) object;
333 OUString attrName = OUString::createFromAscii(name);
334 if (! me->members->xInvocation->hasMethod (attrName))
336 OUStringBuffer buf;
337 buf.append( "Attribute " );
338 buf.append( attrName );
339 buf.append( " unknown" );
340 throw RuntimeException( buf.makeStringAndClear(), Reference< XInterface > () );
342 callable = PyUNO_callable_new (
343 me->members->xInvocation,
344 attrName,
345 runtime.getImpl()->cargo->xInvocation,
346 runtime.getImpl()->cargo->xTypeConverter,
347 ACCEPT_UNO_ANY);
348 paras = args;
350 else
352 // clean the tuple from uno.Any !
353 int size = PyTuple_Size( args );
354 { // for CC, keeping ref-count of tuple being 1
355 paras = PyRef(PyTuple_New( size ), SAL_NO_ACQUIRE);
357 for( int i = 0 ; i < size ;i ++ )
359 PyObject * element = PyTuple_GetItem( args , i );
360 if( PyObject_IsInstance( element , getAnyClass( runtime ).get() ) )
362 element = PyObject_GetAttrString(
363 element, "value" );
365 else
367 Py_XINCREF( element );
369 PyTuple_SetItem( paras.get(), i , element );
371 callable = PyRef( PyObject_GetAttrString( object , (char*)name ), SAL_NO_ACQUIRE );
372 if( !callable.is() )
373 return 0;
375 ret = PyRef( PyObject_CallObject( callable.get(), paras.get() ), SAL_NO_ACQUIRE );
377 catch (const ::com::sun::star::lang::IllegalArgumentException &e)
379 raisePyExceptionWithAny( com::sun::star::uno::makeAny( e ) );
381 catch (const ::com::sun::star::script::CannotConvertException &e)
383 raisePyExceptionWithAny( com::sun::star::uno::makeAny( e ) );
385 catch (const ::com::sun::star::uno::RuntimeException &e)
387 raisePyExceptionWithAny( com::sun::star::uno::makeAny( e ) );
389 catch (const ::com::sun::star::uno::Exception &e)
391 raisePyExceptionWithAny( com::sun::star::uno::makeAny( e ) );
394 return ret.getAcquired();
397 PyObject *PyUNO_str( PyObject * self )
399 PyUNO *me = ( PyUNO * ) self;
401 OStringBuffer buf;
404 if( me->members->wrappedObject.getValueType().getTypeClass()
405 == com::sun::star::uno::TypeClass_STRUCT ||
406 me->members->wrappedObject.getValueType().getTypeClass()
407 == com::sun::star::uno::TypeClass_EXCEPTION)
409 Reference< XMaterialHolder > rHolder(me->members->xInvocation,UNO_QUERY);
410 if( rHolder.is() )
412 PyThreadDetach antiguard;
413 Any a = rHolder->getMaterial();
414 OUString s = val2str( (void*) a.getValue(), a.getValueType().getTypeLibType() );
415 buf.append( OUStringToOString(s,RTL_TEXTENCODING_ASCII_US) );
418 else
420 // a common UNO object
421 PyThreadDetach antiguard;
422 buf.append( "pyuno object " );
424 OUString s = val2str( (void*)me->members->wrappedObject.getValue(),
425 me->members->wrappedObject.getValueType().getTypeLibType() );
426 buf.append( OUStringToOString(s,RTL_TEXTENCODING_ASCII_US) );
429 return PyStr_FromString( buf.getStr());
432 PyObject* PyUNO_dir (PyObject* self)
434 PyUNO* me = (PyUNO*) self;
436 PyObject* member_list = NULL;
437 Sequence<OUString> oo_member_list;
441 oo_member_list = me->members->xInvocation->getMemberNames ();
442 member_list = PyList_New (oo_member_list.getLength ());
443 for (int i = 0; i < oo_member_list.getLength (); i++)
445 // setitem steals a reference
446 PyList_SetItem (member_list, i, ustring2PyString(oo_member_list[i]).getAcquired() );
449 catch( const RuntimeException &e )
451 raisePyExceptionWithAny( makeAny(e) );
454 return member_list;
458 PyObject* PyUNO_getattr (PyObject* self, char* name)
460 PyUNO* me;
465 Runtime runtime;
467 me = (PyUNO*) self;
468 if (strcmp (name, "__dict__") == 0)
470 Py_INCREF (Py_TYPE(me)->tp_dict);
471 return Py_TYPE(me)->tp_dict;
473 if (strcmp (name, "__class__") == 0)
475 if( me->members->wrappedObject.getValueTypeClass() ==
476 com::sun::star::uno::TypeClass_STRUCT ||
477 me->members->wrappedObject.getValueTypeClass() ==
478 com::sun::star::uno::TypeClass_EXCEPTION )
480 return getClass(
481 me->members->wrappedObject.getValueType().getTypeName(), runtime ).getAcquired();
483 Py_INCREF (Py_None);
484 return Py_None;
487 OUString attrName( OUString::createFromAscii( name ) );
488 //We need to find out if it's a method...
489 if (me->members->xInvocation->hasMethod (attrName))
491 //Create a callable object to invoke this...
492 PyRef ret = PyUNO_callable_new (
493 me->members->xInvocation,
494 attrName,
495 runtime.getImpl()->cargo->xInvocation,
496 runtime.getImpl()->cargo->xTypeConverter);
497 Py_XINCREF( ret.get() );
498 return ret.get();
502 //or a property
503 if (me->members->xInvocation->hasProperty ( attrName))
505 //Return the value of the property
506 Any anyRet;
508 PyThreadDetach antiguard;
509 anyRet = me->members->xInvocation->getValue (attrName);
511 PyRef ret = runtime.any2PyObject(anyRet);
512 Py_XINCREF( ret.get() );
513 return ret.get();
516 //or else...
517 PyErr_SetString (PyExc_AttributeError, name);
519 catch( const com::sun::star::reflection::InvocationTargetException & e )
521 raisePyExceptionWithAny( makeAny(e.TargetException) );
523 catch( const com::sun::star::beans::UnknownPropertyException & e )
525 raisePyExceptionWithAny( makeAny(e) );
527 catch( const com::sun::star::lang::IllegalArgumentException &e )
529 raisePyExceptionWithAny( makeAny(e) );
531 catch( const com::sun::star::script::CannotConvertException &e )
533 raisePyExceptionWithAny( makeAny(e) );
535 catch( const RuntimeException &e )
537 raisePyExceptionWithAny( makeAny(e) );
540 return NULL;
543 int PyUNO_setattr (PyObject* self, char* name, PyObject* value)
545 PyUNO* me;
547 me = (PyUNO*) self;
550 Runtime runtime;
551 Any val= runtime.pyObject2Any(value, ACCEPT_UNO_ANY);
553 OUString attrName( OUString::createFromAscii( name ) );
555 PyThreadDetach antiguard;
556 if (me->members->xInvocation->hasProperty (attrName))
558 me->members->xInvocation->setValue (attrName, val);
559 return 0; //Keep with Python's boolean system
563 catch( const com::sun::star::reflection::InvocationTargetException & e )
565 raisePyExceptionWithAny( makeAny(e.TargetException) );
566 return 1;
568 catch( const com::sun::star::beans::UnknownPropertyException & e )
570 raisePyExceptionWithAny( makeAny(e) );
571 return 1;
573 catch( const com::sun::star::script::CannotConvertException &e )
575 raisePyExceptionWithAny( makeAny(e) );
576 return 1;
578 catch( const RuntimeException & e )
580 raisePyExceptionWithAny( makeAny( e ) );
581 return 1;
583 PyErr_SetString (PyExc_AttributeError, name);
584 return 1; //as above.
587 // ensure object identity and struct equality
588 static PyObject* PyUNO_cmp( PyObject *self, PyObject *that, int op )
590 PyObject *result;
592 if(op != Py_EQ && op != Py_NE)
594 PyErr_SetString(PyExc_TypeError, "only '==' and '!=' comparisions are defined");
595 return 0;
597 if( self == that )
599 result = (op == Py_EQ ? Py_True : Py_False);
600 Py_INCREF(result);
601 return result;
605 Runtime runtime;
606 if( PyObject_IsInstance( that, getPyUnoClass().get() ) )
609 PyUNO *me = reinterpret_cast< PyUNO*> ( self );
610 PyUNO *other = reinterpret_cast< PyUNO *> (that );
611 com::sun::star::uno::TypeClass tcMe = me->members->wrappedObject.getValueTypeClass();
612 com::sun::star::uno::TypeClass tcOther = other->members->wrappedObject.getValueTypeClass();
614 if( tcMe == tcOther )
616 if( tcMe == com::sun::star::uno::TypeClass_STRUCT ||
617 tcMe == com::sun::star::uno::TypeClass_EXCEPTION )
619 Reference< XMaterialHolder > xMe( me->members->xInvocation,UNO_QUERY);
620 Reference< XMaterialHolder > xOther( other->members->xInvocation,UNO_QUERY );
621 if( xMe->getMaterial() == xOther->getMaterial() )
623 result = (op == Py_EQ ? Py_True : Py_False);
624 Py_INCREF(result);
625 return result;
628 else if( tcMe == com::sun::star::uno::TypeClass_INTERFACE )
630 if( me->members->wrappedObject == other->members->wrappedObject )
632 result = (op == Py_EQ ? Py_True : Py_False);
633 Py_INCREF(result);
634 return result;
640 catch( const com::sun::star::uno::RuntimeException & e)
642 raisePyExceptionWithAny( makeAny( e ) );
645 result = (op == Py_EQ ? Py_False : Py_True);
646 Py_INCREF(result);
647 return result;
650 static PyMethodDef PyUNOMethods[] =
652 {"__dir__", (PyCFunction)PyUNO_dir, METH_NOARGS, NULL},
653 {NULL, NULL, 0, NULL}
657 /* Python 2 has a tp_flags value for rich comparisons. Python 3 does not (on by default) */
658 #ifdef Py_TPFLAGS_HAVE_RICHCOMPARE
659 #define TP_FLAGS (Py_TPFLAGS_HAVE_RICHCOMPARE)
660 #else
661 #define TP_FLAGS 0
662 #endif
664 static PyTypeObject PyUNOType =
666 PyVarObject_HEAD_INIT( &PyType_Type, 0 )
667 "pyuno",
668 sizeof (PyUNO),
670 (destructor) PyUNO_del,
671 (printfunc) 0,
672 (getattrfunc) PyUNO_getattr,
673 (setattrfunc) PyUNO_setattr,
674 /* this type does not exist in Python 3: (cmpfunc) */ 0,
675 (reprfunc) PyUNO_repr,
679 (hashfunc) 0,
680 (ternaryfunc) 0,
681 (reprfunc) PyUNO_str,
682 (getattrofunc)0,
683 (setattrofunc)0,
684 NULL,
685 TP_FLAGS,
686 NULL,
687 (traverseproc)0,
688 (inquiry)0,
689 (richcmpfunc) PyUNO_cmp,
691 (getiterfunc)0,
692 (iternextfunc)0,
693 PyUNOMethods,
694 NULL,
695 NULL,
696 NULL,
697 NULL,
698 (descrgetfunc)0,
699 (descrsetfunc)0,
701 (initproc)0,
702 (allocfunc)0,
703 (newfunc)0,
704 (freefunc)0,
705 (inquiry)0,
706 NULL,
707 NULL,
708 NULL,
709 NULL,
710 NULL,
711 (destructor)0
712 #if PY_VERSION_HEX >= 0x02060000
714 #endif
717 int PyUNO_initType()
719 return PyType_Ready(&PyUNOType);
722 PyRef getPyUnoClass()
724 return PyRef( reinterpret_cast< PyObject * > ( &PyUNOType ) );
727 PyObject* PyUNO_new (
728 const Any & targetInterface, const Reference<XSingleServiceFactory> &ssf)
730 Reference<XInterface> tmp_interface;
732 targetInterface >>= tmp_interface;
734 if (!tmp_interface.is ())
736 // empty reference !
737 Py_INCREF( Py_None );
738 return Py_None;
740 return PyUNO_new_UNCHECKED (targetInterface, ssf);
744 PyObject* PyUNO_new_UNCHECKED (
745 const Any &targetInterface,
746 const Reference<XSingleServiceFactory> &ssf )
748 PyUNO* self;
749 Sequence<Any> arguments (1);
750 Reference<XInterface> tmp_interface;
752 self = PyObject_New (PyUNO, &PyUNOType);
753 if (self == NULL)
754 return NULL; // == error
755 self->members = new PyUNOInternals();
757 arguments[0] <<= targetInterface;
759 PyThreadDetach antiguard;
760 tmp_interface = ssf->createInstanceWithArguments (arguments);
762 if (!tmp_interface.is ())
764 Py_INCREF( Py_None );
765 return Py_None;
768 Reference<XInvocation2> tmp_invocation (tmp_interface, UNO_QUERY);
769 if (!tmp_invocation.is()) {
770 throw RuntimeException (OUString::createFromAscii (
771 "XInvocation2 not implemented, cannot interact with object"),
772 Reference< XInterface > ());
775 self->members->xInvocation = tmp_invocation;
776 self->members->wrappedObject = targetInterface;
778 return (PyObject*) self;
783 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */