]> git.lyx.org Git - lyx.git/blobdiff - src/TextMetrics.cpp
Russian splash.lyx: updates from Yuriy
[lyx.git] / src / TextMetrics.cpp
index f38c78d3ea7d98e6799d17a41898eafe8bba1049..6c5a3222772cf794f6bc31fa27327477e951f3cc 100644 (file)
@@ -39,7 +39,7 @@
 
 #include "insets/InsetText.h"
 
-#include "mathed/MathMacroTemplate.h"
+#include "mathed/InsetMathMacroTemplate.h"
 
 #include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
@@ -97,7 +97,7 @@ int numberOfHfills(Row const & row, ParagraphMetrics const & pm,
 }
 
 
-}
+} // namespace
 
 /////////////////////////////////////////////////////////////////////
 //
@@ -433,7 +433,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
 
                // do the metric calculation
                Dimension dim;
-               int const w = max_width_ - leftMargin(max_width_, pit, ii->pos)
+               int const w = max_width_ - leftMargin(pit, ii->pos)
                        - right_margin - eop;
                Font const & font = ii->inset->inheritFont() ?
                        displayFont(pit, ii->pos) : bufferfont;
@@ -640,8 +640,10 @@ void TextMetrics::computeRowMetrics(Row & row, int width) const
                        break;
                case LYX_ALIGN_LEFT:
                        // a displayed inset that is flushed
-                       if (Inset const * inset = par.getInset(row.pos()))
+                       if (Inset const * inset = par.getInset(row.pos())) {
                                row.left_margin += inset->indent(*bv_);
+                               row.dimension().wid += inset->indent(*bv_);
+                       }
                        break;
                case LYX_ALIGN_RIGHT:
                        if (Inset const * inset = par.getInset(row.pos())) {
@@ -747,7 +749,7 @@ int TextMetrics::labelEnd(pit_type const pit) const
        if (text_->getPar(pit).layout().margintype != MARGIN_MANUAL)
                return 0;
        // return the beginning of the body
-       return leftMargin(max_width_, pit);
+       return leftMargin(pit);
 }
 
 namespace {
@@ -806,7 +808,7 @@ private:
        pos_type bodypos_;
 };
 
-} // anon namespace
+} // namespace
 
 /** This is the function where the hard work is done. The code here is
  * very sensitive to small changes :) Note that part of the
@@ -822,7 +824,7 @@ bool TextMetrics::breakRow(Row & row, int const right_margin) const
        bool need_new_row = false;
 
        row.clear();
-       row.left_margin = leftMargin(max_width_, row.pit(), pos);
+       row.left_margin = leftMargin(row.pit(), pos);
        row.right_margin = right_margin;
        if (is_rtl)
                swap(row.left_margin, row.right_margin);
@@ -963,10 +965,11 @@ bool TextMetrics::breakRow(Row & row, int const right_margin) const
 
        // if the row is too large, try to cut at last separator. In case
        // of success, reset indication that the row was broken abruptly.
-       int const next_width = max_width_ - leftMargin(max_width_, row.pit(), row.endpos())
+       int const next_width = max_width_ - leftMargin(row.pit(), row.endpos())
                - rightMargin(row.pit());
 
-       row.shortenIfNeeded(body_pos, width, next_width);
+       if (row.shortenIfNeeded(body_pos, width, next_width))
+               row.flushed(false);
        row.right_boundary(!row.empty() && row.endpos() < end
                           && row.back().endpos == row.endpos());
        // Last row in paragraph is flushed
@@ -1582,14 +1585,13 @@ bool TextMetrics::isFirstRow(Row const & row) const
 }
 
 
-int TextMetrics::leftMargin(int max_width, pit_type pit) const
+int TextMetrics::leftMargin(pit_type pit) const
 {
-       return leftMargin(max_width, pit, text_->paragraphs()[pit].size());
+       return leftMargin(pit, text_->paragraphs()[pit].size());
 }
 
 
-int TextMetrics::leftMargin(int max_width,
-               pit_type const pit, pos_type const pos) const
+int TextMetrics::leftMargin(pit_type const pit, pos_type const pos) const
 {
        ParagraphList const & pars = text_->paragraphs();
 
@@ -1622,7 +1624,7 @@ int TextMetrics::leftMargin(int max_width,
                                int nestmargin = depth * nestMargin();
                                if (text_->isMainText())
                                        nestmargin += changebarMargin();
-                               l_margin = max(leftMargin(max_width, newpar), nestmargin);
+                               l_margin = max(leftMargin(newpar), nestmargin);
                                // Remove the parindent that has been added
                                // if the paragraph was empty.
                                if (pars[newpar].empty() &&
@@ -1721,7 +1723,7 @@ int TextMetrics::leftMargin(int max_width,
                ParagraphMetrics const & pm = par_metrics_[pit];
                RowList::const_iterator rit = pm.rows().begin();
                RowList::const_iterator end = pm.rows().end();
-               int minfill = max_width;
+               int minfill = max_width_;
                for ( ; rit != end; ++rit)
                        if (rit->fill() < minfill)
                                minfill = rit->fill();
@@ -1729,13 +1731,13 @@ int TextMetrics::leftMargin(int max_width,
                l_margin += minfill;
 #endif
                // also wrong, but much shorter.
-               l_margin += max_width / 2;
+               l_margin += max_width_ / 2;
                break;
        }
        }
 
        if (!par.params().leftIndent().zero())
-               l_margin += par.params().leftIndent().inPixels(max_width, lfm.em());
+               l_margin += par.params().leftIndent().inPixels(max_width_, lfm.em());
 
        LyXAlignment align = par.getAlign();