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);
}
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();
&& !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
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;
///