2000-06-12 11:27:15 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* ====================================================== */
|
|
|
|
|
|
|
|
#ifndef EXTERNALTEMPLATE_H
|
|
|
|
#define EXTERNALTEMPLATE_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <iosfwd>
|
|
|
|
#include <map>
|
|
|
|
#include "LString.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;
|
|
|
|
/// A file extension regular expression for the file browser
|
|
|
|
string fileRegExp;
|
|
|
|
/// What command should be executed to view the file?
|
|
|
|
string viewCommand;
|
|
|
|
/// 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;
|
|
|
|
/// The shell command to produce a resulting file
|
|
|
|
string updateCommand;
|
|
|
|
/// What features does this external inset require?
|
|
|
|
string requirement;
|
|
|
|
/// What should be inserted into the preamble
|
|
|
|
string preamble;
|
|
|
|
///
|
|
|
|
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;
|
|
|
|
|
|
|
|
/// 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-03-15 16:04:46 +00:00
|
|
|
class ExternalTemplateManager : public 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;
|
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;
|
2001-03-12 11:22:26 +00:00
|
|
|
/// return the template by LyX name
|
|
|
|
ExternalTemplate const & getTemplateByName(const string & name);
|
2000-06-12 11:27:15 +00:00
|
|
|
private:
|
|
|
|
ExternalTemplateManager();
|
|
|
|
void readTemplates(string const & path);
|
|
|
|
void dumpTemplates() const;
|
|
|
|
Templates templates;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|