-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCALCSAVE.PAS
680 lines (654 loc) · 17.1 KB
/
CALCSAVE.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
Unit CalcSave;
INTERFACE
Function SCSave(Var Q):Boolean;
Function SCSaveAs(Var Context;Const FileName:String):Boolean;
IMPLEMENTATION
Uses Video,Math,Numerix,Systex,Memories,Systems,Isatex,Calcex,Dialex,Dials,
DialPlus,MalCalc,ResTex,ResServD;
{$I \Source\Chantal\Library\HashTabl.Inc}
{$I \Source\Chantal\Library\App\Tableur\Column.Inc}
{$I \Source\Chantal\Library\App\Tableur\Cellule.Inc}
Function GetColorClassicHTML(Color:Byte):String;Near;Begin
GetColorClassicHTML:='#'+HexByte2Str(DefaultRGB[Color].R)+HexByte2Str(DefaultRGB[Color].G)+HexByte2Str(DefaultRGB[Color].B);
End;
Function SCSaveAs;
Var
Q:SuperCalcApp Absolute Context;
J,I:LongInt;
K:Byte;
Handle:Hdl;
Size:Word;
PC:PCellule;
First:Boolean;
UpDate:Boolean;
H:HashItemPtr;
S,Path:String;
STarget:String;
Color:String[15];
LW:Window;
Font:DataSetInMemory; { Pour la conversion de la police de caractŠres }
Data:DataMGCIdRec;
Buffer:Array[0..511]of Byte;
LLabel:LabelLotus123 Absolute Buffer;
LHeader:HeaderLotus123 Absolute LLabel;
LEnd:EndLotus123 Absolute LHeader;
LDouble:DoubleLotus123 Absolute LHeader;
SignExcel:BOFExcel Absolute Buffer;
Label4Excel:LabelExcel Absolute Buffer;
Integer4Excel:IntegerExcel Absolute Buffer;
Number4Excel:NumberExcel Absolute Buffer;
EOF4Excel:EOFExcel Absolute Buffer;
Procedure SaveName;
Var
R:FileListBox; { Objet pour l'entr‚e d'un nom de document }
H:History; { Histoire retenu pour cette objet }
Format:Byte;
K:Word;
Begin
HYInit(H,0);
FLInitModel(R,Path,'Sauvegarde sous',H,False,False,True,omCalc);
Case(Q.FormatMode)of
tfMGC:Format:=cfoMGC;
tfLotus:Format:=cfoLotus123;
tfExcel:Format:=cfoExcel21;
tfASCII:Format:=cfoLst;
tfCSV:Format:=cfoCSV;
tfHTML:Format:=cfoHTML;
Else Format:=cfoMGC;
End;
FLUpDateFormat(R,Format);
Repeat
K:=FLRun(R);
Until(K=kbEsc)or(K=kbClose)or(K=kbEnter);
If(K=kbEnter)Then Begin
Case FLFormat(R)of
cfoMGC:Q.FormatMode:=tfMGC;
cfoLotus123:Q.FormatMode:=tfLotus;
cfoExcel21:Q.FormatMode:=tfExcel;
cfoLst:Q.FormatMode:=tfASCII;
cfoCSV:Q.FormatMode:=tfCSV;
cfoHTML:Q.FormatMode:=tfHTML;
Else Q.FormatMode:=tfMGC;
End;
Path:=R.Path;
End;
FLDone(R);
End;
Procedure AddLotusFormula(C,F:Integer;S:String);
Type
Formula=Record
TypeCode:Integer; { Code d'identification = 16 }
Length:Integer; { Longueur des donn‚es }
Format:Byte; { Format }
Column:Integer; { Colonne }
Row:Integer; { Ligne }
Res:Double;
Tma:Integer;
Formula:Array[1..2048]of Byte;
End;
Symbol=(Cellule,num,arr,mas,men,por,dvs,pot,pa1,pa2);
ConSym=Set of Symbol;
Var
Formato:Array[1..2067]of Byte;
Registro:Formula Absolute Formato;
FAbs:Boolean;
V,nro:String;
cfml,ffml:Word;
nfml,i,ii,Index,j,Ret,Len,Lens:Integer;
Sym:Symbol;
SymSig,
SymIniFac:ConSym;
z:Byte;
Procedure CalculaDir(Var Reg:Formula);
Var
Veces:Integer;
Begin
With Reg do Begin
If v[I]='$'Then Begin
Inc(I);
cfml:=Byte(v[i])-Byte('A');
Inc(I);
While(v[i]in['A'..'Z'])and(Len>=i)do Begin
cfml:=(cfml+1)*26+ord(v[i])-ord('A');
Inc(i);
End;
End
Else
Begin
If(Byte(v[i])-Byte('A')<Column)Then Begin
cfml:=49152-Column+(Byte(v[i])-Byte('A'));
Inc(i);
Veces:=1;
While(v[i]in['A'..'Z'])and(Len>=i)do Begin
cfml:=49152-Column+(26*veces)+(ord(v[i])-ord('A'));
cfml:=cfml+((ord(v[i-1])-ord('A'))*26);
Inc(i);
Inc(veces);
End;
End
Else
Begin
cfml:=Byte(v[i])-Byte('A');
Inc(I);
While(v[i]in['A'..'Z'])and(Len>=i)do Begin
cfml:=(cfml+1)*26+Byte(v[i])-Byte('A');
Inc(i);
End;
cfml:=cfml+32768-Column;
End;
End;
Formula[Index]:=Lo(cfml);
Inc(Index);
Formula[Index]:=Hi(cfml);
Inc(Index);
If v[I]='$'Then Begin
Inc(I);
Fabs:=True;
End
Else
FAbs:=False;
j:=i;
While(v[i]in['0'..'9'])and(Len>=i)do Inc(I);
nro:=Copy(v,j,i-j);
Val(nro,ffml,ret);
If(FAbs)Then Begin
If ffml>0Then ffml:=ffml-1;
End
Else
Begin
If(Row<ffml)Then Begin
ffml:=32768+Abs(ffml-Row)-1;
End
Else
Begin
ffml:=49152-Abs(ffml-Row)-1;
End;
End;
Formula[Index]:=Lo(ffml);
Inc(Index);
Formula[Index]:=Hi(ffml);
Inc(Index);
End;
End;
Procedure CalculaNum(Var Reg:Formula);
Var
VDoble:Array[1..8]of Byte;
dfml:Double Absolute VDoble;
d:Real;
esreal:Boolean;
k:Byte;
Numero:LongInt;
codigo:Integer;
Begin
With Reg do Begin
Esreal:=False;
j:=i;
While(v[I]in['0'..'9','.'])and(Len>=I)do Begin
If v[I]='.'Then Esreal:=True;
Inc(I);
End;
nro:=Copy(v,j,i-j);
Val(nro,Numero,Codigo);
EsReal:=Not((Codigo=0)and(Numero>=-32768)and(Numero<=32767));
If(EsReal)Then Begin
Val(nro,d,ret);
D:=DoubleToReal(dfml);
Formula[Index]:=0;
Inc(Index);
For k:=1to 8do Begin
Formula[Index]:=VDoble[k];
Inc(Index);
End;
End
Else
Begin
Val(nro,nfml,ret);
Formula[Index]:=5;
Inc(Index);
Formula[Index]:=Lo(nfml);
Inc(Index);
Formula[Index]:=Hi(nfml);
Inc(Index);
End;
Dec(I);
End;
End;
Procedure CalculaRan(Var Reg:Formula);Begin
With Reg do Begin
Formula[Index]:=2;
Inc(Index);
CalculaDir(Reg);
Inc(I,2);
CalculaDir(Reg);
End;
End;
{** Les codes @TRUE,@FALSE,@SUM(COL1FIL1..COL2FIIL2) **}
Procedure CalculaArr(Var Reg:Formula);
Var
Func,Dir:String;
NArg,nc:Byte;
Begin
With Reg do Begin
Inc(i);
Case v[i]of
'F':nc:=51;
'T':nc:=52;
'S':nc:=80;
End;
While(v[i]in['A'..'Z'])and(Len>=I)do Inc(I);
Inc(I);
If nc=80Then Begin
CalculaRan(Reg);
NArg:=1;
End;
Formula[Index]:=nc;
Inc(Index);
If nc=80Then Begin
Formula[Index]:=NArg;
Inc(Index);
End;
End;
End;
Procedure TraerChar;Begin
Inc(I);
If(Len>=i)Then Begin
Case v[i]of
'A'..'Z','$':Sym:=Cellule;
'0'..'9','.':Sym:=num;
'@':Sym:=arr;
'+':Sym:=mas;
'-':Sym:=men;
'*':Sym:=por;
'/':Sym:=dvs;
'^':Sym:=pot;
'(':Sym:=pa1;
')':Sym:=pa2;
End;
End;
End;
Procedure Expresion(SymSig:ConSym;Var Reg:Formula);
Var
OpSuma:Symbol;
Procedure Termino(SymSig:ConSym;Var Reg:Formula);
Var
OpMul:Symbol;
Procedure Factor(SymSig:ConSym;Var Reg:Formula);
Var
OpExp:Symbol;
Procedure Exponente(SymSig:ConSym;Var Reg:Formula);Begin
While(Sym in SymIniFac)and(Len>=i)do Begin
Case(sym)of
Num:Begin
CalculaNum(Registro);
TraerChar;
End;
Cellule:Begin
Reg.Formula[Index]:=1;
Inc(Index);
CalculaDir(Registro);
Dec(I);
TraerChar;
End;
Arr:Begin
CalculaArr(Registro);
TraerChar;
End;
Else Begin
If(Sym=pa1)Then Begin
TraerChar;
Expresion([pa2]+SymSig,Registro);
If(Sym=pa2)Then Begin
Reg.Formula[Index]:=4; {4 = symbole '(' }
Inc(Index);
TraerChar;
End;
End;
End;
End;
End;
End;
Begin
Exponente(SymSig+[Pot],Registro);
While(Sym=Pot)and(Len>=I)do Begin
OpExp:=Sym;
TraerChar;
Exponente(SymSig+[Pot],Registro);
If(OpExp=Pot)Then Begin
Reg.Formula[index]:=13; {13 = symbole '^' }
Inc(Index);
End;
End;
End;
Begin
Factor(SymSig+[por,dvs],Registro);
While(Sym in[por,dvs])and(Len>=I)do Begin
OpMul:=Sym;
TraerChar;
Factor(symsig+[por,dvs],Registro);
If(OpMul=por)or(Opmul=dvs)Then Begin
If(OpMul=por)Then Reg.Formula[Index]:=11 {11 = symbole '*' }
Else Reg.Formula[Index]:=12; {12 = symbole '/' }
Inc(Index);
End;
End;
End;
Begin
If(Sym)in[mas,men]Then Begin
OpSuma:=Sym;
TraerChar;
Termino(SymSig+[Mas,Men],Registro);
If(opsuma=men)Then Begin
Reg.Formula[index]:=8; {8 = symbole '-' unair}
Inc(Index);
End;
End
Else
Termino(SymSig+[Mas,Men],Registro);
While(Sym in[Mas,Men])and(Len>=i)do Begin
OpSuma:=Sym;
TraerChar;
Termino(SymSig+[Mas,Men],Registro);
If(OpSuma=mas)or(OpSuma=Men)Then Begin
If(OpSuma=mas)Then Reg.Formula[index]:=9 { 9 = symbole '+' }
Else Reg.Formula[index]:=10; {10 = symbole '-' }
Inc(Index);
End;
End;
End;
Begin
FillClr(Registro,SizeOf(Registro));
Registro.TypeCode:=16; { 16 = Formule }
Registro.Column:=c;
Registro.Row:=f;
Registro.Format:=0;
Registro.Length:=Length(S);
S:=StrUp(S);
I:=1;
V:='';
For ii:=1to(Lens)do Begin
If S[ii]<>' 'Then Begin
IncStr(V,s[ii]);
Inc(I);
End;
End;
Len:=I-1;
I:=0;
Index:=1;
SymIniFac:=[Cellule,Num,Arr,pa1];
SymSig:=SymIniFac;
TraerChar;
Expresion(SymSig,Registro);
Registro.Formula[index]:=3;
Registro.Tma:=index;
Registro.Length:=15+Registro.Tma;
_SetRec(Handle,19+index,Formato[1]);
End;
Begin
SCSaveAs:=False;Path:=FileName;
If Path=''Then SaveName;
UpDate:=Q.FileName<>Path;
If(UpDate)Then Begin{ Existe toujours ? }
If FileExist(Path)Then If Not __InputOverwriteFile(Path)Then Exit;
Q.FileName:=StrUp(Path);
End;
WEPushEndBar(LW);
WEPutLastBar('Sauvegarde en cours...');
Case(Q.FormatMode)of
tfMGC:Path:=Path2NoExt(Path)+'.MGC';
tfLotus:Path:=Path2NoExt(Path)+'.WK1';
tfExcel:Path:=Path2NoExt(Path)+'.XLS';
tfCSV:Path:=Path2NoExt(Path)+'.CSV';
tfHTML:Path:=Path2NoExt(Path)+'.HTM';
tfASCII:Path:=Path2NoExt(Path)+'.LST';
End;
Handle:=FileCreateAndBackup(Path);
If(Handle=errHdl)Then Begin
ErrNoMsgOk(CannotCreateFile);
WEDone(LW);
Exit;
End;
Case(Q.FormatMode)of
tfMGC:Begin
PutFileTxt(Handle,'MGC'#26);
{ critures des colonnes }
H:=HTFirstItem(Q.Column.List);
While(H<>NIL)do Begin
FillClr(Data,SizeOf(Data));
MoveLeft(H^.Data,Q.Column.Curr,SizeOf(ColumnRec));
Data.Col:=Q.Column.Curr.Column;
Data.H:=Q.Column.Curr.Header;
Data.H.Format:=cfColumn;
Data.Size:=SizeOf(ColumnHeader);
_SetRec(Handle,SizeOf(Data),Data);
_SetRec(Handle,Data.Size,Q.Column.Curr.c);
H:=HTNextItem(Q.Column.List);
End;
{ criture des cellules }
H:=HTFirstItem(Q.Cellule.List);
While(H<>NIL)do Begin
MoveLeft(H^.Data,Q.Cellule.Curr,SizeOf(CelluleRec));
FillClr(Data,SizeOf(Data));
Data.Col:=Q.Cellule.Curr.Column;
Data.Row:=Q.Cellule.Curr.Row;
Data.H:=Q.Cellule.Curr.Header;
Case(Q.Cellule.Curr.Header.Format)of
cfText:Data.Size:=Length(Q.Cellule.Curr.Data.t.Text)+1;
cfValue:Begin
Data.Size:=SizeOf(Q.Cellule.Curr.Data.v.Value);
If Q.Cellule.Curr.Data.v.Dec<>4Then Begin
Inc(Data.Size);
Data.H.Format:=Data.H.Format or$80;
End;
End;
cfFormula:Data.Size:=Length(Q.Cellule.Curr.Data.f.Formula)+1;
End;
_SetRec(Handle,SizeOf(Data),Data);
Case(Q.Cellule.Curr.Header.Format)of
cfText:_SetRec(Handle,Data.Size,Q.Cellule.Curr.Data.t.Text);
cfValue:_SetRec(Handle,Data.Size,Q.Cellule.Curr.Data.v.Value);
cfFormula:_SetRec(Handle,Data.Size,Q.Cellule.Curr.Data.f.Formula);
End;
H:=HTNextItem(Q.Cellule.List);
End;
End;
tfLotus:Begin
{criture de l'entˆte}
LHeader.TypeCode:=0;
LHeader.Length:=2;
LHeader.Value:=1030;
_SetRec(Handle,SizeOf(LHeader),LHeader);
{criture du corps}
H:=HTFirstItem(Q.Cellule.List);
While(H<>NIL)do Begin
MoveLeft(H^.Data,Q.Cellule.Curr,SizeOf(CelluleRec));
FillClr(LLabel,SizeOf(LLabel));
LLabel.Column:=Q.Cellule.Curr.Column;
LLabel.Row:=Q.Cellule.Curr.Row;
Data.H:=Q.Cellule.Curr.Header;
Case(Q.Cellule.Curr.Header.Format)of
cfText:Begin
LLabel.TypeCode:=$0F;
LLabel.Length:=Length(Q.Cellule.Curr.Data.t.Text)+7;
LLabel.Format:=$FF;
Case(Q.Cellule.Curr.Header.Justify)of
cCenter:LLabel.Text[0]:='^';
cRight:LLabel.Text[0]:='"';
Else LLabel.Text[0]:='''';
End;
StrPascalCopy(LLabel.Text[1],239,Q.Cellule.Curr.Data.t.Text);
End;
cfValue:Begin
LDouble.TypeCode:=$E;
LDouble.Length:=13;
LDouble.Format:=2 or 128;
RealToDouble(Q.Cellule.Curr.Data.v.Value,LDouble.Value);
End;
End;
Case(Q.Cellule.Curr.Header.Format)of
cfText:_SetRec(Handle,Length(Q.Cellule.Curr.Data.t.Text)+11,LLabel);
cfValue:_SetRec(Handle,17,LDouble);
cfFormula:AddLotusFormula(Q.Cellule.Curr.Column,Q.Cellule.Curr.Row,Q.Cellule.Curr.Data.f.Formula);
End;
H:=HTNextItem(Q.Cellule.List);
End;
{criture de la fin}
LEnd.TypeCode:=1;
LEnd.Length:=0;
_SetRec(Handle,SizeOf(LEnd),LEnd);
End;
tfExcel:Begin
{criture de l'entˆte}
FillClr(SignExcel,SizeOf(SignExcel));
SignExcel.Length:=6;
SignExcel.TypeCode:=$0009;
_SetRec(Handle,SizeOf(SignExcel),SignExcel);
{criture du corps}
H:=HTFirstItem(Q.Cellule.List);
While(H<>NIL)do Begin
MoveLeft(H^.Data,Q.Cellule.Curr,SizeOf(CelluleRec));
FillClr(Label4Excel,SizeOf(Label4Excel));
Label4Excel.Column:=Q.Cellule.Curr.Column;
Label4Excel.Row:=Q.Cellule.Curr.Row;
Data.H:=Q.Cellule.Curr.Header;
Case(Q.Cellule.Curr.Header.Format)of
cfText:Begin
Label4Excel.TypeCode:=xltLabel;
Label4Excel.Length:=SizeOf(Label4Excel)-4-SizeOf(String)+Length(Q.Cellule.Curr.Data.t.Text)+2;
Case(Q.Cellule.Curr.Header.Justify)of
cCenter:Label4Excel.Value:='^';
cRight:Label4Excel.Value:='"';
Else Label4Excel.Value:='''';
End;
AddStr(Label4Excel.Value,Q.Cellule.Curr.Data.t.Text);
End;
cfValue:Begin
Number4Excel.TypeCode:=xltNumber;
Number4Excel.Length:=SizeOf(Label4Excel)-4;
RealToDouble(Q.Cellule.Curr.Data.v.Value,Number4Excel.Value);
End;
End;
_SetRec(Handle,Number4Excel.Length+4,Buffer);
H:=HTNextItem(Q.Cellule.List);
End;
{criture de la fin}
EOF4Excel.TypeCode:=xltEOF;
EOF4Excel.Length:=0;
_SetRec(Handle,SizeOf(EOF4Excel),EOF4Excel);
End;
tfCSV:Begin
CENumLine(Q.Cellule);
For J:=Q.Cellule.Y1 to(Q.Cellule.Y2)do Begin
PC:=CEFindLine(Q.Cellule,J);
If(PC=NIL)Then S:=''
Else
Begin
First:=True;
For I:=0to(Q.Cellule.X2)do Begin
PC:=SCGetCellule(Q,I,J);
If(PC=NIL)Then Break;
S:='';
Case(PC^.Header.Format)of
cfText:S:=PC^.Data.t.Text;
cfValue:S:=RealStr(PC^.Data.v.Value);
cfFormula:S:='='+PC^.Data.f.Formula;
End;
If Not(First)Then PutFileTxt(Handle,',');
PutFileTxt(Handle,S);
First:=False;
End;
End;
PutFileLn(Handle);
End;
End;
tfHTML:Begin
DBOpenServerName(ChantalServer,'CHANTAL:/Texte/Format/ASCII2HTML.Dat');
If Not DBCopyToMemory(ChantalServer,Font)Then Begin
__OutOfMemory;
Exit;
End;
CENumLine(Q.Cellule);
PutFileTxt(Handle,'<HTML><BODY><TABLE>');
For J:=Q.Cellule.Y1 to(Q.Cellule.Y2)do Begin
PutFileTxt(Handle,'<TR>');
PC:=CEFindLine(Q.Cellule,J);
If(PC=NIL)Then S:=''
Else
Begin
First:=True;
For I:=0to(Q.Cellule.X2)do Begin
PC:=SCGetCellule(Q,I,J);
If(PC=NIL)Then Break;
S:='';
Case(PC^.Header.Format)of
cfText:S:=PC^.Data.t.Text;
cfValue:S:=RealStr(PC^.Data.v.Value);
cfFormula:S:=RealStr(PC^.Data.f.Value);
End;
If Not(First)Then PutFileTxt(Handle,'</TD>');
PutFileTxt(Handle,'<TD');
Case(PC^.Header.Justify)of
cCenter:PutFileTxt(Handle,' Align=Center');
cRight:PutFileTxt(Handle,' Align=Right');
End;
If PC^.Header.Attribut shr 4<>$FThen Begin
PutFileTxt(Handle,' BgColor='+GetColorClassicHTML(PC^.Header.Attribut shr 4));
End;
PutFileTxt(Handle,'>');
If PC^.Header.Attribut and $F<>0Then Begin
PutFileTxt(Handle,'<FONT Color='+GetColorClassicHTML(PC^.Header.Attribut and$F)+'>');
End;
STarget:='';
For K:=1to Length(S)do Begin
If DBLocateAbsIM(Font,0,S[K],[])Then Begin
Inc(PtrRec(Font.CurrRec).Ofs);
AddStr(STarget,Font.CurrRec.Str^);
End
Else
IncStr(STarget,S[K]);
End;
PutFileTxt(Handle,STarget);
First:=False;
End;
PutFileTxt(Handle,'</TD>');
End;
PutFileTxtLn(Handle,'</TR>');
End;
PutFileTxt(Handle,'</TABLE></BODY></HTML>');
DBDispose(Font);
End;
Else Begin
CENumLine(Q.Cellule);
For J:=Q.Cellule.Y1 to(Q.Cellule.Y2)do Begin
PC:=CEFindLine(Q.Cellule,J);
If(PC=NIL)Then S:=''
Else
Begin
For I:=0to(Q.Cellule.X2)do Begin
PC:=SCGetCellule(Q,I,J);
If(PC=NIL)Then Break;
S:='';
Case(PC^.Header.Format)of
cfText:S:=PC^.Data.t.Text;
cfValue:S:=RealStr(PC^.Data.v.Value);
cfFormula:S:=PC^.Data.f.Formula;
End;
PutFileTxt(Handle,StrUSpc(S,COGetColumnWidth(Q.Column,I)));
End;
End;
PutFileLn(Handle);
End;
End;
End;
FileClose(Handle);
If(Q.FileName='')or(UpDate)Then Begin
Q.FileName:=StrUp(Path);
SCUpdateStatusBar(Q);
End;
WEDone(LW);
Q.GlobalModified:=False;
SCSaveAs:=True;
End;
Function SCSave;Begin
SCSave:=SCSaveAs(Q,SuperCalcApp(Q).FileName)
End;
END.