TRVTextItemInfo

General TRichView support forum. Please post your questions here
Post Reply
MichaelS
Posts: 3
Joined: Fri Aug 17, 2007 1:14 pm

TRVTextItemInfo

Post by MichaelS »

Hello,

I'm iterating a table with his cells. In a cell I have different TCustomRVItemInfo classes. Now I have to extract from every cellitem, which is a TRVTextItemInfo, the RVData into a Stream.

Do you have a fast solution for me? Thanks in Advance!

Yours,
Michael
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I do not understand. Can you explain in another words?
MichaelS
Posts: 3
Joined: Fri Aug 17, 2007 1:14 pm

Post by MichaelS »

Hello,

Sorry, my englisch isn't so good. Here my problem in another words:

I have a TRichViewEdit component, which contains a table with formatted text. Now I would like to extract, for each tablecell the formatted text into a RV-Stream.

Here a example:

Code: Select all

var
  intIndex: Integer;
  objData: TRVEditRVData;
  objItem: TRVTableItemInfo;
  objCell: TRVTableCellData;
  intRow: Integer;
  intCol: Integer;
  intCount: Integer;
begin
  objData := TRVEditRVData(rvEdit.RVData);

  for intIndex := 0 to rvEdit.ItemCount-1 do
  begin
    if objData.GetItem(intIndex) is TRVTableItemInfo then
    begin
      objItem := TRVTableItemInfo(objData.GetItem(intIndex));
      for intRow := 0 to objItem.RowCount -1 do
      begin
        for intCol := 0 to objItem.ColCount - 1 do
        begin
          objCell := objItem.Cells[intRow, intCol];

          for intCount := 0 to objCell.ItemCount - 1 do
          begin
            if objCell.GetItem(intCount) IS TRVTextItemInfo then
            begin

              // => here save for each TRVTextItemInfo the RV-Text

            end;
          end;
        end;
      end;
    end;
  end;
end;
Thanks in Advance.

Yours,
Michael
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

var 
  intIndex: Integer; 
  objData: TRVEditRVData; 
  objItem: TRVTableItemInfo; 
  objCell: TRVTableCellData; 
  intRow: Integer; 
  intCol: Integer; 
  intCount: Integer; 
begin 
  objData := TRVEditRVData(rvEdit.RVData); 

  for intIndex := 0 to rvEdit.ItemCount-1 do 
  begin 
    if objData.GetItem(intIndex) is TRVTableItemInfo then 
    begin 
      objItem := TRVTableItemInfo(objData.GetItem(intIndex)); 
      for intRow := 0 to objItem.RowCount -1 do 
      begin 
        for intCol := 0 to objItem.ColCount - 1 do 
        begin 
          objCell := objItem.Cells[intRow, intCol]; 
[color=blue]          if objCell=nil then
            continue;[/color]

          for intCount := 0 to objCell.[color=blue]GetRVData.[/color]ItemCount - 1 do 
          begin 
            if objCell.[color=blue]GetRVData.[/color]GetItem(intCount) IS TRVTextItemInfo then 
            begin 

              [color=blue]{ Use objCell.GetRVData.GetItemTextA(intCount) }[/color]

            end; 
          end; 
        end; 
      end; 
    end; 
  end; 
end;
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

In addition, you can:
- for TRVTabItemInfo items, add #9 in text
- if objCell.GetRVData.IsFromNewLine(intCount), add #13#10
MichaelS
Posts: 3
Joined: Fri Aug 17, 2007 1:14 pm

Post by MichaelS »

Hello Sergey,

it works fine! Thanks a lot!

Yours,
Michael
Post Reply