XUnoUrlResolver issue in custom C++ application

Java, C++, C#, Delphi, ??? - Using the UNO bridges

XUnoUrlResolver issue in custom C++ application

Postby alexey.g » Fri Apr 26, 2019 6:04 pm

Good evening, friends
I've become faced to implement a piece of software that is supposed, in particular, to generate custom OO.Writer documents both in Linux and Windows. I've started to work in Linux environment.

After reading all googled information I finally got (took from this source) a piece of code that is at least linking and launching:
Code: Select all   Expand viewCollapse view
   // create the initial component context
   Reference< XComponentContext > rComponentContext =
                defaultBootstrap_InitialComponentContext();

   // retrieve the servicemanager from the context
   Reference< XMultiComponentFactory > rServiceManager =
                rComponentContext->getServiceManager();

   // instantiate a sample service with the servicemanager.
   Reference< XInterface > rInstance =  rServiceManager->createInstanceWithContext(
         OUString::createFromAscii("com.sun.star.bridge.UnoUrlResolver" ),rComponentContext );

   // Query for the XUnoUrlResolver interface
   Reference< XUnoUrlResolver > rResolver( rInstance, UNO_QUERY );
   if( ! rResolver.is() ){
      printf( "Error: Couldn't instantiate com.sun.star.bridge.UnoUrlResolver service\n" );
      return NULL;
   }
   try {
      // resolve the uno-url
      rInstance = rResolver->resolve( OUString::createFromAscii(
         "uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" ) );

      if( ! rInstance.is() ){
         printf( "StarOffice.ServiceManager is not exported from remote counterpart\n" );
         return NULL;
      }

      // query for the simpler XMultiServiceFactory interface, sufficient for scripting
      Reference< XMultiServiceFactory > rOfficeServiceManager (rInstance, UNO_QUERY);

      if( ! rOfficeServiceManager.is() ){
            printf( "XMultiServiceFactory interface is not exported for StarOffice.ServiceManager\n" );
            return NULL;
        }
        return rOfficeServiceManager;
   }
   catch( Exception &e ){
      OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US );
      printf( "Error: %s\n", o.pData->buffer );
      return NULL;
   }
   return NULL;


The problem is it crashes right after become launched at the string:
Code: Select all   Expand viewCollapse view
      // resolve the uno-url
      rInstance = rResolver->resolve( OUString::createFromAscii(
         "uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" ) );

with the following output:
/usr/include/libreoffice/com/sun/star/uno/Reference.h:420: interface_type* com::sun::star::uno::Reference<interface_type>::operator->() const [with interface_type = com::sun::star::lang::XMultiServiceFactory]:
assert( _pInterface != NULL )


Before launching this demo application I had started the soffice itself in the following manner:

soffice --accept="uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"


It's my first experience with OOo at such a deep level and I'm not sure.. what is the source of the error above:
[*] is it not a properly installed environment? The tutorials mention about some regmerge/regcomp manipulations at the very beginning, but my distribution doesn't even contain the regcomp utility at all. Moreover, according to this link, the regcomp was already removed from SDK at all. Can that be the issue?
[*] I'm not sure what gcc/toolchain version was used to build the whole OOo package and its dev part in Ubuntu distribution. It can easily differ from the being used right now for sure. Can that be the issue as well?

Could you please give some tips on how to make this stuff work?
Any feedback is really appreciated.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
alexey.g
 
Posts: 1
Joined: Fri Apr 26, 2019 5:45 pm

Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests