X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FTextMetrics.cpp;h=778da312a714a3af675b44fc90f37e6d9bdf8b65;hb=12f8e7a6f91f4e1c631888f303af5c76c7b0cd6f;hp=72506bb420885f35e4c55ce8213969f78e2db23c;hpb=2b44b0ef4d76ce24b6aa67edb5407a594bcdbb87;p=lyx.git diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 72506bb420..778da312a7 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -158,6 +158,7 @@ pair TextMetrics::first() const pair TextMetrics::last() const { + LASSERT(!par_metrics_.empty(), /**/); ParMetricsCache::const_reverse_iterator it = par_metrics_.rbegin(); return make_pair(it->first, &it->second); } @@ -313,6 +314,9 @@ bool TextMetrics::isRTLBoundary(pit_type pit, pos_type pos) const } +// isRTLBoundary returns false on a real end-of-line boundary, +// because otherwise the two boundary types get mixed up. +// This is the whole purpose of this being in TextMetrics. bool TextMetrics::isRTLBoundary(pit_type pit, pos_type pos, Font const & font) const { @@ -371,21 +375,6 @@ bool TextMetrics::redoParagraph(pit_type const pit) main_text_ = (text_ == &buffer.text()); bool changed = false; - // FIXME: This check ought to be done somewhere else. It is the reason - // why text_ is not const. But then, where else to do it? - // Well, how can you end up with either (a) a biblio environment that - // has no InsetBibitem or (b) a biblio environment with more than one - // InsetBibitem? I think the answer is: when paragraphs are merged; - // when layout is set; when material is pasted. - int const moveCursor = par.checkBiblio(buffer); - if (moveCursor > 0) - const_cast(bv_->cursor()).posForward(); - else if (moveCursor < 0) { - Cursor & cursor = const_cast(bv_->cursor()); - if (cursor.pos() >= -moveCursor) - cursor.posBackward(); - } - // Optimisation: this is used in the next two loops // so better to calculate that once here. int const right_margin = rightMargin(pm); @@ -408,12 +397,11 @@ bool TextMetrics::redoParagraph(pit_type const pit) } // redo insets - // FIXME: We should always use getFont(), see documentation of - // noFontChange() in Inset.h. Font const bufferfont = buffer.params().getFont(); InsetList::const_iterator ii = par.insetList().begin(); InsetList::const_iterator iend = par.insetList().end(); for (; ii != iend; ++ii) { + // FIXME Doesn't this HAVE to be non-empty? // position already initialized? if (!parPos.empty()) { parPos.pos() = ii->pos; @@ -430,8 +418,8 @@ bool TextMetrics::redoParagraph(pit_type const pit) Dimension dim; int const w = max_width_ - leftMargin(max_width_, pit, ii->pos) - right_margin; - Font const & font = ii->inset->noFontChange() ? - bufferfont : displayFont(pit, ii->pos); + Font const & font = ii->inset->inheritFont() ? + displayFont(pit, ii->pos) : bufferfont; MacroContext mc(&buffer, parPos); MetricsInfo mi(bv_, font.fontInfo(), w, mc); ii->inset->metrics(mi, dim); @@ -1064,16 +1052,14 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first, if (first == 0 && topBottomSpace) { BufferParams const & bufparams = buffer.params(); // some parskips VERY EASY IMPLEMENTATION - if (bufparams.paragraph_separation - == BufferParams::ParagraphSkipSeparation - && inset.lyxCode() != ERT_CODE - && inset.lyxCode() != LISTINGS_CODE - && pit > 0 - && ((layout.isParagraph() && par.getDepth() == 0) - || (pars[pit - 1].layout().isParagraph() - && pars[pit - 1].getDepth() == 0))) - { - maxasc += bufparams.getDefSkip().inPixels(*bv_); + if (bufparams.paragraph_separation == BufferParams::ParagraphSkipSeparation + && !inset.getLayout().parbreakIsNewline() + && !par.layout().parbreak_is_newline + && pit > 0 + && ((layout.isParagraph() && par.getDepth() == 0) + || (pars[pit - 1].layout().isParagraph() + && pars[pit - 1].getDepth() == 0))) { + maxasc += bufparams.getDefSkip().inPixels(*bv_); } if (par.params().startOfAppendix()) @@ -1510,7 +1496,7 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y, // This should be just before or just behind the // cursor position set above. LASSERT(inset == inset_before - || inset == pars[pit].getInset(pos), /**/); + || inset == pars[pit].getInset(pos), return 0); // Make sure the cursor points to the position before // this inset. @@ -2004,7 +1990,7 @@ int TextMetrics::leftMargin(int max_width, || (layout.labeltype == LABEL_STATIC && layout.latextype == LATEX_ENVIRONMENT && !text_->isFirstInSequence(pit))) - && align == LYX_ALIGN_BLOCK + && (align == LYX_ALIGN_BLOCK || align == LYX_ALIGN_LEFT) && !par.params().noindent() // in some insets, paragraphs are never indented && !text_->inset().neverIndent()