All SDK samples use Bootstrap to connect to a running LO :
private unoidl.com.sun.star.uno.XComponentContext m_xContext;
/** Connect to a running office that is accepting connections.
@return The ServiceManager to instantiate office components. */
private XMultiServiceFactory connect( String [] args )
{
m_xContext = uno.util.Bootstrap.bootstrap();
return (XMultiServiceFactory) m_xContext.getServiceManager();
}
But it is not working and I assume it is related to the «deprecated» note on this page
So what is supposed to be used instead now ?
I’m using LO 6.02 + SDK under an ironpython environment. I’m able to load cli_uno, cli_basetypes, cli_cppuhelper, cli_oootypes, cli_ure, cli_uretypes using clr and seem to be able to access to all other component like XComponentContext.getServiceManager().
Edit 06.04.2018 :
It looks like a pretty old issue according to this stackoverflow subject : c# - Bootstrap Uno API LibreOffice exception - Stack Overflow. Should we report it on a bug tracker or something like this ?
Edit 2 : Apparently, it is already on buggtracker https://bugs.documentfoundation.org/show_bug.cgi?id=94265
Edit 3 : adding following code allow me to apparently use uno.util.Bootstrap.bootstrap()
but an object
is returned instead of an XComponentContext
:
# coding: utf8
import sys
import clr
import os
sys.path.append(r"C:\Program Files\LibreOffice\sdk\cli")
clr.AddReference("cli_basetypes")
clr.AddReference("cli_cppuhelper")
clr.AddReference("cli_oootypes")
clr.AddReference("cli_ure")
clr.AddReference("cli_uretypes")
from unoidl.com.sun.star.uno import XComponentContext
lo_path = r"C:\Program Files\LibreOffice\program"
if lo_path not in os.environ["PATH"]:
os.environ["PATH"] = "{}{};".format(os.environ["PATH"],lo_path)
from uno.util import Bootstrap
xcontext = Bootstrap.bootstrap()
print(type(xcontext)) # -> object