How to retrieve data from the text field in front of the cursor in a LibreOffice Writer macro?

64 views Asked by At

Context: Footnote 1 of my document says, "E.g., see n234 below." The text "234" is a cross-reference text field linked to footnote 234 on page 56.

My style guide says that the footnote should say, "E.g., see p. 56n234." So, I need to add a second cross-reference text field linked to footnote 234 that displays its page number (56) to supplement the original one that displays its footnote number (234).

I have around a thousand such cross-references that I need to change. So, I would like to write a macro to help make the changes.

My Plan: I am thinking I could position the cursor after the "n" ("see n|234"), detect the text field in front of the cursor ("234"), use getPropertyValue to retrieve data from that text field, and then back up a couple spaces and create a new cross-reference using that data.

Problem: I am not sure how to detect the text field in front of the cursor. I have never written a LibreOffice Basic macro before (though I do have some basic programming experience), and I was unable to find anything online.

Question: How can I create a reference in my LibreOffice Basic macro to the text field located immediately after the cursor?

0

There are 0 answers