Can I identify the paragraph number?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
HansVanTilburg
Posts: 2
Joined: Sun Nov 06, 2022 9:07 am

Can I identify the paragraph number?

Post by HansVanTilburg »

My CAT tool https://www.cafetran.com uses LibreOffice Writer as a preview tool: https://youtu.be/PVqzHF6uxYo

There is an issue when a documents contains several instances of the same paragraph:

======
Introduction

Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.

Introduction

Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.Blablabbla. Blablabbla, blablabbla.
======

Is there anyway to differentiate between the instances of the same paragraph? BTW: I'm not sure what automation tool the developer used for controlling Writer from CafeTran Espresso. It must be one that is cross platform.

Thank you in advance for your input!
Hans
LibreOffice Mac Intel 7.4.2.3
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: Can I identify the paragraph number?

Post by JeJe »

If you use MRI to have a look you'll see that each paragraph has its own identifying ID - localname/metadatareference/stringvalue

Edit:
Note: the same ID may not persist when the document is closed and reopened.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
RoryOF
Moderator
Posts: 34611
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Can I identify the paragraph number?

Post by RoryOF »

Nor mght it persist if the file is edited, particularly if editing is done before the object paragraph.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: Can I identify the paragraph number?

Post by JeJe »

Its real easy to get all the non-empty paragraph ranges with a find all, if that's any help...

Code: Select all


 vDescriptor = ThisComponent.createSearchDescriptor()
 With vDescriptor
 .SearchString = ".*"
 .SearchRegularExpression = true
 End With
 vFound = ThisComponent.findall(vDescriptor)
 msgbox vfound.count
 msgbox vfound(3).string 'fourth NON-EMPTY paragraph string
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply