Apache OpenOffice (AOO) Bugzilla – Issue 79482
Table.InsertCellAt loops on a changing collection and throws an exception. Moreover it doesn't respect the zero based index
Last modified: 2013-03-11 15:04:16 UTC
In AODL (cvs path: odftoolkit/aodl/AODL) there's an error: in Document\Content\Tables\Table.cs line 222 This uses an enumerator on a changing collection (it is wrong and it throws an exception) The old line: for(int i=0; i < rowIndex-this.RowCollection.Count; i++) must be changed to: int cnt = this.RowCollection.Count; for(int i=0; i < rowIndex-cnt; i++) BTW: how can I checkin to CVS without reporting the bug here? What user/password should I use? Thank you
Better explained the issue
I found that even with the fix the method doesn't respect the "zero based index" param spec. Table.InsertCellAt(0,0) should insert at "A1" This is a more complete and clean patch: diff -w -b -i -r1.3 Table.cs 210,211c210,211 < /// Inserts the cell at the specified position. Both indexes are zero < /// based indexes! --- > /// Inserts the cell at the specified position. > /// Both indexes are zero based indexes! 220,223c220,221 < if(this.RowCollection.Count <= rowIndex) < { < for(int i=0; i < rowIndex-this.RowCollection.Count; i++) < this.RowCollection.Add(new Row(this, "row"+this.RowCollection.Count.ToString()+i.ToString())); --- > for (int i = this.RowCollection.Count; i <= rowIndex; i++) > this.RowCollection.Add(new Row(this, "row" + i.ToString())); 225,239c223,224 < this.RowCollection[rowIndex-1].InsertCellAt(columnIndex-1, cell); < cell.Row = this.RowCollection[rowIndex-1]; < } < else if(this.RowCollection.Count+1 == rowIndex) < { < Row row = new Row(this, this.RowCollection[this.RowCollection.Count-1].StyleName); < row.InsertCellAt(columnIndex-1, cell); < cell.Row = row; < this.RowCollection.Add(row); < } < else < { < this.RowCollection[rowIndex-1].InsertCellAt(columnIndex-1, cell); < cell.Row = this.RowCollection[rowIndex-1]; < } --- > this.RowCollection[rowIndex].InsertCellAt(columnIndex, cell); > cell.Row = this.RowCollection[rowIndex]; and diff -w -b -i -r1.2 Row.cs 174,177c174 < if(this.CellCollection.Count <= position) < { < //3 - 5 = 6, 5 - 5 = 6 < for(int i=0; i < position-this.CellCollection.Count; i++) --- > for (int i = this.CellCollection.Count; i < position; i++) 179,186c176 < this.CellCollection.Add(cell); < } < else if(this.CellCollection.Count+1 == position) < { < this.CellCollection.Add(cell); < } < else < { --- > 189d178 < }
Created attachment 46745 [details] Patch
Issue fixed
Not quite fixed.. you just made a patch available. Please _attach_ the patch file instead of pasting it as a comment where it may get reformatted at any browser's will and may not apply afterwards. Also, spreadsheet is the wrong component here, it should be odftoolkit instead, but for some mysterious reasons isn't available in the list box now that spreadsheet is assigned?!? Reassigning to the odftoolkit project lead for further processing.
Reopening.
I tried to assign it to component odftoolkit (but it was missing since the beginning) (and I already provided the patch as an attachment)
DL->LarsBehr: Hi Lars, could you please takeover this issue?
I'm adding this comment to all open issues with Issue Type == PATCH. We have 220 such issues, many of them quite old. I apologize for that. We need your help in prioritizing which patches should be integrated into our next release, Apache OpenOffice 4.0. If you have submitted a patch and think it is applicable for AOO 4.0, please respond with a comment to let us know. On the other hand, if the patch is no longer relevant, please let us know that as well. If you have any general questions or want to discuss this further, please send a note to our dev mailing list: dev@openoffice.apache.org Thanks! -Rob