]> git.lyx.org Git - lyx.git/commitdiff
Fix layout write bugs found by tests
authorGeorg Baum <baum@lyx.org>
Sun, 31 Mar 2013 16:17:40 +0000 (18:17 +0200)
committerGeorg Baum <baum@lyx.org>
Sun, 31 Mar 2013 16:17:40 +0000 (18:17 +0200)
src/Layout.cpp
src/Layout.h

index 080e41a85d3e11c30d623f66acdc6fb7b4e6bfb6..b48b764904f2fcc350cd577d963818dd08c41570 100644 (file)
@@ -999,11 +999,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 +1070,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_, "\"", "&quot;")
-                  << '\n';
+               os << "\tLatexParam \"" << subst(latexparam_, "\"", "&quot;")
+                  << "\"\n";
        if (!leftdelim_.empty())
                os << "\tLeftDelim "
                   << to_utf8(subst(leftdelim_, from_ascii("\n"), from_ascii("<br/>")))
@@ -1080,24 +1083,27 @@ void Layout::write(ostream & os) const
                   << to_utf8(subst(rightdelim_, from_ascii("\n"), from_ascii("<br/>")))
                   << '\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 +1149,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())
index 3ffd54246b94f1d4cff8cd44d4529a7051bfd62d..b7c6e708cd1f1c02db73fb28ec3a8b6ce212ee16 100644 (file)
@@ -89,8 +89,6 @@ public:
        std::string const & latexname() const { return latexname_; }
        ///
        std::string const & itemcommand() const { return itemcommand_; }
-       ///
-       void setLatexName(std::string const & n) { latexname_ = n; }
        /// The arguments of this layout
        struct latexarg {
                docstring labelstring;