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

Xisco Faulí anistenis at gmail.com
Sat May 28 05:57:57 PDT 2011


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 <jlc at mail2lee.com>

> 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 at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20110528/686116a4/attachment.html>


More information about the LibreOffice mailing list