ITextDocument textDocument = (ITextDocument)document;
ITextTableCell thisCompareRangeCell = thisCompareRange.getCell();
ITextTableCell textRangeToCompareCell = textRangeToCompare.getCell();
if(thisCompareRangeCell != null && textRangeToCompareCell == null) {
XTextContent textTable = thisCompareRangeCell.getTextTable().getXTextContent();
XSelectionSupplier selectionSupplier = (XSelectionSupplier)UnoRuntime.queryInterface(XSelectionSupplier.class, textDocument.getXTextDocument().getCurrentController());
selectionSupplier.select(textTable);
XTextViewCursorSupplier xTextViewCursorSupplier = (XTextViewCursorSupplier)UnoRuntime.queryInterface(XTextViewCursorSupplier.class, textDocument.getXTextDocument().getCurrentController());
xTextViewCursorSupplier.getViewCursor().goLeft((short)1,false);
thisCompareRange = textDocument.getViewCursorService().getViewCursor().getTextCursorFromEnd().getEnd();
}
else if(textRangeToCompareCell != null && thisCompareRangeCell == null) {
XTextContent textTable = textRangeToCompareCell.getTextTable().getXTextContent();
XSelectionSupplier selectionSupplier = (XSelectionSupplier)UnoRuntime.queryInterface(XSelectionSupplier.class, textDocument.getXTextDocument().getCurrentController());
selectionSupplier.select(textTable);
XTextViewCursorSupplier xTextViewCursorSupplier = (XTextViewCursorSupplier)UnoRuntime.queryInterface(XTextViewCursorSupplier.class, textDocument.getXTextDocument().getCurrentController());
xTextViewCursorSupplier.getViewCursor().goLeft((short)1,false);
textRangeToCompare = textDocument.getViewCursorService().getViewCursor().getTextCursorFromEnd().getEnd();
}
else if(thisCompareRangeCell != null && textRangeToCompareCell != null) {
XTextContent thisCompareRangeTable = thisCompareRangeCell.getTextTable().getXTextContent();
XTextContent textRangeToCompareTable = textRangeToCompareCell.getTextTable().getXTextContent();
boolean sameTable = UnoRuntime.areSame(
thisCompareRangeTable,textRangeToCompareTable);
if(sameTable) {
ITextTableCellName thisCompareRangeCellName = thisCompareRangeCell.getName();
ITextTableCellName textRangeToCompareCellName = textRangeToCompareCell.getName();
int thisCompareRangeCellRow = thisCompareRangeCellName.getRowIndex();
int thisCompareRangeCellCol = thisCompareRangeCellName.getColumnIndex();
int textRangeToCompareCellRow = textRangeToCompareCellName.getRowIndex();
int textRangeToCompareCellCol = textRangeToCompareCellName.getColumnIndex();
if(thisCompareRangeCellRow < textRangeToCompareCellRow)
return 1;
else if(thisCompareRangeCellRow > textRangeToCompareCellRow)
return -1;
else {
if(thisCompareRangeCellCol < textRangeToCompareCellCol)
return 1;
else if(thisCompareRangeCellCol > textRangeToCompareCellCol)
return -1;
}
}
else {
XSelectionSupplier selectionSupplier = (XSelectionSupplier)UnoRuntime.queryInterface(XSelectionSupplier.class, textDocument.getXTextDocument().getCurrentController());
selectionSupplier.select(thisCompareRangeTable);
XTextViewCursorSupplier xTextViewCursorSupplier = (XTextViewCursorSupplier)UnoRuntime.queryInterface(XTextViewCursorSupplier.class, textDocument.getXTextDocument().getCurrentController());
xTextViewCursorSupplier.getViewCursor().goLeft((short)1,false);
thisCompareRange = textDocument.getViewCursorService().getViewCursor().getTextCursorFromEnd().getEnd();
selectionSupplier = (XSelectionSupplier)UnoRuntime.queryInterface(XSelectionSupplier.class, textDocument.getXTextDocument().getCurrentController());
selectionSupplier.select(textRangeToCompareTable);
xTextViewCursorSupplier = (XTextViewCursorSupplier)UnoRuntime.queryInterface(XTextViewCursorSupplier.class, textDocument.getXTextDocument().getCurrentController());
xTextViewCursorSupplier.getViewCursor().goLeft((short)1,false);
textRangeToCompare = textDocument.getViewCursorService().getViewCursor().getTextCursorFromEnd().getEnd();
}
}