Issue 102348 - XTextRangeCompare throws IllegalArgumentException when compairing two XTextRange of two XTextTable
Summary: XTextRangeCompare throws IllegalArgumentException when compairing two XTextRa...
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: OOo 3.0
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
Depends on:
Reported: 2009-05-28 22:36 UTC by budspencer
Modified: 2017-05-20 11:17 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Note You need to log in before you can comment on or make changes to this issue.
Description budspencer 2009-05-28 22:36:32 UTC

gmane.comp.openoffice.devel.general discussion: "Compairing text content
positions with each other"

Exact Problem:
XTextRangeCompare throws following exception when compairing two XTextRanges of

>Exception occurred in target VM:
at Method)
at $Proxy35.compareRegionStarts(Unknown Source)
at ast.structure.ElementController.checkTextTable(
at ast.structure.ElementController.analyze(
at ast.BesserWissA.dispatch(

Explanation of code:
In this testcode Ive written some hardcode to read exactly two tables out of a
writer document. I get the tables via a table supplier and get there ranges by
using getAnchor() of each XTable. I put the anchors for compairing to a
XTextRangeCompare object using compareRegionStarts() and that throws an

Ive checked out the XTextRange object by getAnchor(). Most members are set to
null, just object members are not. But the members of that objects are null
again. So the XTextRange I ve got is invalid in my eyes.


XComponentContext m_aComponentContext; // given
XMultiComponentFactory m_aMCF = m_aComponentContext.getServiceManager();

Object desktop = null;
  desktop = m_aMCF.createInstanceWithContext("",
catch(Exception ex)

XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
  XDesktop.class, desktop);
XComponent xComponent = xDesktop.getCurrentComponent();

XTextTablesSupplier xTextTablesSupplier = (XTextTablesSupplier) UnoRuntime.
  queryInterface(XTextTablesSupplier.class, xComponent);
XNameAccess xNamedTables = xTextTablesSupplier.getTextTables();

String[] tableNames = xNamedTables.getElementNames();
XTextRange[] myRanges = new XTextRange[2];

  "compairing ranges of " + tableNames[0] + " & " + tableNames[1]);

// just read out first two tables
for(int k = 0; k < 2 k++)
  XTextTable table = null;
  XTextContent xTC = null;
    Object obj = xNamedTables.getByName(tableNames[k]);
    table = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, obj);
  catch(Exception ex)

  //myRanges[k] = table.getAnchor().getStart(); // same problem here, same exc
  myRanges[k] = table.getAnchor();

XTextRangeCompare xTextRangeCompare = (XTextRangeCompare) UnoRuntime.
  queryInterface(XTextRangeCompare.class, m_textDoc.getText());
int k = -1000;
  k = xTextRangeCompare.compareRegionStarts(myRanges[0], myRanges[1]);
catch(IllegalArgumentException ex)

Comment 1 Oliver Specht 2009-05-29 06:44:44 UTC
target set
Comment 2 Marcus 2017-05-20 11:17:45 UTC
Reset assigne to the default "".