trichview.support
Working with table cells |
Author |
Message |
Martin Holmes |
Posted: 06/08/2004 15:23:51 I need to be able to count all items in a document which have a specific style and text. To do this, I need a recursive function which iterates through the document checking each item to see if it matches; when it finds a table, it needs to go through each of the cells in the same way, and so on for embedded tables. However, I've hit a problem in that I don't know how to get a reference to the embedded TRichViewEdit that is inside each table cell. This is my function so far: function TfrmMain.CountAnns(AnnText: WideString; AnnType: integer; RVE: TCustomRichViewEdit): integer; var i, Row, Col: integer; Table: TRVTableItemInfo; begin Result := 0; with RVE do begin for i := 0 to ItemCount-1 do begin if GetItemStyle(i) = AnnType then begin if GetItemTextW(i) = AnnText then Inc(Result); end else begin if GetItemStyle(i) = rvsTable then begin //Get a pointer to the table and then iterate //through the rows Table := TRVTableItemInfo(RVData.GetItem(i)); with Table do begin for Row := 0 to Table.Rows.Count-1 do for Col := 0 to Table.Rows[Row].Count-1 do if Table.Cells[Row,Col] <> nil then //FAILS HERE Result := Result + CountAnns(AnnText, AnnType, Table.Cells[Row,Col]); end; end; end; end; end; end; The line that fails is attempting to treat Table.Cells(Row,Col] as a TCustomRichViewEdit, but of course this doesn't work because it's a TRVTableCellData object. How can I use the same function to iterate through the items of a table cell as for iterating through the main document? All help appreciated, Martin |
Powered by ABC Amber Outlook Express Converter