X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FExternalTemplate.cpp;h=64f31343a67d13817daa093e40e5b6dfbd5c2d5c;hb=33fa147fcab25bbc0649d620e9df229736870bfc;hp=c172ccf13609b3dc6b3d428b5add636ed5133333;hpb=e1453ef6873b8c6d371a62471c5d309154133866;p=lyx.git diff --git a/src/insets/ExternalTemplate.cpp b/src/insets/ExternalTemplate.cpp index c172ccf136..64f31343a6 100644 --- a/src/insets/ExternalTemplate.cpp +++ b/src/insets/ExternalTemplate.cpp @@ -19,7 +19,8 @@ #include "support/filetools.h" #include "support/lstrings.h" #include "support/Package.h" -#include "support/Path.h" +#include "support/PathChanger.h" +#include "support/Translator.h" #include @@ -50,7 +51,7 @@ static TransformIDTranslator const & transformIDTranslator() // We have to have dummy default commands for security reasons! Template::Template() - : inputFormat("*") + : inputFormat("*"), automaticProduction(false), preview_mode(PREVIEW_OFF) {} @@ -77,7 +78,7 @@ public: void operator()(value_type const & vt) { os_ << "PreambleDef " << vt.first << '\n' - << vt.second + << to_utf8(vt.second) << "PreambleDefEnd" << endl; } @@ -98,12 +99,23 @@ public: os_ << "Template " << et.lyxName << '\n' << "\tGuiName " << et.guiName << '\n' << "\tHelpText\n" - << et.helpText + << to_utf8(et.helpText) << "\tHelpTextEnd\n" << "\tInputFormat " << et.inputFormat << '\n' << "\tFileFilter " << et.fileRegExp << '\n' - << "\tAutomaticProduction " << et.automaticProduction << '\n'; - + << "\tAutomaticProduction " << et.automaticProduction << '\n' + << "\tPreview "; + switch (et.preview_mode) { + case PREVIEW_OFF: + os_ << "Off\n"; + break; + case PREVIEW_GRAPHICS: + os_ << "Graphics\n"; + break; + case PREVIEW_INSTANT: + os_ << "InstantPreview\n"; + break; + } typedef vector IDs; IDs::const_iterator it = et.transformIds.begin(); IDs::const_iterator end = et.transformIds.end(); @@ -202,8 +214,7 @@ TemplateManager & TemplateManager::get() } -TemplateManager::Templates const & -TemplateManager::getTemplates() const +TemplateManager::Templates const & TemplateManager::getTemplates() const { return templates; } @@ -217,16 +228,15 @@ TemplateManager::getTemplateByName(string const & name) const } -string const -TemplateManager::getPreambleDefByName(string const & name) const +docstring TemplateManager::getPreambleDefByName(string const & name) const { string const trimmed_name = trim(name); if (trimmed_name.empty()) - return string(); + return docstring(); PreambleDefs::const_iterator it = preambledefs.find(trimmed_name); if (it == preambledefs.end()) - return string(); + return docstring(); return it->second; } @@ -267,7 +277,7 @@ void TemplateManager::readTemplates(FileName const & path) case TM_PREAMBLEDEF: { lex.next(); string const name = lex.getString(); - preambledefs[name] = lex.getLongString(preamble_end_tag); + preambledefs[name] = lex.getLongString(from_ascii(preamble_end_tag)); } break; @@ -300,6 +310,7 @@ void Template::readTemplate(Lexer & lex) TO_INPUTFORMAT, TO_FILTER, TO_AUTOMATIC, + TO_PREVIEW, TO_TRANSFORM, TO_FORMAT, TO_END @@ -312,6 +323,7 @@ void Template::readTemplate(Lexer & lex) { "guiname", TO_GUINAME }, { "helptext", TO_HELPTEXT }, { "inputformat", TO_INPUTFORMAT }, + { "preview", TO_PREVIEW }, { "templateend", TO_END }, { "transform", TO_TRANSFORM } }; @@ -328,7 +340,7 @@ void Template::readTemplate(Lexer & lex) break; case TO_HELPTEXT: - helpText = lex.getLongString("HelpTextEnd"); + helpText = lex.getLongString(from_ascii("HelpTextEnd")); break; case TO_INPUTFORMAT: @@ -346,14 +358,25 @@ void Template::readTemplate(Lexer & lex) automaticProduction = lex.getBool(); break; - case TO_TRANSFORM: + case TO_PREVIEW: + lex >> token; + if (token == "InstantPreview") + preview_mode = PREVIEW_INSTANT; + else if (token == "Graphics") + preview_mode = PREVIEW_GRAPHICS; + else + preview_mode = PREVIEW_OFF; + break; + + case TO_TRANSFORM: { lex >> token; TransformID id = transformIDTranslator().find(token); if (int(id) == -1) LYXERR0("Transform " << token << " is not recognized"); else - ids.push_back(id); + transformIds.push_back(id); break; + } case TO_FORMAT: lex.next(true); @@ -362,12 +385,6 @@ void Template::readTemplate(Lexer & lex) case TO_END: return; - - default: - lex.printError("external::Template::readTemplate: " - "Wrong tag: $$Token"); - BOOST_ASSERT(false); - break; } } }