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).
That's simple.
The main problem is avoiding flickering. You cannot use
lockControllers() on the XModel, because you will get wrong values for
the position of your ViewCursor.
Instead of that you can create a second view with a second controller
for this purpose (thanks again to mba):
PropertyValue[] props = new PropertyValue[2];
props[0] = new PropertyValue();
props[0].Name = "Model";
props[0].Value = xModel;//your 'old' XModel
props[1] = new PropertyValue();
props[1].Name = "Hidden";
props[1].Value = true;
/*
* argument xModel wins over URL.
*/
xComponentLoader.loadComponentFromURL("private:factory/swriter",
"_blank", 0, props);
/*
* Controller of the hidden frame
*/
XController xController = textDocument.getCurrentController();
XFrame xFrame = xController.getFrame();
XWindow xContainerWindow = xFrame.getContainerWindow();
XWindow xComponentWindow = xFrame.getComponentWindow();
while (!actionsFinished) {
xContainerWindow.setVisible(true);
xComponentWindow.setFocus();
xContainerWindow.setVisible(false);
doAllYourSearchAndSortActions()
}
xFrame.dispose()
This works like a charme for me.
Regards,
Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]