~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fcl/inc/wformat.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{
2
 
    $Id: wformat.pp,v 1.3 2003/10/04 13:33:43 florian Exp $
3
 
    This file is part of the Free Component Library (FCL)
4
 
    Copyright (c) 1999-2000 by the Free Pascal development team
5
 
 
6
 
    See the file COPYING.FPC, included in this distribution,
7
 
    for details about the copyright.
8
 
 
9
 
    This program is distributed in the hope that it will be useful,
10
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 
 
13
 
 **********************************************************************}
14
 
unit wformat;
15
 
 
16
 
{$ifdef fpc}
17
 
{$mode objfpc}
18
 
{$endif}
19
 
 
20
 
Interface
21
 
 
22
 
uses Classes,SysUtils;
23
 
 
24
 
Type
25
 
  TlistType = (ltNumbered,ltOrdered,ltDefinition);
26
 
 
27
 
  TFormattingWriter = Class
28
 
  Private
29
 
    FStream : TStream;
30
 
  Public
31
 
    Constructor Create (AStream : TStream); Virtual;
32
 
    // To be overridden by descendents
33
 
    Function EscapeText (AText : String) : String; Virtual;
34
 
    // Quick dump.
35
 
    Procedure Dump(Const AText : String);
36
 
    Procedure DumpLn(Const AText : String);
37
 
    // Formatted write. Calls escapetext.
38
 
    Procedure Write(Const AText : String);
39
 
    Procedure WriteFmt(Const Fmt : String; Args : Array of const);
40
 
    // Document Structure
41
 
    Procedure DocumentStart(Const Title : String); Virtual;
42
 
    Procedure DocumentEnd; Virtual;
43
 
    // Header formatting
44
 
    Procedure Header(Alevel : Integer; Msg : String);
45
 
    Procedure HeaderStart(Alevel : Integer); virtual;
46
 
    Procedure HeaderEnd(Alevel : Integer); virtual;
47
 
    // Basic line formatting.
48
 
    Procedure ParagraphStart; virtual;
49
 
    Procedure ParagraphEnd; virtual;
50
 
    Procedure LineBreak; virtual;
51
 
    Procedure Rule; virtual;
52
 
    // text formatting.
53
 
    Procedure BoldStart; Virtual;
54
 
    Procedure BoldEnd;Virtual;
55
 
    Procedure ItalicStart;Virtual;
56
 
    Procedure ItalicEnd;Virtual;
57
 
    Procedure UnderlineStart;Virtual;
58
 
    Procedure UnderlineEnd;Virtual;
59
 
    // Preformatted.
60
 
    Procedure PreformatStart; virtual;
61
 
    Procedure PreformatEnd; virtual;
62
 
    // Table support
63
 
    Procedure TableStart( NoCols: Integer; Border : Boolean); virtual;
64
 
    Procedure TableEnd; virtual;
65
 
    Procedure RowStart; virtual;
66
 
    Procedure RowEnd; virtual;
67
 
    Procedure RowNext;
68
 
    Procedure CellStart; virtual;
69
 
    Procedure CellEnd; virtual;
70
 
    Procedure CellNext;
71
 
    Procedure HeaderCellStart; virtual;
72
 
    Procedure HeaderCellEnd; virtual;
73
 
    Procedure HeaderCellNext;
74
 
    // List support;
75
 
    Procedure ListStart(ListType : TListType); Virtual;
76
 
    Procedure ListEnd(ListType : TListType); Virtual;
77
 
    Procedure ListItemStart; Virtual;
78
 
    Procedure ListItemEnd; Virtual;
79
 
    Procedure ListItem(Const AText : String);
80
 
    Procedure DefinitionItem(Const Aname,AText : String); Virtual;
81
 
    Procedure WriteList(ListType : TListType; List : TStrings);
82
 
  Protected
83
 
    Property Stream : TStream Read FStream;
84
 
  end;
85
 
 
86
 
const
87
 
  LineFeed = LineEnding;
88
 
 
89
 
Implementation
90
 
 
91
 
{ TFormattingWriter }
92
 
 
93
 
procedure TFormattingWriter.BoldEnd;
94
 
begin
95
 
end;
96
 
 
97
 
procedure TFormattingWriter.BoldStart;
98
 
begin
99
 
end;
100
 
 
101
 
procedure TFormattingWriter.CellEnd;
102
 
begin
103
 
end;
104
 
 
105
 
procedure TFormattingWriter.CellStart;
106
 
begin
107
 
end;
108
 
 
109
 
procedure TFormattingWriter.CellNext;
110
 
begin
111
 
  CellEnd;
112
 
  CellStart;
113
 
end;
114
 
 
115
 
constructor TFormattingWriter.Create(AStream: TStream);
116
 
begin
117
 
  FStream:=AStream;
118
 
end;
119
 
 
120
 
procedure TFormattingWriter.DefinitionItem(const Aname, AText: String);
121
 
begin
122
 
 
123
 
end;
124
 
 
125
 
procedure TFormattingWriter.DocumentEnd;
126
 
begin
127
 
 
128
 
end;
129
 
 
130
 
procedure TFormattingWriter.DocumentStart(const Title: String);
131
 
begin
132
 
 
133
 
end;
134
 
 
135
 
procedure TFormattingWriter.Dump(const AText: String);
136
 
begin
137
 
  FStream.WriteBuffer(Atext[1],Length(AText));
138
 
end;
139
 
 
140
 
procedure TFormattingWriter.DumpLn(const AText: String);
141
 
 
142
 
begin
143
 
  Dump(Atext);
144
 
  Dump(LineFeed);
145
 
end;
146
 
 
147
 
Function TFormattingWriter.EscapeText(AText: String) : String;
148
 
begin
149
 
  Result:=AText;
150
 
end;
151
 
 
152
 
procedure TFormattingWriter.Header(Alevel: Integer; Msg: String);
153
 
begin
154
 
  HeaderStart(ALevel);
155
 
  Write(Msg);
156
 
  HeaderEnd(Alevel)
157
 
end;
158
 
 
159
 
procedure TFormattingWriter.HeaderCellEnd;
160
 
begin
161
 
 
162
 
end;
163
 
 
164
 
procedure TFormattingWriter.HeaderCellStart;
165
 
begin
166
 
 
167
 
end;
168
 
 
169
 
procedure TFormattingWriter.HeaderCellNext;
170
 
begin
171
 
  HeaderCellEnd;
172
 
  HeaderCellStart;
173
 
end;
174
 
 
175
 
procedure TFormattingWriter.HeaderEnd(Alevel: Integer);
176
 
begin
177
 
end;
178
 
 
179
 
procedure TFormattingWriter.HeaderStart(Alevel: Integer);
180
 
begin
181
 
 
182
 
end;
183
 
 
184
 
procedure TFormattingWriter.ItalicEnd;
185
 
begin
186
 
 
187
 
end;
188
 
 
189
 
procedure TFormattingWriter.ItalicStart;
190
 
begin
191
 
 
192
 
end;
193
 
 
194
 
procedure TFormattingWriter.LineBreak;
195
 
begin
196
 
end;
197
 
 
198
 
procedure TFormattingWriter.ListEnd(ListType: TListType);
199
 
begin
200
 
 
201
 
end;
202
 
 
203
 
procedure TFormattingWriter.ListItem(const AText: String);
204
 
begin
205
 
  ListItemStart;
206
 
  Write(Atext);
207
 
  ListItemEnd;
208
 
end;
209
 
 
210
 
procedure TFormattingWriter.ListItemEnd;
211
 
begin
212
 
 
213
 
end;
214
 
 
215
 
procedure TFormattingWriter.ListItemStart;
216
 
begin
217
 
 
218
 
end;
219
 
 
220
 
procedure TFormattingWriter.ListStart(ListType: TListType);
221
 
begin
222
 
 
223
 
end;
224
 
 
225
 
procedure TFormattingWriter.ParagraphEnd;
226
 
begin
227
 
end;
228
 
 
229
 
procedure TFormattingWriter.ParagraphStart;
230
 
begin
231
 
end;
232
 
 
233
 
procedure TFormattingWriter.PreformatEnd;
234
 
begin
235
 
end;
236
 
 
237
 
procedure TFormattingWriter.PreformatStart;
238
 
begin
239
 
end;
240
 
 
241
 
procedure TFormattingWriter.RowEnd;
242
 
begin
243
 
end;
244
 
 
245
 
procedure TFormattingWriter.RowStart;
246
 
begin
247
 
end;
248
 
 
249
 
procedure TFormattingWriter.RowNext;
250
 
begin
251
 
  RowEnd;
252
 
  RowStart;
253
 
end;
254
 
 
255
 
procedure TFormattingWriter.Rule;
256
 
begin
257
 
end;
258
 
 
259
 
procedure TFormattingWriter.TableStart(NoCols: Integer; Border: Boolean);
260
 
begin
261
 
end;
262
 
 
263
 
procedure TFormattingWriter.TableEnd;
264
 
begin
265
 
end;
266
 
 
267
 
procedure TFormattingWriter.UnderlineEnd;
268
 
begin
269
 
end;
270
 
 
271
 
procedure TFormattingWriter.UnderlineStart;
272
 
begin
273
 
end;
274
 
 
275
 
procedure TFormattingWriter.Write(const AText: String);
276
 
begin
277
 
  Dump(EscapeText(Atext));
278
 
end;
279
 
 
280
 
procedure TFormattingWriter.WriteFmt(const Fmt: String; Args: array of const);
281
 
begin
282
 
  Write(Format(Fmt,Args));
283
 
end;
284
 
 
285
 
procedure TFormattingWriter.WriteList(ListType: TListType; List: TStrings);
286
 
 
287
 
Var
288
 
  I,J : integer;
289
 
  N,V : String;
290
 
 
291
 
begin
292
 
  ListStart(ListType);
293
 
  try
294
 
    For I:=0 to List.Count-1 do
295
 
      if ListType<>ltDefinition then
296
 
        ListItem(List[i])
297
 
      else
298
 
        begin
299
 
        V:=List[i];
300
 
        J:=Pos('=',V);
301
 
        if (J>0) then
302
 
          begin
303
 
          N:=Copy(V,1,J-1);
304
 
          Delete(V,1,J);
305
 
          end;
306
 
        DefinitionItem(N,V);
307
 
        end;
308
 
  finally
309
 
    ListEnd(ListType)
310
 
  end;
311
 
end;
312
 
 
313
 
end.
314
 
{
315
 
  $Log: wformat.pp,v $
316
 
  Revision 1.3  2003/10/04 13:33:43  florian
317
 
    * system unit has a LineEnding
318
 
 
319
 
  Revision 1.2  2003/10/01 21:05:39  michael
320
 
  + Stream property is now protected
321
 
 
322
 
  Revision 1.1  2003/10/01 20:49:29  michael
323
 
  + Initial implementation
324
 
 
325
 
}