X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLayout.cpp;h=46035513c7bd163a28d15c6505941f48c2001d12;hb=4db3e641ed6765e005343010cb90ee8af26f8f99;hp=080e41a85d3e11c30d623f66acdc6fb7b4e6bfb6;hpb=7cf8b9da78d2747e4bba25d7f103da422ae28a6f;p=lyx.git
diff --git a/src/Layout.cpp b/src/Layout.cpp
index 080e41a85d..46035513c7 100644
--- a/src/Layout.cpp
+++ b/src/Layout.cpp
@@ -104,6 +104,7 @@ enum LayoutTags {
LT_REFPREFIX,
LT_RESETARGS,
LT_RIGHTDELIM,
+ LT_FORCELOCAL,
LT_INTITLE // keep this last!
};
@@ -145,11 +146,32 @@ Layout::Layout()
htmlforcecss_ = false;
htmltitle_ = false;
spellcheck = true;
+ forcelocal = 0;
itemcommand_ = "item";
}
bool Layout::read(Lexer & lex, TextClass const & tclass)
+{
+ // 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);
+ Layout tmp(*this);
+ tmp.forcelocal = 0;
+ bool const ret = tmp.readIgnoreForcelocal(lex, tclass);
+ // Keep the stuff if
+ // - the read version is higher
+ // - both versions are infinity (arbitrary decision)
+ // - the file did not contain any local version (needed for not
+ // skipping user defined local layouts)
+ if (tmp.forcelocal <= 0 || tmp.forcelocal > forcelocal)
+ *this = tmp;
+ return ret;
+}
+
+
+bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass)
{
// This table is sorted alphabetically [asierra 30March96]
LexerKeyword layoutTags[] = {
@@ -166,6 +188,7 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
{ "endlabelstring", LT_ENDLABELSTRING },
{ "endlabeltype", LT_ENDLABELTYPE },
{ "font", LT_FONT },
+ { "forcelocal", LT_FORCELOCAL },
{ "freespacing", LT_FREE_SPACING },
{ "htmlattr", LT_HTMLATTR },
{ "htmlforcecss", LT_HTMLFORCECSS },
@@ -582,6 +605,10 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
case LT_SPELLCHECK:
lex >> spellcheck;
break;
+
+ case LT_FORCELOCAL:
+ lex >> forcelocal;
+ break;
}
}
lex.popTable();
@@ -999,11 +1026,14 @@ void writeArgument(ostream & os, string const & id, Layout::latexarg const & arg
void Layout::write(ostream & os) const
{
os << "Style " << to_utf8(name_) << '\n';
- if (!category_.empty())
- os << "\tCategory " << to_utf8(category_) << '\n';
+ if (!category_.empty() && obsoleted_by_.empty())
+ os << "\tCategory \"" << to_utf8(category_) << "\"\n";
// Can't deduce Copystyle here :-(
- if (!obsoleted_by_.empty())
- os << "\tObsoletedby " << to_utf8(obsoleted_by_) << '\n';
+ if (!obsoleted_by_.empty()) {
+ os << "\tObsoletedBy \"" << to_utf8(obsoleted_by_)
+ << "\"\nEnd\n";
+ return;
+ }
if (!depends_on_.empty())
os << "\tDependsOn " << to_utf8(depends_on_) << '\n';
switch (margintype) {
@@ -1067,10 +1097,10 @@ void Layout::write(ostream & os) const
os << "\tNextNoIndent " << nextnoindent << "\n"
"\tCommandDepth " << commanddepth << '\n';
if (!latexname_.empty())
- os << "\tLatexName " << latexname_ << '\n';
+ os << "\tLatexName \"" << latexname_ << "\"\n";
if (!latexparam_.empty())
- os << "\tLatexParam " << subst(latexparam_, "\"", """)
- << '\n';
+ os << "\tLatexParam \"" << subst(latexparam_, "\"", """)
+ << "\"\n";
if (!leftdelim_.empty())
os << "\tLeftDelim "
<< to_utf8(subst(leftdelim_, from_ascii("\n"), from_ascii("
")))
@@ -1080,24 +1110,27 @@ void Layout::write(ostream & os) const
<< to_utf8(subst(rightdelim_, from_ascii("\n"), from_ascii("
")))
<< '\n';
if (!innertag_.empty())
- os << "\tInnerTag " << innertag_ << '\n';
+ os << "\tInnerTag \"" << innertag_ << "\"\n";
if (!labeltag_.empty())
- os << "\tLabelTag " << labeltag_ << '\n';
+ os << "\tLabelTag \"" << labeltag_ << "\"\n";
if (!itemtag_.empty())
- os << "\tItemTag " << itemtag_ << '\n';
+ os << "\tItemTag \"" << itemtag_ << "\"\n";
if (!itemcommand_.empty())
os << "\tItemCommand " << itemcommand_ << '\n';
if (!preamble_.empty())
- os << "\tPreamble\n"
- << to_utf8(rtrim(preamble_, "\n"))
+ os << "\tPreamble\n\t"
+ << to_utf8(subst(rtrim(preamble_, "\n"),
+ from_ascii("\n"), from_ascii("\n\t")))
<< "\n\tEndPreamble\n";
if (!langpreamble_.empty())
- os << "\tLangPreamble\n"
- << to_utf8(rtrim(langpreamble_, "\n"))
+ os << "\tLangPreamble\n\t"
+ << to_utf8(subst(rtrim(langpreamble_, "\n"),
+ from_ascii("\n"), from_ascii("\n\t")))
<< "\n\tEndLangPreamble\n";
if (!babelpreamble_.empty())
- os << "\tBabelPreamble\n"
- << to_utf8(rtrim(babelpreamble_, "\n"))
+ os << "\tBabelPreamble\n\t"
+ << to_utf8(subst(rtrim(babelpreamble_, "\n"),
+ from_ascii("\n"), from_ascii("\n\t")))
<< "\n\tEndBabelPreamble\n";
switch (labeltype) {
case LABEL_ABOVE:
@@ -1143,9 +1176,9 @@ void Layout::write(ostream & os) const
break;
}
if (!leftmargin.empty())
- os << "\tLeftMargin " << to_utf8(leftmargin) << '\n';
+ os << "\tLeftMargin \"" << to_utf8(leftmargin) << "\"\n";
if (!rightmargin.empty())
- os << "\tRightMargin " << to_utf8(rightmargin) << '\n';
+ os << "\tRightMargin \"" << to_utf8(rightmargin) << "\"\n";
if (!labelindent.empty())
os << "\tLabelIndent " << to_utf8(labelindent) << '\n';
if (!parindent.empty())
@@ -1284,6 +1317,7 @@ void Layout::write(ostream & os) const
<< "\n\tEndPreamble\n";
os << "\tHTMLTitle " << htmltitle_ << "\n"
"\tSpellcheck " << spellcheck << "\n"
+ "\tForceLocal " << forcelocal << "\n"
"End\n";
}
@@ -1472,7 +1506,7 @@ void Layout::makeDefaultCSS() const
}
// tex2lyx does not see output_xhtml.cpp
-#ifndef TEX2LYX
+#ifndef NO_LAYOUT_CSS
// alignment
string where = alignmentToCSS(align);
if (!where.empty()) {