I am exporting a very large document (1400+ pages) to ebook, and have already worked out the Table of Contents (ToC) as hyperlinks to all the chapters and sections, and the hyperlinks work fine after being exported to the target ebook format so that part is done.
Now I want to make all the link targets in the ToC into links themselves pointing back to the appropriate page of the ToC.
I do not wish to attempt this manually one by one, as there are hundreds of entries in the ToC, so I am looking for help to figure out how to take the link target information from the ToC, find said target in the text body, and then convert that target into a link pointing back to the correct ToC page automatically.
Thus my question is how to use a macro or Find/Replace to make ToC link targets into links themselves pointing back to the ToC in Libreoffice?