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"
21 #include "support/signals.h"
38 Error () : error_in_line(0) {}
40 Error(int line, docstring const & desc, docstring const & text,
41 std::string const & fname)
42 : error_in_line(line),
46 /// what line in the TeX file the error occurred in
50 /// The line/cmd that caused the error.
52 /// The name of the child where error occurred, empty otherwise.
53 std::string child_name;
57 typedef std::vector<Error> Errors;
59 Errors::const_iterator begin() const { return errors.begin(); }
61 Errors::const_iterator end() const { return errors.end(); }
63 Errors::const_iterator begin_ref() const { return undef_ref.begin(); }
65 Errors::const_iterator end_ref() const { return undef_ref.end(); }
67 void insertError(int line, docstring const & error_desc,
68 docstring const & error_text,
69 std::string const & child_name = empty_string());
71 void clearErrors() { errors.clear(); }
73 void insertRef(int line, docstring const & error_desc,
74 docstring const & error_text,
75 std::string const & child_name = empty_string());
77 void clearRefs() { undef_ref.clear(); }
81 /// For missing Citation and references
91 support::FileName aux_file;
93 std::set<std::string> citations;
95 std::set<std::string> databases;
97 std::set<std::string> styles;
102 bool operator==(AuxInfo const &, AuxInfo const &);
103 bool operator!=(AuxInfo const &, AuxInfo const &);
107 * Class to run the LaTeX compiler and needed auxiliary programs.
108 * The main .tex file must be in the current directory. The current directory
109 * must not change as long as an object of this class lives.
110 * This is required by the LaTeX compiler, and we also make use of it by
111 * various support::makeAbsPath() calls.
115 /** Return values from scanLogFile() and run() (to come)
117 This enum should be enlarged a bit so that one could
118 get more feedback from the LaTeX run.
128 UNDEF_REF = 4, // Reference '...' on page ... undefined.
130 UNDEF_CIT = 8, // Citation '...' on page ... undefined.
132 RERUN = 16, // Label(s) may have changed. Rerun to get...
142 PACKAGE_WARNING = 512,
148 TOO_MANY_ERRORS = 4096,
152 BIBTEX_ERROR = 16384,
154 NONZERO_ERROR = 32768, // the command exited with nonzero status
158 ERRORS = TEX_ERROR + LATEX_ERROR + NONZERO_ERROR + BIBTEX_ERROR + INDEX_ERROR,
160 WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
163 /// This signal emits an informative message
164 signals2::signal<void(docstring)> message;
168 cmd = the latex command, file = name of the (temporary) latex file,
169 path = name of the files original path,
170 clean_start = This forces a fresh run by deleting the files in the temp
171 dir. We set this e.g. if there was an error on previous
172 preview, which is good if the user installed a package
173 or changed certain document settings (#9061).
175 LaTeX(std::string const & cmd, OutputParams const &,
176 support::FileName const & file,
177 std::string const & path = empty_string(),
178 std::string const & lpath = empty_string(),
179 bool allow_cancellation = false,
180 bool const clean_start = false);
182 /// runs LaTeX several times
183 int run(TeXErrors &);
186 int getNumErrors() { return num_errors;}
189 int scanLogFile(TeXErrors &);
193 LaTeX(LaTeX const &);
194 void operator=(LaTeX const &);
196 /// use this for running LaTeX once
199 /// The dependency file.
200 support::FileName depfile;
203 void deplog(DepTable & head);
205 /// returns exit code
206 int runMakeIndex(std::string const &, OutputParams const &,
207 std::string const & = std::string());
209 /// returns exit code
210 int runMakeIndexNomencl(support::FileName const &,
211 std::string const &, std::string const &);
214 std::vector<AuxInfo> const scanAuxFiles(support::FileName const &,
215 bool const only_childbibs = false);
218 AuxInfo const scanAuxFile(support::FileName const &);
221 void scanAuxFile(support::FileName const &, AuxInfo &);
224 void updateBibtexDependencies(DepTable &,
225 std::vector<AuxInfo> const &);
228 int scanBlgFile(DepTable & head, TeXErrors & terr);
231 int scanIlgFile(TeXErrors & terr);
234 bool runBibTeX(std::vector<AuxInfo> const &,
235 OutputParams const &, int & exit_code);
238 void removeAuxiliaryFiles() const;
244 support::FileName file;
246 /// The document directory path.
249 /// Extra path, possibly relative to the document directory path.
252 /// used by scanLogFile
255 /// The name of the final output file.
256 support::FileName output_file;
259 OutputParams runparams;
264 std::vector <std::string> children;