Count and number Comments/Annotations

Discuss the word processor
Post Reply
User avatar
RoryOF
Moderator
Posts: 35064
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Count and number Comments/Annotations

Post by RoryOF »

I use many Comments/Annotations as reminders in course of long writings (booklength). I can use AltSearch to find and count all such Comments, starting with a specific text - in my case, "Letter:" Is it possible to number these, so that I can extend each instance of the searched string with a sequential number, for example "Letter nn:" or "Letter: nn"?

In the particular case I am considering, I currently have some 40+ letters, and expect to have more before the project is complete.

It is possible to do this by using a post processing code, whether in BASIC or in Python, but it would be handy if the task could be done (say) by manipulating AltSearch.

Rory
Apache OpenOffice 4.1.15 on Xubuntu 22.04.5 LTS
JeJe
Volunteer
Posts: 3068
Joined: Wed Mar 09, 2016 2:40 pm

Re: Count and number Comments/Annotations

Post by JeJe »

Don't know whether this is what you're looking for, but the help file has this
\i - inserts the occurrence number of the found object or text in a count of the occurrences in the text - this works only if [ Replace all ] is used
\i{start,digit} - formatted counter: \i{9,4} - count from 9, for 4 digits (0009, 0010, 0011,...) [v1.4]
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
RoryOF
Moderator
Posts: 35064
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Count and number Comments/Annotations

Post by RoryOF »

A quick test showed that it put the number in the text at the anchor location. If one uses AltSearch to find note content, then Replacing with & (Found text) puts the found text in the main text at the anchor point, not recreating the Comment. There is \f option ("preserve format") which may do the task, but I haven't sorted that yet.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.5 LTS
User avatar
RoryOF
Moderator
Posts: 35064
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Count and number Comments/Annotations

Post by RoryOF »

I've had a quick look at the code, and (caveat: as far as I have found) I find no instance of code to generate an Annotation. There is code to generate most other elements, such as bookmarks, endnotes etc.

So I conclude that what I wish to do using unmodified AltSearch is not possible.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.5 LTS
JeJe
Volunteer
Posts: 3068
Joined: Wed Mar 09, 2016 2:40 pm

Re: Count and number Comments/Annotations

Post by JeJe »

The comment(s) disappears for me when trying to replace within a comment with alt search.

A macro recording of find/replace with "Notes" enabled works so a macro looping through each should be possible.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply