Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread RTF to Plain text filter - version -1
Mon, Dec 3 2007 4:50 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

procedure TEDBTextFilterModule1.EDBTextFilterModuleFilterText(const FilterType: string; const TextToFilter: string; var FilteredText: string);
var
Cntr: integer;
CharsToProcess: integer;
Cmnd: string;
procedure ProcessCommand;
begin
// is an actual command so "simply" move to the end
// most of the time this will be \{ or space BUT \fprq HAS to be terminated with a ;
// Others start & finish with {}, but by skipping to the first \par we should miss those
 Cmnd := '';
 inc(Cntr);
 while (Cntr < CharsToProcess) and (not (TextToFilter[Cntr] in [#32, '\', '}', '{'])) do begin
  Cmnd := Cmnd + TextToFilter[Cntr];
  inc(Cntr);
 end;
 Cmnd := LowerCase(Cmnd);
 if (Cmnd = '*') or
  (Cmnd = 'listtext') or
  (Cmnd = 'sv') or
  (Cmnd = 'sn') or
  (Cmnd = 'pntxtb') or
  (Cmnd = 'pntext') or
  (Cmnd = 'footer') or
  (Cmnd = 'fldrslt')
  then begin
  while (Cntr < CharsToProcess) and (TextToFilter[Cntr] <> '}') do inc(Cntr);
  inc(Cntr);
 end;
 if TextToFilter[Cntr] <> #32 then dec(Cntr);
end;
begin
FilteredText := '';
CharsToProcess := Length(TextToFilter);
Cntr := Pos('\par', TextToFilter);
if Cntr = 0 then Cntr := 1;
while Cntr <= CharsToProcess do begin
 case TextToFilter[Cntr] of
  '{', '}': {just skip};
  #0..#31: if TextToFilter[Cntr] in [#9, #10, #13] then begin
    if (Cntr > 1) and ((FilteredText = '') or (FilteredText[Length(FilteredText)] <> #32)) then FilteredText := FilteredText + #32;
   end;
  '\': if not ((Cntr > 1) and (Cntr < CharsToProcess) and (TextToFilter[Cntr + 1] in [#39, '\', '{', '}']))
   then ProcessCommand
   else begin
    inc(Cntr);
    if TextToFilter[Cntr] = #39 then begin
     FilteredText := FilteredText + Char(StrToInt('$' + TextToFilter[Cntr + 1] + TextToFilter[Cntr + 2]));
     inc(Cntr, 2);
     if (Cntr < CharsToProcess) and (TextToFilter[Cntr + 1] = '}') then inc(Cntr);
    end else FilteredText := FilteredText + TextToFilter[Cntr];
   end;
 else begin
   if Cmnd = 'cell' then FilteredText := FilteredText + ' ';
   Cmnd := '';
   FilteredText := FilteredText + TextToFilter[Cntr]; // we'll end up with some extra crap but these should be removed in the word generator
  end;
 end;
 inc(Cntr);
end;
end;
Mon, Dec 3 2007 7:44 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

Cool, thanks.  Perhaps a post in the binaries in a .zip would be easier for
those that need it ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Dec 4 2007 3:49 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

Can do. But what about posting zips here to keep all the extension stuff together?

Roy Lambert
Tue, Dec 4 2007 4:34 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< Can do. But what about posting zips here to keep all the extension stuff
together? >>

I'm cool with that.  The name of the newsgroup kind of implies that there
will be some actual goodies here.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image