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