]> git.lyx.org Git - lyx.git/blob - src/converter.h
go through horrendous contortions to work around font breakage in every
[lyx.git] / src / converter.h
1 // -*- C++ -*-
2
3 #ifndef CONVERTER_H
4 #define CONVERTER_H
5
6 /**
7  * \file converter.h
8  * This file is part of LyX, the document processor.
9  * Licence details can be found in the file COPYING.
10  *
11  * \author Dekel Tsur
12  *
13  * Full author contact details are available in file CREDITS
14  */
15
16 #include "latexrunparams.h"
17 #include "graph.h"
18
19 #include <vector>
20
21 class Format;
22 class Formats;
23
24 class Buffer;
25
26 ///
27 class Converter {
28 public:
29         ///
30         Converter(string const & f, string const & t, string const & c,
31                   string const & l);
32         ///
33         void readFlags();
34         ///
35         string from;
36         ///
37         string to;
38         ///
39         string command;
40         ///
41         string flags;
42         ///
43         Format const * From;
44         ///
45         Format const * To;
46
47         /// The converter is latex or its derivatives
48         bool latex;
49         /// Do we need to run the converter in the original directory?
50         bool original_dir;
51         /// This converter needs the .aux files
52         bool need_aux;
53         /// If the converter put the result in a directory, then result_dir
54         /// is the name of the directory
55         string result_dir;
56         /// If the converter put the result in a directory, then result_file
57         /// is the name of the main file in that directory
58         string result_file;
59         /// Command to convert the program output to a LaTeX log file format
60         string parselog;
61 };
62
63
64 ///
65 class Converters {
66 public:
67         ///
68         typedef std::vector<int> EdgePath; // to be removed SOON
69         ///
70         typedef std::vector<Converter> ConverterList;
71         ///
72         typedef ConverterList::const_iterator const_iterator;
73         ///
74         Converter const & get(int i) const {
75                 return converterlist_[i];
76         }
77         ///
78         Converter const * getConverter(string const & from, string const & to);
79         ///
80         int getNumber(string const & from, string const & to);
81         ///
82         void add(string const & from, string const & to,
83                  string const & command, string const & flags);
84         //
85         void erase(string const & from, string const & to);
86         ///
87         void sort();
88         ///
89         std::vector<Format const *> const
90         getReachableTo(string const & target, bool clear_visited);
91         ///
92         std::vector<Format const *> const
93         getReachable(string const & from, bool only_viewable,
94                      bool clear_visited);
95         ///
96         bool isReachable(string const & from, string const & to);
97         ///
98         Graph::EdgePath const getPath(string const & from, string const & to);
99         ///
100         bool usePdflatex(Graph::EdgePath const & path);
101         ///
102         bool convert(Buffer const * buffer,
103                      string const & from_file, string const & to_file_base,
104                      string const & from_format, string const & to_format,
105                      string & to_file);
106         ///
107         bool convert(Buffer const * buffer,
108                      string const & from_file, string const & to_file_base,
109                      string const & from_format, string const & to_format);
110         ///
111         string const dvips_options(Buffer const * buffer);
112         ///
113         string const dvipdfm_options(Buffer const * buffer);
114         ///
115         void update(Formats const & formats);
116         ///
117         void updateLast(Formats const & formats);
118         ///
119         bool formatIsUsed(string const & format);
120         ///
121         const_iterator begin() const {
122                 return converterlist_.begin();
123         }
124         const_iterator end() const {
125                 return converterlist_.end();
126         }
127         ///
128         void buildGraph();
129 private:
130         ///
131         std::vector<Format const *> const
132         Converters::intToFormat(std::vector<int> const & input);
133         ///
134         bool scanLog(Buffer const * buffer, string const & command,
135                      string const & filename);
136         ///
137         bool runLaTeX(Buffer const * buffer, string const & command,
138                       LatexRunParams const &);
139         ///
140         ConverterList converterlist_;
141         ///
142         string latex_command_;
143         ///
144         bool move(string const & from, string const & to, bool copy);
145         ///
146         Graph G_;
147 };
148
149 extern Converters converters;
150
151 extern Converters system_converters;
152
153 #endif //CONVERTER_H