[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Thu Jul 17 12:40:59 PDT 2014


 sc/inc/chgtrack.hxx              |    2 
 sc/source/core/tool/chgtrack.cxx |  106 ++++++++++++++++++++-------------------
 2 files changed, 57 insertions(+), 51 deletions(-)

New commits:
commit ebd8d28361a3c0f420346fcafcecadef09efbda5
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Jul 17 15:25:12 2014 -0400

    Scope reduction.
    
    Change-Id: I4caeaf3565255ab141fc4951f1bd149a7af6bb8f

diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 8373605..48e4f7f 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -3163,65 +3163,64 @@ void ScChangeTrack::Undo( sal_uLong nStartAction, sal_uLong nEndAction, bool bMe
             // Deletes are in right order
             ScChangeAction* pAct = IsLastAction(j) ? pLast : GetAction(j);
 
-            if ( pAct )
+            if (!pAct)
+                continue;
+
+            if ( pAct->IsDeleteType() )
             {
-                if ( pAct->IsDeleteType() )
+                if (j == nEndAction || (pAct != pLast && ((ScChangeActionDel*)pAct)->IsTopDelete()))
                 {
-                    if ( j == nEndAction || (pAct != pLast &&
-                            ((ScChangeActionDel*)pAct)->IsTopDelete()) )
-                    {
-                        SetInDeleteTop( true );
-                        SetInDeleteRange( ((ScChangeActionDel*)pAct)->
-                            GetOverAllRange().MakeRange() );
-                    }
+                    SetInDeleteTop( true );
+                    SetInDeleteRange( ((ScChangeActionDel*)pAct)->GetOverAllRange().MakeRange() );
                 }
-                UpdateReference( pAct, true );
-                SetInDeleteTop( false );
-                Remove( pAct );
-                if ( IsInPasteCut() )
-                    aPasteCutMap.insert( ::std::make_pair( pAct->GetActionNumber(), pAct ) );
-                else
-                {
-                    if ( j == nStartAction && pAct->GetType() == SC_CAT_MOVE )
+            }
+            UpdateReference( pAct, true );
+            SetInDeleteTop( false );
+            Remove( pAct );
+            if ( IsInPasteCut() )
+            {
+                aPasteCutMap.insert( ::std::make_pair( pAct->GetActionNumber(), pAct ) );
+                continue;
+            }
+
+            if ( j == nStartAction && pAct->GetType() == SC_CAT_MOVE )
+            {
+                ScChangeActionMove* pMove = (ScChangeActionMove*) pAct;
+                sal_uLong nStart = pMove->GetStartLastCut();
+                sal_uLong nEnd = pMove->GetEndLastCut();
+                if ( nStart && nStart <= nEnd )
+                {   // Recover LastCut
+                    //! Break Links before Cut Append
+                    pMove->RemoveAllLinks();
+                    StartBlockModify( SC_CTM_APPEND, nStart );
+                    for ( sal_uLong nCut = nStart; nCut <= nEnd; nCut++ )
                     {
-                        ScChangeActionMove* pMove = (ScChangeActionMove*) pAct;
-                        sal_uLong nStart = pMove->GetStartLastCut();
-                        sal_uLong nEnd = pMove->GetEndLastCut();
-                        if ( nStart && nStart <= nEnd )
-                        {   // Recover LastCut
-                            //! Break Links before Cut Append
-                            pMove->RemoveAllLinks();
-                            StartBlockModify( SC_CTM_APPEND, nStart );
-                            for ( sal_uLong nCut = nStart; nCut <= nEnd; nCut++ )
-                            {
-                                ScChangeActionMap::iterator itCut = aPasteCutMap.find( nCut );
+                        ScChangeActionMap::iterator itCut = aPasteCutMap.find( nCut );
 
-                                if ( itCut != aPasteCutMap.end() )
-                                {
-                                    OSL_ENSURE( aMap.find( nCut ) == aMap.end(), "ScChangeTrack::Undo: nCut dup" );
-                                    Append( itCut->second, nCut );
-                                    aPasteCutMap.erase( itCut );
-                                }
-                                else
-                                {
-                                    OSL_FAIL( "ScChangeTrack::Undo: nCut not found" );
-                                }
-                            }
-                            EndBlockModify( nEnd );
-                            ResetLastCut();
-                            nStartLastCut = nStart;
-                            nEndLastCut = nEnd;
-                            pLastCutMove = pMove;
-                            SetLastCutMoveRange(
-                                pMove->GetFromRange().MakeRange(), pDoc );
+                        if ( itCut != aPasteCutMap.end() )
+                        {
+                            OSL_ENSURE( aMap.find( nCut ) == aMap.end(), "ScChangeTrack::Undo: nCut dup" );
+                            Append( itCut->second, nCut );
+                            aPasteCutMap.erase( itCut );
                         }
                         else
-                            delete pMove;
+                        {
+                            OSL_FAIL( "ScChangeTrack::Undo: nCut not found" );
+                        }
                     }
-                    else
-                        delete pAct;
+                    EndBlockModify( nEnd );
+                    ResetLastCut();
+                    nStartLastCut = nStart;
+                    nEndLastCut = nEnd;
+                    pLastCutMove = pMove;
+                    SetLastCutMoveRange(
+                        pMove->GetFromRange().MakeRange(), pDoc );
                 }
+                else
+                    delete pMove;
             }
+            else
+                delete pAct;
         }
         EndBlockModify( nEndAction );
     }
commit efd6fc5e99d89509129469843bbdf3e8f94b58a4
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Jul 17 15:21:43 2014 -0400

    Unwind this logic and make it easier to read.
    
    Change-Id: Iaf4ccc8949fb823a7bd3329c0164443220573b03

diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index 59b4058..f036f79 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -1013,6 +1013,8 @@ class ScChangeTrack : public utl::ConfigurationListener
                                 // bRecursion == called from reject with table
     bool Reject( ScChangeAction*, ScChangeActionMap*, bool bRecursion );
 
+    bool IsLastAction( sal_uLong nNum ) const;
+
             void                ClearMsgQueue();
     virtual void                ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ) SAL_OVERRIDE;
 
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 80a66cd..8373605 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -3161,8 +3161,8 @@ void ScChangeTrack::Undo( sal_uLong nStartAction, sal_uLong nEndAction, bool bMe
         for ( sal_uLong j = nEndAction; j >= nStartAction; --j )
         {   // Traverse backwards to recycle nActionMax and for faster access via pLast
             // Deletes are in right order
-            ScChangeAction* pAct = ( (j == nActionMax && pLast &&
-                pLast->GetActionNumber() == j) ? pLast : GetAction( j ) );
+            ScChangeAction* pAct = IsLastAction(j) ? pLast : GetAction(j);
+
             if ( pAct )
             {
                 if ( pAct->IsDeleteType() )
@@ -4409,6 +4409,11 @@ bool ScChangeTrack::Reject(
     return bRejected;
 }
 
+bool ScChangeTrack::IsLastAction( sal_uLong nNum ) const
+{
+    return nNum == nActionMax && pLast && pLast->GetActionNumber() == nNum;
+}
+
 sal_uLong ScChangeTrack::AddLoadedGenerated(
     const ScCellValue& rNewCell, const ScBigRange& aBigRange, const OUString& sNewValue )
 {


More information about the Libreoffice-commits mailing list