trichview.com

trichview.support




Re: Convert text to plain


Return to index


Author

Message

Sergey Tkachenko

Posted: 02/27/2004 18:25:49


This code removes all text and paragraph formatting very fast.

But it cannot be undone.

And it does not change formatting for Unicode text (if RVStyle.TextStyles[0]

is not Unicode)

(if you remove a check for Unicode property, this procedure can damage the

document)


procedure RemoveFormatting(RVData: TCustomRVData);

var i, r, c, StyleNo: Integer;

    table: TRVTableItemInfo;

begin

  for i := RVData.ItemCount-1 downto 0 do begin

    RVData.GetItem(i).ParaNo := 0;

    StyleNo := RVData.GetItemStyle(i);

    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

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

      end

    else if StyleNo=rvsListMarker then

      RVData.RemoveListMarker(i)

    else if (StyleNo>=0) and

      (RVData.GetRVStyle.TextStyles[0].Unicode=

       RVData.GetRVStyle.TextStyles[StyleNo].Unicode) then begin

      RVData.GetItem(i).StyleNo := 0;

      RVData.SetItemTag(i, 0);

    end;

  end;

end;


Call it:

  RemoveFormatting(RichViewEdit1.RVData);

  RichViewEdit1.ClearUndo;

  RichViewEdit1.Format;






Powered by ABC Amber Outlook Express Converter