Bug 42736 - undefined: PyUno document.Text.getString() returns empty text but there is text in document
Summary: undefined: PyUno document.Text.getString() returns empty text but there is te...
Status: RESOLVED INVALID
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
4.0.3.3 release
Hardware: Other All
: lowest normal
Assignee: Not Assigned
URL:
Whiteboard: BSA
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-09 01:36 UTC by Anatoly
Modified: 2013-05-11 17:06 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
test document to reproduce a bug (63.32 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2011-11-09 01:36 UTC, Anatoly
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anatoly 2011-11-09 01:36:48 UTC
Created attachment 53318 [details]
test document to reproduce a bug

Problem description:
When I open document using PyUNO: document.Text.getString() returns empty string when in document there is only one table with some text inside. See attached document and code below to reproduce the bug. Interesting moment: if I type any text before table 'getString()' will return text from table correctly.

Steps to reproduce:
1. Start libreoffice in terminal without gui using following command:
libreoffice
--accept=socket,host=localhost,port=2002;urp;StarOffice.ServiceManager
--norestore --nofirststartwizard --nologo --headless
2. In second terminal I starts python code to open some file, get plain text

Expected behavior:
Return all text from table in document.

Minimum python code to reproduce problem:
--------------------------------------------------------------------------
import uno

local = uno.getComponentContext()
resolver = local.ServiceManager.createInstanceWithContext(
                  "com.sun.star.bridge.UnoUrlResolver", local)
context = resolver.resolve(
               
'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext')
desktop = context.ServiceManager.createInstanceWithContext(
        "com.sun.star.frame.Desktop", context)

doc = desktop.loadComponentFromURL('table_text.docx', "_blank", 0, ())
plain_text = doc.Text.getString()
doc.dispose()
doc.close(False)
del doc
-------------------------------------------------------------

plain_text is equal to u'' but there is text in a table.

Platform (if different from the browser): Mac OS X 10.6, Ubuntu 10.10, LibreOffice 3.4.3, python-uno + python 2.7.1
              
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2
Comment 1 Christopher Yeleighton 2012-03-24 13:50:31 UTC
(In reply to comment #0)
> doc = desktop.loadComponentFromURL('table_text.docx', "_blank", 0, ())


__main__.IllegalArgumentException: URL seems to be an unsupported one.
Comment 2 Matthias Wieser 2013-05-11 17:06:33 UTC
The bug is in the report:

The document does not have a single line of text, thus the return value of doc.Text.getString() is correct.
Instead, doc.TextTables.Tabelle1.getDataArray() will reveal the content of the table.

Note: file:///PATH/TO/DIRECTORY/table_text.docx is the correct URI to open file.