On Sun, 11 May 2025 09:46:20 +0200
Arrigo Marchiori <[email protected]> wrote:
> Hello Rory,
>
> On Fri, May 09, 2025 at 01:46:33PM +0100, Rory O'Farrell wrote:
>
> > In Navigator, when Comments (Annotations) are listed, are they
> > retrieved in order from the file in use, or are they sorted by the
> > Navigator code before display?
> >
> > A macro using an enumeration to retrieve Comments returns them in
> > complicated order; from my experience the first Comment, then the
> > most recent, then mostly in reverse order (i.e., from end of file).
>
> From a quick look at the code, the navigator should use "indexed
> containers", that enforce element ordering.
>
> Could you please share the part of the macro that retrieves the
> comments?
>
> Best regards,
> --
> Arrigo
Below is code for a macro to report content of annotations in a Writer file.
Make a small text file, and insert comments randomly at any points within the
file, not merely sequentially beginning to end. You will observe that the
enumeration process does not report the comments sequentially.
Sub ReportAnnotes
Rem Report the content of all Annotations in a Writer document
Dim oDoc as Object
Dim oEnum as Object
Dim oField as Object
Dim oText as String ' do not Dim as Object or Variant
oDoc = ThisComponent
oEnum = oDoc.getTextFields().createEnumeration()
If Not IsNull(oEnum) Then
Do While oEnum.hasMoreElements()
oField = oEnum.nextElement()
If oField.supportsService("com.sun.star.text.TextField.Annotation") Then
oText = oField.Content
Msgbox "Annotation content is : " + oText
End If
Loop
End If
End Sub ' ReportAnnotes
--
Rory O'Farrell <[email protected]>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]