[Libreoffice-commits] .: 2 commits - sw/inc sw/source

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Feb 8 19:43:47 PST 2011


 sw/inc/undobj.hxx             |   10 +++++++---
 sw/source/core/undo/unnum.cxx |   18 +++++++-----------
 2 files changed, 14 insertions(+), 14 deletions(-)

New commits:
commit a8789d33cfc757630b68b2cf46a68626f5a7fb8a
Author: Nigel Hawkins <n.hawkins at gmx.com>
Date:   Mon Feb 7 16:19:59 2011 +0000

    Replace std::pair with more descriptive names in SwUndoDelNum

diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index e6ea274..ae86015 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -1371,9 +1371,13 @@ public:
 
 class SwUndoDelNum : public SwUndo, private SwUndRng
 {
-    typedef std::vector< std::pair< ULONG, int > > SvNode;
-    SvNode aNodes;
-    SvBools aRstLRSpaces;
+    struct NodeLevel
+    {
+        ULONG index;
+        int level;
+        inline NodeLevel(ULONG idx, int lvl) : index(idx), level(lvl) {};
+    };
+    std::vector<NodeLevel> aNodes;
     SwHistory* pHistory;
 public:
     SwUndoDelNum( const SwPaM& rPam );
diff --git a/sw/source/core/undo/unnum.cxx b/sw/source/core/undo/unnum.cxx
index d5afd1f..f13f94c 100644
--- a/sw/source/core/undo/unnum.cxx
+++ b/sw/source/core/undo/unnum.cxx
@@ -214,11 +214,11 @@ void SwUndoDelNum::Undo( SwUndoIter& rUndoIter )
     pHistory->TmpRollback( &rDoc, 0 );
     pHistory->SetTmpEnd( pHistory->Count() );
 
-    for( SvNode::const_iterator i = aNodes.begin(); i != aNodes.end(); ++i )
+    for( std::vector<NodeLevel>::const_iterator i = aNodes.begin(); i != aNodes.end(); ++i )
     {
-        SwTxtNode* pNd = rDoc.GetNodes()[ i->first ]->GetTxtNode();
-        OSL_ENSURE( pNd, "wo ist der TextNode geblieben?" );
-        pNd->SetAttrListLevel( i->second );
+        SwTxtNode* pNd = rDoc.GetNodes()[ i->index ]->GetTxtNode();
+        OSL_ENSURE( pNd, "Where has the TextNode gone?" );
+        pNd->SetAttrListLevel( i->level );
 
         if( pNd->GetCondFmtColl() )
             pNd->ChkCondColl();
@@ -246,7 +246,7 @@ void SwUndoDelNum::AddNode( const SwTxtNode& rNd, BOOL )
 {
     if( rNd.GetNumRule() )
     {
-        aNodes.push_back( SvNode::value_type( rNd.GetIndex(), rNd.GetActualListLevel() ) );
+        aNodes.push_back( NodeLevel( rNd.GetIndex(), rNd.GetActualListLevel() ) );
     }
 }
 
commit a165669a06c0195691865f20ca57457a53ba1a71
Author: Andrey Turkin <andrey.turkin at gmail.com>
Date:   Tue Feb 8 22:39:41 2011 -0500

    Get rid of SvBytes/SvSvULongs in SwUndoDelNum.

diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index 2252de9..e6ea274 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -1371,8 +1371,8 @@ public:
 
 class SwUndoDelNum : public SwUndo, private SwUndRng
 {
-    SvULongs aNodeIdx;
-    SvBytes aLevels;
+    typedef std::vector< std::pair< ULONG, int > > SvNode;
+    SvNode aNodes;
     SvBools aRstLRSpaces;
     SwHistory* pHistory;
 public:
diff --git a/sw/source/core/undo/unnum.cxx b/sw/source/core/undo/unnum.cxx
index bc2be15..d5afd1f 100644
--- a/sw/source/core/undo/unnum.cxx
+++ b/sw/source/core/undo/unnum.cxx
@@ -190,10 +190,9 @@ void SwUndoInsNum::SaveOldNumRule( const SwNumRule& rOld )
 
 
 SwUndoDelNum::SwUndoDelNum( const SwPaM& rPam )
-    : SwUndo( UNDO_DELNUM ), SwUndRng( rPam ),
-    aNodeIdx( BYTE( nEndNode - nSttNode > 255 ? 255 : nEndNode - nSttNode )),
-    aLevels( BYTE( nEndNode - nSttNode > 255 ? 255 : nEndNode - nSttNode ))
+    : SwUndo( UNDO_DELNUM ), SwUndRng( rPam )
 {
+    aNodes.reserve( nEndNode - nSttNode > 255 ? 255 : nEndNode - nSttNode );
     pHistory = new SwHistory;
 }
 
@@ -215,11 +214,11 @@ void SwUndoDelNum::Undo( SwUndoIter& rUndoIter )
     pHistory->TmpRollback( &rDoc, 0 );
     pHistory->SetTmpEnd( pHistory->Count() );
 
-    for( USHORT n = 0; n < aNodeIdx.Count(); ++n )
+    for( SvNode::const_iterator i = aNodes.begin(); i != aNodes.end(); ++i )
     {
-        SwTxtNode* pNd = rDoc.GetNodes()[ aNodeIdx[ n ] ]->GetTxtNode();
+        SwTxtNode* pNd = rDoc.GetNodes()[ i->first ]->GetTxtNode();
         OSL_ENSURE( pNd, "wo ist der TextNode geblieben?" );
-        pNd->SetAttrListLevel(aLevels[ n ] );
+        pNd->SetAttrListLevel( i->second );
 
         if( pNd->GetCondFmtColl() )
             pNd->ChkCondColl();
@@ -247,10 +246,7 @@ void SwUndoDelNum::AddNode( const SwTxtNode& rNd, BOOL )
 {
     if( rNd.GetNumRule() )
     {
-        USHORT nIns = aNodeIdx.Count();
-        aNodeIdx.Insert( rNd.GetIndex(), nIns );
-
-        aLevels.Insert( static_cast<BYTE>(rNd.GetActualListLevel()), nIns );
+        aNodes.push_back( SvNode::value_type( rNd.GetIndex(), rNd.GetActualListLevel() ) );
     }
 }
 


More information about the Libreoffice-commits mailing list