+2003-10-01 Angus Leeming <leeming@lyx.org>
+
+ * ControlExternal.[Ch]: changes due to the introduction of
+ namespace lyx::external.
+
2003-09-25 Angus Leeming <leeming@lyx.org>
* ControlExternal.C (getTemplatePtr): simplify, due to change in
#include "insets/ExternalTemplate.h"
+namespace external = lyx::external;
+
using std::vector;
{
vector<string> result;
- ExternalTemplateManager::Templates::const_iterator i1, i2;
- i1 = ExternalTemplateManager::get().getTemplates().begin();
- i2 = ExternalTemplateManager::get().getTemplates().end();
+ external::TemplateManager::Templates::const_iterator i1, i2;
+ i1 = external::TemplateManager::get().getTemplates().begin();
+ i2 = external::TemplateManager::get().getTemplates().end();
for (; i1 != i2; ++i1) {
result.push_back(i1->second.lyxName);
int ControlExternal::getTemplateNumber(string const & name) const
{
- ExternalTemplateManager::Templates::const_iterator i1, i2;
- i1 = ExternalTemplateManager::get().getTemplates().begin();
- i2 = ExternalTemplateManager::get().getTemplates().end();
+ external::TemplateManager::Templates::const_iterator i1, i2;
+ i1 = external::TemplateManager::get().getTemplates().begin();
+ i2 = external::TemplateManager::get().getTemplates().end();
for (int i = 0; i1 != i2; ++i1, ++i) {
if (i1->second.lyxName == name)
return i;
}
-ExternalTemplate ControlExternal::getTemplate(int i) const
+external::Template ControlExternal::getTemplate(int i) const
{
- ExternalTemplateManager::Templates::const_iterator i1
- = ExternalTemplateManager::get().getTemplates().begin();
+ external::TemplateManager::Templates::const_iterator i1
+ = external::TemplateManager::get().getTemplates().begin();
std::advance(i1, i);
namespace {
-ExternalTemplate const * getTemplatePtr(InsetExternal::Params const & params)
+external::Template const * getTemplatePtr(InsetExternal::Params const & params)
{
- ExternalTemplateManager const & etm = ExternalTemplateManager::get();
+ external::TemplateManager const & etm =
+ external::TemplateManager::get();
return etm.getTemplateByName(params.templatename());
}
/// Determine the template file extension
string pattern = "*";
- ExternalTemplate const * const et_ptr = getTemplatePtr(params());
+ external::Template const * const et_ptr = getTemplatePtr(params());
if (et_ptr)
pattern = et_ptr->fileRegExp;
#include <boost/scoped_ptr.hpp>
-class ExternalTemplate;
+namespace lyx {
+namespace external {
+class Template;
+} // namespace external
+} // namespace lyx
class ControlExternal : public Dialog::Controller {
///
int getTemplateNumber(string const &) const;
///
- ExternalTemplate getTemplate(int) const;
+ lyx::external::Template getTemplate(int) const;
///
string const Browse(string const &) const;
private:
+2003-10-01 Angus Leeming <leeming@lyx.org>
+
+ * QExternal.C (helpText): changes due to the introduction of
+ namespace lyx::external.
+
2003-09-29 Lars Gullik Bjønnes <larsbj@gullik.net>
* several .C files: add debug.h at top to avoid compilation
string const QExternal::helpText() const
{
- ExternalTemplate templ =
+ lyx::external::Template templ =
controller().getTemplate(dialog_->externalCO->currentItem());
return templ.helpText;
}
+2003-10-01 Angus Leeming <leeming@lyx.org>
+
+ * FormExternal.C (updateComboChange): changes due to the
+ introduction of namespace lyx::external.
+
2003-09-29 Angus Leeming <leeming@lyx.org>
* FormGraphics.C: remove incorrect comment.
void FormExternal::updateComboChange()
{
int const choice = fl_get_choice(dialog_->choice_template) - 1;
- ExternalTemplate templ = controller().getTemplate(choice);
+ lyx::external::Template templ = controller().getTemplate(choice);
// Update the help text
string const txt = formatted(templ.helpText,
+2003-10-01 Angus Leeming <leeming@lyx.org>
+
+ * ExternalTemplace.[Ch]: introduce namespace lyx::external.
+
+ * insetexternal.[Ch]: changes due to the introduction of
+ namespace lyx::external.
+
2003-09-30 Angus Leeming <leeming@lyx.org>
* insetexternal.[Ch] (Params::read, write): new member functions.
using std::vector;
-// We have to have dummy default commands for security reasons!
+namespace lyx {
+namespace external {
-ExternalTemplate::ExternalTemplate()
+// We have to have dummy default commands for security reasons!
+Template::Template()
: inputFormat("*")
{}
-ExternalTemplate::FormatTemplate::FormatTemplate()
+Template::Format::Format()
{}
-ExternalTemplateManager::ExternalTemplateManager()
+TemplateManager::TemplateManager()
{
readTemplates(support::user_lyxdir());
if (lyxerr.debugging(Debug::EXTERNAL)) {
class dumpPreambleDef {
public:
- typedef ExternalTemplateManager::PreambleDefs::value_type value_type;
+ typedef TemplateManager::PreambleDefs::value_type value_type;
dumpPreambleDef(ostream & o) : ost(o) {}
class dumpTemplate {
public:
- typedef ExternalTemplateManager::Templates::value_type value_type;
+ typedef TemplateManager::Templates::value_type value_type;
dumpTemplate(ostream & o) : ost(o) {}
void operator()(value_type const & vt) {
- ExternalTemplate const & et = vt.second;
+ Template const & et = vt.second;
ost << "Template " << et.lyxName << '\n'
<< "\tGuiName " << et.guiName << '\n'
class dumpFormat {
public:
- typedef ExternalTemplate::Formats::value_type value_type;
+ typedef Template::Formats::value_type value_type;
dumpFormat(ostream & o) : ost(o) {}
void operator()(value_type const & vt) const{
- ExternalTemplate::FormatTemplate const & ft = vt.second;
+ Template::Format const & ft = vt.second;
ost << "\tFormat " << vt.first << '\n'
<< "\t\tProduct " << ft.product << '\n'
<< "\t\tUpdateFormat " << ft.updateFormat << '\n'
};
-void ExternalTemplate::dumpFormats(ostream & os) const
+void Template::dumpFormats(ostream & os) const
{
for_each(formats.begin(), formats.end(), dumpFormat(os));
}
-void ExternalTemplateManager::dumpPreambleDefs(ostream & os) const
+void TemplateManager::dumpPreambleDefs(ostream & os) const
{
for_each(preambledefs.begin(), preambledefs.end(), dumpPreambleDef(os));
}
-void ExternalTemplateManager::dumpTemplates(ostream & os) const
+void TemplateManager::dumpTemplates(ostream & os) const
{
for_each(templates.begin(), templates.end(), dumpTemplate(os));
}
-ExternalTemplateManager & ExternalTemplateManager::get()
+TemplateManager & TemplateManager::get()
{
- static ExternalTemplateManager externalTemplateManager;
+ static TemplateManager externalTemplateManager;
return externalTemplateManager;
}
-ExternalTemplateManager::Templates &
-ExternalTemplateManager::getTemplates()
+TemplateManager::Templates &
+TemplateManager::getTemplates()
{
return templates;
}
-ExternalTemplateManager::Templates const &
-ExternalTemplateManager::getTemplates() const
+TemplateManager::Templates const &
+TemplateManager::getTemplates() const
{
return templates;
}
-ExternalTemplate const *
-ExternalTemplateManager::getTemplateByName(string const & name) const
+Template const *
+TemplateManager::getTemplateByName(string const & name) const
{
Templates::const_iterator it = templates.find(name);
return (it == templates.end()) ? 0 : &it->second;
string const
-ExternalTemplateManager::getPreambleDefByName(string const & name) const
+TemplateManager::getPreambleDefByName(string const & name) const
{
string const trimmed_name = support::trim(name);
if (trimmed_name.empty())
}
-void ExternalTemplateManager::readTemplates(string const & path)
+void TemplateManager::readTemplates(string const & path)
{
support::Path p(path);
string filename = support::LibFileSearch("", "external_templates");
if (filename.empty() || !lex.setFile(filename)) {
- lex.printError("ExternalTemplateManager::readTemplates: "
+ lex.printError("external::TemplateManager::readTemplates: "
"No template file");
return;
}
case TM_TEMPLATE: {
lex.next();
string const name = lex.getString();
- ExternalTemplate & tmp = templates[name];
+ Template & tmp = templates[name];
tmp.lyxName = name;
tmp.readTemplate(lex);
}
}
-void ExternalTemplate::readTemplate(LyXLex & lex)
+void Template::readTemplate(LyXLex & lex)
{
enum TemplateOptionTags {
TO_GUINAME = 1,
return;
default:
- lex.printError("ExternalTemplate::readTemplate: "
+ lex.printError("external::Template::readTemplate: "
"Wrong tag: $$Token");
BOOST_ASSERT(false);
break;
}
-void ExternalTemplate::FormatTemplate::readFormat(LyXLex & lex)
+void Template::Format::readFormat(LyXLex & lex)
{
enum FormatTags {
FO_PRODUCT = 1,
}
}
}
+
+} // namespace external
+} // namespace lyx
#ifndef EXTERNALTEMPLATE_H
#define EXTERNALTEMPLATE_H
+#include <boost/function.hpp>
#include <boost/utility.hpp>
#include "support/std_string.h"
#include <iosfwd>
class LyXLex;
+namespace lyx {
+namespace external {
///
-struct ExternalTemplate {
+struct Template {
+ /// We have to have default commands for safety reasons!
+ Template();
+ ///
+ void readTemplate(LyXLex &);
+ ///
+ void dumpFormats(std::ostream &) const;
+
/// What is the name of this template in the LyX format?
string lyxName;
/// What will the button in the GUI say?
/// A short help text
string helpText;
/** The format of the input file. Can be "*", in which case we try and
- ascertain the format from the contents of the file.
- */
+ * ascertain the format from the contents of the file.
+ */
string inputFormat;
/// A file extension regular expression for the file browser
string fileRegExp;
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 {
+ struct Format {
+ /// This constructor has to default a command for safety reasons!
+ Format();
+ ///
+ void readFormat(LyXLex &);
+
/// The text that should be inserted into the exported file
string product;
/// The filename of the resulting file
string requirement;
/// A collection of preamble snippets identified by name.
std::vector<string> preambleNames;
- ///
- void readFormat(LyXLex &);
- /// This constructor has to default a command for safety reasons!
- FormatTemplate();
};
///
- void readTemplate(LyXLex &);
- ///
- typedef std::map<string, FormatTemplate> Formats;
+ typedef std::map<string, Format> Formats;
///
Formats formats;
- ///
- void dumpFormats(std::ostream &) const;
-
- /// We have to have default commands for safety reasons!
- ExternalTemplate();
};
/**
A singleton class that manages the external inset templates
*/
-class ExternalTemplateManager : boost::noncopyable {
+class TemplateManager : boost::noncopyable {
public:
/// Map from the LyX name of the template to the template structure
- typedef std::map<string, ExternalTemplate> Templates;
+ typedef std::map<string, Template> Templates;
/** Map from the LyX name of the preamble definition to the preamble
* definition itself.
*/
typedef std::map<string, string> PreambleDefs;
- static ExternalTemplateManager & get();
+ static TemplateManager & get();
Templates & getTemplates();
Templates const & getTemplates() const;
/** return the template by LyX name.
* If it isn't found, return 0.
*/
- ExternalTemplate const * getTemplateByName(string const & name) const;
+ Template const * getTemplateByName(string const & name) const;
/** return the preamble definition by LyX name.
* If it isn't found, return an empty string.
*/
string const getPreambleDefByName(string const & name) const;
private:
- ExternalTemplateManager();
+ TemplateManager();
void readTemplates(string const & path);
void dumpTemplates(std::ostream &) const;
void dumpPreambleDefs(std::ostream &) const;
PreambleDefs preambledefs;
};
-#endif
+} // namespace external
+} // namespace lyx
+
+#endif // EXTERNALTEMPLATE_H
#include <boost/bind.hpp>
namespace support = lyx::support;
+namespace external = lyx::external;
using std::endl;
void editExternal(InsetExternal::Params const & params, Buffer const & buffer);
-ExternalTemplate const * getTemplatePtr(string const & name)
+external::Template const * getTemplatePtr(string const & name)
{
- ExternalTemplateManager const & etm = ExternalTemplateManager::get();
+ external::TemplateManager const & etm =
+ external::TemplateManager::get();
return etm.getTemplateByName(name);
}
-ExternalTemplate const * getTemplatePtr(InsetExternal::Params const & params)
+external::Template const * getTemplatePtr(InsetExternal::Params const & params)
{
- ExternalTemplateManager const & etm = ExternalTemplateManager::get();
+ external::TemplateManager const & etm =
+ external::TemplateManager::get();
return etm.getTemplateByName(params.templatename());
}
string const getScreenLabel(InsetExternal::Params const & params,
Buffer const & buffer)
{
- ExternalTemplate const * const ptr = getTemplatePtr(params);
+ external::Template const * const ptr = getTemplatePtr(params);
if (!ptr)
return support::bformat(_("External template %1$s is not installed"),
params.templatename());
Buffer const & buf, ostream & os,
bool external_in_tmpdir) const
{
- ExternalTemplate const * const et_ptr = getTemplatePtr(params_);
+ external::Template const * const et_ptr = getTemplatePtr(params_);
if (!et_ptr)
return 0;
- ExternalTemplate const & et = *et_ptr;
+ external::Template const & et = *et_ptr;
- ExternalTemplate::Formats::const_iterator cit =
+ external::Template::Formats::const_iterator cit =
et.formats.find(format);
if (cit == et.formats.end()) {
lyxerr[Debug::EXTERNAL]
// If the template has specified a PDFLaTeX output, then we try and
// use that.
if (runparams.flavor == LatexRunParams::PDFLATEX) {
- ExternalTemplate const * const et_ptr = getTemplatePtr(params_);
+ external::Template const * const et_ptr = getTemplatePtr(params_);
if (!et_ptr)
return 0;
- ExternalTemplate const & et = *et_ptr;
+ external::Template const & et = *et_ptr;
- ExternalTemplate::Formats::const_iterator cit =
+ external::Template::Formats::const_iterator cit =
et.formats.find("PDFLaTeX");
if (cit != et.formats.end())
return write("PDFLaTeX", buf, os, external_in_tmpdir);
void InsetExternal::validate(LaTeXFeatures & features) const
{
- ExternalTemplate const * const et_ptr = getTemplatePtr(params_);
+ external::Template const * const et_ptr = getTemplatePtr(params_);
if (!et_ptr)
return;
- ExternalTemplate const & et = *et_ptr;
+ external::Template const & et = *et_ptr;
- ExternalTemplate::Formats::const_iterator cit = et.formats.find("LaTeX");
+ external::Template::Formats::const_iterator cit = et.formats.find("LaTeX");
if (cit == et.formats.end())
return;
if (!cit->second.requirement.empty())
features.require(cit->second.requirement);
- ExternalTemplateManager & etm = ExternalTemplateManager::get();
+ external::TemplateManager & etm = external::TemplateManager::get();
vector<string>::const_iterator it = cit->second.preambleNames.begin();
vector<string>::const_iterator end = cit->second.preambleNames.end();
Buffer const & buf,
bool external_in_tmpdir) const
{
- ExternalTemplate const * const et_ptr = getTemplatePtr(params_);
+ external::Template const * const et_ptr = getTemplatePtr(params_);
if (!et_ptr)
return;
- ExternalTemplate const & et = *et_ptr;
+ external::Template const & et = *et_ptr;
if (!et.automaticProduction)
return;
- ExternalTemplate::Formats::const_iterator cit =
+ external::Template::Formats::const_iterator cit =
et.formats.find(format);
if (cit == et.formats.end())
return;
- ExternalTemplate::FormatTemplate const & outputFormat = cit->second;
+ external::Template::Format const & outputFormat = cit->second;
if (outputFormat.updateResult.empty())
return;
void editExternal(InsetExternal::Params const & params, Buffer const & buffer)
{
- ExternalTemplate const * const et_ptr = getTemplatePtr(params);
+ external::Template const * const et_ptr = getTemplatePtr(params);
if (!et_ptr)
return;
- ExternalTemplate const & et = *et_ptr;
+ external::Template const & et = *et_ptr;
if (et.editCommand.empty())
return;