enum {CVT_AUCUN=0, CVT_RTF, CVT_TXT, CVT_HTML}; FILE *gblFsortie=NULL; int gblConvType = CVT_AUCUN; void Output_Caractere(int c, int fonte, int gras, int italique, int under, int color) { static int ancFonte, ancGras, ancItalique, ancUnder, ancColor; static int htmlCompteGras, htmlCompteItal, htmlCompteUnder, lastCar, rtfBaliseEnCours, htmlCompteSpan; if (c==-1) { //Initialisation ancFonte=1, ancGras=0, ancItalique=0, ancUnder=0, ancColor=1; htmlCompteGras=htmlCompteItal=lastCar=rtfBaliseEnCours=0; return; } if (fonte!=ancFonte) { if (gblConvType==CVT_HTML) { fprintf(gblFsortie,"",1+fonte); } else if (gblConvType==CVT_RTF) { fprintf(gblFsortie,"\\fs%i",16+4*fonte); rtfBaliseEnCours=1; } ancFonte=fonte; } if (gras!=ancGras) { if (gblConvType==CVT_HTML) { if (gras) { //Si on met ©G1test©G2, cela générera test, et il faudra deux . Il faut //donc éviter les double if (!htmlCompteGras) fprintf(gblFsortie,""); htmlCompteGras=1; } else { if (htmlCompteGras) fprintf(gblFsortie,""); htmlCompteGras=0; } } else if (gblConvType==CVT_RTF) { if (gras) { fprintf(gblFsortie,"\\b"); rtfBaliseEnCours=1; } else { fprintf(gblFsortie,"\\b0"); rtfBaliseEnCours=1; } } ancGras=gras; } if (italique!=ancItalique) { if (gblConvType==CVT_HTML) { if (italique) { if (!htmlCompteItal) fprintf(gblFsortie,""); htmlCompteItal=1; } else { if (htmlCompteItal) fprintf(gblFsortie,""); htmlCompteItal=0; } } else if (gblConvType==CVT_RTF) { if (italique) { fprintf(gblFsortie,"\\i"); rtfBaliseEnCours=1; } else { fprintf(gblFsortie,"\\i0"); rtfBaliseEnCours=1; } } ancItalique=italique; } if (under!=ancUnder) { if (gblConvType==CVT_HTML) { if (under) { if (!htmlCompteUnder) fprintf(gblFsortie,""); htmlCompteUnder=1; } else { if (htmlCompteUnder) fprintf(gblFsortie,""); htmlCompteUnder=0; } } else if (gblConvType==CVT_RTF) { if (under==2) { fprintf(gblFsortie,"\\uldb"); rtfBaliseEnCours=1; } else if (under==1) { fprintf(gblFsortie,"\\ul"); rtfBaliseEnCours=1; } else { fprintf(gblFsortie,"\\ulnone"); rtfBaliseEnCours=1; } } ancUnder=under; } if (color!=ancColor) { if (gblConvType==CVT_HTML) { if (htmlCompteSpan>0) fputs("",gblFsortie); htmlCompteSpan=1; if (color==0 || color==2) fputs("",gblFsortie); else if (color==3) fputs("",gblFsortie); else if (color==4) fputs("",gblFsortie); } else if (gblConvType==CVT_RTF) { if (ancColor==0 || ancColor==2) fputs("\\cf0",gblFsortie); if (color==0 || color==2) { fprintf(gblFsortie,"\\highlight4\\cf3"); rtfBaliseEnCours=1; } else if (color==1) { fprintf(gblFsortie,"\\highlight0"); rtfBaliseEnCours=1; } else if (color==3) { fprintf(gblFsortie,"\\highlight1"); rtfBaliseEnCours=1; } else if (color==4) { fprintf(gblFsortie,"\\highlight2"); rtfBaliseEnCours=1; } } ancColor=color; } if (gblConvType==CVT_HTML) { if (c==CAR_ENTER) fputs("
\n",gblFsortie); else if (c==32 && lastCar==32) fputs(" ",gblFsortie); else fputc(c,gblFsortie); lastCar=c; } else if (gblConvType==CVT_RTF) { if (rtfBaliseEnCours) { fputc(' ',gblFsortie); rtfBaliseEnCours=0; } if (c==CAR_ENTER) fputs("\\par\n",gblFsortie); else fputc(c,gblFsortie); lastCar=c; } else if (gblConvType==CVT_TXT) { fputc(c,gblFsortie); lastCar=c; } } void Output_Image(char *nom_image) { if (gblConvType==CVT_HTML) fprintf(gblFsortie,"\"%s\"",nom_image,nom_image); else if (gblConvType==CVT_TXT) fprintf(gblFsortie,"[image: %s]",nom_image); } void Output_DebutTexte(char *nom) { char str[MAX_PATH+11], petitnom[MAX_PATH]; strcpy(str,nom); str[strlen(str)-4]=0; if (gblConvType==CVT_HTML) { strcpy(petitnom,str); strcat(str,".htm"); gblFsortie=fopen(str,"w"); // fputs("",gblFsortie); // fputs("",gblFsortie); fprintf(gblFsortie,"\n%s\n\n",petitnom); fputs("",gblFsortie); } else if (gblConvType==CVT_RTF) { strcat(str,".rtf"); gblFsortie=fopen(str,"w"); fputs("{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1036{\\fonttbl{\\f0\\fswiss\\fcharset0 Courier new;}}\n" "{\\colortbl ;\\red255\\green255\\blue0;\\red255\\green0\\blue0;\\red255\\green255\\blue255;\\red0\\green0\\blue0;}\n" "{\\*\\generator Msftedit 5.41.15.1507;}\\viewkind4\\uc1\\pard\\fs20 ",gblFsortie); } else if (gblConvType==CVT_TXT) { strcat(str,"_texteseul.txt"); gblFsortie=fopen(str,"w"); } Output_Caractere(-1,0,0,0,0,0); } void Output_FinTexte() { if (gblFsortie) { if (gblConvType==CVT_RTF) fputs("\n\\par \n}\n",gblFsortie); else if (gblConvType==CVT_HTML) fputs("\n\n",gblFsortie); fclose(gblFsortie); } gblFsortie=NULL; gblConvType=0; }