-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEDTSAVE.PAS
788 lines (733 loc) · 26.4 KB
/
EDTSAVE.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
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
{ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÜ
³ Û
³ Malte Genesis/Editeur - Sauvegarde Û
³ Û
³ dition Chantal pour Mode R‚el/IV - Version 1.1 Û
³ 2000/01/01 Û
³ Û
³ Tous droits r‚serv‚s par les Chevaliers de Malte (C) Û
³ Û
ÀÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
Nom du programmeur
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
Sylvain Maltais
Description
ÍÍÍÍÍÍÍÍÍÍÍ
Cette unit‚ permet de sauvegarder le contenu du texte du traŒtement de
texte dans le format d‚sirer et support‚e.
}
{$I DEF.INC}
Unit EdtSave;
{ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
INTERFACE
{ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
Function TESave(Var Context):Boolean;
Function TESaveAs(Var Context;Const _Path:String):Boolean;
{ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
IMPLEMENTATION
{ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
Uses
Systex,Memories,Systems,Isatex,Video,Dials,Editex,Editor,Dialex,
ResServD,Restex,DialPlus,WordTex;
Procedure InvBuf(Var x0;Size:Wd);Near;Forward;
Function PSetPath4AddFile(PC:PChr):String;Near;Forward;
{ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÜ
³ Proc‚dure FusionDirNName Û
ÀÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
Description
ÍÍÍÍÍÍÍÍÍÍÍ
Cette proc‚dure fusionne un r‚pertoire avec un nom de fichier et la place
dans la variable de param‚trage ®Str¯.
}
Procedure FusionDirNName(Var Str:String;Dir,Name:PChr);Near;Begin
Str:=PSetPath4AddFile(Dir)+StrPas(Name)
End;
{ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÜ
³ Fonction PSetPath4AddFile Û
ÀÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
Description
ÍÍÍÍÍÍÍÍÍÍÍ
Cette fonction retourne un chemin de r‚pertoire de fa‡on … ce qu'il est
toujours une barre oblique pour permettre l'addition d'un nom de fichier
en utilisant … la base un chemin contenu dans une chaŒne de caractŠres de
format ASCIIZ.
}
Function PSetPath4AddFile(PC:PChr):String;Begin
PSetPath4AddFile:=SetPath4AddFile(StrPas(PC))
End;
{$I \Source\Chantal\Library\System\Dos\Shell\4Dos\SearchDe.Inc}
{$I \Source\Chantal\Library\System\Dos\Shell\4Dos\SetDescr.Inc}
{ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÜ
³ Proc‚dure InvBuf Û
ÀÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
Description
ÍÍÍÍÍÍÍÍÍÍÍ
Cette proc‚dure inverse les quarters de chaque octets d'un tampon d‚finit
par la variable de param‚trage ®x0¯ pendant une longueur de ®Size¯.
}
Procedure InvBuf;
Var
TBuf:TByte Absolute x0;
I:Word;
Begin
If Size=0Then Exit;
For I:=0to Size-1do TBuf[I]:=(TBuf[I]shr 4)+(TBuf[I]shl 4)
End;
{ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÜ
³ Proc‚dure WaitMsg Û
ÀÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
Description
ÍÍÍÍÍÍÍÍÍÍÍ
Cette proc‚dure effectue une pause d'une demi-seconde afin de laisser voir
un message par exemple.
}
Procedure WaitMsg;
Var
I:Byte;
Begin
For I:=0to 7do If(KeyPress)Then WaitRetrace;
End;
{ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÜ
³ Fonction TESave Û
ÀÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
Description
ÍÍÍÍÍÍÍÍÍÍÍ
Cette fonction sauvegarde le fichier sous son noms r‚guliers
(l'‚quivalent de F2 pour Turbo Pascal ou Borland Pascal). Cette
fonction retourne Ya (True) si l'op‚ration c'est d‚roulant sans
problŠme ou No (False) si un problŠme utilisateur ou mat‚riel
est survenu.
}
Function TESave;
Var
Q:EditorApp Absolute Context; { Objet ‚diteur }
Begin
TESave:=TESaveAs(Q,Q.EditName)
End;
{ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÜ
³ Fonction TESaveAs Û
ÀÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ
Description
ÍÍÍÍÍÍÍÍÍÍÍ
Cette fonction sauvegarde le texte sous un nom particulier selon les
sp‚cifications de l'utilisateur.
}
Function TESaveAs;
Label DefaultGat,NextGat;
Var
Q:EditorApp Absolute Context; { Objet ‚diteur }
Handle:Hdl; { ®Handle¯ associ‚ au fichier … ‚crire }
L,LD:Word;
J,JP:Word; { Compteur de ligne, compteur de position }
I,M:LongInt;
PC:PChr; { Pointeur sur la ligne courante }
UpDate:Boolean; { Demande de mise … jour? }
Chr:Char; { CaractŠre divers }
Buffer:Array[0..2047]of Char; { M‚moire tampon par d‚faut }
FirstChoice:FirstChoiceHeader Absolute Buffer; { Premier Choix }
LW:Window; { Sauvegarde de la ligne d'aide }
Path:String; { Description et chemin complet du fichier }
E:ExtStr; { Extension du fichier }
QX:EditorApp Absolute Q; { Information de l'‚diteur }
Format:Byte; { Format de sauvegarde de document }
K:Word; { Code clavier de sortie }
UnderlineMode:Boolean; { Mode soulign‚? }
DoubleMode:Boolean; { Mode double largeur? }
BoldMode:Boolean; { Mode gras? }
ItalicMode:Boolean; { Mode Italique?}
Paragraph:Boolean; { criture d'un paragraphe? }
Line:Boolean; { Est-ce une ligne s‚paratrice? }
Style:Char; { Style de ligne s‚paratrice}
LastAttr:Byte; { Attribue pr‚c‚dent }
PosLastAttr:Byte; { Position de l'attribue pr‚c‚dent }
TmpRead:PChr; { Tampon temporaire de lecture (si }
{ sauvegarde directe … partir d'un }
{ autre fichier)}
TmpReadSize:Word; { Taille du tampon ®TmpRead¯ }
FPR:LongInt; { Position du fichier actuel en lecture }
PDrw:^DrawInEdt; { D‚finition d'objet d'image }
PLineHor:^LineHorInEdt Absolute PDrw;{ D‚finition d'objet de ligne horizontal }
Font:DataSetInMemory; { Pour la conversion de la police de caractŠres }
Procedure UpdateDescription;
Var
Descr:String;
Begin
If(DescrInFile)Then Begin
Descr:=SearchDescription(Q.EditName);
If Descr=''Then Begin
If(_WinInp(45,'Description','Entrez la description d‚sirez (40 maximum):',False,Descr)=kbYes)Then
SetDescription(Path,Descr);
End;
End;
End;
Procedure SaveGat;
Var
R:FileListBox; { Objet pour l'entr‚e d'un nom de document }
H:History; { Histoire retenu pour cette objet }
Begin
HYInit(H,0);
FLInitModel(R,Path,'Sauvegarde sous',H,False,False,True,omDocument);
Case(Q.ModeSub)of
vtsPW:Format:=cfoProfessionnalWrite;
vtsFirstChoice:Format:=cfoFirstChoice;
vtsHTML:Format:=cfoHTML;
vtsANSI:Format:=cfoANSI;
vtsASCII:Format:=cfoASCII;
vtsTextUnix:Format:=cfoTextUnix;
vtsRTF:Format:=cfoRTF;
Else Format:=cfoGAT;
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
cfoProfessionnalWrite:Q.ModeSub:=vtsPW;
cfoFirstChoice:Q.ModeSub:=vtsFirstChoice;
cfoHTML:Q.ModeSub:=vtsHTML;
cfoANSI:Q.ModeSub:=vtsANSI;
cfoASCII:Q.ModeSub:=vtsASCII;
cfoTextUnix:Q.ModeSub:=vtsTextUnix;
cfoRTF:Q.ModeSub:=vtsRTF;
Else Q.ModeSub:=vtsGAT;
End;
Path:=R.Path;
End;
FLDone(R);
End;
Procedure PushChar(Chr:Char);Begin
Buffer[LD]:=Chr;Inc(LD);
If LD>=SizeOf(Buffer)Then Begin
_SetRec(Handle,LD,Buffer[0]);
LD:=0;
End;
End;
Procedure PushString(Const S:String);
Var
I:Byte;
Begin
For I:=1to Length(S)do PushChar(S[I]);
End;
Procedure UnsetHTML;Begin
If(LastAttr and cgUnderline=cgUnderline)Then PushString('</U>');
If(LastAttr and cgBold=cgBold)Then PushString('</B>');
If(LastAttr and cgItalic=cgItalic)Then PushString('</I>');
LastAttr:=0;PosLastAttr:=0;
UnderlineMode:=False;BoldMode:=False;ItalicMode:=False;
End;
Procedure UnsetRTF;Begin
If(LastAttr and cgUnderline=cgUnderline)Then PushString('}');
If(LastAttr and cgBold=cgBold)Then PushString('}');
If(LastAttr and cgItalic=cgItalic)Then PushString('}');
If(LastAttr and cgDouble=cgDouble)Then PushString('\fs24\cgrid0 ');
LastAttr:=0;PosLastAttr:=0;
UnderlineMode:=False;BoldMode:=False;
ItalicMode:=False;DoubleMode:=False;
End;
Function GetCurrLine:Pointer;Begin
If TmpReadSize<>0Then Begin
__GetAbsFilePTxtLn(Q.Handle,FPR,TmpRead,TmpReadSize);
GetCurrLine:=TmpRead;
End
Else
GetCurrLine:=_ALGetCurrBuf(Q.List);
End;
Function FindObject(P:Word):Pointer;
Var
PDrw:^DrawInEdt; { D‚finition d'objet d'image }
I:Word; { Compteur de boucle }
Begin
FindObject:=NIL;
If Q.Processus.Count>0Then Begin
ALSetPtr(Q.Processus,0);
For I:=0to Q.Processus.Count-1do Begin
PDrw:=_ALGetCurrBuf(Q.Processus);
If(PDrw<>NIL)Then Begin
If(PDrw^.Y1<=P)and(PDrw^.Y2>P)Then Begin
FindObject:=PDrw;
Break;
End;
End;
ALNext(Q.Processus);
End;
End;
End;
Begin
Path:=_Path;SysErr:=0;TESaveAs:=False;
TmpRead:=NIL;TmpReadSize:=0;FPR:=0;
{ Si lecture directe … partir d'un fichier, alors pr‚parer de la m‚moire }
If(Q.Handle)in[2..$FE]Then Begin
TmpReadSize:=4096;
TmpRead:=MemAlloc(TmpReadSize);
If(TmpRead=NIL)Then TmpReadSize:=0;
GetCurrLine;
End;
{ Si r‚pertoire sur unit‚ inconnu, effectu‚ une recherche... }
If(Length(Path)>2)and(Path[1]in['*','?'])and(Path[2]=':')Then Begin
For Chr:='C'to 'Z'do Begin
Path[1]:=Chr;
If DirExist(Path2Dir(Path))Then Break;
End;
End;
If Path=''Then Begin { R‚pertoire: }
Case(Q.Mode)of { ÄÄÄÄÄÄÄÄÄÄÄ }
vtRC:FusionDirNName(Path,PathResource,ExtRC); { Ressource }
vtPas:FusionDirNName(Path,PathPas,ExtPas); { Pascal }
vtFortran:FusionDirNName(Path,PathFortran,ExtFortran); { Fortran }
vtForth:Path:=PSetPath4AddFile(PathForth)+'*.*'; { Forth }
vtEuphoria:FusionDirNName(Path,PathEuphoria,ExtEuphoria); { Euphoria }
vtCobol:Path:=PSetPath4AddFile(PathCobol)+'*.*'; { Cobol }
vtC:FusionDirNName(Path,PathC,ExtC); { C/C++ }
vtBas:FusionDirNName(Path,PathBas,ExtBas); { Basic }
vtAsm:FusionDirNName(Path,PathAsm,ExtAsm); { Assembleur }
vtAda:Path:=PSetPath4AddFile(PathAda)+'*.*'; { Ada }
vtGat:Case(Q.ModeSub)of
vtsPW,vtsFirstChoice:Path:=PSetPath4AddFile(PathGat)+'*.DOC';
vtsHTML:Path:=PSetPath4AddFile(PathGat)+'*.HTM';
vtsANSI:Path:=PSetPath4AddFile(PathGat)+'*.ANS';
vtsASCII,vtsTextUnix:Path:=PSetPath4AddFile(PathGat)+'*.TXT';
vtsRTF:Path:=PSetPath4AddFile(PathGat)+'*.RTF';
Else Path:=PSetPath4AddFile(PathGat)+'*.GAT'; { GAT }
End;
Else Path:='';
End;
If(Q.Mode=vtGat)Then Begin
SaveGat;
If(K<>kbEnter)Then Exit;
End
Else
Path:=OpenWin(Path,'Sauvegarde sous');
End;
UpDate:=Q.EditName<>Path;
If(UpDate)Then Begin{ Existe toujours ? }
If FileExist(Path)Then If Not(__InputOverwriteFile(Path))Then Exit;
Q.EditName:=StrUp(Path)
End;
WEPushEndBar(LW);
WEPutLastBar('Sauvegarde en cours...');
If(Q.Mode=vtGAT)and(Q.ModeSub=vtsGAT)Then Begin
Path:=Path2NoExt(Path)+'.GAT';
UpDate:=True;
End;
Handle:=FileCreateAndBackup(Path);
If(Handle=errHdl)Then Begin
ErrNoMsgOk(CannotCreateFile);
WEDone(LW);
Exit;
End;
ALSetPtr(Q.List,0);
If(Q.Mode=vtGAT)and(Q.ModeSub<>vtsGAT)Then Begin
{ criture de l'entˆte du document }
Case(Q.ModeSub)of
vtsFirstChoice:Begin
FillClr(FirstChoice,SizeOf(FirstChoice));
FirstChoice.X1:=Q.SheetFormat.X1;
FirstChoice.X2:=Q.SheetFormat.X2;
FirstChoice.NumLine:=Q.List.Count;
FirstChoice.Sign:='GERBILDOC ';
FirstChoice.MargeUp:=Q.SheetFormat.Y1;
If Q.SheetFormat.Y2>66Then FirstChoice.PageLen:=88
Else FirstChoice.PageLen:=66;
FirstChoice.MargeDn:=FirstChoice.PageLen-Q.SheetFormat.Y2;
FirstChoice.ResC[356]:=Byte('C');
FirstChoice.ResC[357]:=Byte('C');
FirstChoice.ResC[358]:=1;
FirstChoice.ResC[359]:=Byte('N');
FirstChoice.ResC[362]:=1;
FirstChoice.ResC[363]:=Byte('N');
FirstChoice.ResC[381]:=1;
FirstChoice.ResC[391]:=1;
FirstChoice.ResC[401]:=1;
FirstChoice.ResC[411]:=1;
FirstChoice.ResC[421]:=1;
FirstChoice.ResC[431]:=1;
FirstChoice.ResC[504]:=2;
_SetAbsRec(Handle,0,SizeOf(FirstChoice),FirstChoice);
End;
vtsHTML:Begin
PutFileTxtLn(Handle,'<HTML>');
DBOpenServerName(ChantalServer,'CHANTAL:/Texte/Format/ASCII2HTML.Dat');
If Not DBCopyToMemory(ChantalServer,Font)Then Begin
__OutOfMemory;
Exit;
End;
End;
vtsRTF:Begin
PutFileTxt(Handle,'{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1036');
PutFileTxt(Handle,'{\fonttbl{\f0\froman\fcharset0\fprq2');
PutFileTxt(Handle,'{\*\panose 02020603050405020304}Times New Roman;}');
PutFileTxt(Handle,'{\f17\froman\fcharset238\fprq2 Times New Roman CE;}');
PutFileTxt(Handle,'{\f18\froman\fcharset204\fprq2 Times New Roman Cyr;}');
PutFileTxt(Handle,'{\f20\froman\fcharset161\fprq2 Times New Roman Greek;}');
PutFileTxt(Handle,'{\f21\froman\fcharset162\fprq2 Times New Roman Tur;}');
PutFileTxt(Handle,'{\f22\froman\fcharset186\fprq2 Times New Roman Baltic;}}');
PutFileTxt(Handle,'{\colortbl;\red0\green0\blue0;\red0\green0\blue255;');
PutFileTxt(Handle,'\red0\green255\blue255;\red0\green255\blue0;');
PutFileTxt(Handle,'\red255\green0\blue255;\red255\green0\blue0;');
PutFileTxt(Handle,'\red255\green255\blue0;\red255\green255\blue255;');
PutFileTxt(Handle,'\red0\green0\blue128;\red0\green128\blue128;');
PutFileTxt(Handle,'\red0\green128\blue0;\red128\green0\blue128;');
PutFileTxt(Handle,'\red128\green0\blue0;\red128\green128\blue0;');
PutFileTxt(Handle,'\red128\green128\blue128;\red192\green192\blue192;}');
PutFileTxt(Handle,'{\stylesheet{\nowidctlpar\widctlpar\adjustright ');
PutFileTxt(Handle,'\fs20\lang3084\cgrid \snext0 Normal;}');
PutFileTxt(Handle,'{\s1\keepn\nowidctlpar\widctlpar\outlinelevel0\adjustright ');
PutFileTxt(Handle,'\fs20\ul\lang3084\cgrid \sbasedon0 \snext0 heading 1;}');
PutFileTxt(Handle,'{\*\cs10 \additive Default Paragraph Font;}}');
DBOpenServerName(ChantalServer,'CHANTAL:/Texte/Format/ASCII2RTF.Dat');
If Not DBCopyToMemory(ChantalServer,Font)Then Begin
__OutOfMemory;
Exit;
End;
End;
Else Goto DefaultGat;
End;
{ criture du contenu du document }
LD:=0;UnderlineMode:=False;BoldMode:=False;
ItalicMode:=False;Paragraph:=False;
LastAttr:=0;PosLastAttr:=0;DoubleMode:=False;
For I:=0to Q.List.Count-1do Begin
PC:=GetCurrLine;
If Not IsPChrEmpty(PC)Then Begin
L:=StrLen(PC);
Case(Q.ModeSub)of
vtsASCII,vtsTextUnix:For J:=0to L-1do Begin
If PC^[J]>=' 'Then PushChar(PC^[J]);
End;
vtsHTML:Begin
If(Q.SheetFormat.X1<L)Then Begin
Style:=PC^[Q.SheetFormat.X1];
Line:=True;
For J:=Q.SheetFormat.X1+1to L-1do If(PC^[J]<>Style)Then Begin
Line:=False;
Break;
End;
If(Line)Then Begin
PushString('<div style=''border:none;border-bottom:solid windowtext 1.5pt;padding:0cm 0cm 1.0pt 0cm''>');
PushString('<p class=MsoNormal style=''border:none;mso-border-bottom-alt:solid windowtext 1.5pt;');
PushString('padding:0cm;mso-padding-alt:0cm 0cm 1.0pt 0cm''><span lang=EN-US');
PushString('style=''mso-ansi-language:EN-US''><![if !supportEmptyParas]> <![endif]><o:p></o:p></span></p>');
PushString('</div>');
End;
End;
If Not(Line)Then Begin
If(L>Q.SheetFormat.X1)Then Begin
If Not(Paragraph)Then Begin
Paragraph:=True;
If Not((PC^[L-1]=' ')or(L>=Q.SheetFormat.X2))Then Begin
For JP:=0to L-1do If PC^[JP]<>' 'Then Break;
If JP>=Q.SheetFormat.X2-(L-JP)-2Then PushString('<P ALIGN=RIGHT>')Else
If(JP>=((Q.SheetFormat.X2-Q.SheetFormat.X1-(L-JP)-2)shr 1)+Q.SheetFormat.X1)Then
PushString('<P ALIGN=CENTER>')
Else
PushString('<P ALIGN=JUSTIFY>');
End
Else
PushString('<P ALIGN=LEFT>');
End;
End;
For J:=0to L-1do Begin
If DBLocateAbsIM(Font,0,PC^[J],[])Then Begin
Inc(PtrRec(Font.CurrRec).Ofs);
PushString(Font.CurrRec.Str^);
End
Else
Case PC^[J]of
' '..'%',#39..#59,#61,#63..#127,
#244..#245,#247,#250,#252,#254..#255:PushChar(PC^[J]);
Else Begin
PosLastAttr:=J;
LastAttr:=Byte(PC^[J]);
If(UnderlineMode)and(Byte(PC^[J])and cgUnderline=0)Then Begin
PushString('</U>');
UnderlineMode:=False;
End
Else
If(Not(UnderlineMode))and(Byte(PC^[J])and cgUnderline=cgUnderline)Then Begin
PushString('<U>');
UnderlineMode:=True;
End;
If(BoldMode)and(Byte(PC^[J])and cgBold=0)Then Begin
PushString('</B>');
BoldMode:=False;
End
Else
If(Not(BoldMode))and(Byte(PC^[J])and cgBold=cgBold)Then Begin
PushString('<B>');
BoldMode:=True;
End;
If(ItalicMode)and(Byte(PC^[J])and cgItalic=0)Then Begin
PushString('</I>');
ItalicMode:=False;
End
Else
If(Not(ItalicMode))and(Byte(PC^[J])and cgItalic=cgItalic)Then Begin
PushString('<I>');
ItalicMode:=True;
End;
End;
End;
If J>PosLastAttr+1Then Begin
{ Attribut ³ CaractŠre ³ CaractŠre ? }
{ ÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ}
{ PosLastAttr ³ PosLastAttr+1 ³ J }
UnsetHTML;
End;
End;
If(Paragraph)Then Begin
If Not((PC^[L-1]=' ')or(L>=Q.SheetFormat.X2))Then Begin
PushString('</P>');
Paragraph:=False;
End;
End;
If LastAttr>0Then UnsetHTML;
End;
End;
vtsANSI:For J:=0to L-1do Begin
If PC^[J]>=' 'Then PushChar(PC^[J]);
End;
vtsFirstChoice:For J:=0to L-1do Begin
If(J>=Q.SheetFormat.X1)and(J<=Q.SheetFormat.X2)Then Begin
PosLastAttr:=0;
If PC^[J]>=#128Then PosLastAttr:=PosLastAttr or 8;
If PC^[J]>=' 'Then Begin
If LastAttr>0Then Begin
PushChar(Char(Byte(PC^[J])or 128));
If LastAttr and cgItalic>0Then PosLastAttr:=PosLastAttr or 4;
If LastAttr and(cgBold+cgDouble)>0Then PosLastAttr:=PosLastAttr or 2;
If LastAttr and cgUnderline>0Then PosLastAttr:=PosLastAttr or 1;
If PosLastAttr>0Then PushChar(Char(PosLastAttr+128));
End
Else
Begin
PushChar(PC^[J]);
If PC^[J]>=#128Then PushChar(#136);
End;
LastAttr:=0;
End
Else
LastAttr:=Byte(PC^[J]);
End;
End;
vtsRTF:Begin
If(L>Q.SheetFormat.X1)Then Begin
If Not(Paragraph)Then Begin
Paragraph:=True;
If Not((PC^[L-1]=' ')or(L>=Q.SheetFormat.X2))Then Begin
For JP:=0to L-1do If PC^[JP]<>' 'Then Break;
If JP>=Q.SheetFormat.X2-(L-JP)-2Then PushString('{\par ')Else
If(JP>=((Q.SheetFormat.X2-Q.SheetFormat.X1-(L-JP)-2)shr 1)+Q.SheetFormat.X1)Then
PushString('{\pard \qj\nowidctlpar\adjustcenter ')
Else
PushString('{\par ');
End
Else
PushString('{\pard \qj\nowidctlpar\adjustright ');
End;
End;
If L=0Then PushString('\par ');
(*If(Q.XW1<L)Then Begin
Style:=PC^[Q.XW1];
Line:=True;
For J:=Q.XW1+1to L-1do If(PC^[J]<>Style)Then Begin
Line:=False;
Break;
End;
If(Line)Then Begin
PushString('\par }\pard \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 {');
End;
End;*)
For J:=0to L-1do Begin
If DBLocateAbsIM(Font,0,PC^[J],[])Then Begin
Inc(PtrRec(Font.CurrRec).Ofs);
PushString(Font.CurrRec.Str^);
End
Else
Case PC^[J]of
' ':If(J>=Q.SheetFormat.X1)Then PushChar(' ');
#33..'%',#40..#127,
#158..#159,#166..#170,
#187..#245,#247..#255:PushChar(PC^[J]);
Else Begin
PosLastAttr:=J;
LastAttr:=Byte(PC^[J]);
If(UnderlineMode)and(Byte(PC^[J])and cgUnderline=0)Then Begin
PushString('}');
UnderlineMode:=False;
End
Else
If(Not(UnderlineMode))and(Byte(PC^[J])and cgUnderline=cgUnderline)Then Begin
PushString('{\ul ');
UnderlineMode:=True;
End;
If(BoldMode)and(Byte(PC^[J])and cgBold=0)Then Begin
PushString('}');
BoldMode:=False;
End
Else
If(Not(BoldMode))and(Byte(PC^[J])and cgBold=cgBold)Then Begin
PushString('{\b ');
BoldMode:=True;
End;
If(ItalicMode)and(Byte(PC^[J])and cgItalic=0)Then Begin
PushString('}');
ItalicMode:=False;
End
Else
If(Not(ItalicMode))and(Byte(PC^[J])and cgItalic=cgItalic)Then Begin
PushString('{\i ');
ItalicMode:=True;
End;
If(DoubleMode)and(Byte(PC^[J])and cgDouble=0)Then Begin
PushString('\fs24\cgrid0 ');
DoubleMode:=False;
End
Else
If(Not(DoubleMode))and(Byte(PC^[J])and cgDouble=cgDouble)Then Begin
PushString('\fs48\cgrid0 ');
DoubleMode:=True;
End;
End;
End;
If(J>PosLastAttr)Then Begin
{ Attribut ³ CaractŠre ³ CaractŠre ? }
{ ÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ}
{ PosLastAttr ³ PosLastAttr+1 ³ J }
UnsetRTF;
End;
End;
If(Paragraph)Then Begin
If Not((PC^[L-1]=' ')or(L>=Q.SheetFormat.X2))Then Begin
PushString('\par }');
Paragraph:=False;
End;
End;
If LastAttr>0Then UnsetRTF;
End;
End;
End;
Case(Q.ModeSub)of
vtsASCII,vtsANSI,vtsHTML,vtsRTF:PushString(#13#10);
vtsTextUnix:PushChar(#13);
vtsFirstChoice:PushChar(#12);
End;
ALNext(Q.List);
If(FPR>Q.FileSize)Then Break;
End;
{criture de fin}
Case(Q.ModeSub)of
vtsHTML:Begin
PushString('</HTML>');
DBDispose(Font);
End;
vtsRTF:Begin
PushChar('}');
DBDispose(Font);
End;
End;
_SetRec(Handle,LD,Buffer[0]);
If(Q.ModeSub=vtsFirstChoice)Then Begin
_GetAbsRec(Handle,0,SizeOf(FirstChoice),FirstChoice);
FirstChoice.NumLetters:=FileSize(Handle)-SizeOf(FirstChoice);
_SetAbsRec(Handle,0,SizeOf(FirstChoice),FirstChoice);
End;
End
Else
Begin
{ Sauvegarde sans aucune filtration ou transformation }
If(Q.Mode=vtGAT)Then Begin
DefaultGat:
If Length(Q.PassWord)=0Then Chr:=':'Else Chr:=';';
PutFileTxt(Handle,Chr+BasicStrW(Q.SheetFormat.X1)+
BasicStrW(Q.SheetFormat.Y1)+
BasicStrW(Q.SheetFormat.X2)+
BasicStrW(Q.SheetFormat.Y2)+' ');
Case(Q.PageNumIn)of
ptLeft:Chr:='L'; { Num‚ro de page … gauche }
ptRight:Chr:='R'; { Num‚ro de page … droite }
ptAltern:Chr:='A'; { Num‚ro de page altern‚ gauche/droite }
Else Chr:='N'; { Pas de num‚ro de page }
End;
PutFileTxt(Handle,Chr);
PutFileTxt(Handle,BasicStr(LongInt(Q.PageNumStart)));
If(Q.InfoCompl)Then PutFileTxt(Handle,' I');
PutFileLn(Handle);
End;
If Length(Q.PassWord)>0Then Begin
MoveLeft(Q.Password,Buffer,SizeOf(QX.PassWord));
InvBuf(Buffer,SizeOf(QX.PassWord));
_SetRec(Handle,SizeOf(QX.PassWord),Buffer);
End;
M:=Q.List.Count-1;
If Integer(M)<>-1Then For I:=0to(M)do Begin
PDrw:=FindObject(I);
If(PDrw<>NIL)Then Case(PDrw^.Model)of
mtImage:;
mtLineHor:Begin
PutFileTxtLn(Handle,Spc(Q.SheetFormat.X1)+MultChr(PLineHor^.Bar,Q.SheetFormat.X2-Q.SheetFormat.X1));
Goto NextGat;
End;
End;
PC:=GetCurrLine;
L:=StrLen(PC);
If Length(Q.PassWord)>0Then Begin
If L>=SizeOf(Buffer)Then L:=SizeOf(Buffer)-1;
MoveLeft(PC^[0],Buffer,L+1);
InvBuf(Buffer,L);
_SetRec(Handle,L+1,Buffer);
End
Else
Begin
If L>0Then _SetRec(Handle,L,PC^[0]);
If(I<M)Then _PutFileLn(Handle);
End;
NextGat:
If GetSysErr<>0Then Begin
__DiskFull;
FileClose(Handle);
WEDone(LW);
Exit;
End;
ALNext(Q.List);
If(FPR>Q.FileSize)Then Break;
End;
End;
FileClose(Handle);
If TmpReadSize=0Then Begin
Q.Modified:=False;
Q.FileSize:=GetFileSize(Path);
TEPutBar(Q);
If(Q.EditName='')or(UpDate)Then Begin
Q.EditName:=StrUp(Path);
If Path2Ext(Q.EditName)<>Path2Ext(Path)Then Begin
E:=Path2Ext(Q.EditName); { Extension: }
Repeat { ÄÄÄÄÄÄÄÄÄÄ }
If Pos(E,StrPas(ExtRC))>0Then L:=vtRC Else { Ressource }
If Pos(E,StrPas(ExtPas))>0Then L:=vtPas Else { Pascal }
If Pos(E,StrPas(ExtFortran))>0Then L:=vtFortran Else { Fortran }
If Pos(E,StrPas(ExtEuphoria))>0Then L:=vtEuphoria Else { Euphoria }
If Pos(E,StrPas(ExtC))>0Then L:=vtC Else { C/C++ }
If Pos(E,StrPas(ExtBas))>0Then L:=vtBas Else { Basic }
If Pos(E,StrPas(ExtAsm))>0Then L:=vtAsm Else { Assembleur }
If Pos(E,StrPas(ExtAC))>0Then L:=vtAC Else { AC }
If Pos(E,'.GAT')>0Then L:=vtGat Else { GAT }
If Pos(E,'.INI')>0Then L:=vtIni Else { Initie }
If Pos(E,'.BAT;.BTM')>0Then L:=vtBatch { Batch }
Else Break;
TESetViewMode(Q,L);
Until True
End;
WESetTitle(Q.W,TruncName(Q.EditName,Q.W.MaxX),Q.W.Palette.Title);
End;
{Recherche de description}
UpDateDescription;
{Fin de description}
End;
FreeMemory(TmpRead,TmpReadSize);
WaitMsg;
WEDone(LW);
TESaveAs:=True;
End;
{ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
END.