[Libreoffice-commits] .: sw/source

Stephan Bergmann sbergmann at kemper.freedesktop.org
Mon Mar 26 03:08:20 PDT 2012


 sw/source/core/layout/paintfrm.cxx |   34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)

New commits:
commit 8945f1bc858f3636d4270f16bd2e66ce88c0021c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Mar 26 11:58:51 2012 +0200

    Fix recent paintfrm.cxx regressions
    
    ...as reported by Linux-RHEL6-x86_64 at 14-with-check tinderbox.
    
    For one, e94c4ab5523c7dcbee2f1b7fd47685529498e774 "Conver SV VARARR to
    std::deque for sw module." did not use rbegin/rend to iterate backwards.
    
    For another, e94c4ab5523c7dcbee2f1b7fd47685529498e774 and subsequent
    1a412714031bf6cf3f7962b044b2edea74899b46 "fixed crash due to use of STL deque
    for SwLineRects" failed to get the nested loop "Remove all help line that are
    almost covered (tables)" at the start of SwSubsRects::PaintSubsidiary converted
    correctly.  This attempt here at fixing it models the original behavior (before
    conversion) more closely, and hopefully gets it right now.

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index a9f60f3..286908a 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -492,7 +492,8 @@ void SwLineRects::AddLineRect( const SwRect &rRect, const Color *pCol, const Svx
     //Loop backwards because lines which can be combined, can usually be painted
     //in the same context.
 
-    for (SwLineRects::iterator it = this->end(); it != this->begin(); --it)
+    for (SwLineRects::reverse_iterator it = this->rbegin(); it != this->rend();
+         ++it)
     {
         SwLineRect &rLRect = (*it);
         // Test for the orientation, color, table
@@ -948,17 +949,14 @@ void SwSubsRects::PaintSubsidiary( OutputDevice *pOut,
         SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *pOut );
 
         // Remove all help line that are almost covered (tables)
-        SwSubsRects::iterator it = this->begin();
-        while ( it != this->end() )
+        for (SwSubsRects::size_type i = 0; i != this->size(); ++i)
         {
-            SwLineRect &rLi = *it;
+            SwLineRect &rLi = (*this)[i];
             const bool bVerticalSubs = rLi.Height() > rLi.Width();
 
-            SwSubsRects::iterator itK = it;
-            while ( itK != this->end() )
+            for (SwSubsRects::size_type k = i + 1; k != this->size(); ++k)
             {
-                bool bRemoved = false;
-                SwLineRect &rLk = (*itK);
+                SwLineRect &rLk = (*this)[k];
                 if ( rLi.SSize() == rLk.SSize() )
                 {
                     if ( bVerticalSubs == ( rLk.Height() > rLk.Width() ) )
@@ -971,11 +969,11 @@ void SwSubsRects::PaintSubsidiary( OutputDevice *pOut,
                                  ((nLi < rLk.Left() && nLi+21 > rLk.Left()) ||
                                   (nLk < rLi.Left() && nLk+21 > rLi.Left())))
                             {
-                                this->erase( itK );
+                                this->erase(this->begin() + k);
                                 // don't continue with inner loop any more:
                                 // the array may shrink!
-                                itK = this->end();
-                                bRemoved = true;
+                                --i;
+                                break;
                             }
                         }
                         else
@@ -986,21 +984,16 @@ void SwSubsRects::PaintSubsidiary( OutputDevice *pOut,
                                  ((nLi < rLk.Top() && nLi+21 > rLk.Top()) ||
                                   (nLk < rLi.Top() && nLk+21 > rLi.Top())))
                             {
-                                this->erase( itK );
+                                this->erase(this->begin() + k);
                                 // don't continue with inner loop any more:
                                 // the array may shrink!
-                                itK = this->end();
-                                bRemoved = true;
+                                --i;
+                                break;
                             }
                         }
                     }
                 }
-
-                if ( !bRemoved )
-                    ++itK;
             }
-
-            ++it;
         }
 
         if ( pRects && (!pRects->empty()) )
@@ -1021,7 +1014,8 @@ void SwSubsRects::PaintSubsidiary( OutputDevice *pOut,
                 pOut->SetDrawMode( 0 );
             }
 
-            for (it = this->begin(); it != this->end(); ++it)
+            for (SwSubsRects::iterator it = this->begin(); it != this->end();
+                 ++it)
             {
                 SwLineRect &rLRect = (*it);
                 // Add condition <!rLRect.IsLocked()> to prevent paint of locked subsidiary lines.


More information about the Libreoffice-commits mailing list