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
11 * Full author contact details are available in file CREDITS.
17 #include "OutputParams.h"
19 #include "support/docstring.h"
20 #include "support/FileName.h"
22 #include <boost/noncopyable.hpp>
23 #include <boost/signal.hpp>
40 Error () : error_in_line(0) {}
42 Error(int line, docstring const & desc, docstring const & text,
43 std::string const & fname)
44 : error_in_line(line),
48 /// what line in the TeX file the error occured in
52 /// The line/cmd that caused the error.
54 /// The name of the child where error occurred, empty otherwise.
55 std::string child_name;
59 typedef std::vector<Error> Errors;
61 Errors::const_iterator begin() const { return errors.begin(); }
63 Errors::const_iterator end() const { return errors.end(); }
65 void insertError(int line, docstring const & error_desc,
66 docstring const & error_text,
67 std::string const & child_name = empty_string());
79 support::FileName aux_file;
81 std::set<std::string> citations;
83 std::set<std::string> databases;
85 std::set<std::string> styles;
90 bool operator==(AuxInfo const &, AuxInfo const &);
91 bool operator!=(AuxInfo const &, AuxInfo const &);
95 * Class to run the LaTeX compiler and needed auxiliary programs.
96 * The main .tex file must be in the current directory. The current directory
97 * must not change as long as an object of this class lives.
98 * This is required by the LaTeX compiler, and we also make use of it by
99 * various support::makeAbsPath() calls.
101 class LaTeX : boost::noncopyable {
103 /** Return values from scanLogFile() and run() (to come)
105 This enum should be enlarged a bit so that one could
106 get more feedback from the LaTeX run.
116 UNDEF_REF = 4, // Reference '...' on page ... undefined.
118 UNDEF_CIT = 8, // Citation '...' on page ... undefined.
120 RERUN = 16, // Label(s) may have changed. Rerun to get...
130 PACKAGE_WARNING = 512,
136 TOO_MANY_ERRORS = 4096,
140 BIBTEX_ERROR = 16384,
142 //FIXME: BIBTEX_ERROR has been removed from ERRORS for now, since users were irritated
143 // about those errors which prevented compilation of previously compiling documents.
144 // Think about a "gentle" transfer to BibTeX error reporting.
145 ERRORS = TEX_ERROR + LATEX_ERROR,
147 WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
150 /// This signal emits an informative message
151 boost::signal<void(docstring)> message;
155 cmd = the latex command, file = name of the (temporary) latex file,
156 path = name of the files original path.
158 LaTeX(std::string const & cmd, OutputParams const &,
159 support::FileName const & file,
160 std::string const & path = empty_string());
162 /// runs LaTeX several times
163 int run(TeXErrors &);
166 int getNumErrors() { return num_errors;}
169 int scanLogFile(TeXErrors &);
172 /// use this for running LaTeX once
175 /// The dependency file.
176 support::FileName depfile;
179 void deplog(DepTable & head);
182 bool runMakeIndex(std::string const &, OutputParams const &,
183 std::string const & = std::string());
186 bool runMakeIndexNomencl(support::FileName const &,
187 std::string const &, std::string const &);
190 std::vector<AuxInfo> const scanAuxFiles(support::FileName const &);
193 AuxInfo const scanAuxFile(support::FileName const &);
196 void scanAuxFile(support::FileName const &, AuxInfo &);
199 void updateBibtexDependencies(DepTable &,
200 std::vector<AuxInfo> const &);
203 int scanBlgFile(DepTable & head, TeXErrors & terr);
206 bool runBibTeX(std::vector<AuxInfo> const &,
207 OutputParams const &);
210 void deleteFilesOnError() const;
216 support::FileName file;
221 /// used by scanLogFile
224 /// The name of the final output file.
225 support::FileName output_file;
228 OutputParams runparams;