diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/w2latex/rtf.context.c |
Initial commit
Diffstat (limited to 'support/w2latex/rtf.context.c')
-rw-r--r-- | support/w2latex/rtf.context.c | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/support/w2latex/rtf.context.c b/support/w2latex/rtf.context.c new file mode 100644 index 0000000000..b7ce8a5e67 --- /dev/null +++ b/support/w2latex/rtf.context.c @@ -0,0 +1,182 @@ +void parcourscontexts(void); +/************************************************************************************************** +** Function name : nouvcontext +** +** Description : Cree un nouveau maillon contexte a partir de sa description et retourne un + pointeur sur ce maillon +** Input : Etat: Centre, aligne a gauche, aligne a droite ou justifie. +** Output : Pointeur sur le maillon cree. +**************************************************************************************************/ +p_contexte nouvcontext(int Etatctxt) +{ + p_contexte contextemp=DebLisContextes; + p_contexte contextaux=NULL; + /*fprintf(stderr,"NouvContextIn\n");*/ + if (contextemp!=NULL) + { + while(contextemp->suiv!=NULL) + contextemp=contextemp->suiv; + contextaux=(p_contexte) malloc (sizeof(t_contexte)); + if (contextaux==NULL) + { + fprintf(stderr,"FATAL ERROR: MALLOC FAILED\n"); + exit(0); + } + contextemp->suiv=contextaux; + contextemp->suiv->prec=contextemp; + contextemp=contextemp->suiv; + } + else + { + contextemp=(p_contexte) malloc (sizeof(t_contexte)); + if (contextemp==NULL) + { + fprintf(stderr,"FATAL ERROR: MALLOC FAILED\n"); + exit(0); + } + DebLisContextes=contextemp; + contextemp->prec=NULL; + }; + contextemp->EtatTexte=Etatctxt; + contextemp->suiv=NULL; + /*fprintf(stderr,"NouvContextOut\n");*/ + return contextemp; +} + +/************************************************************************************************** +** Function name : contextback +** +** Description : +** Input : +** Output : +**************************************************************************************************/ +contextback() +{ + /*fprintf(stderr,"ContextBackIn\n");*/ + parcourscontexts(); + if (ContextActuel!=NULL) + { + switch (ContextActuel->EtatTexte) + { + case JUST: + break; + case CENTER: + FLAG_Center=0; + fprintf(SORT,"\n\\end{center}%%\n"); + break; + case RIGHT: + FLAG_FlushRight=0; + fprintf(SORT,"\n\\end{flushright}%%\n"); + break; + case LEFT: + FLAG_FlushLeft=0; + fprintf(SORT,"\n\\end{flushleft}%%\n"); + break; + default: + /*fprintf(SORT,"\nERROR: Contexte\n");*/ + break; + } + ContextActuel=ContextActuel->prec; + if (ContextActuel!=NULL) + { + free(ContextActuel->suiv); + ContextActuel->suiv=NULL; + } + else + { + free(DebLisContextes); + DebLisContextes=NULL; + ContextActuel=NULL; + } + } +} + +/************************************************************************************************** +** Function name : parcourscontexts +** +** Description : Parcours de la liste chainee de contextes. (Debuggage); +** Input :void +** Output :void +**************************************************************************************************/ +void parcourscontexts(void) +{ + /*p_contexte contextemp=DebLisContextes; + while (contextemp!=NULL) + { + contextemp=contextemp->suiv; + } + fprintf(stderr,"ParcoursContextOut\n");*/ +} + +/************************************************************************************************** +** Function name : endkeepcontext +** +** Description : Termine le contexte courrant mais le garde en tant que contexte courrant. + Utile pour les Tableaux, car TeX impose de terminer les environnements + avant de sortir de la minipage, alors que RTF ne le fait pas. + A utiliser suivi immediatement de showcontext... +** Input :void +** Output :void +**************************************************************************************************/ +void endkeepcontext(void) +{ + if (ContextActuel!=NULL) + { + switch (ContextActuel->EtatTexte) + { + case JUST: + break; + case CENTER: + FLAG_Center=1; + fprintf(SORT,"\n\\end{center}%%\n"); + break; + case RIGHT: + FLAG_FlushRight=1; + fprintf(SORT,"\n\\end{flushright}%%\n"); + break; + case LEFT: + FLAG_FlushLeft=1; + fprintf(SORT,"\n\\end{flushleft}%%\n"); + break; + default: + fprintf(SORT,"\nERROR: Contexte\n"); + } + } +} + + +/************************************************************************************************** +** Function name : showcontext +** +** Description : Exprime les caracteristiques du contexte courrant. A utiliser en particulier + pour les tableaux apres endkeepcontext +** Input :void +** Output :void +**************************************************************************************************/ +void showcontext(void) +{ + if (ContextActuel!=NULL) + { + switch (ContextActuel->EtatTexte) + { + case JUST: + break; + case CENTER: + FLAG_Center=1; + fprintf(SORT,"\n\\begin{center}%%\n"); + break; + case RIGHT: + FLAG_FlushRight=1; + fprintf(SORT,"\n\\begin{flushright}%%\n"); + break; + case LEFT: + FLAG_FlushLeft=1; + fprintf(SORT,"\n\\begin{flushleft}%%\n"); + break; + default: + fprintf(SORT,"\nERROR: Contexte\n"); + } + } +} + + |