]> git.lyx.org Git - features.git/commitdiff
Fix flushing of row that was cut after an hyphen
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 27 Jan 2017 15:09:03 +0000 (16:09 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 6 Feb 2017 09:39:38 +0000 (10:39 +0100)
When using Qt stuff in breakAt, it may happen that the row is broken
after an hyphen (whereas the old code would only consider spaces).

The fact that we abuse the Row::right_boundary() property to detect when
a row should be flushed broke justification when a row is cut at an
hyphen.

Fix this by introducing a new Row::flushed() property and set it as needed.
(cherry picked from commit 8e7d0c2002bdc69c95f3a43f7c78d13fe47ce5f3)

src/Row.cpp
src/Row.h
src/TextMetrics.cpp
status.22x

index ba1a5aa9bbca4316c1de22e9ca7031ee43c54d8a..f19a40bf60650d76662aab1e7823af572aa36e45 100644 (file)
@@ -148,7 +148,7 @@ Row::Row()
          sel_beg(-1), sel_end(-1),
          begin_margin_sel(false), end_margin_sel(false),
          changed_(false), crc_(0),
-         pit_(0), pos_(0), end_(0), right_boundary_(false)
+         pit_(0), pos_(0), end_(0), right_boundary_(false), flushed_(false)
 {}
 
 
index b35c976083fccb98744d1524bbcd5faf83ba26b5..91f0e7323921b6807bba7b2e9faaa91e22fb7ba6 100644 (file)
--- a/src/Row.h
+++ b/src/Row.h
@@ -160,6 +160,10 @@ public:
        void right_boundary(bool b) { right_boundary_ = b; }
        ///
        bool right_boundary() const { return right_boundary_; }
+       ///
+       void flushed(bool b) { flushed_ = b; }
+       ///
+       bool flushed() const { return flushed_; }
 
        ///
        Dimension const & dimension() const { return dim_; }
@@ -297,8 +301,10 @@ private:
        pos_type pos_;
        /// one behind last pos covered by this row
        pos_type end_;
-       // Is there is a boundary at the end of the row (display inset...)
+       // Is there a boundary at the end of the row (display inset...)
        bool right_boundary_;
+       // Shall the row be flushed when it is supposed to be justified?
+       bool flushed_;
        /// Row dimension.
        Dimension dim_;
 };
index dbe1f6370dbbb86b3d42a756dd6cedb4e71fce36..280c90a3df4f35bbeced8315007077fe22b46cc4 100644 (file)
@@ -553,8 +553,7 @@ LyXAlignment TextMetrics::getAlign(Paragraph const & par, Row const & row) const
                // not justify stuff, then don't stretch.
                // A forced block alignment can only be overridden the 'no
                // justification on screen' setting.
-               if (((row.right_boundary() || row.endpos() == par.size())
-                    && !forced_block)
+               if ((row.flushed() && !forced_block)
                    || !bv_->buffer().params().justification)
                        align = text_->isRTL(par) ? LYX_ALIGN_RIGHT : LYX_ALIGN_LEFT;
        }
@@ -904,7 +903,7 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit
                        && inset->display())
                    || (!row.empty() && row.back().inset
                        && row.back().inset->display())) {
-                       row.right_boundary(true);
+                       row.flushed(true);
                        need_new_row = par.isNewline(i);
                        ++i;
                        break;
@@ -935,8 +934,13 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit
        // of success, reset indication that the row was broken abruptly.
        int const next_width = max_width_ - leftMargin(max_width_, row.pit(), row.endpos())
                - rightMargin(row.pit());
-       if (row.shortenIfNeeded(body_pos, width, next_width))
-               row.right_boundary(!row.empty() && row.back().endpos == row.endpos());
+
+       row.shortenIfNeeded(body_pos, width, next_width);
+       row.right_boundary(!row.empty() && row.endpos() < end
+                          && row.back().endpos == row.endpos());
+       // Last row in paragraph is flushed
+       if (row.endpos() == end)
+               row.flushed(true);
 
        // make sure that the RTL elements are in reverse ordering
        row.reverseRTL(is_rtl);
index 23deeb493e5abed83260063c5368f35d8833b685..8328b234b656210b67b5fb1b3dc63da8190bd36e 100644 (file)
@@ -164,6 +164,8 @@ What's new
 - Fix wrong on-screen text layout where a word would be alone on a
   line.
 
+- Fix wrong on-screen flushing of a row that was cut after an hyphen.
+
 - Fix crash when the document contains Unicode line-breaking characters.
 
 - Allow using colors supported by xcolor inside mathed (bug 10417).