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/signal.hpp>
39 Error () : error_in_line(0) {}
41 Error(int line, docstring const & desc, docstring const & text,
42 std::string const & fname)
43 : error_in_line(line),
47 /// what line in the TeX file the error occurred in
51 /// The line/cmd that caused the error.
53 /// The name of the child where error occurred, empty otherwise.
54 std::string child_name;
58 typedef std::vector<Error> Errors;
60 Errors::const_iterator begin() const { return errors.begin(); }
62 Errors::const_iterator end() const { return errors.end(); }
64 void insertError(int line, docstring const & error_desc,
65 docstring const & error_text,
66 std::string const & child_name = empty_string());
68 void clearErrors() { errors.clear(); }
80 support::FileName aux_file;
82 std::set<std::string> citations;
84 std::set<std::string> databases;
86 std::set<std::string> styles;
91 bool operator==(AuxInfo const &, AuxInfo const &);
92 bool operator!=(AuxInfo const &, AuxInfo const &);
96 * Class to run the LaTeX compiler and needed auxiliary programs.
97 * The main .tex file must be in the current directory. The current directory
98 * must not change as long as an object of this class lives.
99 * This is required by the LaTeX compiler, and we also make use of it by
100 * various support::makeAbsPath() calls.
104 /** Return values from scanLogFile() and run() (to come)
106 This enum should be enlarged a bit so that one could
107 get more feedback from the LaTeX run.
117 UNDEF_REF = 4, // Reference '...' on page ... undefined.
119 UNDEF_CIT = 8, // Citation '...' on page ... undefined.
121 RERUN = 16, // Label(s) may have changed. Rerun to get...
131 PACKAGE_WARNING = 512,
137 TOO_MANY_ERRORS = 4096,
141 BIBTEX_ERROR = 16384,
143 NONZERO_ERROR = 32768, // the command exited with nonzero status
145 ERRORS = TEX_ERROR + LATEX_ERROR + NONZERO_ERROR + BIBTEX_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,
157 clean_start = This forces a fresh run by deleting the files in the temp
158 dir. We set this e.g. if there was an error on previous
159 preview, which is good if the user installed a package
160 or changed certain document settings (#9061).
162 LaTeX(std::string const & cmd, OutputParams const &,
163 support::FileName const & file,
164 std::string const & path = empty_string(),
165 std::string const & lpath = empty_string(),
166 bool const clean_start = false);
168 /// runs LaTeX several times
169 int run(TeXErrors &);
172 int getNumErrors() { return num_errors;}
175 int scanLogFile(TeXErrors &);
179 LaTeX(LaTeX const &);
180 void operator=(LaTeX const &);
182 /// use this for running LaTeX once
185 /// The dependency file.
186 support::FileName depfile;
189 void deplog(DepTable & head);
192 bool runMakeIndex(std::string const &, OutputParams const &,
193 std::string const & = std::string());
196 bool runMakeIndexNomencl(support::FileName const &,
197 std::string const &, std::string const &);
200 std::vector<AuxInfo> const scanAuxFiles(support::FileName const &);
203 AuxInfo const scanAuxFile(support::FileName const &);
206 void scanAuxFile(support::FileName const &, AuxInfo &);
209 void updateBibtexDependencies(DepTable &,
210 std::vector<AuxInfo> const &);
213 int scanBlgFile(DepTable & head, TeXErrors & terr);
216 bool runBibTeX(std::vector<AuxInfo> const &,
217 OutputParams const &);
220 void removeAuxiliaryFiles() const;
226 support::FileName file;
228 /// The document directory path.
231 /// Extra path, possibly relative to the document directory path.
234 /// used by scanLogFile
237 /// The name of the final output file.
238 support::FileName output_file;
241 OutputParams runparams;