mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-12 03:23:12 +00:00
The remaining External Template clean-up patch ;-)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7666 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
bf053299a6
commit
e9c209c298
@ -1,3 +1,8 @@
|
|||||||
|
2003-09-04 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* external_templates: add a new PreambleDef section and use it in the
|
||||||
|
XFig template.
|
||||||
|
|
||||||
2003-09-04 Johnathan Burchill <jkerrb@shaw.ca>
|
2003-09-04 Johnathan Burchill <jkerrb@shaw.ca>
|
||||||
|
|
||||||
* external_templates: add some clever LaTeX to the XFIG template so that
|
* external_templates: add some clever LaTeX to the XFIG template so that
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
# Basic External Templates for LyX
|
# Basic External Templates for LyX
|
||||||
|
|
||||||
|
PreambleDef XFigInput
|
||||||
|
%% This inputs the file if it exists, else prints a warning
|
||||||
|
%% encased in an fbox.
|
||||||
|
\def\stripprefix#1>{}
|
||||||
|
\newcommand*{\xfiginput}[1]{%
|
||||||
|
\edef\tempfilename{#1}%
|
||||||
|
\InputIfFileExists{#1}{}{%
|
||||||
|
\fbox{Could not find
|
||||||
|
\ttfamily\expandafter\stripprefix\meaning\tempfilename
|
||||||
|
!}}}
|
||||||
|
PreambleDefEnd
|
||||||
|
|
||||||
Template XFig
|
Template XFig
|
||||||
GuiName "[XFig: $$Basename]"
|
GuiName "[XFig: $$Basename]"
|
||||||
HelpText
|
HelpText
|
||||||
@ -15,34 +27,14 @@ Template XFig
|
|||||||
UpdateFormat pstex
|
UpdateFormat pstex
|
||||||
UpdateResult "$$Basename.pstex_t"
|
UpdateResult "$$Basename.pstex_t"
|
||||||
Requirement "graphicx"
|
Requirement "graphicx"
|
||||||
Preamble
|
Preamble XFigInput
|
||||||
%% This inputs the file if it exists, else prints a warning
|
|
||||||
%% encased in an fbox.
|
|
||||||
\def\stripprefix#1>{}
|
|
||||||
\newcommand*{\xfiginput}[1]{%
|
|
||||||
\edef\tempfilename{#1}%
|
|
||||||
\InputIfFileExists{#1}{}{%
|
|
||||||
\fbox{Could not find
|
|
||||||
\ttfamily\expandafter\stripprefix\meaning\tempfilename
|
|
||||||
!}}}
|
|
||||||
PreambleEnd
|
|
||||||
FormatEnd
|
FormatEnd
|
||||||
Format PDFLaTeX
|
Format PDFLaTeX
|
||||||
Product "\\xfiginput{$$Basename.pdftex_t}"
|
Product "\\xfiginput{$$Basename.pdftex_t}"
|
||||||
UpdateFormat pdftex
|
UpdateFormat pdftex
|
||||||
UpdateResult "$$Basename.pdftex_t"
|
UpdateResult "$$Basename.pdftex_t"
|
||||||
Requirement "graphicx"
|
Requirement "graphicx"
|
||||||
Preamble
|
Preamble XFigInput
|
||||||
%% This inputs the file if it exists, else prints a warning
|
|
||||||
%% encased in an fbox.
|
|
||||||
\def\stripprefix#1>{}
|
|
||||||
\newcommand*{\xfiginput}[1]{%
|
|
||||||
\edef\tempfilename{#1}%
|
|
||||||
\InputIfFileExists{#1}{}{%
|
|
||||||
\fbox{Could not find
|
|
||||||
\ttfamily\expandafter\stripprefix\meaning\tempfilename
|
|
||||||
!}}}
|
|
||||||
PreambleEnd
|
|
||||||
FormatEnd
|
FormatEnd
|
||||||
Format Ascii
|
Format Ascii
|
||||||
Product "$$Contents(\"$$Basename.asc\")"
|
Product "$$Contents(\"$$Basename.asc\")"
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2003-09-04 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* LaTeXFeatures.C (getMacros): move the output of the preamble_snippets
|
||||||
|
here (from getPackages).
|
||||||
|
|
||||||
|
* debug.[Ch]: add a new EXTERNAL tag.
|
||||||
|
|
||||||
2003-09-04 Lars Gullik Bjønnes <larsbj@lyx.org>
|
2003-09-04 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||||
|
|
||||||
* text2.C (cursorEnd): simplify
|
* text2.C (cursorEnd): simplify
|
||||||
|
@ -302,12 +302,6 @@ string const LaTeXFeatures::getPackages() const
|
|||||||
packages << "]{natbib}\n";
|
packages << "]{natbib}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
FeaturesList::const_iterator pit = preamble_snippets.begin();
|
|
||||||
FeaturesList::const_iterator pend = preamble_snippets.end();
|
|
||||||
for (; pit != pend; ++pit) {
|
|
||||||
packages << *pit << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
return STRCONV(packages.str());
|
return STRCONV(packages.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,6 +310,14 @@ string const LaTeXFeatures::getMacros() const
|
|||||||
{
|
{
|
||||||
ostringstream macros;
|
ostringstream macros;
|
||||||
|
|
||||||
|
if (!preamble_snippets.empty())
|
||||||
|
macros << '\n';
|
||||||
|
FeaturesList::const_iterator pit = preamble_snippets.begin();
|
||||||
|
FeaturesList::const_iterator pend = preamble_snippets.end();
|
||||||
|
for (; pit != pend; ++pit) {
|
||||||
|
macros << *pit << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
if (isRequired("LyX"))
|
if (isRequired("LyX"))
|
||||||
macros << lyx_def << '\n';
|
macros << lyx_def << '\n';
|
||||||
|
|
||||||
|
@ -19,13 +19,15 @@
|
|||||||
using std::ostream;
|
using std::ostream;
|
||||||
|
|
||||||
|
|
||||||
|
Box::Box()
|
||||||
|
: x1(0), x2(0), y1(0), y2(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
Box::Box(int x1_, int x2_, int y1_, int y2_)
|
Box::Box(int x1_, int x2_, int y1_, int y2_)
|
||||||
: x1(x1_), x2(x2_), y1(y1_), y2(y2_)
|
: x1(x1_), x2(x2_), y1(y1_), y2(y2_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Box::Box()
|
|
||||||
: x1(0), x2(0), y1(0), y2(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool Box::contains(int x, int y)
|
bool Box::contains(int x, int y)
|
||||||
{
|
{
|
||||||
|
@ -57,6 +57,7 @@ error_item errorTags[] = {
|
|||||||
{ Debug::INSETTEXT, "insettext", N_("Insettext/tabular messages")},
|
{ Debug::INSETTEXT, "insettext", N_("Insettext/tabular messages")},
|
||||||
{ Debug::GRAPHICS, "graphics", N_("Graphics conversion and loading")},
|
{ Debug::GRAPHICS, "graphics", N_("Graphics conversion and loading")},
|
||||||
{ Debug::CHANGES, "changes", N_("Change tracking")},
|
{ Debug::CHANGES, "changes", N_("Change tracking")},
|
||||||
|
{ Debug::EXTERNAL, "external", N_("External template/inset messages")},
|
||||||
{ Debug::ANY, "any", N_("All debugging messages")}
|
{ Debug::ANY, "any", N_("All debugging messages")}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ Debug::type const Debug::ANY = Debug::type(
|
|||||||
Debug::MATHED | Debug::FONT | Debug::TCLASS | Debug::LYXVC |
|
Debug::MATHED | Debug::FONT | Debug::TCLASS | Debug::LYXVC |
|
||||||
Debug::LYXSERVER | Debug::ROFF | Debug::ACTION | Debug::LYXLEX |
|
Debug::LYXSERVER | Debug::ROFF | Debug::ACTION | Debug::LYXLEX |
|
||||||
Debug::DEPEND | Debug::INSETS | Debug::FILES | Debug::WORKAREA |
|
Debug::DEPEND | Debug::INSETS | Debug::FILES | Debug::WORKAREA |
|
||||||
Debug::INSETTEXT | Debug::GRAPHICS | Debug::CHANGES);
|
Debug::INSETTEXT | Debug::GRAPHICS | Debug::CHANGES | Debug::EXTERNAL);
|
||||||
|
|
||||||
|
|
||||||
Debug::type Debug::value(string const & val)
|
Debug::type Debug::value(string const & val)
|
||||||
|
@ -71,7 +71,9 @@ struct Debug {
|
|||||||
///
|
///
|
||||||
GRAPHICS = (1 << 21),
|
GRAPHICS = (1 << 21),
|
||||||
/// change tracking
|
/// change tracking
|
||||||
CHANGES = (1 << 22)
|
CHANGES = (1 << 22),
|
||||||
|
///
|
||||||
|
EXTERNAL = (1 << 23)
|
||||||
};
|
};
|
||||||
///
|
///
|
||||||
static type const ANY;
|
static type const ANY;
|
||||||
|
@ -10,6 +10,16 @@
|
|||||||
up the dialogs. Cursor has to be in front of the inset (i.e.
|
up the dialogs. Cursor has to be in front of the inset (i.e.
|
||||||
start of row) for this to function.
|
start of row) for this to function.
|
||||||
|
|
||||||
|
2003-09-04 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* ExternalTemplate.[Ch]: store the preamble snippets in a separate
|
||||||
|
structure outside of the Format struct. Format::preambleName refers to
|
||||||
|
an item in the map of all preamble snippets.
|
||||||
|
Make use of the new Debug::EXTERNAL flag.
|
||||||
|
|
||||||
|
* insetexternal.C: make use of the new Debug::EXTERNAL flag.
|
||||||
|
(validate): Small change due to the changed storage of preamble snippets.
|
||||||
|
|
||||||
2003-09-04 Angus Leeming <leeming@lyx.org>
|
2003-09-04 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* insetgraphics.C: #include "support/os.h"
|
* insetgraphics.C: #include "support/os.h"
|
||||||
|
@ -17,11 +17,12 @@
|
|||||||
#include "support/path.h"
|
#include "support/path.h"
|
||||||
#include "support/LAssert.h"
|
#include "support/LAssert.h"
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
|
#include "support/lstrings.h"
|
||||||
#include "support/path_defines.h"
|
#include "support/path_defines.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace lyx::support;
|
namespace support = lyx::support;
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
@ -41,28 +42,50 @@ ExternalTemplate::FormatTemplate::FormatTemplate()
|
|||||||
ExternalTemplateManager::ExternalTemplateManager()
|
ExternalTemplateManager::ExternalTemplateManager()
|
||||||
{
|
{
|
||||||
// gimp gnuchess gnuplot ical netscape tetris xpaint
|
// gimp gnuchess gnuplot ical netscape tetris xpaint
|
||||||
readTemplates(user_lyxdir());
|
readTemplates(support::user_lyxdir());
|
||||||
if (lyxerr.debugging())
|
if (lyxerr.debugging(Debug::EXTERNAL)) {
|
||||||
dumpTemplates();
|
dumpPreambleDefs(lyxerr);
|
||||||
|
lyxerr << '\n';
|
||||||
|
dumpTemplates(lyxerr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class dumpPreambleDef {
|
||||||
|
public:
|
||||||
|
typedef ExternalTemplateManager::PreambleDefs::value_type value_type;
|
||||||
|
|
||||||
|
dumpPreambleDef(ostream & o) : ost(o) {}
|
||||||
|
|
||||||
|
void operator()(value_type const & vt) {
|
||||||
|
ost << "PreambleDef " << vt.first << '\n'
|
||||||
|
<< vt.second
|
||||||
|
<< "PreambleDefEnd" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ostream & ost;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class dumpTemplate {
|
class dumpTemplate {
|
||||||
public:
|
public:
|
||||||
dumpTemplate(ostream & o)
|
typedef ExternalTemplateManager::Templates::value_type value_type;
|
||||||
: ost(o) {}
|
|
||||||
void operator()(ExternalTemplateManager::Templates::value_type const & vt) {
|
dumpTemplate(ostream & o) : ost(o) {}
|
||||||
|
|
||||||
|
void operator()(value_type const & vt) {
|
||||||
ExternalTemplate const & et = vt.second;
|
ExternalTemplate const & et = vt.second;
|
||||||
|
|
||||||
ost << "Template " << et.lyxName << "\n"
|
ost << "Template " << et.lyxName << '\n'
|
||||||
<< "\tGuiName " << et.guiName << "\n"
|
<< "\tGuiName " << et.guiName << '\n'
|
||||||
<< "\tHelpText\n"
|
<< "\tHelpText\n"
|
||||||
<< et.helpText
|
<< et.helpText
|
||||||
<< "\tHelpTextEnd\n"
|
<< "\tHelpTextEnd\n"
|
||||||
<< "\tInputFormat " << et.inputFormat << "\n"
|
<< "\tInputFormat " << et.inputFormat << '\n'
|
||||||
<< "\tFileFilter " << et.fileRegExp << "\n"
|
<< "\tFileFilter " << et.fileRegExp << '\n'
|
||||||
<< "\tEditCommand " << et.editCommand << "\n"
|
<< "\tEditCommand " << et.editCommand << '\n'
|
||||||
<< "\tAutomaticProduction " << et.automaticProduction << "\n";
|
<< "\tAutomaticProduction " << et.automaticProduction << '\n';
|
||||||
et.dumpFormats(ost);
|
et.dumpFormats(ost);
|
||||||
ost << "TemplateEnd" << endl;
|
ost << "TemplateEnd" << endl;
|
||||||
|
|
||||||
@ -74,18 +97,18 @@ private:
|
|||||||
|
|
||||||
class dumpFormat {
|
class dumpFormat {
|
||||||
public:
|
public:
|
||||||
dumpFormat(ostream & o)
|
typedef ExternalTemplate::Formats::value_type value_type;
|
||||||
: ost(o) {}
|
|
||||||
void operator()(ExternalTemplate::Formats::value_type const & vt) const{
|
dumpFormat(ostream & o) : ost(o) {}
|
||||||
|
|
||||||
|
void operator()(value_type const & vt) const{
|
||||||
ExternalTemplate::FormatTemplate const & ft = vt.second;
|
ExternalTemplate::FormatTemplate const & ft = vt.second;
|
||||||
ost << "\tFormat " << vt.first << "\n"
|
ost << "\tFormat " << vt.first << '\n'
|
||||||
<< "\t\tProduct " << ft.product << "\n"
|
<< "\t\tProduct " << ft.product << '\n'
|
||||||
<< "\t\tUpdateFormat " << ft.updateFormat << "\n"
|
<< "\t\tUpdateFormat " << ft.updateFormat << '\n'
|
||||||
<< "\t\tUpdateResult " << ft.updateResult << "\n"
|
<< "\t\tUpdateResult " << ft.updateResult << '\n'
|
||||||
<< "\t\tRequirement " << ft.requirement << "\n"
|
<< "\t\tRequirement " << ft.requirement << '\n'
|
||||||
<< "\t\tPreamble\n"
|
<< "\t\tPreamble " << ft.preambleName << '\n'
|
||||||
<< ft.preamble
|
|
||||||
<< "\t\tPreambleEnd\n"
|
|
||||||
<< "\tFormatEnd\n";
|
<< "\tFormatEnd\n";
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
@ -99,9 +122,15 @@ void ExternalTemplate::dumpFormats(ostream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExternalTemplateManager::dumpTemplates() const
|
void ExternalTemplateManager::dumpPreambleDefs(ostream & os) const
|
||||||
{
|
{
|
||||||
for_each(templates.begin(), templates.end(), dumpTemplate(lyxerr));
|
for_each(preambledefs.begin(), preambledefs.end(), dumpPreambleDef(os));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExternalTemplateManager::dumpTemplates(ostream & os) const
|
||||||
|
{
|
||||||
|
for_each(templates.begin(), templates.end(), dumpTemplate(os));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -132,48 +161,76 @@ ExternalTemplate const & ExternalTemplateManager::getTemplateByName(string const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string const
|
||||||
|
ExternalTemplateManager::getPreambleDefByName(string const & name) const
|
||||||
|
{
|
||||||
|
string const trimmed_name = support::trim(name);
|
||||||
|
if (trimmed_name.empty())
|
||||||
|
return string();
|
||||||
|
|
||||||
|
PreambleDefs::const_iterator it = preambledefs.find(trimmed_name);
|
||||||
|
if (it == preambledefs.end())
|
||||||
|
return string();
|
||||||
|
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExternalTemplateManager::readTemplates(string const & path)
|
void ExternalTemplateManager::readTemplates(string const & path)
|
||||||
{
|
{
|
||||||
Path p(path);
|
support::Path p(path);
|
||||||
|
|
||||||
enum TemplateTags {
|
enum TemplateTags {
|
||||||
TM_TEMPLATE = 1,
|
TM_PREAMBLEDEF = 1,
|
||||||
TM_END
|
TM_PREAMBLEDEF_END,
|
||||||
|
TM_TEMPLATE,
|
||||||
|
TM_TEMPLATE_END
|
||||||
};
|
};
|
||||||
|
|
||||||
keyword_item templatetags[] = {
|
keyword_item templatetags[] = {
|
||||||
|
{ "preambledef", TM_PREAMBLEDEF },
|
||||||
|
{ "preambledefend", TM_PREAMBLEDEF_END },
|
||||||
{ "template", TM_TEMPLATE },
|
{ "template", TM_TEMPLATE },
|
||||||
{ "templateend", TM_END }
|
{ "templateend", TM_TEMPLATE_END }
|
||||||
};
|
};
|
||||||
|
|
||||||
string filename = LibFileSearch("", "external_templates");
|
LyXLex lex(templatetags, TM_TEMPLATE_END);
|
||||||
if (filename.empty()) {
|
|
||||||
lyxerr << "ExternalTemplateManager::readTemplates: "
|
string filename = support::LibFileSearch("", "external_templates");
|
||||||
"No template file" << endl;
|
if (filename.empty() || !lex.setFile(filename)) {
|
||||||
|
lex.printError("ExternalTemplateManager::readTemplates: "
|
||||||
|
"No template file");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LyXLex lex(templatetags, TM_END);
|
char const * const preamble_end_tag =
|
||||||
if (!lex.setFile(filename)) {
|
templatetags[TM_PREAMBLEDEF_END-1].tag;
|
||||||
lyxerr << "ExternalTemplateManager::readTemplates: "
|
|
||||||
"No template file" << endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (lex.isOK()) {
|
while (lex.isOK()) {
|
||||||
switch (lex.lex()) {
|
switch (lex.lex()) {
|
||||||
|
case TM_PREAMBLEDEF: {
|
||||||
|
lex.next();
|
||||||
|
string const name = lex.getString();
|
||||||
|
preambledefs[name] = lex.getLongString(preamble_end_tag);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case TM_TEMPLATE: {
|
case TM_TEMPLATE: {
|
||||||
lex.next();
|
lex.next();
|
||||||
string const temp = lex.getString();
|
string const name = lex.getString();
|
||||||
ExternalTemplate & tmp = templates[temp];
|
ExternalTemplate & tmp = templates[name];
|
||||||
tmp.lyxName = temp;
|
tmp.lyxName = name;
|
||||||
tmp.readTemplate(lex);
|
tmp.readTemplate(lex);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TM_END:
|
case TM_TEMPLATE_END:
|
||||||
lex.printError("Warning: End outside Template.");
|
lex.printError("Warning: End outside Template.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TM_PREAMBLEDEF_END:
|
||||||
|
lex.printError("Warning: End outside PreambleDef.");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,7 +304,7 @@ void ExternalTemplate::readTemplate(LyXLex & lex)
|
|||||||
default:
|
default:
|
||||||
lex.printError("ExternalTemplate::readTemplate: "
|
lex.printError("ExternalTemplate::readTemplate: "
|
||||||
"Wrong tag: $$Token");
|
"Wrong tag: $$Token");
|
||||||
Assert(false);
|
support::Assert(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,12 +356,11 @@ void ExternalTemplate::FormatTemplate::readFormat(LyXLex & lex)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FO_PREAMBLE:
|
case FO_PREAMBLE:
|
||||||
preamble = lex.getLongString("preambleend");
|
lex.next(true);
|
||||||
|
preambleName = lex.getString();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FO_END:
|
case FO_END:
|
||||||
if (lyxerr.debugging())
|
|
||||||
lex.printError("FormatEnd");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ struct ExternalTemplate {
|
|||||||
string updateFormat;
|
string updateFormat;
|
||||||
/// What features does this external inset require?
|
/// What features does this external inset require?
|
||||||
string requirement;
|
string requirement;
|
||||||
/// What should be inserted into the preamble
|
/// Identify the preamble snippet using \c preambleName.
|
||||||
string preamble;
|
string preambleName;
|
||||||
///
|
///
|
||||||
void readFormat(LyXLex &);
|
void readFormat(LyXLex &);
|
||||||
/// This constructor has to default a command for safety reasons!
|
/// This constructor has to default a command for safety reasons!
|
||||||
@ -76,17 +76,25 @@ class ExternalTemplateManager : boost::noncopyable {
|
|||||||
public:
|
public:
|
||||||
/// Map from the LyX name of the template to the template structure
|
/// Map from the LyX name of the template to the template structure
|
||||||
typedef std::map<string, ExternalTemplate> Templates;
|
typedef std::map<string, ExternalTemplate> 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 ExternalTemplateManager & get();
|
||||||
Templates & getTemplates();
|
Templates & getTemplates();
|
||||||
Templates const & getTemplates() const;
|
Templates const & getTemplates() const;
|
||||||
/// return the template by LyX name
|
/// return the template by LyX name
|
||||||
ExternalTemplate const & getTemplateByName(string const & name);
|
ExternalTemplate const & getTemplateByName(string const & name);
|
||||||
|
string const getPreambleDefByName(string const & name) const;
|
||||||
private:
|
private:
|
||||||
ExternalTemplateManager();
|
ExternalTemplateManager();
|
||||||
void readTemplates(string const & path);
|
void readTemplates(string const & path);
|
||||||
void dumpTemplates() const;
|
void dumpTemplates(std::ostream &) const;
|
||||||
|
void dumpPreambleDefs(std::ostream &) const;
|
||||||
|
|
||||||
Templates templates;
|
Templates templates;
|
||||||
|
PreambleDefs preambledefs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -367,12 +367,13 @@ void InsetExternal::read(Buffer const & buffer, LyXLex & lex)
|
|||||||
// Replace the inset's store
|
// Replace the inset's store
|
||||||
setParams(params, buffer);
|
setParams(params, buffer);
|
||||||
|
|
||||||
lyxerr[Debug::INFO] << "InsetExternal::Read: "
|
lyxerr[Debug::EXTERNAL]
|
||||||
<< "template: '" << params_.templatename
|
<< "InsetExternal::Read: "
|
||||||
<< "' filename: '" << params_.filename.absFilename()
|
<< "template: '" << params_.templatename
|
||||||
<< "' display: '" << params_.display
|
<< "' filename: '" << params_.filename.absFilename()
|
||||||
<< "' scale: '" << params_.lyxscale
|
<< "' display: '" << params_.display
|
||||||
<< '\'' << endl;
|
<< "' scale: '" << params_.lyxscale
|
||||||
|
<< '\'' << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -388,9 +389,10 @@ int InsetExternal::write(string const & format,
|
|||||||
ExternalTemplate::Formats::const_iterator cit =
|
ExternalTemplate::Formats::const_iterator cit =
|
||||||
et.formats.find(format);
|
et.formats.find(format);
|
||||||
if (cit == et.formats.end()) {
|
if (cit == et.formats.end()) {
|
||||||
lyxerr << "External template format '" << format
|
lyxerr[Debug::EXTERNAL]
|
||||||
<< "' not specified in template "
|
<< "External template format '" << format
|
||||||
<< params_.templatename << endl;
|
<< "' not specified in template "
|
||||||
|
<< params_.templatename << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,18 +456,17 @@ void InsetExternal::validate(LaTeXFeatures & features) const
|
|||||||
return;
|
return;
|
||||||
ExternalTemplate const & et = *et_ptr;
|
ExternalTemplate const & et = *et_ptr;
|
||||||
|
|
||||||
ExternalTemplate::Formats::const_iterator cit =
|
ExternalTemplate::Formats::const_iterator cit = et.formats.find("LaTeX");
|
||||||
et.formats.find("LaTeX");
|
|
||||||
|
|
||||||
if (cit == et.formats.end())
|
if (cit == et.formats.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!cit->second.requirement.empty()) {
|
if (!cit->second.requirement.empty())
|
||||||
features.require(cit->second.requirement);
|
features.require(cit->second.requirement);
|
||||||
}
|
|
||||||
if (!cit->second.preamble.empty()) {
|
ExternalTemplateManager & etm = ExternalTemplateManager::get();
|
||||||
features.addExternalPreamble(cit->second.preamble);
|
string const preamble = etm.getPreambleDefByName(cit->second.preambleName);
|
||||||
}
|
if (!preamble.empty())
|
||||||
|
features.addExternalPreamble(preamble);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -511,9 +512,10 @@ void InsetExternal::updateExternal(string const & format,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!converters.isReachable(from_format, to_format)) {
|
if (!converters.isReachable(from_format, to_format)) {
|
||||||
lyxerr << "InsetExternal::updateExternal. "
|
lyxerr[Debug::EXTERNAL]
|
||||||
"Unable to convert from "
|
<< "InsetExternal::updateExternal. "
|
||||||
<< from_format << " to " << to_format << endl;
|
<< "Unable to convert from "
|
||||||
|
<< from_format << " to " << to_format << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,7 +607,7 @@ void editExternal(InsetExternal::Params const & params, Buffer const & buffer)
|
|||||||
|
|
||||||
support::Path p(buffer.filePath());
|
support::Path p(buffer.filePath());
|
||||||
support::Forkedcall call;
|
support::Forkedcall call;
|
||||||
if (lyxerr.debugging()) {
|
if (lyxerr.debugging(Debug::EXTERNAL)) {
|
||||||
lyxerr << "Executing '" << command << "' in '"
|
lyxerr << "Executing '" << command << "' in '"
|
||||||
<< buffer.filePath() << '\'' << endl;
|
<< buffer.filePath() << '\'' << endl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user