]> git.lyx.org Git - lyx.git/blob - src/converter.h
dc151dba05dd98ee597840c6ee8df873d4ee90ef
[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                 bool o)
30                 : from(f), to(t), command(c), original_dir(o) {}
31         ///
32         string from;
33         ///
34         string to;
35         ///
36         string command;
37         ///
38         bool original_dir;
39         ///
40         bool visited;
41         ///
42         std::vector<Command>::iterator previous;
43 };
44
45 ///
46 class Format {
47 public:
48         ///
49         Format() : in_degree(0) {}
50         ///
51         Format(string const & n);
52         ///
53         string name;
54         ///
55         string prettyname;
56         ///
57         string viewer;
58         ///
59         int in_degree;
60 };
61
62 ///
63 class Formats {
64 public:
65         ///
66         static
67         void Add(string const & name);
68         ///
69         static
70         void SetViewer(string const & name, string const & command);
71         ///
72         static
73         bool View(Buffer * buffer, string const & filename);
74         ///
75         static
76         Format * GetFormat(string const & name);
77         ///
78         static
79         string const PrettyName(string const & name);
80 private:
81         ///
82         static
83         std::map<string, Format> formats;
84 };
85
86 ///
87 class Converter {
88 public:
89         ///
90         static
91         void Add(string const & from, string const & to,
92                  string const & command, string const & flags);
93         ///
94         static
95         std::vector<std::pair<string, string> > const
96         GetReachable(string const & from,
97                      bool only_viewable = false);
98         ///
99         static
100         bool Convert(Buffer * buffer, string const & from_file,
101                      string const & to_file, string const & using_format);
102         static
103         string const SplitFormat(string const & str, string & format);
104         ///
105         static
106         string dvi_papersize(Buffer * buffer);
107         ///
108         static
109         string dvips_options(Buffer * buffer);
110 private:
111         ///
112         static
113         bool runLaTeX(Buffer * buffer, string const & command);
114         ///
115         static
116         std::vector<Command> commands;
117 };
118
119 #endif