// create a urlresolver
Object urlResolver = xLocalServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", xLocalContext );
// query for the XUnoUrlResolver interface
XUnoUrlResolver xUrlResolver =
(XUnoUrlResolver) UnoRuntime.queryInterface( XUnoUrlResolver.class, urlResolver );
// try to connect to soffice
Object aInitialObject = null;
try
{
aInitialObject = xUrlResolver.resolve( mURL );
}
catch( com.sun.star.connection.NoConnectException e )
{
// launch soffice
OfficeService aSOffice = new OfficeService();
aSOffice.startupService();
// wait until soffice is started
long nMaxMillis = System.currentTimeMillis() + 1000*aSOffice.getStartupTime();
while ( aInitialObject == null )
{
try
{
// try to connect to soffice
Thread.currentThread().sleep( 500 );
aInitialObject = xUrlResolver.resolve( mURL );
}
catch( com.sun.star.connection.NoConnectException aEx )
{
// soffice did not start in time
if ( System.currentTimeMillis() > nMaxMillis )