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