mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Fixup 294e4884
: center correctly Abstract label when paragraph is empty
When a paragraph is empty, it was not possible to query what the left margin would be for an hypothetical second row. Modify TextMetrics::leftMargin so that it does not test whether position is after the last position of the paragraph. Cosmetics: set the size of label to "small" for Abstract layout in standard classes and reduce the spacing between label and text. Fixes remainder of #11939.
This commit is contained in:
parent
b8188e54dd
commit
824d1c993a
@ -27,13 +27,12 @@ Style Abstract
|
||||
Align Block
|
||||
LabelType Centered
|
||||
LabelString "Abstract"
|
||||
LabelBottomSep 0.5
|
||||
LabelBottomSep 0.2
|
||||
Font
|
||||
Size Small
|
||||
EndFont
|
||||
LabelFont
|
||||
Series Bold
|
||||
Size Large
|
||||
EndFont
|
||||
HTMLLabelFirst 1
|
||||
HTMLForceCSS 1
|
||||
|
@ -1598,7 +1598,8 @@ void TextMetrics::deleteLineForward(Cursor & cur)
|
||||
|
||||
int TextMetrics::leftMargin(pit_type pit) const
|
||||
{
|
||||
return leftMargin(pit, text_->paragraphs()[pit].size());
|
||||
// the + 1 is useful when the paragraph is empty
|
||||
return leftMargin(pit, text_->paragraphs()[pit].size() + 1);
|
||||
}
|
||||
|
||||
|
||||
@ -1610,7 +1611,10 @@ int TextMetrics::leftMargin(pit_type const pit, pos_type const pos) const
|
||||
LASSERT(pit < int(pars.size()), return 0);
|
||||
Paragraph const & par = pars[pit];
|
||||
LASSERT(pos >= 0, return 0);
|
||||
LASSERT(pos <= par.size(), return 0);
|
||||
// We do not really care whether pos > par.size(), since we do not
|
||||
// access the data. It can be actially useful, when querying the
|
||||
// margin without indentation (see leftMargin(pit_type).
|
||||
|
||||
Buffer const & buffer = bv_->buffer();
|
||||
//lyxerr << "TextMetrics::leftMargin: pit: " << pit << " pos: " << pos << endl;
|
||||
DocumentClass const & tclass = buffer.params().documentClass();
|
||||
@ -1764,8 +1768,8 @@ int TextMetrics::leftMargin(pit_type const pit, pos_type const pos) const
|
||||
&& !text_->inset().neverIndent()
|
||||
// display style insets do not need indentation
|
||||
&& !(!par.empty()
|
||||
&& par.isInset(pos)
|
||||
&& par.getInset(pos)->rowFlags() & Inset::Display)
|
||||
&& par.isInset(0)
|
||||
&& par.getInset(0)->rowFlags() & Inset::Display)
|
||||
&& (!(tclass.isDefaultLayout(par.layout())
|
||||
|| tclass.isPlainLayout(par.layout()))
|
||||
|| buffer.params().paragraph_separation
|
||||
|
@ -123,12 +123,14 @@ public:
|
||||
int height() const { return dim_.height(); }
|
||||
|
||||
/**
|
||||
* Returns the left beginning of the text.
|
||||
* Returns the left beginning of a row starting at \c pos.
|
||||
* This information cannot be taken from the layout object, because
|
||||
* in LaTeX the beginning of the text fits in some cases
|
||||
* (for example sections) exactly the label-width.
|
||||
*/
|
||||
int leftMargin(pit_type pit, pos_type pos) const;
|
||||
/// Return the left beginning of a row which is not the first one.
|
||||
/// This is the left margin when there is no indentation.
|
||||
int leftMargin(pit_type pit) const;
|
||||
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user