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
| function Rtf2Str(AString:string):String;
var temptext : string;
start,i : integer;
begin
temptext := AString;
// Effacement de la première ligne
Delete(temptext,1,Pos(Chr(13)+Chr(10),temptext)+1);
//
temptext := stringreplaceall (temptext,'\'+chr(39)+'e7','ç');
temptext := stringreplaceall (temptext,'\'+chr(39)+'e8','è');
temptext := stringreplaceall (temptext,'\'+chr(39)+'e9','é');
temptext := stringreplaceall (temptext,'\'+chr(39)+'e1','é');
temptext := stringreplaceall (temptext,'\'+chr(39)+'e0','à');
temptext := stringreplaceall (temptext,'\'+chr(39)+'f9','ù');
temptext := stringreplaceall (temptext,'\'+chr(39)+'fb','û');
temptext := stringreplaceall (temptext,'\}','#]#');
temptext := stringreplaceall (temptext,'\{','#[#');
temptext := stringreplaceall (temptext,'{\fonttbl','');
temptext := stringreplaceall (temptext,'{\f0\fnil MS Sans Serif;}','');
temptext := stringreplaceall (temptext,'{\f0\fnil\fcharset0 Verdana;}','');
temptext := stringreplaceall (temptext,'{\f0\fnil\fcharset0 Arial;}','');
temptext := stringreplaceall (temptext,'{\f1\fnil\fcharset2 Symbol;}','');
temptext := stringreplaceall (temptext,'{\f2\fswiss\fprq2 System;}}','');
temptext := stringreplaceall (temptext,'{\colortbl\red0\green0\blue0;}','');
temptext := stringreplaceall (temptext,'\cf0','');
temptext := stringreplaceall (temptext,'\deflang','');
temptext := stringreplaceall (temptext,'{\rtf1\ansi\ansicpg1252\deff0}','');
temptext := stringreplaceall (temptext,'{\pntext\f1\'+chr(39)+'B7\tab}','');
temptext := stringreplaceall (temptext,'{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'+char(39)+'B7}}\fi-200\li200 ','');
while pos ('\fs',temptext) >0 do
begin
application.processmessages;
start := pos ('\fs',temptext);
Delete(temptext,start,5);
end;
temptext := stringreplaceall (temptext,'\viewkind4\uc1\pard\lang1036 ','');
temptext := stringreplaceall (temptext,'\viewkind4\uc1\pard\lang1036\f0 ','');
temptext := stringreplaceall (temptext,'\b0','');
temptext := stringreplaceall (temptext,'\i0','');
temptext := stringreplaceall (temptext,'\b','');
temptext := stringreplaceall (temptext,'\i','');
temptext := stringreplaceall (temptext,'\f1','');
temptext := stringreplaceall (temptext,'\par }','');
temptext := stringreplaceall (temptext,'\pard','');
temptext := stringreplaceall (temptext,'\par'+#13+#10,'. ');
temptext := stringreplaceall (temptext,'}','');
temptext := stringreplaceall (temptext,'#]#','}');
temptext := stringreplaceall (temptext,'#[#','{');
temptext := stringreplaceall (temptext,'\\','\');
result := temptext;
end; |
Partager