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
|
2003-10-07 22:59:58 +00:00
|
|
|
* \author Angus Leeming
|
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
|
|
|
|
|
2003-10-07 22:59:58 +00:00
|
|
|
#include "ExternalTransforms.h"
|
|
|
|
|
2007-09-30 15:47:00 +00:00
|
|
|
#include <boost/noncopyable.hpp>
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2011-07-14 17:00:35 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2007-04-06 13:09:54 +00:00
|
|
|
namespace support { class FileName; }
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
class Lexer;
|
2000-06-12 11:27:15 +00:00
|
|
|
|
2008-06-13 07:34:55 +00:00
|
|
|
enum PreviewMode {
|
|
|
|
PREVIEW_OFF = 0,
|
|
|
|
PREVIEW_GRAPHICS,
|
|
|
|
PREVIEW_INSTANT
|
|
|
|
};
|
|
|
|
|
2003-10-01 10:16:00 +00:00
|
|
|
namespace external {
|
2003-09-25 10:49:13 +00:00
|
|
|
|
2005-01-19 15:03:31 +00:00
|
|
|
class Template {
|
|
|
|
public:
|
2003-10-01 10:16:00 +00:00
|
|
|
/// We have to have default commands for safety reasons!
|
|
|
|
Template();
|
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
void readTemplate(Lexer &);
|
2003-10-01 10:16:00 +00:00
|
|
|
///
|
|
|
|
void dumpFormats(std::ostream &) const;
|
|
|
|
|
2005-01-19 15:03:31 +00:00
|
|
|
class Option {
|
|
|
|
public:
|
2003-10-07 22:59:58 +00:00
|
|
|
Option(std::string const & name_, std::string const & opt_)
|
|
|
|
: name(name_), option(opt_) {}
|
|
|
|
std::string name;
|
|
|
|
std::string option;
|
|
|
|
};
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
/// What is the name of this template in the LyX format?
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string lyxName;
|
2000-06-12 11:27:15 +00:00
|
|
|
/// What will the button in the GUI say?
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string guiName;
|
2000-06-12 11:27:15 +00:00
|
|
|
/// A short help text
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string helpText;
|
2003-06-04 09:16:29 +00:00
|
|
|
/** The format of the input file. Can be "*", in which case we try and
|
2003-10-01 10:16:00 +00:00
|
|
|
* ascertain the format from the contents of the file.
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string inputFormat;
|
2000-06-12 11:27:15 +00:00
|
|
|
/// A file extension regular expression for the file browser
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string fileRegExp;
|
2000-06-12 11:27:15 +00:00
|
|
|
/// Should we do automatic production of the output?
|
|
|
|
bool automaticProduction;
|
2008-06-13 07:34:55 +00:00
|
|
|
/// How should we preview the data in LyX?
|
|
|
|
PreviewMode preview_mode;
|
2003-10-07 22:59:58 +00:00
|
|
|
/// A collection of transforms that we can use to transform the data.
|
|
|
|
std::vector<TransformID> transformIds;
|
2003-10-01 10:16:00 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
/// This is the information needed to support a specific output format
|
2005-01-19 15:03:31 +00:00
|
|
|
class Format {
|
|
|
|
public:
|
2003-10-01 10:16:00 +00:00
|
|
|
Format();
|
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
void readFormat(Lexer &);
|
2003-10-01 10:16:00 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
/// The text that should be inserted into the exported file
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string product;
|
2001-11-02 16:18:07 +00:00
|
|
|
/// The filename of the resulting file
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string updateResult;
|
2003-06-04 09:16:29 +00:00
|
|
|
/// The format of this file.
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string updateFormat;
|
2000-06-12 11:27:15 +00:00
|
|
|
/// What features does this external inset require?
|
2005-04-05 11:00:09 +00:00
|
|
|
std::vector<std::string> requirements;
|
2003-09-23 17:04:25 +00:00
|
|
|
/// A collection of preamble snippets identified by name.
|
2003-10-06 15:43:21 +00:00
|
|
|
std::vector<std::string> preambleNames;
|
2003-10-07 22:59:58 +00:00
|
|
|
/// A list of options to the basic command.
|
|
|
|
std::vector<Option> options;
|
|
|
|
|
|
|
|
/// The factory functions for each supported transformation.
|
|
|
|
std::map<TransformID, TransformStore> command_transformers;
|
|
|
|
std::map<TransformID, TransformStore> option_transformers;
|
2004-06-01 13:39:33 +00:00
|
|
|
|
|
|
|
typedef std::map<std::string,
|
2006-04-05 23:56:29 +00:00
|
|
|
std::vector<std::string> > FileMap;
|
2004-06-01 13:39:33 +00:00
|
|
|
/// Referenced files for some formats
|
|
|
|
FileMap referencedFiles;
|
2000-06-12 11:27:15 +00:00
|
|
|
};
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
typedef std::map<std::string, Format> Formats;
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
Formats formats;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2003-10-07 11:03:37 +00:00
|
|
|
* A singleton class that manages the external inset templates
|
|
|
|
*/
|
2014-11-14 23:40:07 +00:00
|
|
|
class TemplateManager {
|
2000-06-12 11:27:15 +00:00
|
|
|
public:
|
|
|
|
/// Map from the LyX name of the template to the template structure
|
2003-10-06 15:43:21 +00:00
|
|
|
typedef std::map<std::string, Template> Templates;
|
2003-09-04 17:01:00 +00:00
|
|
|
/** Map from the LyX name of the preamble definition to the preamble
|
|
|
|
* definition itself.
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
typedef std::map<std::string, std::string> PreambleDefs;
|
2001-03-12 11:22:26 +00:00
|
|
|
|
2003-10-01 10:16:00 +00:00
|
|
|
static TemplateManager & get();
|
2003-10-07 11:03:37 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
Templates const & getTemplates() const;
|
2003-09-25 10:49:13 +00:00
|
|
|
/** return the template by LyX name.
|
|
|
|
* If it isn't found, return 0.
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
Template const * getTemplateByName(std::string const & name) const;
|
2003-09-25 10:49:13 +00:00
|
|
|
/** return the preamble definition by LyX name.
|
2003-10-06 15:43:21 +00:00
|
|
|
* If it isn't found, return an empty std::string.
|
2003-09-25 10:49:13 +00:00
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const getPreambleDefByName(std::string const & name) const;
|
2000-06-12 11:27:15 +00:00
|
|
|
private:
|
2003-10-01 10:16:00 +00:00
|
|
|
TemplateManager();
|
2014-11-14 23:40:07 +00:00
|
|
|
/// noncopyable
|
|
|
|
TemplateManager(TemplateManager const &);
|
|
|
|
void operator=(TemplateManager const &);
|
|
|
|
|
2007-04-06 13:09:54 +00:00
|
|
|
void readTemplates(support::FileName 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
|
|
|
};
|
|
|
|
|
2003-10-01 10:16:00 +00:00
|
|
|
} // namespace external
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#endif // EXTERNALTEMPLATE_H
|