Re: [Libreoffice] [GSOC] Java > Python, problem with uno.invoke

2011-05-30 Thread Michael Meeks
Hi John,

On Fri, 2011-05-27 at 22:12 -0700, John LeMoyne Castle wrote:
> I think your Java->Python porting project is awesome.  ...

Wow - and your feedback is brilliant :-) it would be wonderful to have
you working with Xisco on this, and/or helping to mentor if Bjoern is up
for that :-)

I guess if you're building LibreOffice, it is well worth configuring
with the --enable-ext-scripting-python and --with-extension-integration
to make that work more pleasantly.

AFAIR ooinstall doesn't install those extensions either (which is
something of a disaster), so getting python to work well in LibO out of
the box is as hard (or harder) than it ever was: fixes to configure.in
to turn that on by default if we have python much appreciated etc. :-)

Thanks,

Michael.

-- 
 michael.me...@novell.com  <><, Pseudo Engineer, itinerant idiot


___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [GSOC] Java > Python, problem with uno.invoke

2011-05-28 Thread Xisco FaulĂ­
Hello,

It's funny how close I was to the solution and the time it took me to find
it.

uno.invoke(xPSet, "setPropertyValue", (PropertyName,
uno.Any( \
"[]string",PropertyValue)))

Thank you John for your answer.

2011/5/28 John LeMoyne Castle 

> Hi Xisco,
> I think your Java->Python porting project is awesome.  My experience is
> thin
> on many counts here: Java, Python, pyuno and LibreOffice, but I have been
> curious about them all, so I dove in a little on your question.
>
> My short answer of encouragement: Yes, you can solve it!
>
> One question is how are you treating PropertyValue?
> If PropertyValue can still be either boolean or a list of strings (in your
> Python as in the Java) then your initial test "If PropertyValue:" may
> prevent setting *any* property to false.  I think this safety check is moot
> anyway: Python will complain and quit before calling the setControlProperty
> function with nothing as the third argument object.
>
> I see that the invoke call is new - nice to see the setControlProperty
> function actually setting the property on the control ;-)  I think the path
> that call takes is through the extern C static invoke at:
>
> http://opengrok.libreoffice.org/xref/ure/pyuno/source/module/pyuno_module.cxx#596
> through PYUNO_invoke at:
> http://opengrok.libreoffice.org/xref/ure/pyuno/source/module/pyuno.cxx#335
> where it seems that the Any wrapper is optional (!!).  If you do pass
> PYUNO_invoke a tuple of Anys it just unpacks them before making a call
> like:
> object.name(tuple of args)
>
> I see that the Any wrapper is required to make calls through the
> Adapter::invoke here:
>
> http://opengrok.libreoffice.org/xref/ure/pyuno/source/module/pyuno_adapter.cxx#194
> --- but I'm sure you are not calling that invoke as it has a very different
> signature.  The extern C static invoke function requires the third arg to
> be
> a tuple, so I think it is sufficient to test for tuple type and then make
> the singletons a tuple of 1 before the invoke call.
>
> Finally, from the way PYUNO_invoke turns the ControlName and PropertyName
> into the callable function object, I think that passing the PropertyName as
> the second argument is sufficient - it doesn't need to go in the tuple as
> well.
>
> My understanding is that Java needs the Any foo to pass both simple types
> and objects as generic objects whereas everything in Python is an object so
> ... your Python glue code may often be simpler than the original Java.
>
> Please remember I'm no expert -- I just spent a few hours on this to start
> to dig into pyuno while doing a full LibreOffice build ...
>
> Hope This Helps,
> LeMoyne
>
>
>
> --
> View this message in context:
> http://nabble.documentfoundation.org/GSOC-Java-Python-problem-with-uno-invoke-tp2994887p2995406.html
> Sent from the Dev mailing list archive at Nabble.com.
> ___
> LibreOffice mailing list
> LibreOffice@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice
>
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [GSOC] Java > Python, problem with uno.invoke

2011-05-27 Thread John LeMoyne Castle
Hi Xisco, 
I think your Java->Python porting project is awesome.  My experience is thin
on many counts here: Java, Python, pyuno and LibreOffice, but I have been
curious about them all, so I dove in a little on your question.  

My short answer of encouragement: Yes, you can solve it! 

One question is how are you treating PropertyValue? 
If PropertyValue can still be either boolean or a list of strings (in your
Python as in the Java) then your initial test "If PropertyValue:" may
prevent setting *any* property to false.  I think this safety check is moot
anyway: Python will complain and quit before calling the setControlProperty
function with nothing as the third argument object.  

I see that the invoke call is new - nice to see the setControlProperty
function actually setting the property on the control ;-)  I think the path
that call takes is through the extern C static invoke at:
http://opengrok.libreoffice.org/xref/ure/pyuno/source/module/pyuno_module.cxx#596
through PYUNO_invoke at:
http://opengrok.libreoffice.org/xref/ure/pyuno/source/module/pyuno.cxx#335
where it seems that the Any wrapper is optional (!!).  If you do pass
PYUNO_invoke a tuple of Anys it just unpacks them before making a call like: 
object.name(tuple of args)

I see that the Any wrapper is required to make calls through the
Adapter::invoke here:
http://opengrok.libreoffice.org/xref/ure/pyuno/source/module/pyuno_adapter.cxx#194
--- but I'm sure you are not calling that invoke as it has a very different
signature.  The extern C static invoke function requires the third arg to be
a tuple, so I think it is sufficient to test for tuple type and then make
the singletons a tuple of 1 before the invoke call.  

Finally, from the way PYUNO_invoke turns the ControlName and PropertyName
into the callable function object, I think that passing the PropertyName as
the second argument is sufficient - it doesn't need to go in the tuple as
well. 

My understanding is that Java needs the Any foo to pass both simple types
and objects as generic objects whereas everything in Python is an object so
... your Python glue code may often be simpler than the original Java.   

Please remember I'm no expert -- I just spent a few hours on this to start
to dig into pyuno while doing a full LibreOffice build ... 

Hope This Helps,
LeMoyne



--
View this message in context: 
http://nabble.documentfoundation.org/GSOC-Java-Python-problem-with-uno-invoke-tp2994887p2995406.html
Sent from the Dev mailing list archive at Nabble.com.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] [GSOC] Java > Python, problem with uno.invoke

2011-05-27 Thread Xisco FaulĂ­
Hello,

I have converted the method setControlProperty in  UnoDialog:
http://opengrok.libreoffice.org/xref/components/wizards/com/sun/star/wizards/ui/UnoDialog.java#149
as follow:

def setControlProperty(self, ControlName, PropertyName, PropertyValue):
try:
if PropertyValue:

if self.xDialogModel.hasByName(ControlName) == False:
return
xPSet = self.xDialogModel.getByName(ControlName)
if isinstance(PropertyValue,tuple):
uno.invoke(xPSet, "setPropertyValue", (PropertyName,
uno.Any( \
"com.sun.star.beans.PropertyValue",PropertyValue)))
else:
xPSet.setPropertyValue(PropertyName, PropertyValue)

except Exception, exception:
traceback.print_exc()

but I get this Exception:

  File "/usr/lib/python2.6/dist-packages/uno.py", line 249, in invoke
return pyuno.invoke( object, methodname, argTuple )
com.sun.star.uno.RuntimeException: value is not of same or derived type!

as vmiklos told me in IRC the third parameter of invoke should be a tuple of
PropertyValue but in the Java code the variable PropertyValue  is a Bool or
a list of strings.

Anybody knows can I solve it ?

Greetings
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice