]> git.lyx.org Git - lyx.git/blobdiff - src/Layout.cpp
Cmake build: Creating a define for a header file found
[lyx.git] / src / Layout.cpp
index 7e0308db9bf1d8fbe1a646e2b262e3bb5607b173..48489548c0984a09a8ba223640db7a0036b05e11 100644 (file)
@@ -13,7 +13,6 @@
 #include <config.h>
 
 #include "Layout.h"
-#include "Encoding.h"
 #include "FontInfo.h"
 #include "Language.h"
 #include "Lexer.h"
@@ -328,6 +327,7 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
                        if (reset) {
                                latexargs_.clear();
                                itemargs_.clear();
+                               postcommandargs_.clear();
                        }
                        break;
 
@@ -684,11 +684,10 @@ void Layout::readLabelType(Lexer & lex)
        enum {
                LA_NO_LABEL = 1,
                LA_MANUAL,
-               LA_TOP_ENVIRONMENT,
-               LA_CENTERED_TOP_ENVIRONMENT,
+               LA_ABOVE,
+               LA_CENTERED,
                LA_STATIC,
                LA_SENSITIVE,
-               LA_COUNTER,
                LA_ENUMERATE,
                LA_ITEMIZE,
                LA_BIBLIO
@@ -696,16 +695,15 @@ void Layout::readLabelType(Lexer & lex)
 
 
        LexerKeyword labelTypeTags[] = {
-               { "bibliography",             LA_BIBLIO },
-               { "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
-               { "counter",                  LA_COUNTER },
-               { "enumerate",                LA_ENUMERATE },
-               { "itemize",                  LA_ITEMIZE },
-               { "manual",                   LA_MANUAL },
-               { "no_label",                 LA_NO_LABEL },
-               { "sensitive",                LA_SENSITIVE },
-               { "static",                   LA_STATIC },
-               { "top_environment",          LA_TOP_ENVIRONMENT }
+         { "above",        LA_ABOVE },
+               { "bibliography", LA_BIBLIO },
+               { "centered",     LA_CENTERED },
+               { "enumerate",    LA_ENUMERATE },
+               { "itemize",      LA_ITEMIZE },
+               { "manual",       LA_MANUAL },
+               { "no_label",     LA_NO_LABEL },
+               { "sensitive",    LA_SENSITIVE },
+               { "static",       LA_STATIC }
        };
 
        PushPopHelper pph(lex, labelTypeTags);
@@ -723,11 +721,11 @@ void Layout::readLabelType(Lexer & lex)
        case LA_MANUAL:
                labeltype = LABEL_MANUAL;
                break;
-       case LA_TOP_ENVIRONMENT:
-               labeltype = LABEL_TOP_ENVIRONMENT;
+       case LA_ABOVE:
+               labeltype = LABEL_ABOVE;
                break;
-       case LA_CENTERED_TOP_ENVIRONMENT:
-               labeltype = LABEL_CENTERED_TOP_ENVIRONMENT;
+       case LA_CENTERED:
+               labeltype = LABEL_CENTERED;
                break;
        case LA_STATIC:
                labeltype = LABEL_STATIC;
@@ -735,9 +733,6 @@ void Layout::readLabelType(Lexer & lex)
        case LA_SENSITIVE:
                labeltype = LABEL_SENSITIVE;
                break;
-       case LA_COUNTER:
-               labeltype = LABEL_COUNTER;
-               break;
        case LA_ENUMERATE:
                labeltype = LABEL_ENUMERATE;
                break;
@@ -896,6 +891,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();
@@ -952,6 +948,8 @@ 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;
 }
@@ -960,6 +958,8 @@ void Layout::readArgument(Lexer & lex)
 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;
@@ -974,6 +974,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;
 }
 
@@ -986,6 +991,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;
 }
 
@@ -1025,8 +1035,8 @@ string const & Layout::htmlitemattr() const
 string const & Layout::htmllabeltag() const 
 { 
        if (htmllabeltag_.empty()) {
-               if (labeltype != LABEL_TOP_ENVIRONMENT &&
-                   labeltype != LABEL_CENTERED_TOP_ENVIRONMENT)
+               if (labeltype != LABEL_ABOVE &&
+                   labeltype != LABEL_CENTERED)
                        htmllabeltag_ = "span";
                else
                        htmllabeltag_ = "div";
@@ -1151,7 +1161,7 @@ void Layout::makeDefaultCSS() const
        // label font
        if (labelfont != font)
                labelCSS = labelfont.asCSS() + from_ascii("\n");
-       if (labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
+       if (labeltype == LABEL_CENTERED)
                labelCSS += from_ascii("text-align: center;\n");
        
        if (!labelCSS.empty())