trichview.com

trichview.support




Re: Parsing the text


Return to index


Author

Message

Sergey Tkachenko

Posted: 11/03/2004 22:28:22


This procedure searches for bold navy text. When found, it adds parentheses

around it.


uses CRVData, RVTable;


procedure FindNavyBoldText(RVData: TCustomRVData);

var i,r,c,StyleNo: Integer;

    table: TRVTableItemInfo;

    s: String;

begin

  for i := 0 to RVData.ItemCount-1 do

  begin

    StyleNo := RVData.GetItemStyle(i);

    if StyleNo>=0 then

    begin

      // this is a text;

      if (RVData.GetRVStyle.TextStyles[StyleNo].Color=clNavy) and

         (fsBold in RVData.GetRVStyle.TextStyles[StyleNo].Style) then

      begin

        s := RVData.GetItemTextA(i);

        s := '('+s+')';

        RVData.SetItemTextA(i, s);

      end;

    end

    else if StyleNo=rvsTable then

    begin

      table := TRVTableItemInfo(RVData.GetItem(i));

      for r := 0 to table.Rows.Count-1 do

        for c := 0 to table.Rows[r].Count-1 do

          if table.Cells[r,c]<>nil then

            FindNavyBoldText(table.Cells[r,c].GetRVData);

    end;

  end;

end;


Example:

FindNavyBoldText(RichView1.RVData);

RichView1.Format;


This procedure cannot be undone and redone. So, if you call it for editor,

call ClearUndoBuffer when calling this procedure.





>

> Hi everybody...

>

> I've been finding for an example how can I parse the entire RichViewEdit

> text and search words with specific colors and then replace them for

another

> words, but I couldn't find...

>

> For example... I have the following text:

>

> "hello world! My name is Su..."

>

> And the words "world" and "name" are in darkblue and bold. How can I do a

> parse in this text and find only words with this styles (darkblue and

bold)

> and replace only this words ? I am using C++ Builder.

>

> Please heeeeeeeeellllllllpppppp me!

>





Powered by ABC Amber Outlook Express Converter