]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetLayout.cpp
DocBook: support bookauthor in bibliographies.
[lyx.git] / src / insets / InsetLayout.cpp
index 0ff5c50ad463b8ac3e3a6c77807671f5befc2834..8e5ed651cf4329dd90f1bb69a2536c7b2fde5f10 100644 (file)
@@ -64,6 +64,10 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
 {
        enum {
                IL_ADDTOTOC,
+               IL_ALLOWED_IN_INSET,
+               IL_ALLOWED_IN_LAYOUT,
+               IL_ALLOWED_OCCURRENCES,
+               IL_ALLOWED_OCCURRENCES_PER_ITEM,
                IL_ARGUMENT,
                IL_BABELPREAMBLE,
                IL_BGCOLOR,
@@ -83,6 +87,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                IL_FREESPACING,
                IL_HTMLTAG,
                IL_HTMLATTR,
+               IL_HTMLCLASS,
                IL_HTMLFORCECSS,
                IL_HTMLINNERTAG,
                IL_HTMLINNERATTR,
@@ -96,6 +101,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                IL_DOCBOOKSECTION,
                IL_DOCBOOKININFO,
                IL_DOCBOOKARGUMENTBEFOREMAINTAG,
+               IL_DOCBOOKARGUMENTAFTERMAINTAG,
                IL_DOCBOOKNOTINPARA,
                IL_DOCBOOKWRAPPERTAG,
                IL_DOCBOOKWRAPPERTAGTYPE,
@@ -106,6 +112,12 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                IL_DOCBOOKITEMWRAPPERTAG,
                IL_DOCBOOKITEMWRAPPERTAGTYPE,
                IL_DOCBOOKITEMWRAPPERATTR,
+               IL_DOCBOOKINNERTAG,
+               IL_DOCBOOKINNERTAGTYPE,
+               IL_DOCBOOKINNERATTR,
+               IL_DOCBOOKNOFONTINSIDE,
+               IL_DOCBOOKRENDERASIMAGE,
+               IL_INHERITFONT,
                IL_INTOC,
                IL_ISTOCCAPTION,
                IL_LABELFONT,
@@ -141,6 +153,10 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
 
        LexerKeyword elementTags[] = {
                { "addtotoc", IL_ADDTOTOC },
+               { "allowedininsets", IL_ALLOWED_IN_INSET },
+               { "allowedinlayouts", IL_ALLOWED_IN_LAYOUT },
+               { "allowedoccurrences", IL_ALLOWED_OCCURRENCES },
+               { "allowedoccurrencesperitem", IL_ALLOWED_OCCURRENCES_PER_ITEM },
                { "argument", IL_ARGUMENT },
                { "babelpreamble", IL_BABELPREAMBLE },
                { "bgcolor", IL_BGCOLOR },
@@ -150,16 +166,22 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                { "custompars", IL_CUSTOMPARS },
                { "decoration", IL_DECORATION },
                { "display", IL_DISPLAY },
+               { "docbookargumentaftermaintag", IL_DOCBOOKARGUMENTAFTERMAINTAG },
                { "docbookargumentbeforemaintag", IL_DOCBOOKARGUMENTBEFOREMAINTAG },
                { "docbookattr", IL_DOCBOOKATTR },
                { "docbookininfo", IL_DOCBOOKININFO },
+               { "docbookinnerattr", IL_DOCBOOKINNERATTR },
+               { "docbookinnertag", IL_DOCBOOKINNERTAG },
+               { "docbookinnertagtype", IL_DOCBOOKINNERTAGTYPE },
                { "docbookitemattr", IL_DOCBOOKITEMATTR },
                { "docbookitemtag", IL_DOCBOOKITEMTAG },
                { "docbookitemtagtype", IL_DOCBOOKITEMTAGTYPE },
                { "docbookitemwrapperattr", IL_DOCBOOKITEMWRAPPERATTR },
                { "docbookitemwrappertag", IL_DOCBOOKITEMWRAPPERTAG },
                { "docbookitemwrappertagtype", IL_DOCBOOKITEMWRAPPERTAGTYPE },
+               { "docbooknofontinside", IL_DOCBOOKNOFONTINSIDE },
                { "docbooknotinpara", IL_DOCBOOKNOTINPARA },
+               { "docbookrenderasimage", IL_DOCBOOKRENDERASIMAGE },
                { "docbooksection", IL_DOCBOOKSECTION },
                { "docbooktag", IL_DOCBOOKTAG },
                { "docbooktagtype", IL_DOCBOOKTAGTYPE },
@@ -176,6 +198,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                { "forceplain", IL_FORCEPLAIN },
                { "freespacing", IL_FREESPACING },
                { "htmlattr", IL_HTMLATTR },
+               { "htmlclass", IL_HTMLCLASS },
                { "htmlforcecss", IL_HTMLFORCECSS },
                { "htmlinnerattr", IL_HTMLINNERATTR},
                { "htmlinnertag", IL_HTMLINNERTAG},
@@ -184,6 +207,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                { "htmlpreamble", IL_HTMLPREAMBLE },
                { "htmlstyle", IL_HTMLSTYLE },
                { "htmltag", IL_HTMLTAG },
+               { "inheritfont", IL_INHERITFONT },
                { "intoc", IL_INTOC },
                { "istoccaption", IL_ISTOCCAPTION },
                { "keepempty", IL_KEEPEMPTY },
@@ -217,8 +241,10 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
 
        lex.pushTable(elementTags);
 
-       labelfont_ = inherit_font;
-       bgcolor_ = Color_none;
+       if (labelfont_ == sane_font)
+               labelfont_ = inherit_font;
+       if (bgcolor_ == Color_error)
+               bgcolor_ = Color_none;
        bool getout = false;
        // whether we've read the CustomPars or ForcePlain tag
        // for issuing a warning in case MultiPars comes later
@@ -296,7 +322,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                        break;
                case IL_LATEXPARAM:
                        lex >> tmp;
-                       latexparam_ = subst(tmp, """, "\"");
+                       latexparam_ = subst(tmp, """, "\"");
                        break;
                case IL_LEFTDELIM:
                        lex >> leftdelim_;
@@ -323,6 +349,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                case IL_FORCEOWNLINES:
                        lex >> forceownlines_;
                        break;
+               case IL_INHERITFONT:
+                       lex >> inheritfont_;
+                       break;
                case IL_INTOC:
                        lex >> intoc_;
                        break;
@@ -485,6 +514,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                case IL_HTMLATTR:
                        lex >> htmlattr_;
                        break;
+               case IL_HTMLCLASS:
+                       lex >> htmlclass_;
+                       break;
                case IL_HTMLFORCECSS:
                        lex >> htmlforcecss_;
                        break;
@@ -515,12 +547,24 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                case IL_DOCBOOKTAGTYPE:
                        lex >> docbooktagtype_;
                        break;
+               case IL_DOCBOOKINNERTAG:
+                       lex >> docbookinnertag_;
+                       break;
+               case IL_DOCBOOKINNERATTR:
+                       lex >> docbookinnerattr_;
+                       break;
+               case IL_DOCBOOKINNERTAGTYPE:
+                       lex >> docbookinnertagtype_;
+                       break;
                case IL_DOCBOOKININFO:
                        lex >> docbookininfo_;
                        break;
                case IL_DOCBOOKARGUMENTBEFOREMAINTAG:
                        lex >> docbookargumentbeforemaintag_;
                        break;
+               case IL_DOCBOOKARGUMENTAFTERMAINTAG:
+                       lex >> docbookargumentaftermaintag_;
+                       break;
                case IL_DOCBOOKNOTINPARA:
                        lex >> docbooknotinpara_;
                        break;
@@ -554,6 +598,12 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                case IL_DOCBOOKWRAPPERATTR:
                        lex >> docbookwrapperattr_;
                        break;
+               case IL_DOCBOOKNOFONTINSIDE:
+                       lex >> docbooknofontinside_;
+                       break;
+               case IL_DOCBOOKRENDERASIMAGE:
+                       lex >> docbookrenderasimage_;
+                       break;
                case IL_REQUIRES: {
                        lex.eatLine();
                        vector<string> const req
@@ -580,6 +630,37 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                case IL_EDITEXTERNAL:
                        lex >> edit_external_;
                        break;
+               case IL_ALLOWED_IN_INSET: {
+                       docstring allowed = lex.getLongString(from_ascii("EndAllowedInInsets"));
+                       allowed = subst(allowed, from_ascii("\n"), docstring());
+                       allowed = subst(allowed, from_ascii("\t"), docstring());
+                       allowed = subst(allowed, from_ascii("\""), docstring());
+                       allowed = subst(allowed, '_', ' ');
+                       vector<docstring> const allowances =
+                               getVectorFromString(allowed, from_ascii(","), false, true);
+                       allowed_in_insets_.clear();
+                       allowed_in_insets_.insert(allowances.begin(), allowances.end());
+                       break;
+               }
+
+               case IL_ALLOWED_IN_LAYOUT: {
+                       docstring allowed = lex.getLongString(from_ascii("EndAllowedInLayouts"));
+                       allowed = subst(allowed, from_ascii("\n"), docstring());
+                       allowed = subst(allowed, from_ascii("\t"), docstring());
+                       allowed = subst(allowed, from_ascii("\""), docstring());
+                       allowed = subst(allowed, '_', ' ');
+                       vector<docstring> const allowances =
+                               getVectorFromString(allowed, from_ascii(","), false, true);
+                       allowed_in_layouts_.clear();
+                       allowed_in_layouts_.insert(allowances.begin(), allowances.end());
+                       break;
+               }
+               case IL_ALLOWED_OCCURRENCES:
+                       lex >> allowed_occurrences_;
+                       break;
+               case IL_ALLOWED_OCCURRENCES_PER_ITEM:
+                       lex >> allowed_occurrences_per_item_;
+                       break;
                case IL_END:
                        getout = true;
                        break;
@@ -621,11 +702,23 @@ string const & InsetLayout::htmltag() const
 }
 
 
-string const & InsetLayout::htmlattr() const
+string const & InsetLayout::htmlclass() const
 {
-       if (htmlattr_.empty())
-               htmlattr_ = "class=\"" + defaultCSSClass() + "\"";
-       return htmlattr_;
+       if (htmlclass_.empty())
+               htmlclass_ = defaultCSSClass();
+       return htmlclass_;
+}
+
+
+std::string const & InsetLayout::htmlGetAttrString() const {
+       if (!htmlfullattrs_.empty())
+               return htmlfullattrs_;
+       htmlfullattrs_ = htmlclass();
+       if (!htmlfullattrs_.empty())
+               htmlfullattrs_ = "class='" + htmlfullattrs_ + "'";
+       if (!htmlattr_.empty())
+               htmlfullattrs_ += " " + htmlattr_;
+       return htmlfullattrs_;
 }
 
 
@@ -702,6 +795,14 @@ std::string InsetLayout::docbooktagtype() const
 }
 
 
+std::string InsetLayout::docbookinnertagtype() const
+{
+       if (docbookinnertagtype_ != "block" && docbookinnertagtype_ != "paragraph" && docbookinnertagtype_ != "inline")
+               docbookinnertagtype_ = "block";
+       return docbookinnertagtype_;
+}
+
+
 std::string InsetLayout::docbookwrappertagtype() const
 {
        if (docbookwrappertagtype_ != "block" && docbookwrappertagtype_ != "paragraph" && docbookwrappertagtype_ != "inline")
@@ -790,8 +891,8 @@ void InsetLayout::readArgument(Lexer & lex)
                        lex.next();
                        arg.tooltip = lex.getDocString();
                } else if (tok == "requires") {
-                       lex.next();
-                       arg.required = lex.getString();
+                       lex.eatLine();
+                       arg.required = trim(lex.getString(true));
                } else if (tok == "decoration") {
                        lex.next();
                        arg.decoration = lex.getString();
@@ -832,6 +933,9 @@ void InsetLayout::readArgument(Lexer & lex)
                } else if (tok == "docbookargumentbeforemaintag") {
                        lex.next();
                        arg.docbookargumentbeforemaintag = lex.getBool();
+               } else if (tok == "docbookargumentaftermaintag") {
+                       lex.next();
+                       arg.docbookargumentaftermaintag = lex.getBool();
                } else {
                        lex.printError("Unknown tag");
                        error = true;