]> git.lyx.org Git - lyx.git/blobdiff - src/TextMetrics.cpp
avoid float-conversion warning and simplify size computation
[lyx.git] / src / TextMetrics.cpp
index 33baa8cafd0940c49d3dd1bb9fd6ed94489cd73e..da9e404cb013813a1cd437f8165322426e13095b 100644 (file)
@@ -385,7 +385,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
                Cursor & cur = const_cast<Cursor &>(bv_->cursor());
                // In some cases, we do not know how to record undo
                if (&cur.inset() == &text_->inset())
-                       cur.recordUndo(ATOMIC_UNDO, pit, pit);
+                       cur.recordUndo(pit, pit);
 
                int const moveCursor = par.fixBiblio(buffer);
 
@@ -777,7 +777,7 @@ private:
 
 /** This is the function where the hard work is done. The code here is
  * very sensitive to small changes :) Note that part of the
- * intelligence is also in Row::shorten_if_needed
+ * intelligence is also in Row::shortenIfNeeded.
  */
 void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit) const
 {
@@ -900,12 +900,6 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit
        // if the row is too large, try to cut at last separator.
        row.shortenIfNeeded(body_pos, width);
 
-       // if the row ends with a separator that is not at end of
-       // paragraph, remove it
-       if (!row.empty() && row.back().type == Row::SEPARATOR
-           && row.endpos() < par.size())
-               row.pop_back();
-
        // make sure that the RTL elements are in reverse ordering
        row.reverseRTL(text_->isRTL(par));
 }
@@ -1616,12 +1610,16 @@ int TextMetrics::leftMargin(int max_width,
        l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
                tclass.leftmargin());
 
-       if (par.getDepth() != 0) {
+       int depth = par.getDepth();
+       if (depth != 0) {
                // find the next level paragraph
                pit_type newpar = text_->outerHook(pit);
                if (newpar != pit_type(pars.size())) {
                        if (pars[newpar].layout().isEnvironment()) {
-                               l_margin = leftMargin(max_width, newpar);
+                               int nestmargin = depth * nestMargin();
+                               if (text_->isMainText())
+                                       nestmargin += changebarMargin();
+                               l_margin = max(leftMargin(max_width, newpar), nestmargin);
                                // Remove the parindent that has been added
                                // if the paragraph was empty.
                                if (pars[newpar].empty() &&
@@ -1884,7 +1882,7 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const
                        || rowSlice == bv_->lastRowSlice();
 
                // Take this opportunity to spellcheck the row contents.
-               if (row_has_changed && lyxrc.spellcheck_continuously) {
+               if (row_has_changed && pi.do_spellcheck && lyxrc.spellcheck_continuously) {
                        text_->getPar(pit).spellCheck();
                }