]> git.lyx.org Git - lyx.git/blob - src/insets/ExternalTemplate.h
Don't remove cell selections after fontchange.
[lyx.git] / src / insets / ExternalTemplate.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-2001 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef EXTERNALTEMPLATE_H
13 #define EXTERNALTEMPLATE_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include <iosfwd>
20 #include <map>
21 #include "LString.h"
22 #include <boost/utility.hpp>
23
24 class LyXLex;
25
26 ///
27 struct ExternalTemplate {
28         /// What is the name of this template in the LyX format?
29         string lyxName;
30         /// What will the button in the GUI say?
31         string guiName;
32         /// A short help text
33         string helpText;
34         /// A file extension regular expression for the file browser
35         string fileRegExp;
36         /// What command should be executed to view the file?
37         string viewCommand;
38         /// What command should be executed to edit the file?
39         string editCommand;
40         /// Should we do automatic production of the output?
41         bool automaticProduction;
42         /// This is the information needed to support a specific output format
43         struct FormatTemplate {
44                 /// The text that should be inserted into the exported file
45                 string product;
46                 /// The shell command to produce a resulting file
47                 string updateCommand;
48                 /// The filename of the resulting file
49                 string updateResult;
50                 /// What features does this external inset require?
51                 string requirement;
52                 /// What should be inserted into the preamble
53                 string preamble;
54                 ///
55                 void readFormat(LyXLex &);
56                 /// This constructor has to default a command for safety reasons!
57                 FormatTemplate();
58         };
59         ///
60         void readTemplate(LyXLex &);
61         ///
62         typedef std::map<string, FormatTemplate> Formats;
63         ///
64         Formats formats;
65         ///
66         void dumpFormats(std::ostream &) const;
67         
68         /// We have to have default commands for safety reasons!
69         ExternalTemplate();
70                 
71 };
72
73
74 /**
75    A singleton class that manages the external inset templates
76 */
77 class ExternalTemplateManager : boost::noncopyable {
78 public:
79         /// Map from the LyX name of the template to the template structure
80         typedef std::map<string, ExternalTemplate> Templates;
81
82         static ExternalTemplateManager & get();
83         Templates & getTemplates();
84         Templates const & getTemplates() const;
85         /// return the template by LyX name 
86         ExternalTemplate const & getTemplateByName(const string & name);
87 private:
88         ExternalTemplateManager();
89         void readTemplates(string const & path);
90         void dumpTemplates() const;
91         Templates templates;
92 };
93
94 #endif