]> git.lyx.org Git - lyx.git/blobdiff - src/TextMetrics.cpp
info-insert without arg is valid
[lyx.git] / src / TextMetrics.cpp
index 2a9f8497e708b65b61668a33bf88893f12580d16..2b0903c750d23f1398d462db0ddb8e8956300eb5 100644 (file)
@@ -160,7 +160,8 @@ ParagraphMetrics & TextMetrics::parMetrics(pit_type pit, bool redo)
 }
 
 
-bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim, int min_width)
+bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim, int min_width,
+                         bool const expand_on_multipars)
 {
        LBUFERR(mi.base.textwidth > 0);
        max_width_ = mi.base.textwidth;
@@ -170,7 +171,7 @@ bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim, int min_width)
        dim_ = Dimension();
        dim_.wid = min_width;
        pit_type const npar = text_->paragraphs().size();
-       if (npar > 1)
+       if (npar > 1 && expand_on_multipars)
                // If there is more than one row, expand the text to
                // the full allowable width.
                dim_.wid = max_width_;
@@ -468,16 +469,13 @@ bool TextMetrics::redoParagraph(pit_type const pit)
                need_new_row = breakRow(row, right_margin);
                setRowHeight(row);
                row.changed(true);
-               if (row_index || row.endpos() < par.size()
-                   || (row.right_boundary() && par.inInset().lyxCode() != CELL_CODE)) {
+               if ((row_index || row.endpos() < par.size() || row.right_boundary())
+                   && par.inInset().lyxCode() != CELL_CODE) {
                        /* If there is more than one row or the row has been
                         * broken by a display inset or a newline, expand the text
                         * to the full allowable width. This setting here is
-                        * needed for the computeRowMetrics() below. In the case
-                        * of a display inset, we do nothing when inside a table
-                        * cell, because the tabular code is not prepared for
-                        * that, and it triggers when using a caption in a
-                        * longtable (see bugs #9945 and #9757).
+                        * needed for the computeRowMetrics() below.
+                        * We do nothing when inside a table cell.
                         */
                        if (dim_.wid < max_width_)
                                dim_.wid = max_width_;
@@ -1095,8 +1093,6 @@ void TextMetrics::setRowHeight(Row & row) const
        int maxdes = int(fm.maxDescent() * spacing_val);
 
        // Find the ascent/descent of the row contents
-       Row::const_iterator cit = row.begin();
-       Row::const_iterator cend = row.end();
        for (Row::Element const & e : row) {
                if (e.inset) {
                        maxasc = max(maxasc, e.dim.ascent());
@@ -1568,7 +1564,7 @@ void TextMetrics::deleteLineForward(Cursor & cur)
                if (!cur.selection())
                        text_->deleteWordForward(cur);
                else
-                       cap::cutSelection(cur, true, false);
+                       cap::cutSelection(cur, false);
                cur.checkBufferStructure();
        }
 }
@@ -1613,10 +1609,10 @@ int TextMetrics::leftMargin(pit_type const pit, pos_type const pos) const
 
        int l_margin = 0;
 
-       if (text_->isMainText())
+       if (text_->isMainText()) {
                l_margin += bv_->leftMargin();
-
-       l_margin += bfm.signedWidth(tclass.leftmargin());
+               l_margin += bfm.signedWidth(tclass.leftmargin());
+       }
 
        int depth = par.getDepth();
        if (depth != 0) {