2009/2/26 Peter Eberlein <[email protected]>:
> Hi Morten,
>
> first, the api or the d...@sw mailing lists seems to be a better place to
> ask, so I took the freedom to f'up.
>
> Morten Omholt Alver schrieb:
>>
>> Hi,
>>
>> I am working on a plugin for interfacing JabRef and OpenOffice. This
>> involves inserting citation markers in a Writer text (representing a
>> bibliography citation), and formatting a reference list based on which
>> citations appear in the text.
>>
>> In order to sort the reference list by order of appearance in the
>> document, I use XTextRangeCompare to sort the reference marks.
>> However, if some reference marks are placed in table cells or
>> footnotes, this doesn't work, since XTextRangeCompare only compares
>> text ranges within the same Text, and this apparently doesn't hold in
>> this case (a reference mark in a normal paragraph is not within the
>> same Text as a reference mark in a table cell or footnote).
>>
>> Is there another way of ordering reference marks by position in the
>> text, or can I somehow access the position of a table / table cell or
>> footnote within the outer Text, so they can be compared?
>>
>>
>
> I got a similar problem some time ago and solved it as follows (in Java):
> The XTextViewCursor jumps to all relevant XTextRanges. The found
> positions(X,Y) and the page number can you store in a new class, which
> implements the Comparable Interface. So, after adding all this new objects
> to an ArrayList you can sort them with Collections.sort(arrayList).

Peter,

thanks for this advice - it works great! I didn't know there was a way
to get absolute positions from a document, but I suspected thee had to
be.

Only one problem remains - I think citations in footnotes should be
sorted based on the location of the footnote marker in the text,
rather than the footnote itself (if citation [2] is in a footnote
linked from the top of a page, citations further down on the page
should be numbered [3] and further, but with the current technique
they will be put before it because the footnote body is at the bottom
of the page). To solve this, I suppose I need to find which citations
are in footnotes, and then find the footnote reference in the text,
and finally take the location of that reference. I can probably figure
out how to do this, but I'd be happy to get any pointers!


Sincerely,
Morten

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to