Page 1 of 1

First steps UNO/C++

Posted: Wed Dec 28, 2011 7:19 pm
by petric
Hello,

i tried the code at http://user.services.openoffice.org/en/ ... 720#p94720 using LibreOffice 3.4.3.2 on Gentoo Linux (64 Bit).

During execution - after the main lirbreoffice window came up i got a segmentation fault. This is the code i used:

Code: Select all

      Reference<XComponentContext> rComponentContext = ::cppu::bootstrap ();
      Reference<XMultiComponentFactory> xServiceManager = rComponentContext->getServiceManager ();
      Reference<XInterface> xDesktop = xServiceManager->createInstanceWithContext (OUString::createFromAscii ("com.sun.star.frame.Desktop"), rComponentContext);
      Reference<XComponentLoader> xCompLoader (xDesktop, UNO_QUERY);

      Sequence< ::com::sun::star::beans::PropertyValue> props (1);
      props[0].Name = OUString::createFromAscii ("AsTemplate");
      props[0].Value <<= OUString::createFromAscii ("MS Excel 97");

      // calling this i get a segmentation fault
      Reference<XComponent> component = xCompLoader->loadComponentFromURL (OUString::createFromAscii ("private:factory/scalc"),
                                                                           OUString::createFromAscii ("_default"),
                                                                           0,
                                                                           props);
      // get a handle to the newly created spreadsheet
      Reference<XSpreadsheetDocument> spreadDoc (component, UNO_QUERY);
Compiler is gcc 4.5.3.

Any hints ?