X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLayout.cpp;h=e5d683ec1855d3f089eaa19828926c7eff5a1017;hb=771e46c58d62e9cdfd98f77dae20a9401c1c425c;hp=f5e6f771308ff6a476852adf7995d705fa3a2ffb;hpb=6c51cabd35b48eb2245330cda49b2be5c9a2c223;p=features.git diff --git a/src/Layout.cpp b/src/Layout.cpp index f5e6f77130..e5d683ec18 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -13,16 +13,14 @@ #include #include "Layout.h" -#include "FontInfo.h" -#include "Language.h" #include "Lexer.h" #include "output_xhtml.h" #include "TextClass.h" #include "support/debug.h" +#include "support/docstream.h" #include "support/lassert.h" #include "support/lstrings.h" -#include "support/Messages.h" #include "support/textutils.h" @@ -107,12 +105,16 @@ enum LayoutTags { LT_DOCBOOKTAG, LT_DOCBOOKATTR, LT_DOCBOOKTAGTYPE, + LT_DOCBOOKINNERATTR, + LT_DOCBOOKINNERTAG, + LT_DOCBOOKINNERTAGTYPE, LT_DOCBOOKININFO, LT_DOCBOOKABSTRACT, LT_DOCBOOKWRAPPERTAG, LT_DOCBOOKWRAPPERATTR, LT_DOCBOOKWRAPPERTAGTYPE, LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS, + LT_DOCBOOKSECTION, LT_DOCBOOKSECTIONTAG, LT_DOCBOOKITEMWRAPPERTAG, LT_DOCBOOKITEMWRAPPERATTR, @@ -127,13 +129,14 @@ enum LayoutTags { LT_DOCBOOKITEMINNERATTR, LT_DOCBOOKITEMINNERTAGTYPE, LT_DOCBOOKFORCEABSTRACTTAG, + LT_DOCBOOKNOFONTINSIDE, LT_INPREAMBLE, LT_HTMLTITLE, LT_SPELLCHECK, LT_REFPREFIX, LT_RESETARGS, LT_RESUMECOUNTER, - LT_STEPMASTERCOUNTER, + LT_STEPPARENTCOUNTER, LT_RIGHTDELIM, LT_FORCELOCAL, LT_TOGGLE_INDENT, @@ -151,7 +154,7 @@ Layout::Layout() margintype = MARGIN_STATIC; latextype = LATEX_PARAGRAPH; resumecounter = false; - stepmastercounter = false; + stepparentcounter = false; intitle = false; inpreamble = false; needprotect = false; @@ -186,6 +189,7 @@ Layout::Layout() htmltitle_ = false; docbookabstract_ = false; docbookwrappermergewithprevious_ = false; + docbooksection_ = false; spellcheck = true; forcelocal = 0; itemcommand_ = "item"; @@ -194,15 +198,15 @@ Layout::Layout() } -bool Layout::read(Lexer & lex, TextClass const & tclass) +bool Layout::read(Lexer & lex, TextClass const & tclass, bool validating) { // If this is an empty layout, or if no force local version is set, // we know that we will not discard the stuff to read if (forcelocal == 0) - return readIgnoreForcelocal(lex, tclass); + return readIgnoreForcelocal(lex, tclass, validating); Layout tmp(*this); tmp.forcelocal = 0; - bool const ret = tmp.readIgnoreForcelocal(lex, tclass); + bool const ret = tmp.readIgnoreForcelocal(lex, tclass, validating); // Keep the stuff if // - the read version is higher // - both versions are infinity (arbitrary decision) @@ -214,7 +218,8 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) } -bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) +bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass, + bool validating) { // This table is sorted alphabetically [asierra 30March96] LexerKeyword layoutTags[] = { @@ -233,6 +238,9 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) { "docbookattr", LT_DOCBOOKATTR }, { "docbookforceabstracttag", LT_DOCBOOKFORCEABSTRACTTAG }, { "docbookininfo", LT_DOCBOOKININFO }, + { "docbookinnerattr", LT_DOCBOOKINNERATTR }, + { "docbookinnertag", LT_DOCBOOKINNERTAG }, + { "docbookinnertagtype", LT_DOCBOOKINNERTAGTYPE }, { "docbookitemattr", LT_DOCBOOKITEMATTR }, { "docbookiteminnerattr", LT_DOCBOOKITEMINNERATTR }, { "docbookiteminnertag", LT_DOCBOOKITEMINNERTAG }, @@ -245,6 +253,8 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) { "docbookitemwrapperattr", LT_DOCBOOKITEMWRAPPERATTR }, { "docbookitemwrappertag", LT_DOCBOOKITEMWRAPPERTAG }, { "docbookitemwrappertagtype", LT_DOCBOOKITEMWRAPPERTAGTYPE }, + { "docbooknofontinside", LT_DOCBOOKNOFONTINSIDE, }, + { "docbooksection", LT_DOCBOOKSECTION }, { "docbooksectiontag", LT_DOCBOOKSECTIONTAG }, { "docbooktag", LT_DOCBOOKTAG }, { "docbooktagtype", LT_DOCBOOKTAGTYPE }, @@ -316,7 +326,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) { "rightmargin", LT_RIGHTMARGIN }, { "spacing", LT_SPACING }, { "spellcheck", LT_SPELLCHECK }, - { "stepmastercounter", LT_STEPMASTERCOUNTER }, + { "stepparentcounter", LT_STEPPARENTCOUNTER }, { "textfont", LT_TEXTFONT }, { "toclevel", LT_TOCLEVEL }, { "toggleindent", LT_TOGGLE_INDENT }, @@ -436,12 +446,12 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> resumecounter; break; - case LT_STEPMASTERCOUNTER: - lex >> stepmastercounter; + case LT_STEPPARENTCOUNTER: + lex >> stepparentcounter; break; case LT_ARGUMENT: - readArgument(lex); + readArgument(lex, validating); break; case LT_NEED_PROTECT: @@ -749,6 +759,18 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> docbooktagtype_; break; + case LT_DOCBOOKINNERTAG: + lex >> docbookinnertag_; + break; + + case LT_DOCBOOKINNERATTR: + lex >> docbookinnerattr_; + break; + + case LT_DOCBOOKINNERTAGTYPE: + lex >> docbookinnertagtype_; + break; + case LT_DOCBOOKFORCEABSTRACTTAG: lex >> docbookforceabstracttag_; break; @@ -777,15 +799,19 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> docbookwrappermergewithprevious_; break; + case LT_DOCBOOKSECTION: + lex >> docbooksection_; + break; + case LT_DOCBOOKSECTIONTAG: lex >> docbooksectiontag_; break; - case LT_DOCBOOKITEMWRAPPERTAG: - lex >> docbookitemwrappertag_; - break; - - case LT_DOCBOOKITEMWRAPPERATTR: + case LT_DOCBOOKITEMWRAPPERTAG: + lex >> docbookitemwrappertag_; + break; + + case LT_DOCBOOKITEMWRAPPERATTR: lex >> docbookitemwrapperattr_; break; @@ -829,6 +855,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> docbookiteminnertagtype_; break; + case LT_DOCBOOKNOFONTINSIDE: + lex >> docbooknofontinside_; + break; + case LT_SPELLCHECK: lex >> spellcheck; break; @@ -1148,28 +1178,30 @@ void Layout::readSpacing(Lexer & lex) } -void Layout::readArgument(Lexer & lex) +void Layout::readArgument(Lexer & lex, bool validating) { - latexarg arg; - // writeArgument() makes use of these default values - arg.mandatory = false; - arg.nodelims = false; - arg.autoinsert = false; - arg.insertcotext = false; - arg.insertonnewline = false; - bool error = false; - bool finished = false; - arg.font = inherit_font; - arg.labelfont = inherit_font; - arg.is_toc_caption = false; - arg.passthru = PT_INHERITED; - arg.free_spacing = false; - string id; - lex >> id; + if (!lex.next()) { + LYXERR0("Unable to read argument ID!"); + return; + } + string const id = lex.getString(); + bool const itemarg = prefixIs(id, "item:"); bool const postcmd = prefixIs(id, "post:"); bool const listpreamble = prefixIs(id, "listpreamble:"); + LaTeXArgMap & lam = itemarg ? itemargs_ : + (postcmd ? postcommandargs_ : + (listpreamble ? listpreamble_ : + latexargs_)); + latexarg & arg = lam[id]; + + if (listpreamble) + // list preamble has no delimiters by default + arg.nodelims = true; + + bool error = false; + bool finished = false; while (!finished && lex.isOK() && !error) { lex.next(); string const tok = ascii_lowercase(lex.getString()); @@ -1243,23 +1275,31 @@ void Layout::readArgument(Lexer & lex) } else if (tok == "freespacing") { lex.next(); arg.free_spacing = lex.getBool(); + } else if (tok == "docbooktag") { + lex.next(); + arg.docbooktag = lex.getDocString(); + } else if (tok == "docbookattr") { + lex.next(); + arg.docbookattr = lex.getDocString(); + } else if (tok == "docbooktagtype") { + lex.next(); + arg.docbooktagtype = lex.getDocString(); + } else if (tok == "docbookargumentaftermaintag") { + lex.next(); + arg.docbookargumentaftermaintag = lex.getBool(); + } else if (tok == "docbookargumentbeforemaintag") { + lex.next(); + arg.docbookargumentbeforemaintag = lex.getBool(); } else { lex.printError("Unknown tag"); error = true; } } - if (arg.labelstring.empty()) + if (!validating && arg.labelstring.empty()) { LYXERR0("Incomplete Argument definition!"); - else if (itemarg) - itemargs_[id] = arg; - else if (postcmd) - postcommandargs_[id] = arg; - else if (listpreamble) { - // list preamble has no delimiters by default - arg.nodelims = true; - listpreamble_[id] = arg; - } else - latexargs_[id] = arg; + // remove invalid definition + lam.erase(id); + } } @@ -1373,7 +1413,7 @@ void Layout::write(ostream & os) const "\tInPreamble " << inpreamble << "\n" "\tTocLevel " << toclevel << "\n" "\tResumeCounter " << resumecounter << "\n" - "\tStepMasterCounter " << stepmastercounter << '\n'; + "\tStepParentCounter " << stepparentcounter << '\n'; // ResetArgs does not make sense here for (LaTeXArgMap::const_iterator it = latexargs_.begin(); it != latexargs_.end(); ++it) @@ -1646,6 +1686,12 @@ void Layout::write(ostream & os) const os << "\tDocBookAttr \"" << docbookattr_ << "\"\n"; if(!docbooktagtype_.empty()) os << "\tDocBookTagType " << docbooktagtype_ << '\n'; + if(!docbookinnertag_.empty()) + os << "\tDocBookInnerTag " << docbookinnertag_ << '\n'; + if(!docbookinnerattr_.empty()) + os << "\tDocBookInnerAttr \"" << docbookinnerattr_ << "\"\n"; + if(!docbookinnertagtype_.empty()) + os << "\tDocBookInnerTagType " << docbookinnertagtype_ << '\n'; if(!docbookininfo_.empty()) os << "\tDocBookInInfo " << docbookininfo_ << '\n'; os << "\tDocBookAbstract " << docbookabstract_ << '\n'; @@ -1655,6 +1701,7 @@ void Layout::write(ostream & os) const os << "\tDocBookWrapperAttr " << docbookwrapperattr_ << '\n'; if(!docbookwrappertagtype_.empty()) os << "\tDocBookWrapperTagType " << docbookwrappertagtype_ << '\n'; + os << "\tDocBookSection " << docbooksection_ << '\n'; if(!docbooksectiontag_.empty()) os << "\tDocBookSectionTag " << docbooksectiontag_ << '\n'; if(!docbookitemtag_.empty()) @@ -1684,7 +1731,8 @@ void Layout::write(ostream & os) const os << "\tDocBookItemInnerTagType " << docbookiteminnertagtype_ << '\n'; if(!docbookforceabstracttag_.empty()) os << "\tDocBookForceAbstractTag " << docbookforceabstracttag_ << '\n'; - os << "\tSpellcheck " << spellcheck << "\n" + os << "\tDocBookNoFontInside " << docbooknofontinside_ << "\n" + "\tSpellcheck " << spellcheck << "\n" "\tForceLocal " << forcelocal << "\n" "End\n"; } @@ -1851,7 +1899,7 @@ string const & Layout::docbookattr() const } -bool isValidTagType(std::string type) +bool isValidTagType(std::string const & type) { return !(type.empty() || (type != "block" && type != "paragraph" && type != "inline")); } @@ -1865,6 +1913,28 @@ string const & Layout::docbooktagtype() const } +string const & Layout::docbookinnertag() const +{ + if (docbookinnertag_.empty()) + docbookinnertag_ = "NONE"; + return docbookinnertag_; +} + + +string const & Layout::docbookinnerattr() const +{ + return docbookinnerattr_; +} + + +string const & Layout::docbookinnertagtype() const +{ + if (!isValidTagType(docbookinnertagtype_)) + docbookinnertagtype_ = "block"; + return docbookinnertagtype_; +} + + string const & Layout::docbookininfo() const { // Indeed, a trilean. Only titles should be "maybe": otherwise, metadata is "always", content is "never".