2
This file is part of the Free Pascal run time library.
3
Copyright (c) 1999-2000 by Michael Van Canneyt, member of the
4
Free Pascal development team
6
This program demonstrates the RTF parser object.
8
See the file COPYING.FPC, included in this distribution,
9
for details about the copyright.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
**********************************************************************}
23
TRTFDemo = class(TObject)
26
Procedure DoDestination;
31
procedure handleerror ( s : shortstring);
37
procedure TRTFDemo.DoDestination;
39
skip all special destinations.
45
procedure TRTFDemo.dospecial;
47
Don't do anything special.
50
if FParser.RTFMinor=rtfpar then
55
procedure TRTFDemo.doctrl;
58
case Fparser.rtfmajor of
59
rtfdestination : dodestination;
60
rtfspecialchar : dospecial;
65
Procedure TRTFDemo.Dowrite;
68
{ RTFmajor contains the character ASCII Code, we just dump it }
69
Write (chr(FParser.RTFMajor));
72
procedure TRTFDemo.Start;
74
var Thestream : TFilestream;
77
Thestream:=TFileStream.Create(FFileName,fmopenread);
78
FParser:=TRTFParser.Create(TheStream);
79
FParser.classcallbacks[rtfText]:=@dowrite;
80
FParser.classcallbacks[rtfcontrol]:=@doctrl;
81
FParser.onrtferror:=@handleerror;
87
procedure TRTFDemo.handleerror ( s : shortstring);
96
RTFDemo:=TRTFDemo.Create;
97
If Paramstr(1)='' then
99
Write ('Enter filename to process: ');
104
RTFDemo.FFileName:=Name;