]> git.lyx.org Git - lyx.git/blob - src/converter.h
Fixes to insettabular/text.
[lyx.git] / src / converter.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *        
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2000 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef CONVERTER_H
13 #define CONVERTER_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include <map>
20 #include <vector>
21 #include "LString.h"
22
23 class Buffer;
24
25 ///
26 struct Command {
27         ///
28         Command(string const & f, string const & t, string const & c)
29                 : from(f), to(t), command(c),
30                   original_dir(false), need_aux(false) {}
31         ///
32         string from;
33         ///
34         string to;
35         ///
36         string command;
37         /// Do we need to run the converter in the original directory?
38         bool original_dir;
39         /// This converter needs the .aux files
40         bool need_aux;
41         /// If the converter put the result in a directory, then result_dir
42         /// is the name of the directory
43         string result_dir;
44         /// If the converter put the result in a directory, then result_file
45         /// is the name of the main file in that directory
46         string result_file;
47         ///
48         bool visited;
49         ///
50         std::vector<Command>::iterator previous;
51 };
52
53 ///
54 class Format {
55 public:
56         ///
57         Format() : in_degree(0) {}
58         ///
59         Format(string const & n);
60         ///
61         string name;
62         ///
63         string prettyname;
64         ///
65         string viewer;
66         ///
67         int in_degree;
68 };
69
70 ///
71 class Formats {
72 public:
73         ///
74         static
75         void Add(string const & name);
76         ///
77         static
78         void SetViewer(string const & name, string const & command);
79         ///
80         static
81         bool View(Buffer * buffer, string const & filename);
82         ///
83         static
84         Format * GetFormat(string const & name);
85         ///
86         static
87         string const PrettyName(string const & name);
88 private:
89         ///
90         static
91         std::map<string, Format> formats;
92 };
93
94 ///
95 class Converter {
96 public:
97         ///
98         static
99         void Add(string const & from, string const & to,
100                  string const & command, string const & flags);
101         ///
102         static
103         std::vector<std::pair<string, string> > const
104         GetReachable(string const & from,
105                      bool only_viewable = false);
106         ///
107         static
108         bool Convert(Buffer * buffer, string const & from_file,
109                      string const & to_file, string const & using_format,
110                      string * view_file = 0);
111         ///
112         static
113         string const SplitFormat(string const & str, string & format);
114         ///
115         static
116         string const dvi_papersize(Buffer const * buffer);
117         ///
118         static
119         string const dvips_options(Buffer const * buffer);
120 private:
121         ///
122         static
123         bool runLaTeX(Buffer * buffer, string const & command);
124         ///
125         static
126         std::vector<Command> commands;
127         ///
128         static
129         string latex_command;
130 };
131
132 #endif