How do I tear down soffice cleanly?
Jens Tröger
jens.troeger at light-speed.de
Tue Mar 3 12:27:41 PST 2015
On Thu, Feb 26, 2015 at 01:54:38PM +0100, Stephan Bergmann wrote:
> Ah, right. So better to go via queryInterface as below (or add a
> convenient wrapper around it into uno.py say).
>
> >>> 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
Thank you for the discussion. I have adjusted my code to the following,
which seems to work:
from com.sun.star.uno.TypeClass import INTERFACE
# or use: hasattr(document, "queryInterface")
if "queryInterface" in dir(document) and document.queryInterface(uno.Type("com.sun.star.util.XCloseable", INTERFACE)) :
document.close(True)
else :
document.dispose()
Cheers,
Jens
--
Jens Tröger
http://savage.light-speed.de/
More information about the LibreOffice
mailing list