]> git.lyx.org Git - lyx.git/blobdiff - src/text.C
ws fixes
[lyx.git] / src / text.C
index 9a17b781d3997042f3da0fafc63f57797ce5f77d..9a668d4bfc28e2c7a60e356628d520eba8b619b5 100644 (file)
@@ -527,8 +527,6 @@ void LyXText::rowBreakPoint(ParagraphList::iterator pit, Row & row) const
                        }
 
                        x += thiswidth;
-                       //lyxerr << "i: " << i << " x: "
-                       //<< x << " width: " << width << endl;
                        chunkwidth += thiswidth;
                }
 
@@ -537,10 +535,11 @@ void LyXText::rowBreakPoint(ParagraphList::iterator pit, Row & row) const
                if (x >= width) {
                        // if no break before, break here
                        if (point == end || chunkwidth >= width - left) {
-                               if (i > pos) {
+                               if (i > pos)
                                        point = i;
-                                       break;
-                               }
+                               else
+                                       point = i + 1;
+
                        }
                        // exit on last registered breakpoint:
                        break;
@@ -571,8 +570,7 @@ void LyXText::rowBreakPoint(ParagraphList::iterator pit, Row & row) const
 }
 
 
-// returns the minimum space a row needs on the screen in pixel
-void LyXText::fill(ParagraphList::iterator pit, Row & row, int workwidth) const
+void LyXText::setRowWidth(ParagraphList::iterator pit, Row & row) const
 {
        // get the pure distance
        pos_type const end = row.endpos();
@@ -611,9 +609,7 @@ void LyXText::fill(ParagraphList::iterator pit, Row & row, int workwidth) const
                w = max(w, labelEnd(pit));
        }
 
-       int const fill = workwidth - w - rightMargin(*pit);
-       row.fill(fill);
-       row.width(workwidth - fill);
+       row.width(w + rightMargin(*pit));
 }
 
 
@@ -1026,7 +1022,7 @@ void LyXText::charInserted()
 
 void LyXText::prepareToPrint(ParagraphList::iterator pit, Row & row) const
 {
-       double w = row.fill();
+       double w = textWidth() - row.width();
        double fill_hfill = 0;
        double fill_label_hfill = 0;
        double fill_separator = 0;
@@ -1088,32 +1084,32 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit, Row & row) const
                }
 
                switch (align) {
-    case LYX_ALIGN_BLOCK: {
-                               int const ns = numberOfSeparators(*pit, row);
-                               bool disp_inset = false;
-                               if (row.endpos() < pit->size()) {
-                                       InsetBase * in = pit->getInset(row.endpos());
-                                       if (in)
-                                               disp_inset = in->display();
-                               }
-                               // If we have separators, this is not the last row of a
-                               // par, does not end in newline, and is not row above a
-                               // display inset... then stretch it
-                               if (ns
-                                       && row.endpos() < pit->size()
-                                       && !pit->isNewline(row.endpos() - 1)
-                                       && !disp_inset
-                                       ) {
-                                               fill_separator = w / ns;
-                               } else if (is_rtl) {
-                                       x += w;
-                               }
-                               break;
+               case LYX_ALIGN_BLOCK: {
+                       int const ns = numberOfSeparators(*pit, row);
+                       bool disp_inset = false;
+                       if (row.endpos() < pit->size()) {
+                               InsetBase * in = pit->getInset(row.endpos());
+                               if (in)
+                                       disp_inset = in->display();
                        }
-    case LYX_ALIGN_RIGHT:
+                       // If we have separators, this is not the last row of a
+                       // par, does not end in newline, and is not row above a
+                       // display inset... then stretch it
+                       if (ns
+                           && row.endpos() < pit->size()
+                           && !pit->isNewline(row.endpos() - 1)
+                           && !disp_inset
+                               ) {
+                               fill_separator = w / ns;
+                       } else if (is_rtl) {
+                               x += w;
+                       }
+                       break;
+               }
+               case LYX_ALIGN_RIGHT:
                        x += w;
                        break;
-    case LYX_ALIGN_CENTER:
+               case LYX_ALIGN_CENTER:
                        x += w / 2;
                        break;
                }
@@ -1596,14 +1592,14 @@ void LyXText::redoParagraphInternal(ParagraphList::iterator pit)
        do {
                Row row(z);
                rowBreakPoint(pit, row);
-               z = row.endpos();
-               fill(pit, row, textwidth_);
+               setRowWidth(pit, row);
                prepareToPrint(pit, row);
                setHeightOfRow(pit, row);
                row.y_offset(pit->height);
                pit->rows.push_back(row);
                pit->width = std::max(pit->width, row.width());
                pit->height += row.height();
+               z = row.endpos();
        } while (z < pit->size());
 
        height += pit->height;