]> git.lyx.org Git - lyx.git/blobdiff - src/Layout.cpp
Add test-refstyle-references to cmake. Also added missing file test-refstyle-referenc...
[lyx.git] / src / Layout.cpp
index 95cb28bdbea65c3d9dd7387718e6d94ad47d37e6..78485d49969a235e676a5e2d6a39372e0221efbe 100644 (file)
@@ -13,7 +13,6 @@
 #include <config.h>
 
 #include "Layout.h"
-#include "Encoding.h"
 #include "FontInfo.h"
 #include "Language.h"
 #include "Lexer.h"
@@ -53,6 +52,7 @@ enum LayoutTags {
        LT_FREE_SPACING,
        LT_PASS_THRU,
        LT_PARBREAK_IS_NEWLINE,
+       LT_ITEMCOMMAND,
        LT_ITEMSEP,
        LT_KEEPEMPTY,
        LT_LABEL_BOTTOMSEP,
@@ -145,6 +145,7 @@ Layout::Layout()
        htmlforcecss_ = false;
        htmltitle_ = false;
        spellcheck = true;
+       itemcommand_ = "item";
 }
 
 
@@ -180,6 +181,7 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
                { "innertag",       LT_INNERTAG },
                { "inpreamble",     LT_INPREAMBLE },
                { "intitle",        LT_INTITLE },
+               { "itemcommand",    LT_ITEMCOMMAND },
                { "itemsep",        LT_ITEMSEP },
                { "itemtag",        LT_ITEMTAG },
                { "keepempty",      LT_KEEPEMPTY },
@@ -325,6 +327,7 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
                        if (reset) {
                                latexargs_.clear();
                                itemargs_.clear();
+                               postcommandargs_.clear();
                        }
                        break;
 
@@ -372,10 +375,14 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
 
                case LT_LEFTDELIM:
                        lex >> leftdelim_;
+                       leftdelim_ = support::subst(leftdelim_, from_ascii("<br/>"),
+                                                   from_ascii("\n"));
                        break;
 
                case LT_RIGHTDELIM:
                        lex >> rightdelim_;
+                       rightdelim_ = support::subst(rightdelim_, from_ascii("<br/>"),
+                                                    from_ascii("\n"));
                        break;
 
                case LT_INNERTAG:
@@ -390,6 +397,10 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
                        lex >> itemtag_;
                        break;
 
+               case LT_ITEMCOMMAND:
+                       lex >> itemcommand_;
+                       break;
+
                case LT_PREAMBLE:
                        preamble_ = from_utf8(lex.getLongString("EndPreamble"));
                        break;
@@ -877,6 +888,7 @@ void Layout::readArgument(Lexer & lex)
 {
        latexarg arg;
        arg.mandatory = false;
+       arg.autoinsert = false;
        bool error = false;
        bool finished = false;
        arg.font = inherit_font;
@@ -884,6 +896,7 @@ void Layout::readArgument(Lexer & lex)
        string id;
        lex >> id;
        bool const itemarg = prefixIs(id, "item:");
+       bool const postcmd = prefixIs(id, "post:");
 
        while (!finished && lex.isOK() && !error) {
                lex.next();
@@ -896,15 +909,28 @@ void Layout::readArgument(Lexer & lex)
                } else if (tok == "labelstring") {
                        lex.next();
                        arg.labelstring = lex.getDocString();
+               } else if (tok == "menustring") {
+                       lex.next();
+                       arg.menustring = lex.getDocString();
                } else if (tok == "mandatory") {
                        lex.next();
                        arg.mandatory = lex.getBool();
+               } else if (tok == "autoinsert") {
+                       lex.next();
+                       arg.autoinsert = lex.getBool();
                } else if (tok == "leftdelim") {
                        lex.next();
                        arg.ldelim = lex.getDocString();
+                       arg.ldelim = support::subst(arg.ldelim, from_ascii("<br/>"),
+                                                   from_ascii("\n"));
                } else if (tok == "rightdelim") {
                        lex.next();
                        arg.rdelim = lex.getDocString();
+                       arg.rdelim = support::subst(arg.rdelim, from_ascii("<br/>"),
+                                                   from_ascii("\n"));
+               } else if (tok == "presetarg") {
+                       lex.next();
+                       arg.presetarg = lex.getDocString();
                } else if (tok == "tooltip") {
                        lex.next();
                        arg.tooltip = lex.getDocString();
@@ -927,11 +953,24 @@ void Layout::readArgument(Lexer & lex)
                LYXERR0("Incomplete Argument definition!");
        else if (itemarg)
                itemargs_[id] = arg;
+       else if (postcmd)
+               postcommandargs_[id] = arg;
        else
                latexargs_[id] = arg;
 }
 
 
+Layout::LaTeXArgMap Layout::args() const
+{
+       LaTeXArgMap args = latexargs_;
+       if (!postcommandargs_.empty())
+               args.insert(postcommandargs_.begin(), postcommandargs_.end());
+       if (!itemargs_.empty())
+               args.insert(itemargs_.begin(), itemargs_.end());
+       return args;
+}
+
+
 int Layout::optArgs() const
 {
        int nr = 0;
@@ -940,6 +979,11 @@ int Layout::optArgs() const
                if (!(*it).second.mandatory)
                        ++nr;
        }
+       LaTeXArgMap::const_iterator iit = postcommandargs_.begin();
+       for (; iit != postcommandargs_.end(); ++iit) {
+               if (!(*iit).second.mandatory)
+                       ++nr;
+       }
        return nr;
 }
 
@@ -952,6 +996,11 @@ int Layout::requiredArgs() const
                if ((*it).second.mandatory)
                        ++nr;
        }
+       LaTeXArgMap::const_iterator iit = postcommandargs_.begin();
+       for (; iit != postcommandargs_.end(); ++iit) {
+               if (!(*iit).second.mandatory)
+                       ++nr;
+       }
        return nr;
 }