sw/source/core/view/viewimp.cxx |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit a6b9fbfc15b9e1756ac8ea939b4c588e3f170c1d
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Mon Jun 20 12:32:07 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Mon Jun 20 14:26:08 2022 +0200

    fix SwViewShellImp::AddPaintRect() for sub-rects (tdf#146536)
    
    Using just two corners to build the new resulting rect works only
    if the new rectangle actually really extends the previous one,
    but the <= means that this may compress also rects that are already
    contained in the previous rect, in which case it's necessary to
    make sure to use union to get the larger coordinate).
    
    Change-Id: Ie4303dfef903bded6d63625531e424a32cc01b06
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136144
    Tested-by: Luboš Luňák <l.lu...@collabora.com>
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx
index 3b216a09b443..f44850d70f82 100644
--- a/sw/source/core/view/viewimp.cxx
+++ b/sw/source/core/view/viewimp.cxx
@@ -132,12 +132,13 @@ bool SwViewShellImp::AddPaintRect( const SwRect &rRect )
         if(!m_pPaintRegion->empty())
         {
             // This function often gets called with rectangles that line up 
vertically.
-            // Try to extend the last one downwards to include the new one.
+            // Try to extend the last one downwards to include the new one 
(use Union()
+            // in case the new one is actually already contained in the last 
one).
             SwRect& last = m_pPaintRegion->back();
             if(last.Left() == rRect.Left() && last.Width() == rRect.Width()
                 && last.Bottom() + 1 >= rRect.Top() && last.Bottom() <= 
rRect.Bottom())
             {
-                last = SwRect( last.TopLeft(), rRect.BottomRight());
+                last.Union(rRect);
                 // And these rectangles lined up vertically often come up in 
groups
                 // that line up horizontally. Try to extend the previous 
rectangle
                 // to the right to include the last one.
@@ -147,7 +148,7 @@ bool SwViewShellImp::AddPaintRect( const SwRect &rRect )
                     if(last2.Top() == last.Top() && last2.Height() == 
last.Height()
                         && last2.Right() + 1 >= last.Left() && last2.Right() 
<= last2.Right())
                     {
-                        last2 = SwRect( last2.TopLeft(), last.BottomRight());
+                        last2.Union(last);
                         m_pPaintRegion->pop_back();
                         return true;
                     }

Reply via email to