throws TextException {
try {
ITextRange thisCompareRange = this;
if (document instanceof ITextDocument) {
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();