Issue 102348 - XTextRangeCompare throws IllegalArgumentException when compairing two XTextRange of two XTextTable
Summary: XTextRangeCompare throws IllegalArgumentException when compairing two XTextRa...
Status: ACCEPTED
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:
URL:
Keywords:
Depends on:
Blocks:
 
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: ---


Attachments

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
Hi,

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


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

>Exception occurred in target VM:
com.sun.star.lang.IllegalArgumentException:
at com.sun.star.bridges.jni_uno.JNI_proxy.dispatch_call(Native Method)
at com.sun.star.bridges.jni_uno.JNI_proxy.invoke(JNI_proxy.java:178)
at $Proxy35.compareRegionStarts(Unknown Source)
at ast.structure.ElementController.checkTextTable(ElementController.java:939)
at ast.structure.ElementController.analyze(ElementController.java:980)
at ast.BesserWissA.dispatch(BesserWissA.java:408)
< 


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
IllegalArgumentException.

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.


Code:


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

Object desktop = null;
try
{
  desktop = m_aMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
    m_aComponentContext);
}
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];

System.out.println(
  "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;
  try
  {
    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;
try
{
  k = xTextRangeCompare.compareRegionStarts(myRanges[0], myRanges[1]);
}
catch(IllegalArgumentException ex)
{
}

System.out.println(k);
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 "issues@openoffice.apache.org".