]> git.lyx.org Git - lyx.git/blob - src/LaTeX.h
ebeb4b66495c0687a71f0c0e4f6d28ee3ac2e233
[lyx.git] / src / LaTeX.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor         
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-2000 The Lyx Team
8  *
9  *           This file is Copyright 1996-1999
10  *           Lars Gullik Bjønnes
11  *
12  * ====================================================== 
13  */
14
15 #ifndef LATEX_H
16 #define LATEX_H
17
18 #ifdef __GNUG__
19 #pragma interface
20 #endif
21
22 #include "LString.h"
23 #include "DepTable.h"
24 #include <vector>
25
26 using std::vector;
27
28 class MiniBuffer;
29
30 ///
31 class TeXErrors {
32 private:
33         ///
34         struct Error {
35                 ///
36                 Error () : error_in_line(0) {}
37                 ///
38                 Error(int line, string const & desc, string const & text)
39                         : error_in_line(line),
40                           error_desc(desc),
41                           error_text(text) {}
42                 /// what line in the TeX file the error occured in
43                 int error_in_line;
44                 /// The kind of error
45                 string error_desc;
46                 /// The line/cmd that caused the error.
47                 string error_text;
48         };
49 public:
50         ///
51         typedef vector<Error> Errors;
52         ///
53         Errors::const_iterator begin() const { return errors.begin(); }
54         ///
55         Errors::const_iterator end() const { return errors.end(); }
56         ///
57         void insertError(int line, string const & error_desc,
58                          string const & error_text);
59 private:
60         ///
61         Errors errors;
62 };
63
64
65 ///
66 class LaTeX {
67 public:
68         /** All the different files produced by TeX.
69             
70             This is the files mentioned on page 208-9 in Lamports book +
71             .ltx and .tex files.
72         */
73         enum TEX_FILES {
74                 ///
75                 NO_FILES = 0,
76                 /// used for table of contents et.al.
77                 AUX = 1,
78                 /// written by BibTeX
79                 BBL = 2,
80                 /// LaTeX's output
81                 DVI = 4,
82                 /// glossary (not supported by LyX so far)
83                 GLO = 8,
84                 ///index
85                 IDX = 16,
86                 /// written by makeindex
87                 IND = 32,
88                 /// list of figures
89                 LOF = 64,
90                 /// the LaTeX log file
91                 LOG = 128,
92                 /// list of tables
93                 LOT = 256,
94                 /// table of contents
95                 TOC = 512,
96                 /// latex files
97                 LTX = 1024,
98                 /// tex files
99                 TEX = 2048,
100                 /// list of algorithms
101                 LOA = 4096
102         };
103         
104         /** Return values from scanLogFile() and run() (to come)
105
106           This enum should be enlarged a bit so that one could
107           get more feedback from the LaTeX run.
108           */
109         enum log_status {
110                 ///
111                 NO_ERRORS = 0,
112                 ///
113                 NO_LOGFILE = 1,
114                 ///
115                 NO_OUTPUT = 2,
116                 ///
117                 UNDEF_REF = 4, // Reference '...' on page ... undefined.
118                 ///
119                 UNDEF_CIT = 8, // Citation '...' on page ... undefined.
120                 ///
121                 RERUN = 16, // Label(s) may have changed. Rerun to get...
122                 ///
123                 TEX_ERROR = 32,
124                 ///
125                 TEX_WARNING = 64,
126                 ///
127                 LATEX_ERROR = 128,
128                 ///
129                 LATEX_WARNING = 256,
130                 ///
131                 PACKAGE_WARNING = 512,
132                 ///
133                 NO_FILE = 1024,
134                 ///
135                 NO_CHANGE = 2048,
136                 ///
137                 TOO_MANY_ERRORS = 4096,
138                 ///
139                 ERRORS = TEX_ERROR + LATEX_ERROR,
140                 ///
141                 WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
142         };
143         
144
145         /**
146            cmd = the latex command, file = name of the (temporary) latex file,
147            path = name of the files original path.
148         */
149         LaTeX(string const & cmd, string const & file, string const & path);
150         
151         /// runs LaTeX several times
152         int run(TeXErrors &, MiniBuffer *);
153
154         ///
155         int getNumErrors() { return num_errors;}
156
157         /// use this for running LaTeX once
158         int operator() ();
159 protected:
160         /// The dependency file.
161         string depfile;
162
163         /// unavail
164         LaTeX(LaTeX const &);
165         /// unavail
166         LaTeX & operator= (LaTeX const &);
167         
168         ///
169         void deplog(DepTable & head);
170
171         ///
172         void deptex(DepTable & head);
173         
174         ///
175         int scanLogFile(TeXErrors &);
176
177         ///
178         bool runMakeIndex(string const &);
179
180         ///
181         bool scanAux(DepTable &);
182         
183         ///
184         bool runBibTeX(string const &, DepTable &);
185         
186         ///
187         string cmd;
188
189         ///
190         string file;
191         
192         ///
193         string path;
194         ///
195         TEX_FILES tex_files;
196         
197         ///
198         int file_count;
199
200         // used by scanLogFile
201         int num_errors;
202 };
203
204 #endif