4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
23 Format(std::string const & n, std::string const & e, std::string const & p,
24 std::string const & s, std::string const & v, std::string const & ed,
28 /// Tell whether this format is a child format.
29 /// Child formats inherit settings like the viewer from their parent.
30 bool isChildFormat() const;
31 /// Name fo the parent format
32 std::string const parentFormat() const;
34 std::string const & name() const {
38 std::string const & extension() const {
42 std::string const & prettyname() const {
46 std::string const & shortcut() const {
50 std::string const & viewer() const {
54 void setViewer(std::string const & v) {
58 std::string const & editor() const {
62 void setEditor(std::string const & v) {
66 bool documentFormat() const {
70 /// Internal name. Needs to be unique.
72 /// Filename extension
73 std::string extension_;
74 /// Name presented to the user. Needs to be unique.
75 std::string prettyname_;
76 /// Keyboard shortcut for the View and Export menu.
77 std::string shortcut_;
79 * Viewer for this format. Needs to be in the PATH or an absolute
81 * This format cannot be viewed if \c viewer_ is empty.
82 * If it is \c auto the default viewer of the OS for this format is
86 /// Editor for this format. \sa viewer_.
88 /// Is this format a document format? (as opposed to e.g. image formats)
89 /// Some formats are both (e.g. pdf), they have this flag set.
94 bool operator<(Format const & a, Format const & b);
100 typedef std::vector<Format> FormatList;
102 typedef FormatList::const_iterator const_iterator;
104 Format const & get(FormatList::size_type i) const {
105 return formatlist[i];
107 /// \returns format named \p name if it exists, otherwise 0
108 Format const * getFormat(std::string const & name) const;
110 * Get the format of \p filename from file contents or, if this
111 * fails, from file extension.
112 * \returns file format if it could be found, otherwise an empty
115 std::string getFormatFromFile(std::string const & filename) const;
116 /// Set editor and/or viewer to "auto" for formats that can be
117 /// opened by the OS.
120 int getNumber(std::string const & name) const;
122 void add(std::string const & name);
124 void add(std::string const & name, std::string const & extension,
125 std::string const & prettyname, std::string const & shortcut,
126 std::string const & viewer, std::string const & editor,
129 void erase(std::string const & name);
133 void setViewer(std::string const & name, std::string const & command);
135 bool view(Buffer const & buffer, std::string const & filename,
136 std::string const & format_name) const;
138 bool edit(Buffer const & buffer, std::string const & filename,
139 std::string const & format_name) const;
141 std::string const prettyName(std::string const & name) const;
143 std::string const extension(std::string const & name) const;
145 const_iterator begin() const {
146 return formatlist.begin();
149 const_iterator end() const {
150 return formatlist.end();
153 FormatList::size_type size() const {
154 return formatlist.size();
158 FormatList formatlist;
161 extern Formats formats;
163 extern Formats system_formats;