]> git.lyx.org Git - lyx.git/blob - src/converter.h
split LyXText::rowlist_ into individual Paragraph::rows_ chunks
[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         void update(Formats const & formats);
112         ///
113         void updateLast(Formats const & formats);
114         ///
115         bool formatIsUsed(string const & format);
116         ///
117         const_iterator begin() const {
118                 return converterlist_.begin();
119         }
120         const_iterator end() const {
121                 return converterlist_.end();
122         }
123         ///
124         void buildGraph();
125 private:
126         ///
127         std::vector<Format const *> const
128         Converters::intToFormat(std::vector<int> const & input);
129         ///
130         bool scanLog(Buffer const * buffer, string const & command,
131                      string const & filename);
132         ///
133         bool runLaTeX(Buffer const * buffer, string const & command,
134                       LatexRunParams const &);
135         ///
136         ConverterList converterlist_;
137         ///
138         string latex_command_;
139         ///
140         bool move(string const & from, string const & to, bool copy);
141         ///
142         Graph G_;
143 };
144
145 extern Converters converters;
146
147 extern Converters system_converters;
148
149 #endif //CONVERTER_H