]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
Fix fa0f142e (plain quotes fix).
[lyx.git] / src / BufferParams.cpp
index 19abefc0dd9706fd872c284aa9f14af470368482..bdfbc59572d17d2784f3365da33002c9ee527f24 100644 (file)
 #include "ColorSet.h"
 #include "Converter.h"
 #include "Encoding.h"
-#include "HSpace.h"
 #include "IndicesList.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
 #include "LaTeXFonts.h"
+#include "Length.h"
 #include "ModuleList.h"
 #include "Font.h"
 #include "Lexer.h"
@@ -337,12 +337,12 @@ public:
        Bullet user_defined_bullets[4];
        IndicesList indiceslist;
        Spacing spacing;
+       Length parindent;
+       Length mathindent;
        /** This is the amount of space used for paragraph_separation "skip",
         * and for detached paragraphs in "indented" documents.
         */
-       HSpace indentation;
        VSpace defskip;
-       HSpace math_indentation;
        PDFOptions pdfoptions;
        LayoutFileIndex baseClass_;
        FormatList exportableFormatList;
@@ -385,7 +385,7 @@ BufferParams::BufferParams()
        makeDocumentClass();
        paragraph_separation = ParagraphIndentSeparation;
        is_math_indent = false;
-       math_indentation = "default";
+       math_number_before = false;
        quotes_style = InsetQuotesParams::EnglishQuotes;
        dynamic_quotes = false;
        fontsize = "default";
@@ -629,27 +629,27 @@ PDFOptions const & BufferParams::pdfoptions() const
 }
 
 
-HSpace const & BufferParams::getMathIndentation() const
+Length const & BufferParams::getMathIndent() const
 {
-       return pimpl_->math_indentation;
+       return pimpl_->mathindent;
 }
 
 
-void BufferParams::setMathIndentation(HSpace const & indent)
+void BufferParams::setMathIndent(Length const & indent)
 {
-       pimpl_->math_indentation = indent;
+       pimpl_->mathindent = indent;
 }
 
 
-HSpace const & BufferParams::getIndentation() const
+Length const & BufferParams::getParIndent() const
 {
-       return pimpl_->indentation;
+       return pimpl_->parindent;
 }
 
 
-void BufferParams::setIndentation(HSpace const & indent)
+void BufferParams::setParIndent(Length const & indent)
 {
-       pimpl_->indentation = indent;
+       pimpl_->parindent = indent;
 }
 
 
@@ -836,8 +836,11 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                paragraph_separation = parseptranslator().find(parsep);
        } else if (token == "\\paragraph_indentation") {
                lex.next();
-               string indentation = lex.getString();
-               pimpl_->indentation = HSpace(indentation);
+               string parindent = lex.getString();
+               if (parindent == "default")
+                       pimpl_->parindent = Length();
+               else
+                       pimpl_->parindent = Length(parindent);
        } else if (token == "\\defskip") {
                lex.next();
                string const defskip = lex.getString();
@@ -849,8 +852,9 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                lex >> is_math_indent;
        } else if (token == "\\math_indentation") {
                lex.next();
-               string math_indentation = lex.getString();
-               pimpl_->math_indentation = HSpace(math_indentation);
+               pimpl_->mathindent = Length(lex.getString());
+       } else if (token == "\\math_number_before") {
+               lex >> math_number_before;
        } else if (token == "\\quotes_style") {
                string qstyle;
                lex >> qstyle;
@@ -1344,12 +1348,14 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
           << "\n\\paragraph_separation "
           << string_paragraph_separation[paragraph_separation];
        if (!paragraph_separation)
-               os << "\n\\paragraph_indentation " << getIndentation().asLyXCommand();
+               os << "\n\\paragraph_indentation "
+                  << (getParIndent().empty() ? "default" : getParIndent().asString());
        else
                os << "\n\\defskip " << getDefSkip().asLyXCommand();
        os << "\n\\is_math_indent " << is_math_indent;
-       if (is_math_indent)
-               os << "\n\\math_indentation " << getMathIndentation().asLyXCommand();
+       if (is_math_indent && !getMathIndent().empty())
+               os << "\n\\math_indentation " << getMathIndent().asString();
+       os << "\n\\math_number_before " << math_number_before;
        os << "\n\\quotes_style "
           << string_quotes_style[quotes_style]
           << "\n\\dynamic_quotes " << dynamic_quotes
@@ -1634,6 +1640,9 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        if (is_math_indent)
                clsoptions << "fleqn,";
 
+       if (math_number_before)
+               clsoptions << "leqno,";
+
        // language should be a parameter to \documentclass
        if (language->babel() == "hebrew"
            && default_language->babel() != "hebrew")
@@ -1951,9 +1960,9 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        } else {
                // when separation by indentation
                // only output something when a width is given
-               if (getIndentation().asLyXCommand() != "default") {
+               if (!getParIndent().empty()) {
                        os << "\\setlength{\\parindent}{"
-                          << from_utf8(getIndentation().asLatexCommand())
+                          << from_utf8(getParIndent().asLatexString())
                           << "}\n";
                }
        }
@@ -1961,9 +1970,9 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        if (is_math_indent) {
                // when formula indentation
                // only output something when it is not the default
-               if (getMathIndentation().asLyXCommand() != "default") {
+               if (!getMathIndent().empty()) {
                        os << "\\setlength{\\mathindent}{"
-                          << from_utf8(getMathIndentation().asLatexCommand())
+                          << from_utf8(getMathIndent().asString())
                           << "}\n";
                }
        }