2000-06-12 11:27:15 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
/**
|
|
|
|
* \file ExternalTemplate.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2000-06-12 11:27:15 +00:00
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
* \author Asger Alstrup Nielsen
|
2002-03-21 17:09:55 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
*/
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
#ifndef EXTERNALTEMPLATE_H
|
|
|
|
#define EXTERNALTEMPLATE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <iosfwd>
|
|
|
|
#include <map>
|
2003-09-05 17:23:11 +00:00
|
|
|
#include "support/std_string.h"
|
2000-10-02 00:55:02 +00:00
|
|
|
#include <boost/utility.hpp>
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
class LyXLex;
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
struct ExternalTemplate {
|
|
|
|
/// What is the name of this template in the LyX format?
|
|
|
|
string lyxName;
|
|
|
|
/// What will the button in the GUI say?
|
|
|
|
string guiName;
|
|
|
|
/// A short help text
|
|
|
|
string helpText;
|
2003-06-04 09:16:29 +00:00
|
|
|
/** The format of the input file. Can be "*", in which case we try and
|
|
|
|
ascertain the format from the contents of the file.
|
|
|
|
*/
|
|
|
|
string inputFormat;
|
2000-06-12 11:27:15 +00:00
|
|
|
/// A file extension regular expression for the file browser
|
|
|
|
string fileRegExp;
|
|
|
|
/// What command should be executed to edit the file?
|
|
|
|
string editCommand;
|
|
|
|
/// Should we do automatic production of the output?
|
|
|
|
bool automaticProduction;
|
|
|
|
/// This is the information needed to support a specific output format
|
|
|
|
struct FormatTemplate {
|
|
|
|
/// The text that should be inserted into the exported file
|
|
|
|
string product;
|
2001-11-02 16:18:07 +00:00
|
|
|
/// The filename of the resulting file
|
|
|
|
string updateResult;
|
2003-06-04 09:16:29 +00:00
|
|
|
/// The format of this file.
|
|
|
|
string updateFormat;
|
2000-06-12 11:27:15 +00:00
|
|
|
/// What features does this external inset require?
|
|
|
|
string requirement;
|
2003-09-04 17:01:00 +00:00
|
|
|
/// Identify the preamble snippet using \c preambleName.
|
|
|
|
string preambleName;
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
|
|
|
void readFormat(LyXLex &);
|
|
|
|
/// This constructor has to default a command for safety reasons!
|
|
|
|
FormatTemplate();
|
|
|
|
};
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
void readTemplate(LyXLex &);
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
typedef std::map<string, FormatTemplate> Formats;
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
Formats formats;
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
void dumpFormats(std::ostream &) const;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
/// We have to have default commands for safety reasons!
|
|
|
|
ExternalTemplate();
|
|
|
|
};
|
|
|
|
|
2000-06-15 15:44:39 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
/**
|
2000-08-07 20:58:24 +00:00
|
|
|
A singleton class that manages the external inset templates
|
|
|
|
*/
|
2001-04-17 14:17:11 +00:00
|
|
|
class ExternalTemplateManager : boost::noncopyable {
|
2000-06-12 11:27:15 +00:00
|
|
|
public:
|
|
|
|
/// Map from the LyX name of the template to the template structure
|
|
|
|
typedef std::map<string, ExternalTemplate> Templates;
|
2003-09-04 17:01:00 +00:00
|
|
|
/** Map from the LyX name of the preamble definition to the preamble
|
|
|
|
* definition itself.
|
|
|
|
*/
|
|
|
|
typedef std::map<string, string> PreambleDefs;
|
2001-03-12 11:22:26 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
static ExternalTemplateManager & get();
|
|
|
|
Templates & getTemplates();
|
|
|
|
Templates const & getTemplates() const;
|
2002-03-21 17:09:55 +00:00
|
|
|
/// return the template by LyX name
|
2003-06-28 01:23:11 +00:00
|
|
|
ExternalTemplate const & getTemplateByName(string const & name);
|
2003-09-04 17:01:00 +00:00
|
|
|
string const getPreambleDefByName(string const & name) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
private:
|
|
|
|
ExternalTemplateManager();
|
|
|
|
void readTemplates(string const & path);
|
2003-09-04 17:01:00 +00:00
|
|
|
void dumpTemplates(std::ostream &) const;
|
|
|
|
void dumpPreambleDefs(std::ostream &) const;
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
Templates templates;
|
2003-09-04 17:01:00 +00:00
|
|
|
PreambleDefs preambledefs;
|
2000-06-12 11:27:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|