Issue 58646 - xTableRows insertByIndex() method fails inserting new row to blank table
Summary: xTableRows insertByIndex() method fails inserting new row to blank table
Status: UNCONFIRMED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords: oooqa
Depends on:
Blocks:
 
Reported: 2005-11-30 05:02 UTC by mr_than
Modified: 2013-07-30 02:14 UTC (History)
2 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 mr_than 2005-11-30 05:02:57 UTC
I just updated to OOo version 2.0.m142/2.0.1rc from the 2.0 release version and
the insertByIndex( ) method which is being used in the following to create one
or more tables and insert rows into them. It still works fine on another machine
running OOo 2.0 release and has since I started using it on 1.1.2/3.

The exception thrown is:

com.sun.star.uno.RuntimeException: Illegal arguments

	at
com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:275)

	at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:141)

	at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:377)

	at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:346)

	at
com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:106)

	at
com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:860)

	at
com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:809)

	at
com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:154)

	at
com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:140)

	at $Proxy23.insertByIndex(Unknown Source)

	at convert.DocumentCreator.createPartA(DocumentCreator.java:491)

	at convert.DocumentCreator.createDocs(DocumentCreator.java:132)

done

	at convert.CourseProfileGenerator.<init>(CourseProfileGenerator.java:254)

	at convert.CourseProfileGenerator.Process(CourseProfileGenerator.java:88)

	at convert.CourseProfileGenerator.main(CourseProfileGenerator.java:55)



I'll include a full working sample tomorrow.

//break process through data and add tables with item headings as required
	  String prevAssessmentType = "";
	  XTextTable xTable = null;
          String assessText = "";          
					int rowNum = 1;         //iterate DOWN rows by rownum counter
          boolean firstItem = true;
          XTableRows xTableRows = null;     //XIndexAccess of the table rows for
adding table rows
          XPropertySet xTableProps = null;  //XTextTable properties
          TableColumnSeparator[] colWidth = { new TableColumnSeparator(
(short)8000, true) }; //set width of column to 80% - relative numbers of 10000

          Row aRow = assessment.next();
          do { //if first item of a type or last item altogether
            if (!prevAssessmentType.equals(
aRow.getAttribute("AssessmentType").toString() ) ) {

              //add a new title to the page showing the assessment type
              // Insert the table into the document at the bookmark cursor's
location
              if (aRow.getAttribute("LongName") != null) {
                xtext.insertString(assessmentCursor,
aRow.getAttribute("LongName").toString(), true );
              }
              //set new title para style to "Item Subheading" style defined in
document
              XPropertySet xTitleProps = (XPropertySet)UnoRuntime.queryInterface(
                      XPropertySet.class, assessmentCursor );
              xTitleProps.setPropertyValue("ParaStyleName", "Item Subheading" );
              //deselect title and write table to document
              assessmentCursor.collapseToEnd();

              //create a new table and add it to the page
              xTable = (XTextTable) UnoRuntime.queryInterface(XTextTable.class,
mxBaseDocFactory.createInstance("com.sun.star.text.TextTable" ) );
              xTable.initialize( 1, 2);					    
              xtext.insertTextContent( assessmentCursor, xTable, false);

              // Get an XIndexAccess of the table rows for adding table rows
              xTableRows = xTable.getRows();
                            
              // Access the XPropertySet of the table
              xTableProps = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xTable );
              xTableProps.setPropertyValue( "TableColumnSeparators", colWidth );
              xTableProps.setPropertyValue("Split", new Boolean(false) ); //keep
table together on a page

              //reset row counter
              rowNum = 1;              
						} else { //continue - create a new row
              xTableRows.insertByIndex( rowNum, 1 ); <-- fails here
						}

          //add the row data to the row
          assessText = "";
          if (aRow.getAttribute("AssessmentNo") != null) {
            assessText = "Assessment item " +
aRow.getAttribute("AssessmentNo").toString() + ": ";
          }
          if (aRow.getAttribute("AssessmentText") != null) {
            assessText +=
aRow.getAttribute("AssessmentText").toString().replaceAll( "<br ?/?>", ""
).replaceAll( "\r?\n", "\n" );
          }
          if (assessText.length() > 0) {
            insertIntoCell("A" + rowNum, assessText, xTable);
          }
          if (aRow.getAttribute("AssessmentPercentage") != null) {
            insertIntoCell("B" + rowNum,
aRow.getAttribute("AssessmentPercentage").toString() + "%", xTable);
          }

          rowNum++;
          prevAssessmentType = aRow.getAttribute("AssessmentType").toString();
            
        } while( (aRow = assessment.next()) != null );
Comment 1 michael.ruess 2005-12-07 10:41:28 UTC
MRU->FME: can you please have a look if this is of any worth to you or if this
is more for API? Thanks a lot!
Comment 2 frank.meies 2005-12-07 11:36:28 UTC
FME: Looks like an API issue. 
Comment 3 michael.ruess 2005-12-07 11:50:18 UTC
MRU->CN: could you please reassign to correct contact?
Comment 4 chne 2006-01-03 07:52:59 UTC
cn->mr_than: Can you tell me on which platform you are working. And can you
verify this behavior on a newer version of OOo. If the failure occure also on a
newer version please attach the full working example.
Comment 5 hwoarang 2006-03-01 02:10:34 UTC
Closing (worksforme) as there's no answer from reporter for too long.

Feel free to reopen it if necessary.

Thank you.
Comment 6 hwoarang 2006-03-01 02:10:45 UTC
.
Comment 7 mr_than 2006-08-07 04:43:58 UTC
I've tracked the problem down to the xTableRows.insertByIndex method. It now
requires two longs as it's arguments, but I think it must have taken two ints in
the past.

The documentation
(http://api.openoffice.org/docs/common/ref/com/sun/star/table/XTableRows.html)
now says two longs, but it will not compile against recent builds (currently
608_b180) but is still OK on the 2.0 release version.

I've tried this in Jdeveloper and now Eclipse and both show the same in content
assist (ints) and neither will compile it with longs.

If I run it with ints, OpenOffice gives the same fatal error.
Comment 8 mr_than 2006-08-07 04:52:27 UTC
This is on Windows XP BTW
Comment 9 mr_than 2006-10-10 01:16:17 UTC
issue 59143 also shows an error with this API
Comment 10 Rob Weir 2013-07-30 02:14:57 UTC
Reset assignee on issues not touched by assignee in more than 2000 days.