Delete characters with special attribute, i.e. Hidden or Bold

Problem + Solutions with the modern WPTools architecture which was introduced with WPTool 5
wpsupport
Site Admin
Posts: 7383
Joined: Fri Oct 24, 2003 4:06 pm
Contact:

Delete characters with special attribute, i.e. Hidden or Bold

Postby wpsupport » Thu Aug 20, 2015 7:25 pm

Q: How to delete characters with special attribute, i.e. Hidden or Bold

A: The following code loops to all the text and marks all characters which have a certain character style with the deletion marker. Later all text with that marker is deleted by DeleteMarkedChar.

Code: Select all

par : TParagraph;
    i: Integer;
    c : Cardinal;
begin
  par := WPRichText1.HeaderFooter.FirstPar;
  while par<>nil do
  begin
     for I := 0 to par.CharCount-1 do
     begin
        c := par.CharAttr[i];
        WPRichText1.AttrHelper.CharAttr := c;
        if WPRichText1.AttrHelper.HasAStyle(afsBold) then // afsHidden
        begin
          c := c or cafsDelete;
          par.CharAttr[i] := c;
        end;
     end;
     par := par.globalnext;
  end;
  WPRichText1.DeleteMarkedChar(true);
end;

Return to “FAQ WPTools 5, 6 and 7 - General”



Who is online

Users browsing this forum: No registered users and 1 guest