]> git.lyx.org Git - lyx.git/blobdiff - src/insets/ExternalTemplate.C
fix typo that put too many include paths for most people
[lyx.git] / src / insets / ExternalTemplate.C
index 15b8fecc11d05af3153503e0e303cda528f2aa56..fffd528392580c84bf857e825052c81f7e147f8f 100644 (file)
@@ -1,10 +1,10 @@
 /* This file is part of
  * ======================================================
- * 
+ *
  *           LyX, The Document Processor
- *      
+ *
  *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-2000 The LyX Team.
+ *          Copyright 1995-2001 The LyX Team.
  *
  * ====================================================== */
 
@@ -34,12 +34,11 @@ extern string user_lyxdir;
 // We have to have dummy default commands for security reasons!
 
 ExternalTemplate::ExternalTemplate()
-       : viewCommand("true"), editCommand("true")
 {}
 
 
 ExternalTemplate::FormatTemplate::FormatTemplate()
-       : updateCommand("true") {}
+{}
 
 
 ExternalTemplateManager::ExternalTemplateManager()
@@ -53,11 +52,11 @@ ExternalTemplateManager::ExternalTemplateManager()
 
 class dumpTemplate {
 public:
-       dumpTemplate(std::ostream & o) 
+       dumpTemplate(ostream & o)
                : ost(o) {}
        void operator()(ExternalTemplateManager::Templates::value_type const & vt) {
                ExternalTemplate const & et = vt.second;
-               
+
                ost << "Template " << et.lyxName << "\n"
                    << "\tGuiName " << et.guiName << "\n"
                    << "\tHelpText\n"
@@ -69,7 +68,7 @@ public:
                    << "\tAutomaticProduction " << et.automaticProduction << "\n";
                et.dumpFormats(ost);
                ost << "TemplateEnd" << endl;
-               
+
        }
 
 private:
@@ -78,13 +77,14 @@ private:
 
 class dumpFormat {
 public:
-       dumpFormat(ostream & o) 
+       dumpFormat(ostream & o)
                : ost(o) {}
        void operator()(ExternalTemplate::Formats::value_type const & vt) const{
                ExternalTemplate::FormatTemplate const & ft = vt.second;
                ost << "\tFormat " << vt.first << "\n"
                    << "\t\tProduct " << ft.product << "\n"
                    << "\t\tUpdateCommand " << ft.updateCommand << "\n"
+                   << "\t\tUpdateResult " << ft.updateResult << "\n"
                    << "\t\tRequirement " << ft.requirement << "\n"
                    << "\t\tPreamble\n"
                    << ft.preamble
@@ -96,13 +96,13 @@ private:
 };
 
 
-void ExternalTemplate::dumpFormats(ostream & os) const 
+void ExternalTemplate::dumpFormats(ostream & os) const
 {
        for_each(formats.begin(), formats.end(), dumpFormat(os));
 }
 
 
-void ExternalTemplateManager::dumpTemplates() const 
+void ExternalTemplateManager::dumpTemplates() const
 {
        for_each(templates.begin(), templates.end(), dumpTemplate(lyxerr));
 }
@@ -129,7 +129,13 @@ ExternalTemplateManager::getTemplates() const
 }
 
 
-void ExternalTemplateManager::readTemplates(string const & path) 
+ExternalTemplate const & ExternalTemplateManager::getTemplateByName(string const & name)
+{
+       return templates[name];
+}
+
+
+void ExternalTemplateManager::readTemplates(string const & path)
 {
        Path p(path);
 
@@ -137,7 +143,7 @@ void ExternalTemplateManager::readTemplates(string const & path)
                TM_TEMPLATE = 1,
                TM_END
        };
-       
+
        keyword_item templatetags[] = {
                { "template", TM_TEMPLATE },
                { "templateend", TM_END }
@@ -156,18 +162,18 @@ void ExternalTemplateManager::readTemplates(string const & path)
                        "No template file" << endl;
                return;
        }
-       
-       while (lex.IsOK()) {
+
+       while (lex.isOK()) {
                switch (lex.lex()) {
                case TM_TEMPLATE: {
                        lex.next();
-                       string temp = lex.GetString();
+                       string const temp = lex.getString();
                        ExternalTemplate & tmp = templates[temp];
                        tmp.lyxName = temp;
                        tmp.readTemplate(lex);
                }
                break;
-               
+
                case TM_END:
                        lex.printError("Warning: End outside Template.");
                break;
@@ -201,106 +207,104 @@ void ExternalTemplate::readTemplate(LyXLex & lex)
        };
 
        pushpophelper pph(lex, templateoptiontags, TO_END);
-       
-       while (lex.IsOK()) {
+
+       while (lex.isOK()) {
                switch (lex.lex()) {
                case TO_GUINAME:
                        lex.next(true);
-                       guiName = lex.GetString();
+                       guiName = lex.getString();
                        break;
-                       
+
                case TO_HELPTEXT:
                        helpText = lex.getLongString("HelpTextEnd");
                        break;
-                       
+
                case TO_FILTER:
                        lex.next(true);
-                       fileRegExp = lex.GetString();
+                       fileRegExp = lex.getString();
                        break;
-                       
+
                case TO_VIEWCMD:
                        lex.next(true);
-                       viewCommand = lex.GetString();
-                       // For security reasons, a command may not be empty!
-                       if (viewCommand.empty())
-                               viewCommand = "true";
+                       viewCommand = lex.getString();
                        break;
-                       
+
                case TO_EDITCMD:
                        lex.next(true);
-                       editCommand = lex.GetString();
-                       // For security reasons, a command may not be empty!
-                       if (editCommand.empty())
-                               editCommand = "true";
+                       editCommand = lex.getString();
                        break;
-                       
+
                case TO_AUTOMATIC:
                        lex.next();
-                       automaticProduction = lex.GetBool();
+                       automaticProduction = lex.getBool();
                        break;
-                       
+
                case TO_FORMAT:
                        lex.next(true);
-                       formats[lex.GetString()].readFormat(lex);
+                       formats[lex.getString()].readFormat(lex);
                        break;
-                       
+
                case TO_END:
                        return;
-                       
+
                default:
                        lex.printError("ExternalTemplate::readTemplate: "
                                       "Wrong tag: $$Token");
-                       Assert(false);
+                       lyx::Assert(false);
                        break;
                }
        }
 }
 
 
-void ExternalTemplate::FormatTemplate::readFormat(LyXLex & lex) 
+void ExternalTemplate::FormatTemplate::readFormat(LyXLex & lex)
 {
        enum FormatTags {
                FO_PRODUCT = 1,
                FO_UPDATECMD,
+               FO_UPDATERESULT,
                FO_REQUIREMENT,
                FO_PREAMBLE,
                FO_END
        };
-       
+
        keyword_item formattags[] = {
                { "formatend", FO_END },
                { "preamble", FO_PREAMBLE },
                { "product", FO_PRODUCT },
                { "requirement", FO_REQUIREMENT },
-               { "updatecommand", FO_UPDATECMD }
+               { "updatecommand", FO_UPDATECMD },
+               { "updateresult", FO_UPDATERESULT }
        };
 
        pushpophelper pph(lex, formattags, FO_END);
-       
-       while (lex.IsOK()) {
+
+       while (lex.isOK()) {
                switch (lex.lex()) {
                case FO_PRODUCT:
                        lex.next(true);
-                       product = lex.GetString();
+                       product = lex.getString();
                        break;
-                       
+
                case FO_UPDATECMD:
                        lex.next(true);
-                       updateCommand = lex.GetString();
-                       // For security reasons, a command may not be empty!
-                       if (updateCommand.empty())
-                               updateCommand = "true";
+                       updateCommand = lex.getString();
                        break;
-                       
+
+               case FO_UPDATERESULT:
+                       lex.next(true);
+                       updateResult = lex.getString();
+                       break;
+
                case FO_REQUIREMENT:
                        lex.next(true);
-                       requirement = lex.GetString();
+                       requirement = lex.getString();
                        break;
-                       
+
                case FO_PREAMBLE:
                        preamble = lex.getLongString("preambleend");
                        break;
-                       
+
                case FO_END:
                        if (lyxerr.debugging())
                                lex.printError("FormatEnd");
@@ -308,4 +312,3 @@ void ExternalTemplate::FormatTemplate::readFormat(LyXLex & lex)
                }
        }
 }
-