To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=102348
                 Issue #|102348
                 Summary|XTextRangeCompare throws IllegalArgumentException when
                        | compairing two XTextRange of two XTextTable
               Component|api
                 Version|OOo 3.0
                Platform|PC
                     URL|
              OS/Version|Windows XP
                  Status|UNCONFIRMED
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P3
            Subcomponent|code
             Assigned to|os
             Reported by|budspencer





------- Additional comments from [email protected] Thu May 28 21:36:32 
+0000 2009 -------
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);

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to