X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FTextMetrics.cpp;h=ecc9e5219487d3015fde15ecb0d6aaf336fcb139;hb=3dfe917a4ed504de29ac18028936d02f856c92b1;hp=6c3197cfbc72bbd39b16886112679d29b8497362;hpb=c981018111b0fc9d15f3c23d9cbfa8750e214a80;p=lyx.git diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 6c3197cfbc..ecc9e52194 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,6 +375,21 @@ 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); @@ -393,12 +412,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; @@ -415,8 +433,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); @@ -1049,16 +1067,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()) @@ -1495,7 +1511,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. @@ -1989,7 +2005,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()