I've got a writer doc wich contains some paragraph in bold character. I need to parse all the paragraph (wich is simple) and apply a special action for them.
Here is the python code I wrote for now.
while tCursor.gotoNextParagraph(True):
mri(ctx, tCursor.CharWeight)
tCursor.collapseToEnd()
The selection is ok. It parses each paragraph, but introspection tool Mri returns "void" for CharWeight property. How could I test wether it's a bold or normal paragraph?
Last edited by Bastien on Wed Mar 06, 2019 10:26 am, edited 1 time in total.
Use different paragraph styles and check the applied style and/or the properties of the applied paragraph style.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
The property value is void when the selected section has more than one value for that property.
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
You may have to parse the paragraph on a word by word basis and apply some criterion to decide if that paragraph has sufficient of "bold" to qualify for treatment - perhaps first word/last word in bold might be sufficient.
You can create an enumeration of paragraphs from the Text of the document. Each paragraph is made up of Portions of uniform formatting. A Portion will have a single CharWeight value. In Basic
oText = ThisComponent.Text
oP_Enum = oText.createEnumeration()
While oP_Enum.hasMoreElements()
oP = oP_Enum.nextElement()
oPor_Enum = oP.createEnumeration()
While oPor_Enum.hasMoreElements
oPor = oPor_Enum.nextElement()
if oPor.CharWeight > 100 then
print oPor.string
end If
Wend
Wend
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC's second enumeration would be needed if the paragraph contained parts that were bold and parts that weren't. If its the whole paragraph that's bold then you just need to enumerate those.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)