]> git.lyx.org Git - lyx.git/blob - src/LaTeX.h
Add support for multline and alignat environments from amsmath.
[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 #include <set>
26
27 #include <boost/utility.hpp>
28
29 class MiniBuffer;
30
31 ///
32 class TeXErrors {
33 private:
34         ///
35         struct Error {
36                 ///
37                 Error () : error_in_line(0) {}
38                 ///
39                 Error(int line, string const & desc, string const & text)
40                         : error_in_line(line),
41                           error_desc(desc),
42                           error_text(text) {}
43                 /// what line in the TeX file the error occured in
44                 int error_in_line;
45                 /// The kind of error
46                 string error_desc;
47                 /// The line/cmd that caused the error.
48                 string error_text;
49         };
50 public:
51         ///
52         typedef std::vector<Error> Errors;
53         ///
54         Errors::const_iterator begin() const { return errors.begin(); }
55         ///
56         Errors::const_iterator end() const { return errors.end(); }
57         ///
58         void insertError(int line, string const & error_desc,
59                          string const & error_text);
60 private:
61         ///
62         Errors errors;
63 };
64
65 class Aux_Info {
66 public:
67         ///
68         Aux_Info() {}
69         ///
70         string aux_file;
71         ///
72         std::set<string> citations;
73         ///
74         std::set<string> databases;
75         ///
76         std::set<string> styles;
77         ///
78         operator==(Aux_Info const & o) const {
79                 return aux_file == o.aux_file &&
80                         citations == o.citations &&
81                         databases == o.databases &&
82                         styles == o.styles;
83         }
84 };
85
86 ///
87 class LaTeX : public noncopyable {
88 public:
89         /** Return values from scanLogFile() and run() (to come)
90             
91             This enum should be enlarged a bit so that one could
92             get more feedback from the LaTeX run.
93         */
94         enum log_status {
95                 ///
96                 NO_ERRORS = 0,
97                 ///
98                 NO_LOGFILE = 1,
99                 ///
100                 NO_OUTPUT = 2,
101                 ///
102                 UNDEF_REF = 4, // Reference '...' on page ... undefined.
103                 ///
104                 UNDEF_CIT = 8, // Citation '...' on page ... undefined.
105                 ///
106                 RERUN = 16, // Label(s) may have changed. Rerun to get...
107                 ///
108                 TEX_ERROR = 32,
109                 ///
110                 TEX_WARNING = 64,
111                 ///
112                 LATEX_ERROR = 128,
113                 ///
114                 LATEX_WARNING = 256,
115                 ///
116                 PACKAGE_WARNING = 512,
117                 ///
118                 NO_FILE = 1024,
119                 ///
120                 NO_CHANGE = 2048,
121                 ///
122                 TOO_MANY_ERRORS = 4096,
123                 ///
124                 ERROR_RERUN = 8192,
125                 ///
126                 ERRORS = TEX_ERROR + LATEX_ERROR,
127                 ///
128                 WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
129         };
130         
131
132         /**
133            cmd = the latex command, file = name of the (temporary) latex file,
134            path = name of the files original path.
135         */
136         LaTeX(string const & cmd, string const & file, string const & path);
137
138         ///
139         virtual ~LaTeX() {}
140         
141         /// runs LaTeX several times
142         int run(TeXErrors &, MiniBuffer *);
143
144         ///
145         int getNumErrors() { return num_errors;}
146
147         /// use this for running LaTeX once
148         int operator() ();
149
150         ///
151         int scanLogFile(TeXErrors &);
152
153 protected:
154         /// The dependency file.
155         string depfile;
156
157         ///
158         void deplog(DepTable & head);
159
160         ///
161         bool runMakeIndex(string const &);
162
163         ///
164         std::vector<Aux_Info> const scanAuxFiles(string const &);
165
166         ///
167         Aux_Info const scanAuxFile(string const &);
168
169         ///
170         void scanAuxFile(string const &, Aux_Info &);
171         
172         ///
173         void updateBibtexDependencies(DepTable &, vector<Aux_Info> const &);
174
175         ///
176         bool runBibTeX(vector<Aux_Info> const &);
177
178         ///
179         void deleteFilesOnError() const;
180         
181         ///
182         string cmd;
183
184         ///
185         string file;
186         
187         ///
188         string path;
189
190         /// used by scanLogFile
191         int num_errors;
192 };
193
194 #endif