On Thu, 15 May 2025 22:06:01 +0200
Arrigo Marchiori <ard...@apache.org> wrote:

> Hello Rory,
> 
> On Sun, May 11, 2025 at 09:06:56AM +0100, Rory O'Farrell wrote:
> 
> > On Sun, 11 May 2025 09:46:20 +0200
> > Arrigo Marchiori <ard...@apache.org> 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
> [...]
> 
> Thank you for this very good example.
> It's true: the elements are not returned in the expected order.
> 
> I spent some time looking at the code but unfortunately I could not
> find the code where the tree is built.
> 
> A possible workaround could be treating the oField's as instances of
> com.sun.star.text.XTextContent, and then using their getAnchor()
> method to obtaining the sort key.
> 
> I am sorry I cannot be any more specific than this.
> 
> Best regards,
> -- 
> Arrigo

Thank you for confirming the non-sequential order in which the Annotations are 
returned.

Immediately I see two solutions: 

one is to pass through the file from start to finish, inspecting each object in 
turn, and returning only the Annotations to allow whatever processing is 
required - in my case this might be inserting a sequential number.  

The other possibility is to use a macro (perhaps Python) to close the file 
(after Saving it), then parse the XML of content.xml, again doing any required 
processing and reinsertion into an updated content.xml, then reopen the file 
using that updated content.xml. 

In both cases it might be that the file would have to be closed, processed and 
then reopened, but that is a simple requirement for any macro.

At present, when I am bored, I manually renumber the relevant Annotations every 
week or two - their numbering is not important, it is merely a nicety, for 
information.  But Real Life catches up on me, and I have several papers and 
presentations to research and write, which have deadlines, so I'll put my 
project on hold. 

Off topic: I find the AOO code confusing because of all the test code files 
interspersed with the collection of application code files.  It would be 
simpler for the occasional visitor to the code if these extraneous files were 
in a separate folder, but I understand the manpower situation. 

-- 
Rory O'Farrell <ofarr...@iol.ie>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org

Reply via email to