]> git.lyx.org Git - lyx.git/blobdiff - src/TextMetrics.cpp
listerrors.lyx : Update a link.
[lyx.git] / src / TextMetrics.cpp
index 4ca0592e74fa8e7779c2c9561b34d8ba077735f9..50f6062275a685b238031c94eb8c02cccc8bf8f5 100644 (file)
@@ -158,6 +158,7 @@ pair<pit_type, ParagraphMetrics const *> TextMetrics::first() const
 
 pair<pit_type, ParagraphMetrics const *> TextMetrics::last() const
 {
+       LASSERT(!par_metrics_.empty(), /**/);
        ParMetricsCache::const_reverse_iterator it = par_metrics_.rbegin();
        return make_pair(it->first, &it->second);
 }
@@ -374,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<Cursor &>(bv_->cursor()).posForward();
+       else if (moveCursor < 0) {
+               Cursor & cursor = const_cast<Cursor &>(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);
@@ -400,6 +416,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
        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;
@@ -581,6 +598,11 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
                        }
                }
 
+               // Has the user requested we not justify stuff?
+               if (!bv_->buffer().params().justification
+                   && align == LYX_ALIGN_BLOCK)
+                       align = LYX_ALIGN_LEFT;
+
                switch (align) {
                case LYX_ALIGN_BLOCK: {
                        int const ns = numberOfSeparators(par, row);
@@ -1050,16 +1072,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())
@@ -1496,7 +1516,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.