Well, there is no easy way to do anything in this API and recorded dispatcher methods use to fall short. I could find some more efficient interfaces to append paragraphs and transfer formatted stuff.
There is some internal numbering oNote.getReferenceId() which does not correspond with the displayed numbering. There is oNote.getLabel() without number. There are two services
FootnoteSettings and
EndnoteSettings. They comprise document specific settings for the notes. The services don't help to read the actual numbers. If footnotes re-start their numbering on every page they may be a moving target while running a macro that inserts lines. Anyway, I implemented a simple consecutive, numbering from 1 to notes.count. The numbers may or may not be in sync with the displayed numbers of the foot/endnotes.
Code: Select all
REM ***** BASIC *****
Option Explicit
Sub Main
Dim oView, XText, oCollection
oView = thisComponent.getCurrentController()
XText = thisComponent.getText()
oCollection = thisComponent.FootNotes
processNotes(oView, oCollection, XText)
oCollection = thisComponent.EndNotes
processNotes(oView, oCollection, XText)
End Sub
Sub processNotes(oView, oCollection, XText)
Dim i%, oNote, XTrans
for i = 0 to oCollection.getCount() -1
REM copy the note content (does not include the prefix number)
oNote = oCollection.getByIndex(i)
oView.select(oNote.getText())
XTrans = oView.getTransferable()
REM append a new paragraph to the passed text and set it's style
XText = XText.Text.appendParagraph(Array())
XText.ParaStyleName = oNote.Start.ParaStyleName
REM add the number & ". "
XText.setString(cStr(i +1)&". ")
REM paste the transferable content
oView.select(XText.getEnd(False))
oView.insertTransferable(XTrans)
next
End Sub