diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 1c00dbdd97..73b47436b8 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -337,10 +337,10 @@ public: Bullet user_defined_bullets[4]; IndicesList indiceslist; Spacing spacing; + Length parindent; /** 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; @@ -641,15 +641,15 @@ void BufferParams::setMathIndentation(HSpace const & 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; } @@ -835,9 +835,7 @@ string BufferParams::readToken(Lexer & lex, string const & token, lex >> parsep; paragraph_separation = parseptranslator().find(parsep); } else if (token == "\\paragraph_indentation") { - lex.next(); - string indentation = lex.getString(); - pimpl_->indentation = HSpace(indentation); + lex >> pimpl_->parindent; } else if (token == "\\defskip") { lex.next(); string const defskip = lex.getString(); @@ -1344,7 +1342,7 @@ 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 " << Lexer::quoteString(pimpl_->parindent.asString()); else os << "\n\\defskip " << getDefSkip().asLyXCommand(); os << "\n\\is_math_indent " << is_math_indent; @@ -1951,9 +1949,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"; } } diff --git a/src/BufferParams.h b/src/BufferParams.h index 3b0b8a79de..14935a9370 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -44,6 +44,7 @@ class IndicesList; class Language; class LayoutFile; class LayoutFileIndex; +class Length; class Lexer; class PDFOptions; class Spacing; @@ -93,9 +94,9 @@ public: bool hasClassDefaults() const; /// - HSpace const & getIndentation() const; + Length const & getParIndent() const; /// - void setIndentation(HSpace const & indent); + void setParIndent(Length const & indent); /// VSpace const & getDefSkip() const; /// diff --git a/src/HSpace.cpp b/src/HSpace.cpp index 7d03ecc1d7..8a56899a12 100644 --- a/src/HSpace.cpp +++ b/src/HSpace.cpp @@ -145,7 +145,7 @@ int HSpace::inPixels(BufferView const & bv) const switch (kind_) { case DEFAULT: // FIXME: replace by correct length - return bv.buffer().params().getIndentation().inPixels(bv); + return bv.buffer().params().getParIndent().inPixels(bv.workWidth()); case LENGTH: return len_.len().inPixels(bv.workWidth()); default: diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 13c1d02cdf..bb38914149 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -1717,32 +1717,32 @@ int TextMetrics::leftMargin(int max_width, // set the correct parindent if (pos == 0 && (layout.labeltype == LABEL_NO_LABEL - || layout.labeltype == LABEL_ABOVE - || layout.labeltype == LABEL_CENTERED - || (layout.labeltype == LABEL_STATIC - && layout.latextype == LATEX_ENVIRONMENT - && !text_->isFirstInSequence(pit))) + || layout.labeltype == LABEL_ABOVE + || layout.labeltype == LABEL_CENTERED + || (layout.labeltype == LABEL_STATIC + && layout.latextype == LATEX_ENVIRONMENT + && !text_->isFirstInSequence(pit))) && (align == LYX_ALIGN_BLOCK || align == LYX_ALIGN_LEFT) && !par.params().noindent() // in some insets, paragraphs are never indented && !text_->inset().neverIndent() // display style insets are always centered, omit indentation && !(!par.empty() - && par.isInset(pos) - && par.getInset(pos)->display()) + && par.isInset(pos) + && par.getInset(pos)->display()) && (!(tclass.isDefaultLayout(par.layout()) - || tclass.isPlainLayout(par.layout())) + || tclass.isPlainLayout(par.layout())) || buffer.params().paragraph_separation == BufferParams::ParagraphIndentSeparation)) { - // use the parindent of the layout when the - // default indentation is used otherwise use - // the indentation set in the document - // settings - if (buffer.params().getIndentation().asLyXCommand() == "default") - l_margin += bfm.signedWidth(parindent); - else - l_margin += buffer.params().getIndentation().inPixels(*bv_); - } + /* use the parindent of the layout when the default + * indentation is used otherwise use the indentation set in + * the document settings + */ + if (buffer.params().getParIndent().empty()) + l_margin += bfm.signedWidth(parindent); + else + l_margin += buffer.params().getParIndent().inPixels(max_width_, bfm.em()); + } return l_margin; } diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index b1db0e9886..52515dd85c 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -2953,19 +2953,19 @@ void GuiDocument::applyView() bp_.paragraph_separation = BufferParams::ParagraphIndentSeparation; switch (textLayoutModule->indentCO->currentIndex()) { case 0: - bp_.setIndentation(HSpace(HSpace::DEFAULT)); + bp_.setParIndent(Length()); break; case 1: { - HSpace indent = HSpace( + Length indent( widgetsToLength(textLayoutModule->indentLE, textLayoutModule->indentLengthCO) ); - bp_.setIndentation(indent); + bp_.setParIndent(indent); break; } default: // this should never happen - bp_.setIndentation(HSpace(HSpace::DEFAULT)); + bp_.setParIndent(Length()); break; } } else { @@ -3445,12 +3445,12 @@ void GuiDocument::paramsToDialog() if (bp_.paragraph_separation == BufferParams::ParagraphIndentSeparation) { textLayoutModule->indentRB->setChecked(true); - string indentation = bp_.getIndentation().asLyXCommand(); + string parindent = bp_.getParIndent().asString(); int indent = 0; - if (indentation != "default") { + if (!parindent.empty()) { lengthToWidgets(textLayoutModule->indentLE, - textLayoutModule->indentLengthCO, - indentation, default_unit); + textLayoutModule->indentLengthCO, + parindent, default_unit); indent = 1; } textLayoutModule->indentCO->setCurrentIndex(indent);