trichview.support
table cell data question |
Author |
Message |
Daniel Zimmerman |
Posted: 06/25/2005 5:12:45 I've just encountered what seems to be a strange problem: I'm iterating through a table recursively, in order to change the size, and it appears that while changing the size, in one case, the cell data contains an item which is a table, which in turn contains a cell which is equivalent to the original cell. To make this clearer, here is the relevant code. This method is always initially called with the rvedit's data property (and it is not the case that the cell data is equal to the rvedit's data). The end result of this problem is that the method gets stuck in an infinite loop, because when it calls adjustTableSizeRecur, it's calling it with an object which is identical to the object that was passed in. Most of the time this works perfectly - just one time, with an RVEdit with a single table and 2 rows and 2 columns, did it fail. procedure adjustTableSizeRecur(const byFactor: single; data: TcustomRvFormattedData; var wasChanged: boolean); var cntr, colCntr, rowCntr, cellCntr: integer; curTable: TRvTableItemInfo; curCell: TRvTableCellData; startingHeight: integer;//, startingWidth: integer; begin if data = nil then exit; for cntr := 0 to data.ItemCount - 1 do begin if data.GetItem(cntr).StyleNo = rvsTable then begin curTable := TRvTableItemInfo(getItem(cntr)); {code for changing the table size ...} for rowCntr := 0 to curTable.Rows.count-1 do begin for colCntr := 0 to curTable.rows[rowCntr].count-1 do begin curCell := curTable.cells[rowCntr, colCntr]; if curCell <> nil then begin // catch any embedded tables adjustTableSizeRecur(byFactor, curCell, wasChanged); {more code to change the cell size...} end; end; end; end; end; end; Is there anything obvious that we are doing wrong here? Should we simply allow for the possibility that "curCell" might be equal to "data", and make that test before calling the recursive call? Thanks in advance, Daniel |
Powered by ABC Amber Outlook Express Converter