- Is there a way, given an UNO object like a paragraph or text portion (each of which implements different interfaces), to read certain attributes from it using a generic method? For example, I can say par.CharHeight but is there something like read_attr(par, "CharHeight") or some such?
- When iterating over the paragraphs and text portions of a document, how do I recognize numbered/unordered lists?
- Same as above, how to I recognize images?
Handling UNO objects, images, lists (in Python)
Handling UNO objects, images, lists (in Python)
These questions are somewhat Python related, but I'd think they can be answered for different languages as well.
Mac 13.7 using LO 24.8.2.1, Ubuntu Linux using LO 24.8 headless.
Re: Handling UNO objects, images, lists (in Python)
Install the MRI extension.
Read and understand http://www.openoffice.org/udk/python/python-bridge.html
Of course, you should be fluent in Python.
Read and understand http://www.openoffice.org/udk/python/python-bridge.html
Of course, you should be fluent in Python.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Handling UNO objects, images, lists (in Python)
The document seems a little outdated, but it's an interesting introduction. Thanks!
It didn't really answer my questions though: how to I recognize images and numbered lists when I iterate over the paragraphs of a document? I also tried different ways of reading attributes (as described in the above document) but that's didn't really work either.
So I'm not any farther than before
It didn't really answer my questions though: how to I recognize images and numbered lists when I iterate over the paragraphs of a document? I also tried different ways of reading attributes (as described in the above document) but that's didn't really work either.
So I'm not any farther than before

Mac 13.7 using LO 24.8.2.1, Ubuntu Linux using LO 24.8 headless.
Re: Handling UNO objects, images, lists (in Python)
Well, it seems like lists (enumerations) are implemented by paragraph style "NumberingStyleName" different than an empty string, for example
indicates an element of a numbered list. Other properties like "ParaIsNumberingRestart" and "NumberingStartValue" and "NumberingLevel" give more information on the context of this paragraph list. So it seems, at least.
As for images, I am still unsure.
As for how to query random properties of a UNO object, I am still unsure.
I also assume that footnotes are handled as paragraph styles also?
Code: Select all
> par.NumberingStyleName
'WW8Num2'
As for images, I am still unsure.
As for how to query random properties of a UNO object, I am still unsure.
I also assume that footnotes are handled as paragraph styles also?
Mac 13.7 using LO 24.8.2.1, Ubuntu Linux using LO 24.8 headless.
Re: Handling UNO objects, images, lists (in Python)
This is how it seems to work, although some more checks to make sure a particular interface is implemented by a UNO object would help:_savage wrote:As for how to query random properties of a UNO object, I am still unsure.
Code: Select all
>>> type(par)
<class 'pyuno'>
>>> getattr(par, "ParaStyleName")
'Free Form'
>>> getattr(par, "CharFontName")
'Comic Sans MS'
Mac 13.7 using LO 24.8.2.1, Ubuntu Linux using LO 24.8 headless.