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