summaryrefslogtreecommitdiff
path: root/support/rtflatex/rtflatex.h
blob: e44a9ab6e6304459f5e48f9ce6f0699fae04aeb7 (plain)
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
const
  lmx=511; olmx=1023; maxlevel=72; maxkeyln=64; bfslen=24;
  numsizes=16; maxfonts=128; maxstyles=12; max_skip_strings=8; maxRTFstyles=64;
  RTFstyle_length=128;
type
  string24=string[bfslen];
  string2=string[2]; string5=string[5]; string128=string[128];
   string255=string[255];
  exline_type=array[1..olmx] of char; string_RTFstyle=string[RTFstyle_length];
var
  inputfile, outputfile, figurefile, logfile, skipfile : text;
  catcode, digit, majusc, letter : array[0..255] of integer;
  acc_transl, ftech_transl : array[0..255] of string24;
  prev_line, inpline : array[1..lmx] of char;
  exline : exline_type;
  tex_verbose, verbose, icharz, numl, kout, kinp, prev_kinp, bracelvl : integer;
  lvlcode, tab_nb_cellx, tab_nb_ands, tab_cellx : array[0..maxlevel] of integer;
  kar, hexaone, hexatwo : char;
  next_rtf : string255;
  removed_ok, write_log, do_it_again, no_space_conv, use_sl, latex209,
    latex_header, base_flag, envir_closed_ok, last_percent, simplify_ok,
    no_RTFrtf, par_to_begin : boolean;
  num_styles, input_line_number, numfonts, num_word_fonts, stdsize, stdkz : integer;
  close_kar, form_code, bfslcode, sizecode, currsize, currbfsl,
  spacingcode, active_RTFf : array[0..maxlevel] of string24;
  center_flag, flushright_flag, math_mode : array[0..maxlevel] of integer;
  underl_flag, auto_close : array[0..maxlevel] of boolean;
  sizekey : array[1..numsizes] of string24;
  sizeval : array[1..3,1..numsizes] of integer;
  sizemags : array[1..3,1..numsizes] of integer;
  newfonts, word_fonts, equiv_fonts, font_names : array[1..maxfonts] of string24;
  word_font_num :  array[1..maxfonts] of integer;
  inkeyw : string255;
  num_diff_sizes, keyw, cat, ikar, numval, numsign, num_hexa, num_skip_strings : integer;
  decl_font_num, num_latex_options, num_indent, i, j, k, l, m, n : integer;
  works, worksa, worksb, latex_style, end_math_code : string24;
  latex_options : array [0..maxstyles] of string24;
  environ_type : array [0..10] of string24;
  skip_strings : array [1..max_skip_strings] of string255;
  leftskip, rightskip, leftcurskip, rightcurskip, save_skip, space_after,
    displ_skip : integer;
  RTFstyles : array [1..maxRTFstyles] of string_RTFstyle;
  ref_styles : array [0..255] of integer;

  clbrdrr,  clbrdrl,  clbrdrt,  clbrdrb : boolean;

{ indications to build file names of figure bitmaps } 
  figure_name, figure_path, figure_type : string128;
  pict_name : string24; 
  rtfpicw, rtfpich, pict_char_number, pict_byte_number : longint;
  pict_last_hexa, pict_number : integer;
  pict_left_hexa : boolean;
  last_kar : char;


{---------------------------------------------------------------------------}
{ resets all integers to 0, all strings to '', for safety }

procedure clean_all;
 var
   z : integer;
 begin
  for z:=1 to lmx do prev_line[k]:=' ';
  for z:=1 to lmx do inpline[k]:=' ';
  for z:=1 to olmx do exline[k]:=' ';

  tex_verbose:=0; verbose:=0; icharz:=0; numl:=0; kout:=0; kinp:=0;
  prev_kinp:=0; bracelvl:=0;

  for z:=0 to maxlevel do
    begin
      lvlcode[z]:=0; tab_nb_cellx[z]:=0; tab_nb_ands[z]:=0; tab_cellx[z]:=0;
    end
  ;
  kar:=' '; hexaone:=' '; hexatwo:=' ';

  next_rtf:='';
  removed_ok:=FALSE; write_log:=FALSE; do_it_again:=FALSE;
  no_space_conv:=FALSE; use_sl:=FALSE; latex209:=FALSE;
  latex_header:=FALSE; base_flag:=FALSE; envir_closed_ok:=FALSE;
  last_percent:=FALSE; simplify_ok:=FALSE; no_RTFrtf:=FALSE;
  par_to_begin:=FALSE;
  
  num_styles:=0; input_line_number:=0; numfonts:=0; num_word_fonts:=0;
  stdsize:=0; stdkz:=0;

  for z:=0 to maxlevel do
    begin close_kar[z]:=''; form_code[z]:=''; bfslcode[z]:=''; sizecode[z]:='';
      currsize[z]:=''; currbfsl[z]:=''; spacingcode[z]:=''; active_RTFf[z]:='';
      center_flag[z]:=0; flushright_flag[z]:=0; math_mode[z]:=0;
      underl_flag[z]:=FALSE; auto_close[z]:=FALSE;
    end
  ;
(*  sizekey : array[1..numsizes] of string24; *)
(*  sizeval : array[1..3,1..numsizes] of integer; *)
(*  sizemags : array[1..3,1..numsizes] of integer; *)
  for z:=1 to maxfonts do
    begin
      newfonts[z]:=''; word_fonts[z]:=''; equiv_fonts[z]:='';
      font_names[z]:='';
      word_font_num[z]:=0;
    end
  ;
  inkeyw:='';
  num_diff_sizes:=0; keyw:=0; cat:=0; ikar:=0; numval:=0; numsign:=0;
  num_hexa:=0; num_skip_strings:=0;
  decl_font_num:=0; num_latex_options:=0; num_indent:=0; i:=0; j:=0;
  k:=0; l:=0; m:=0; n:=0;
  works:=''; worksa:=''; worksb:=''; latex_style:=''; end_math_code:='';

  for z:=0 to maxstyles do latex_options[z]:='';
  for z:=0 to 10 do environ_type[z]:='';
  for z:=1 to max_skip_strings do skip_strings[z]:='';
  leftskip:=0; rightskip:=0; leftcurskip:=0; rightcurskip:=0;
  save_skip:=0; space_after:=0; displ_skip:=0;

  for z:=1 to maxRTFstyles do RTFstyles[z]:='';
  for z:=0 to 255 do ref_styles[z]:=0;

  clbrdrr:=FALSE;  clbrdrl:=FALSE;  clbrdrt:=FALSE;  clbrdrb:=FALSE;

{ indications to build file names of figure bitmaps } 
  figure_name:=''; figure_path:=''; figure_type:='';
  pict_name:='';
  rtfpicw:=0; rtfpich:=0; pict_char_number:=0; pict_byte_number:=0;
  pict_last_hexa:=0; pict_number:=0;
  pict_left_hexa:=FALSE;
  last_kar:=' ';
 end;
 
{---------------------------------------------------------------------------}

procedure title;

 begin
   writeln ('           MICROSOFT RTF(Word[Perfect]) to LaTeX conversion');
   writeln ('           Daniel Taupin, CNRS, 20th September 1996');
   writeln ('           Universite de Paris-Sud, Orsay, France');
   writeln ('           Version 2.15');
   writeln ('           E-mail: taupin@lps.u-psud.fr');
 end;

{---------------------------------------------------------------------------}
{ converts a hexa character into a number from 0 to 15 }

function hx_to_i(kar : char) : integer;
var
  ikar, okar : integer;
begin
  ikar:=ord(kar);
  if(ikar < ord('0')) then okar:=0
  else if (ikar<=ord('9')) then okar:=ikar-ord('0')
  else if (ikar<=ord('Z')) then okar:=ikar-ord('A')+10
  else if (ikar<=ord('z')) then okar:=ikar-ord('a')+10
  else okar:=0
  ; {END IF ikar }
  hx_to_i:=okar;
end;

{---------------------------------------------------------------------------}
{ converts a string of two hexa character into a number from 0 to 255 }

function hs_to_i(input_stg : string2) : integer;
begin
  hs_to_i:=16*hx_to_i(input_stg[1])+hx_to_i(input_stg[2]);
end;

{---------------------------------------------------------------------------}
{ truncate at bfslen a string }

function truncate24(a: string) : string24;
begin
  truncate24:=copy(a,1,bfslen);
end;