]> git.lyx.org Git - lyx.git/blobdiff - src/Layout.cpp
Partially revert r34995, which broke math output. Not sure why yet....
[lyx.git] / src / Layout.cpp
index 7a26c8cf65a6a640dc66204fe187d4ee801f4a3a..a9a5487b989e624d10203f0bccb20b34d666efd3 100644 (file)
@@ -23,7 +23,7 @@
 #include "support/lassert.h"
 #include "support/lstrings.h"
 
-#include <boost/regex.hpp>
+#include "support/regex.h"
 
 using namespace std;
 using namespace lyx::support;
@@ -106,6 +106,7 @@ enum LayoutTags {
        LT_HTMLTITLE,
        LT_SPELLCHECK,
        LT_REFPREFIX,
+       LT_REQARGS,
        LT_INTITLE // keep this last!
 };
 
@@ -118,7 +119,6 @@ Layout::Layout()
        latextype = LATEX_PARAGRAPH;
        intitle = false;
        inpreamble = false;
-       optionalargs = 0;
        needprotect = false;
        keepempty = false;
        font = inherit_font;
@@ -149,6 +149,8 @@ Layout::Layout()
        htmlforcecss_ = false;
        htmltitle_ = false;
        spellcheck = true;
+       optargs = 0;
+       reqargs = 0;
 }
 
 
@@ -214,6 +216,7 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
                { "passthru",       LT_PASS_THRU },
                { "preamble",       LT_PREAMBLE },
                { "refprefix",      LT_REFPREFIX },
+               { "requiredargs",   LT_REQARGS },
                { "requires",       LT_REQUIRES },
                { "rightmargin",    LT_RIGHTMARGIN },
                { "spacing",        LT_SPACING },
@@ -320,7 +323,11 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
                        break;
 
                case LT_OPTARGS:
-                       lex >> optionalargs ;
+                       lex >> optargs;
+                       break;
+
+               case LT_REQARGS:
+                       lex >> reqargs;
                        break;
 
                case LT_NEED_PROTECT:
@@ -500,9 +507,15 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
                        break;
                }
                        
-               case LT_REFPREFIX:
-                       lex >> refprefix;
+               case LT_REFPREFIX: {
+                       docstring arg;
+                       lex >> arg;
+                       if (arg == "OFF")
+                               refprefix.clear();
+                       else
+                               refprefix = arg;
                        break;
+               }
 
                case LT_HTMLTAG:
                        lex >> htmltag_;
@@ -553,6 +566,12 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
                }
        }
        lex.popTable();
+       // make sure we only have inpreamble = true for commands
+       if (inpreamble && latextype != LATEX_COMMAND) {
+               LYXERR0("InPreamble not permitted except with Command-type layouts.");
+               LYXERR0("Layout name: " << name());
+               inpreamble = false;
+       }
 
        return !error;
 }
@@ -860,11 +879,11 @@ docstring const i18npreamble(Language const * lang, docstring const & templ)
        LASSERT(false, /**/);
 #else
        // FIXME UNICODE
-       // boost::regex is not unicode-safe.
+       // lyx::regex is not unicode-safe.
        // Should use QRegExp or (boost::u32regex, but that requires ICU)
-       static boost::regex const reg("_\\(([^\\)]+)\\)");
-       boost::smatch sub;
-       while (boost::regex_search(preamble, sub, reg)) {
+       static regex const reg("_\\(([^\\)]+)\\)");
+       smatch sub;
+       while (regex_search(preamble, sub, reg)) {
                string const key = sub.str(1);
                string translated;
                if (isAscii(key))