[Libreoffice-commits] core.git: 4 commits - sw/source

Michael Stahl mstahl at redhat.com
Mon Jan 13 10:45:20 PST 2014


 sw/source/core/txtnode/txtedt.cxx |   58 ++++++++++++++++++++------------------
 1 file changed, 32 insertions(+), 26 deletions(-)

New commits:
commit 9b9b9ccb7ce5c689e86edffef07f6f78f00391c2
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Jan 13 19:16:02 2014 +0100

    SwTxtNode::RstTxtAttr(): remove special case "continue"
    
    The newly inserted hints will always be inserted "behind" the existing
    pHt, since their start position is truly greater than pHt's, so no need
    for "continue" with same i (...and why not i-1 since 2 hints could be
    inserted?).
    
    Change-Id: I3c796e7084dc84a360020dfa0ed362fb3305141a

diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 343cfdf..b26e6ad 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -612,10 +612,6 @@ void SwTxtNode::RstTxtAttr(
                             InsertHint( pNew,
                                 nsSetAttrMode::SETATTR_NOHINTADJUST );
                         }
-
-                        // don't increment, the inserted attribute has pushed
-                        // another onto position i!
-                        continue;
                     }
 
                     // this case appears to rely on InsertHint not re-sorting
commit 8aab0442355a07cd3bdaf58d37a1f242a0ccf123
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Jan 13 19:09:16 2014 +0100

    SwTxtNode::RstTxtAttr(): translate german comments
    
    Change-Id: Ie54ff6147ded6cfe88ac86ec02625fbb4a19b364

diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index f885990..343cfdf 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -488,23 +488,21 @@ void SwTxtNode::RstTxtAttr(
             continue;
         }
 
-        if( nStt <= nAttrStart )          // Faelle: 1,3,5
+        if (nStt <= nAttrStart)     // Case: 1,3,5
         {
             const sal_Int32 nAttrEnd = pAttrEnd != NULL
                                         ? *pAttrEnd
                                         : nAttrStart;
-            if( nEnd > nAttrStart
-                || ( nEnd == nAttrEnd && nEnd == nAttrStart ) )
+            if (nEnd > nAttrStart
+                || (nEnd == nAttrEnd && nEnd == nAttrStart)) // Case: 1,3
             {
-                // Faelle: 1,3
                 if ( nMin > nAttrStart )
                     nMin = nAttrStart;
                 if ( nMax < nAttrEnd )
                     nMax = nAttrEnd;
-                // Falls wir nur ein nichtaufgespanntes Attribut entfernen,
-                // tun wir mal so, als ob sich nichts geaendert hat.
+                // If only a no-extent hint is deleted, no resorting is needed
                 bChanged = bChanged || nEnd > nAttrStart || bNoLen;
-                if( nAttrEnd <= nEnd ) // Fall: 1
+                if (nAttrEnd <= nEnd)   // Case: 1
                 {
                     m_pSwpHints->DeleteAtPos(i);
                     DestroyAttr( pHt );
@@ -521,16 +519,13 @@ void SwTxtNode::RstTxtAttr(
                         break;
 
                     //JP 26.11.96:
-                    // beim DeleteAtPos wird ein Resort ausgefuehrt!!
-                    // darum muessen wir wieder bei 0 anfangen!!!
-                    // ueber den Fall 3 koennen Attribute nach hinten
-                    // verschoben worden sein; damit stimmt jetzt das i
-                    // nicht mehr!!!
+                    // DeleteAtPos does a Resort!  Via Case 3 or 4 hints could
+                    // have been moved around so i is wrong now.
+                    // So we have to start over at 0 again.
                     i = 0;
-
                     continue;
                 }
-                else // Fall: 3
+                else    // Case: 3
                 {
                     m_pSwpHints->NoteInHistory( pHt );
                     // UGLY: this may temporarily destroy the sorting!
@@ -552,11 +547,11 @@ void SwTxtNode::RstTxtAttr(
                 }
             }
         }
-        else if ( pAttrEnd != NULL )    // Faelle: 2,4,5
+        else if (pAttrEnd != 0)         // Case: 2,4,5
         {
-            if( *pAttrEnd > nStt )     // Faelle: 2,4
+            if (*pAttrEnd > nStt)       // Case: 2,4
             {
-                if( *pAttrEnd < nEnd )  // Fall: 2
+                if (*pAttrEnd < nEnd)   // Case: 2
                 {
                     if ( nMin > nAttrStart )
                         nMin = nAttrStart;
@@ -582,10 +577,10 @@ void SwTxtNode::RstTxtAttr(
                     // and pNew being inserted behind pHt
                     assert(pHt == m_pSwpHints->GetTextHint(i));
                 }
-                else if( nLen ) // Fall: 4
+                else if (nLen)  // Case: 4
                 {
-                    // bei Lange 0 werden beide Hints vom Insert(Ht)
-                    // wieder zu einem zusammengezogen !!!!
+                    // for Length 0 both hints would be merged again by
+                    // InsertHint, so leave them alone!
                     if ( nMin > nAttrStart )
                         nMin = nAttrStart;
                     if ( nMax < *pAttrEnd )
@@ -618,8 +613,8 @@ void SwTxtNode::RstTxtAttr(
                                 nsSetAttrMode::SETATTR_NOHINTADJUST );
                         }
 
-                        // jetzt kein i+1, weil das eingefuegte Attribut
-                        // ein anderes auf die Position geschoben hat !
+                        // don't increment, the inserted attribute has pushed
+                        // another onto position i!
                         continue;
                     }
 
@@ -639,7 +634,7 @@ void SwTxtNode::RstTxtAttr(
         {   // possibly sometimes Resort would be sufficient, but...
             m_pSwpHints->MergePortions(*this);
         }
-        //TxtFrm's reagieren auf aHint, andere auf aNew
+        // TxtFrm's respond to aHint, others to aNew
         SwUpdateAttr aHint( nMin, nMax, 0 );
         NotifyClients( 0, &aHint );
         SwFmtChg aNew( GetFmtColl() );
commit 2c2ace30ec9f671042c94ee83dfdc5d6fd5ddd32
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Jan 13 18:52:46 2014 +0100

    SwTxtNode::RstTxtAttr() depends on some implementation details..
    
    ... of the hints array, attempt to document those with assertions.
    
    Change-Id: I5e0310e7a213c7c8fd2e1f992ae91b739a7923a5

diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 9abddfa..f885990 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -533,6 +533,7 @@ void SwTxtNode::RstTxtAttr(
                 else // Fall: 3
                 {
                     m_pSwpHints->NoteInHistory( pHt );
+                    // UGLY: this may temporarily destroy the sorting!
                     *pHt->GetStart() = nEnd;
                     m_pSwpHints->NoteInHistory( pHt, sal_True );
 
@@ -543,6 +544,10 @@ void SwTxtNode::RstTxtAttr(
                         InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST );
                     }
 
+                    // this case appears to rely on InsertHint not re-sorting
+                    // and pNew being inserted behind pHt
+                    assert(pHt == m_pSwpHints->GetTextHint(i));
+
                     bChanged = true;
                 }
             }
@@ -562,6 +567,7 @@ void SwTxtNode::RstTxtAttr(
                     const sal_Int32 nAttrEnd = *pAttrEnd;
 
                     m_pSwpHints->NoteInHistory( pHt );
+                    // UGLY: this may temporarily destroy the sorting!
                     *pAttrEnd = nStt;
                     m_pSwpHints->NoteInHistory( pHt, sal_True );
 
@@ -571,6 +577,10 @@ void SwTxtNode::RstTxtAttr(
                             *pStyleHandle, nStt, nAttrEnd );
                         InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST );
                     }
+
+                    // this case appears to rely on InsertHint not re-sorting
+                    // and pNew being inserted behind pHt
+                    assert(pHt == m_pSwpHints->GetTextHint(i));
                 }
                 else if( nLen ) // Fall: 4
                 {
@@ -583,6 +593,7 @@ void SwTxtNode::RstTxtAttr(
                     bChanged = true;
                     const sal_Int32 nTmpEnd = *pAttrEnd;
                     m_pSwpHints->NoteInHistory( pHt );
+                    // UGLY: this may temporarily destroy the sorting!
                     *pAttrEnd = nStt;
                     m_pSwpHints->NoteInHistory( pHt, sal_True );
 
@@ -611,6 +622,10 @@ void SwTxtNode::RstTxtAttr(
                         // ein anderes auf die Position geschoben hat !
                         continue;
                     }
+
+                    // this case appears to rely on InsertHint not re-sorting
+                    // and pNew being inserted behind pHt
+                    assert(pHt == m_pSwpHints->GetTextHint(i));
                 }
             }
         }
commit 8c59c30153b8a67d9455d70a66b4a42c35120f97
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Jan 13 18:36:04 2014 +0100

    fdo#72788: sw: fix infinite loop in SwTxtAttr::RstTxtAttr
    
    The increment was erroneously moved into the else branch in commit
    c1c5feaff453cfbb23c43f2b423201b883ff048d.
    
    Change-Id: If71cb58967e215548aed5679da86af20de17a0f1

diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index c2c6602..9abddfa 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -613,8 +613,8 @@ void SwTxtNode::RstTxtAttr(
                     }
                 }
             }
-            ++i;
         }
+        ++i;
     }
 
     TryDeleteSwpHints();


More information about the Libreoffice-commits mailing list