]> git.lyx.org Git - lyx.git/blob - src/format.h
"Inter-word Space"
[lyx.git] / src / format.h
1 // -*- C++ -*-
2
3
4 #ifndef FORMAT_H
5 #define FORMAT_H
6
7
8 /**
9  * \file format.h
10  * This file is part of LyX, the document processor.
11  * Licence details can be found in the file COPYING.
12  *
13  * \author Dekel Tsur
14  *
15  * Full author contact details are available in file CREDITS
16  */
17
18
19
20 #include "LString.h"
21
22 #include <vector>
23
24 class Buffer;
25
26 string const papersize(Buffer const * buffer) ;
27
28 class Format {
29 public:
30         ///
31         Format(string const & n, string const & e, string const & p,
32                string const & s, string const & v);
33         ///
34         bool dummy() const;
35         ///
36         bool isChildFormat() const;
37         ///
38         string const parentFormat() const;
39         ///
40         string const & name() const {
41                 return name_;
42         }
43         ///
44         string const & extension() const {
45                 return extension_;
46         }
47         ///
48         string const & prettyname() const {
49                 return prettyname_;
50         }
51         ///
52         string const & shortcut() const {
53                 return shortcut_;
54         }
55         ///
56         string const & viewer() const {
57                 return viewer_;
58         }
59         ///
60         void setViewer(string const & v) {
61                 viewer_ = v;
62         }
63 private:
64         string name_;
65         ///
66         string extension_;
67         ///
68         string prettyname_;
69         ///
70         string shortcut_;
71         ///
72         string viewer_;
73 };
74
75
76 bool operator<(Format const & a, Format const & b);
77
78 ///
79 class Formats {
80 public:
81         ///
82         typedef std::vector<Format> FormatList;
83         ///
84         typedef FormatList::const_iterator const_iterator;
85         ///
86         Format const & get(FormatList::size_type i) const {
87                 return formatlist[i];
88         }
89         ///
90         Format const * getFormat(string const & name) const;
91         ///
92         int getNumber(string const & name) const;
93         ///
94         void add(string const & name);
95         ///
96         void add(string const & name, string const & extension,
97                  string const & prettyname, string const & shortcut);
98         ///
99         void erase(string const & name);
100         ///
101         void sort();
102         ///
103         void setViewer(string const & name, string const & command);
104         ///
105         bool view(Buffer const * buffer, string const & filename,
106                   string const & format_name) const;
107         ///
108         string const prettyName(string const & name) const;
109         ///
110         string const extension(string const & name) const;
111         ///
112         const_iterator begin() const {
113                 return formatlist.begin();
114         }
115         ///
116         const_iterator end() const {
117                 return formatlist.end();
118         }
119         ///
120         FormatList::size_type size() const {
121                 return formatlist.size();
122         }
123 private:
124         ///
125         FormatList formatlist;
126 };
127
128 extern Formats formats;
129
130 extern Formats system_formats;
131
132 #endif //FORMAT_H