Description: I have python scripts that import uno module and connect to the soffice headless instance, open my spreadsheets, and get data from it. I used Danny's OOo lib modules to setup the interface. This worked fine in OpenOffice and then LibreOffice builds from Ubuntu PPA. But now on my Lubuntu 11.04 (where no OpenOffice is installed), I installed all the DEB packages that were part of the archive from the LibO website. Now my python script connects to uno, but loading a spreadsheet fails pointing to: Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: loadComponentFromURL Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 57, in apport_excepthook from apport.fileutils import likely_packaged File "/opt/libreoffice/basis3.3/program/uno.py", line 291, in _uno_import raise ImportError( "type "+ name + "." +x + " is unknown" ) ImportError: type apport.fileutils.likely_packaged is unknown Original exception was: Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: loadComponentFromURL So, I tried again with ubuntu 10.04 which has python 2.6.6, even there I get an error: AttributeError: loadComponentFromURL Steps: 1. This is what I do in a python console: Python 2.7.1+ (r271:86832, Mar 24 2011, 00:39:14) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import uno >>> oLocalContext = uno.getComponentContext() >>> oLocalResolver = oLocalContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", oLocalContext ) >>> oContext = oLocalResolver.resolve( "uno:socket,host=127.0.0.1,port=2002;urp;StarOffice.ComponentContext" ) >>> goServiceManager = oContext.ServiceManager >>> StarDesktop = goServiceManager.createInstance( "com.sun.star.frame.Desktop") >>> dir(StarDesktop) ['ActiveFrame', 'DispatchRecorderSupplier', 'ImplementationId', 'ImplementationName', 'IsPlugged', 'PropertySetInfo', 'SupportedServiceNames', 'SuspendQuickstartVeto', 'Title', 'Types', 'addEventListener', 'addPropertyChangeListener', 'addVetoableChangeListener', 'dispose', 'disposing', 'getImplementationId', 'getImplementationName', 'getPropertySetInfo', 'getPropertyValue', 'getSupportedServiceNames', 'getTypes', 'handle', 'queryInterface', 'removeEventListener', 'removePropertyChangeListener', 'removeVetoableChangeListener', 'setPropertyValue', 'supportsService'] 2. The same steps on OpenOffice/LibreOffice from ubuntu ppa shows me the attribute "loadComponentFromURL", this attribute seems vital to opening files using soffice headless.
I tested with LibreOffice 3.4.2 Final (2011-08-01) today and this bug is fixed. I was able to connect to LibreOffice over uno and operate on my spreadsheets! Thanks for fixing this bug.
Verification steps: 1. Cleanup any earlier libreoffice package. 2. Install all deb packages from LibreOffice 3.4.2 Final (2011-08-01) 3. Start libreoffice this way: libreoffice3.4 --nodefault --minimized --nologo --norestore "--accept=socket,host=localhost,port=2002;urp;" & 4. From the terminal, set variable that are required: export URE_BOOTSTRAP="file:///opt/libreoffice3.4/program/fundamentalrc" export PYTHONPATH=/opt/libreoffice3.4/basis3.4/program 5. Run a test python script, here is mine: import uno ctx = uno.getComponentContext() res = ctx.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", ctx ) cxt = res.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" ) desktop = cxt.ServiceManager.createInstance( "com.sun.star.frame.Desktop" ) def makePropertyValue(cName, uValue, nHandle, nState): core = cxt.ServiceManager.createInstance( "com.sun.star.reflection.CoreReflection" ) oXIdlClass = core.forName( "com.sun.star.beans.PropertyValue" ) oReturnValue, oStruct = oXIdlClass.createObject( None ) oStruct.Name = cName oStruct.Value = uValue oStruct.Handle = nHandle oStruct.State = nState return oStruct #doc = desktop.loadComponentFromURL( "private:factory/scalc","_blank", 0, () ) props = tuple([makePropertyValue( 'ReadOnly' , True , 0 , 0), makePropertyValue( 'Hidden' , False , 0 , 0)]) doc = desktop.loadComponentFromURL( "file:///home/test/docs/sheets/test.xls", "_blank", 0, props ) oSheet = doc.getSheets().getByIndex(0) oCell = oSheet.getCellByPosition( 0, 3 ) print oCell.getValue() print oCell.getFormula() doc.dispose()