mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 23:09:40 +00:00
Cleanup parindent support
Rename (g|s)etter to (get|set)ParIndent(), and rename member variables accordingly. Do not rely on HSpace anymore, since Length does have all we need.
This commit is contained in:
parent
8c4139434f
commit
fc4ca36403
@ -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";
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
///
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user