]> git.lyx.org Git - lyx.git/blobdiff - src/Layout.cpp
Revert "DocBook: add a layout tag to tell whether an item is the abstract or not."
[lyx.git] / src / Layout.cpp
index fa6b58cc118c143fe06d8e4ea509d7ae921a49f6..eeb58d04527246aa1cb01c697de99808d8f35555 100644 (file)
@@ -31,7 +31,7 @@ using namespace lyx::support;
 
 namespace lyx {
 
-/// Special value of toclevel for layouts that to not belong in a TOC
+/// Special value of toclevel for layouts that do not belong to a TOC
 const int Layout::NOT_IN_TOC = -1000;
 
 //  The order of the LayoutTags enum is no more important. [asierra300396]
@@ -104,6 +104,22 @@ enum LayoutTags {
        LT_HTMLPREAMBLE,
        LT_HTMLSTYLE,
        LT_HTMLFORCECSS,
+       LT_DOCBOOKTAG,
+       LT_DOCBOOKATTR,
+       LT_DOCBOOKININFO,
+       LT_DOCBOOKWRAPPERTAG,
+       LT_DOCBOOKWRAPPERATTR,
+       LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS,
+       LT_DOCBOOKSECTIONTAG,
+       LT_DOCBOOKITEMWRAPPERTAG,
+       LT_DOCBOOKITEMWRAPPERATTR,
+       LT_DOCBOOKITEMTAG,
+       LT_DOCBOOKITEMATTR,
+       LT_DOCBOOKITEMLABELTAG,
+       LT_DOCBOOKITEMLABELATTR,
+       LT_DOCBOOKITEMINNERTAG,
+       LT_DOCBOOKITEMINNERATTR,
+       LT_DOCBOOKFORCEABSTRACTTAG,
        LT_INPREAMBLE,
        LT_HTMLTITLE,
        LT_SPELLCHECK,
@@ -161,6 +177,7 @@ Layout::Layout()
        htmllabelfirst_ = false;
        htmlforcecss_ = false;
        htmltitle_ = false;
+       docbookwrappermergewithprevious_ = false;
        spellcheck = true;
        forcelocal = 0;
        itemcommand_ = "item";
@@ -204,6 +221,22 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                { "commanddepth",   LT_COMMANDDEPTH },
                { "copystyle",      LT_COPYSTYLE },
                { "dependson",      LT_DEPENDSON },
+               { "docbookattr",             LT_DOCBOOKATTR },
+               { "docbookforceabstracttag", LT_DOCBOOKFORCEABSTRACTTAG },
+               { "docbookininfo",           LT_DOCBOOKININFO },
+               { "docbookitemattr",         LT_DOCBOOKITEMATTR },
+               { "docbookiteminnerattr",    LT_DOCBOOKITEMINNERATTR },
+               { "docbookiteminnertag",     LT_DOCBOOKITEMINNERTAG },
+               { "docbookitemlabelattr",    LT_DOCBOOKITEMLABELATTR },
+               { "docbookitemlabeltag",     LT_DOCBOOKITEMLABELTAG },
+               { "docbookitemtag",          LT_DOCBOOKITEMTAG },
+               { "docbookitemwrapperattr",  LT_DOCBOOKITEMWRAPPERATTR },
+               { "docbookitemwrappertag",   LT_DOCBOOKITEMWRAPPERTAG },
+               { "docbooksectiontag",       LT_DOCBOOKSECTIONTAG },
+               { "docbooktag",              LT_DOCBOOKTAG },
+               { "docbookwrapperattr",      LT_DOCBOOKWRAPPERATTR },
+               { "docbookwrappermergewithprevious", LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS },
+               { "docbookwrappertag",       LT_DOCBOOKWRAPPERTAG },
                { "end",            LT_END },
                { "endlabelstring", LT_ENDLABELSTRING },
                { "endlabeltype",   LT_ENDLABELTYPE },
@@ -607,7 +640,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                        lex.eatLine();
                        vector<string> const req =
                                getVectorFromString(lex.getString(true));
-                       requires_.insert(req.begin(), req.end());
+                       required_.insert(req.begin(), req.end());
                        break;
                }
 
@@ -689,6 +722,70 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
                        lex >> htmltitle_;
                        break;
 
+               case LT_DOCBOOKTAG:
+                       lex >> docbooktag_;
+                       break;
+
+               case LT_DOCBOOKATTR:
+                       lex >> docbookattr_;
+                       break;
+
+               case LT_DOCBOOKFORCEABSTRACTTAG:
+                       lex >> docbookforceabstracttag_;
+                       break;
+
+               case LT_DOCBOOKININFO:
+                       lex >> docbookininfo_;
+                       break;
+
+               case LT_DOCBOOKWRAPPERTAG:
+                       lex >> docbookwrappertag_;
+                       break;
+
+               case LT_DOCBOOKWRAPPERATTR:
+                       lex >> docbookwrapperattr_;
+                       break;
+
+               case LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS:
+                       lex >> docbookwrappermergewithprevious_;
+                       break;
+
+               case LT_DOCBOOKSECTIONTAG:
+                       lex >> docbooksectiontag_;
+                       break;
+
+        case LT_DOCBOOKITEMWRAPPERTAG:
+            lex >> docbookitemwrappertag_;
+            break;
+
+        case LT_DOCBOOKITEMWRAPPERATTR:
+                       lex >> docbookitemwrapperattr_;
+                       break;
+
+               case LT_DOCBOOKITEMTAG:
+                       lex >> docbookitemtag_;
+                       break;
+
+               case LT_DOCBOOKITEMATTR:
+                       lex >> docbookitemattr_;
+                       break;
+
+               case LT_DOCBOOKITEMLABELTAG:
+                       lex >> docbookitemlabeltag_;
+                       break;
+
+               case LT_DOCBOOKITEMLABELATTR:
+                       lex >> docbookitemlabelattr_;
+                       break;
+
+               case LT_DOCBOOKITEMINNERTAG:
+                       lex >> docbookiteminnertag_;
+                       break;
+
+               case LT_DOCBOOKITEMINNERATTR:
+                       lex >> docbookiteminnerattr_;
+                       break;
+
                case LT_SPELLCHECK:
                        lex >> spellcheck;
                        break;
@@ -1016,6 +1113,7 @@ void Layout::readArgument(Lexer & lex)
        arg.nodelims = false;
        arg.autoinsert = false;
        arg.insertcotext = false;
+       arg.insertonnewline = false;
        bool error = false;
        bool finished = false;
        arg.font = inherit_font;
@@ -1073,7 +1171,7 @@ void Layout::readArgument(Lexer & lex)
                        arg.tooltip = lex.getDocString();
                } else if (tok == "requires") {
                        lex.next();
-                       arg.requires = lex.getString();
+                       arg.required = lex.getString();
                } else if (tok == "decoration") {
                        lex.next();
                        arg.decoration = lex.getString();
@@ -1149,8 +1247,8 @@ void writeArgument(ostream & os, string const & id, Layout::latexarg const & arg
                os << "\t\tPresetArg \"" << to_utf8(arg.presetarg) << "\"\n";
        if (!arg.tooltip.empty())
                os << "\t\tToolTip \"" << to_utf8(arg.tooltip) << "\"\n";
-       if (!arg.requires.empty())
-               os << "\t\tRequires \"" << arg.requires << "\"\n";
+       if (!arg.required.empty())
+               os << "\t\tRequires \"" << arg.required << "\"\n";
        if (!arg.decoration.empty())
                os << "\t\tDecoration \"" << arg.decoration << "\"\n";
        if (!arg.newlinecmd.empty())
@@ -1172,6 +1270,8 @@ void writeArgument(ostream & os, string const & id, Layout::latexarg const & arg
        }
        if (!arg.pass_thru_chars.empty())
                os << "\t\tPassThruChars \"" << to_utf8(arg.pass_thru_chars) << "\"\n";
+       if (arg.free_spacing)
+               os << "\t\tFreeSpacing " << arg.free_spacing << "\n";
        os << "\tEndArgument\n";
 }
 
@@ -1440,11 +1540,11 @@ void Layout::write(ostream & os) const
        case Spacing::Default:
                break;
        }
-       if (!requires_.empty()) {
+       if (!required_.empty()) {
                os << "\tRequires ";
-               for (set<string>::const_iterator it = requires_.begin();
-                    it != requires_.end(); ++it) {
-                       if (it != requires_.begin())
+               for (set<string>::const_iterator it = required_.begin();
+                    it != required_.end(); ++it) {
+                       if (it != required_.begin())
                                os << ',';
                        os << *it;
                }
@@ -1496,8 +1596,39 @@ void Layout::write(ostream & os) const
                os << "\tHTMLPreamble\n"
                   << to_utf8(rtrim(htmlpreamble_, "\n"))
                   << "\n\tEndPreamble\n";
-       os << "\tHTMLTitle " << htmltitle_ << "\n"
-             "\tSpellcheck " << spellcheck << "\n"
+       os << "\tHTMLTitle " << htmltitle_ << "\n";
+       if(!docbooktag_.empty())
+               os << "\tDocBookTag " << docbooktag_ << '\n';
+       if(!docbookattr_.empty())
+               os << "\tDocBookAttr " << docbookattr_ << '\n';
+       if(!docbookininfo_.empty())
+               os << "\tDocBookInInfo " << docbookininfo_ << '\n';
+       if(!docbookwrappertag_.empty())
+               os << "\tDocBookWrapperTag " << docbookwrappertag_ << '\n';
+       if(!docbookwrapperattr_.empty())
+               os << "\tDocBookWrapperAttr " << docbookwrapperattr_ << '\n';
+       if(!docbooksectiontag_.empty())
+               os << "\tDocBookSectionTag " << docbooksectiontag_ << '\n';
+       if(!docbookitemtag_.empty())
+               os << "\tDocBookItemTag " << docbookitemtag_ << '\n';
+       if(!docbookitemattr_.empty())
+               os << "\tDocBookItemAttr " << docbookitemattr_ << '\n';
+       if(!docbookitemwrappertag_.empty())
+               os << "\tDocBookItemWrapperTag " << docbookitemwrappertag_ << '\n';
+       if(!docbookitemwrapperattr_.empty())
+               os << "\tDocBookItemWrapperAttr " << docbookitemwrapperattr_ << '\n';
+       os << "\tDocBookItemWrapperMergeWithPrevious " << docbookwrappermergewithprevious_ << '\n';
+       if(!docbookitemlabeltag_.empty())
+               os << "\tDocBookItemLabelTag " << docbookitemlabeltag_ << '\n';
+       if(!docbookitemlabelattr_.empty())
+               os << "\tDocBookItemLabelAttr " << docbookitemlabelattr_ << '\n';
+       if(!docbookiteminnertag_.empty())
+               os << "\tDocBookItemInnerTag " << docbookiteminnertag_ << '\n';
+       if(!docbookiteminnerattr_.empty())
+               os << "\tDocBookItemInnerAttr " << docbookiteminnerattr_ << '\n';
+       if(!docbookforceabstracttag_.empty())
+               os << "\tDocBookForceAbstractTag " << docbookforceabstracttag_ << '\n';
+       os << "\tSpellcheck " << spellcheck << "\n"
              "\tForceLocal " << forcelocal << "\n"
              "End\n";
 }
@@ -1645,6 +1776,116 @@ string Layout::defaultCSSClass() const
 }
 
 
+string const & Layout::docbooktag() const
+{
+       // No sensible default value, unhappily...
+       if (docbooktag_.empty())
+               docbooktag_ = to_utf8(name_);
+       return docbooktag_;
+}
+
+
+string const & Layout::docbookattr() const
+{
+       // Perfectly OK to return no attributes, so docbookattr_ does not need to be filled.
+       return docbookattr_;
+}
+
+
+string const & Layout::docbookininfo() const
+{
+       // Indeed, a trilean. Only titles should be "maybe": otherwise, metadata is "always", content is "never". 
+       if (docbookininfo_.empty() || (docbookininfo_ != "never" && docbookininfo_ != "always" && docbookininfo_ != "maybe"))
+               docbookininfo_ = "never";
+       return docbookininfo_;
+}
+
+
+string const & Layout::docbookwrappertag() const
+{
+    if (docbookwrappertag_.empty())
+        docbookwrappertag_ = "NONE";
+    return docbookwrappertag_;
+}
+
+
+string const & Layout::docbookwrapperattr() const
+{
+    return docbookwrapperattr_;
+}
+
+
+string const & Layout::docbooksectiontag() const
+{
+       if (docbooksectiontag_.empty())
+               docbooksectiontag_ = "section";
+       return docbooksectiontag_;
+}
+
+
+string const & Layout::docbookitemwrappertag() const
+{
+    if (docbookitemwrappertag_.empty())
+        docbookitemwrappertag_ = "NONE";
+    return docbookitemwrappertag_;
+}
+
+
+string const & Layout::docbookitemwrapperattr() const
+{
+    return docbookitemwrapperattr_;
+}
+
+
+string const & Layout::docbookitemtag() const
+{
+    return docbookitemtag_;
+}
+
+
+string const & Layout::docbookitemattr() const
+{
+    return docbookitemattr_;
+}
+
+
+string const & Layout::docbookitemlabeltag() const
+{
+       if (docbookitemlabeltag_.empty())
+               docbookitemlabeltag_ = "NONE";
+       return docbookitemlabeltag_;
+}
+
+
+string const & Layout::docbookitemlabelattr() const
+{
+       return docbookitemlabelattr_;
+}
+
+
+string const & Layout::docbookiteminnertag() const
+{
+       if (docbookiteminnertag_.empty())
+               docbookiteminnertag_ = "NONE";
+       return docbookiteminnertag_;
+}
+
+
+string const & Layout::docbookiteminnerattr() const
+{
+       return docbookiteminnerattr_;
+}
+
+
+std::string const & Layout::docbookforceabstracttag() const
+{
+       if (docbookforceabstracttag_.empty())
+               docbookforceabstracttag_ = "NONE";
+       return docbookforceabstracttag_;
+}
+
+
+
 namespace {
 
 string makeMarginValue(char const * side, double d)