Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


On 02/26/2015 01:46 PM, Michael Stahl wrote:
On 26.02.2015 12:09, Stephan Bergmann wrote:
According to Miklos: "afaik the usual way to check if a python object
has a method "foo" is 'if "foo" in dir(obj):', hope that also works with
pyuno objects."

guess that would work, unless a service implements 2 different
interfaces that overload the same method name (i hope we don't have any
such overloading...).

Ah, right. So better to go via queryInterface as below (or add a convenient wrapper around it into uno.py say).

it's also possible to manually call queryInterface though probably that
is not idiomatic in Python:

import uno
from com.sun.star.uno.TypeClass import INTERFACE
x = uno.getComponentContext()
y = x.queryInterface(uno.Type("com.sun.star.uno.XComponentContext",
INTERFACE))
y
pyuno object (com.sun.star.uno.XComponentContext)0x7f0941697060{,
supportedInterfaces={com.sun.star.uno.XComponentContext,com.sun.star.container.XNameContainer,com.sun.star.lang.XTypeProvider,com.sun.star.uno.XWeak,com.sun.star.lang.XComponent}}
z = x.queryInterface(uno.Type("com.sun.star.util.XCloseable",
INTERFACE))
z is None
True

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.