Update lyx examples to latest file format (for 1.5.0 release)
[lyx.git] / src / LaTeX.h
blob52b8ff7a0a0ea5fe4a54a41a3689389099f60fe6
1 // -*- C++ -*-
2 /**
3 * \file LaTeX.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Angus Leeming
9 * \author Dekel Tsur
11 * Full author contact details are available in file CREDITS.
14 #ifndef LATEX_H
15 #define LATEX_H
17 #include "OutputParams.h"
19 #include "support/docstring.h"
20 #include "support/FileName.h"
22 #include <boost/utility.hpp>
23 #include <boost/signal.hpp>
25 #include <vector>
26 #include <set>
29 namespace lyx {
31 class DepTable;
33 ///
34 class TeXErrors {
35 private:
36 ///
37 class Error {
38 public:
39 ///
40 Error () : error_in_line(0) {}
41 ///
42 Error(int line, docstring const & desc, docstring const & text)
43 : error_in_line(line),
44 error_desc(desc),
45 error_text(text) {}
46 /// what line in the TeX file the error occured in
47 int error_in_line;
48 /// The kind of error
49 docstring error_desc;
50 /// The line/cmd that caused the error.
51 docstring error_text;
53 public:
54 ///
55 typedef std::vector<Error> Errors;
56 ///
57 Errors::const_iterator begin() const { return errors.begin(); }
58 ///
59 Errors::const_iterator end() const { return errors.end(); }
60 ///
61 void insertError(int line, docstring const & error_desc,
62 docstring const & error_text);
63 private:
64 ///
65 Errors errors;
69 class Aux_Info {
70 public:
71 ///
72 Aux_Info() {}
73 ///
74 support::FileName aux_file;
75 ///
76 std::set<std::string> citations;
77 ///
78 std::set<std::string> databases;
79 ///
80 std::set<std::string> styles;
84 ///
85 bool operator==(Aux_Info const &, Aux_Info const &);
86 bool operator!=(Aux_Info const &, Aux_Info const &);
89 /**
90 * Class to run the LaTeX compiler and needed auxiliary programs.
91 * The main .tex file must be in the current directory. The current directory
92 * must not change as long as an object of this class lives.
93 * This is required by the LaTeX compiler, and we also make use of it by
94 * various support::makeAbsPath() calls.
96 class LaTeX : boost::noncopyable {
97 public:
98 /** Return values from scanLogFile() and run() (to come)
100 This enum should be enlarged a bit so that one could
101 get more feedback from the LaTeX run.
103 enum log_status {
105 NO_ERRORS = 0,
107 NO_LOGFILE = 1,
109 NO_OUTPUT = 2,
111 UNDEF_REF = 4, // Reference '...' on page ... undefined.
113 UNDEF_CIT = 8, // Citation '...' on page ... undefined.
115 RERUN = 16, // Label(s) may have changed. Rerun to get...
117 TEX_ERROR = 32,
119 TEX_WARNING = 64,
121 LATEX_ERROR = 128,
123 LATEX_WARNING = 256,
125 PACKAGE_WARNING = 512,
127 NO_FILE = 1024,
129 NO_CHANGE = 2048,
131 TOO_MANY_ERRORS = 4096,
133 ERROR_RERUN = 8192,
135 ERRORS = TEX_ERROR + LATEX_ERROR,
137 WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
140 /// This signal emits an informative message
141 boost::signal<void(docstring)> message;
145 cmd = the latex command, file = name of the (temporary) latex file,
146 path = name of the files original path.
148 LaTeX(std::string const & cmd, OutputParams const &,
149 support::FileName const & file);
151 /// runs LaTeX several times
152 int run(TeXErrors &);
155 int getNumErrors() { return num_errors;}
158 int scanLogFile(TeXErrors &);
160 private:
161 /// use this for running LaTeX once
162 int startscript();
164 /// The dependency file.
165 support::FileName depfile;
168 void deplog(DepTable & head);
171 bool runMakeIndex(std::string const &, OutputParams const &,
172 std::string const & = std::string());
175 bool runMakeIndexNomencl(support::FileName const &, OutputParams const &,
176 std::string const &, std::string const &);
179 std::vector<Aux_Info> const scanAuxFiles(support::FileName const &);
182 Aux_Info const scanAuxFile(support::FileName const &);
185 void scanAuxFile(support::FileName const &, Aux_Info &);
188 void updateBibtexDependencies(DepTable &,
189 std::vector<Aux_Info> const &);
192 bool runBibTeX(std::vector<Aux_Info> const &);
195 void deleteFilesOnError() const;
198 std::string cmd;
201 support::FileName file;
203 /// used by scanLogFile
204 int num_errors;
206 /// The name of the final output file.
207 support::FileName output_file;
210 OutputParams runparams;
214 } // namespace lyx
216 #endif