[Libreoffice-commits] .: sw/source

Fridrich Strba fridrich at kemper.freedesktop.org
Thu Mar 22 04:30:41 PDT 2012


 sw/source/core/doc/docdraw.cxx    |    3 --
 sw/source/core/doc/docedt.cxx     |    9 ++----
 sw/source/core/docnode/ndcopy.cxx |   56 +++++++++++++++++++-------------------
 sw/source/core/inc/mvsave.hxx     |    5 +--
 4 files changed, 34 insertions(+), 39 deletions(-)

New commits:
commit db51589575d37ca608067ad9904dcc6a09651e8c
Author: Bartosz Kosiorek <gang65 at poczta.onet.pl>
Date:   Thu Mar 15 07:26:54 2012 +0100

    Convert SVARRAY SORT into STL set

diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx
index 2d5671c..cbff064 100644
--- a/sw/source/core/doc/docdraw.cxx
+++ b/sw/source/core/doc/docdraw.cxx
@@ -76,9 +76,6 @@
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::linguistic2;
 
-
-SV_IMPL_VARARR_SORT( _ZSortFlys, _ZSortFly )
-
 /*************************************************************************
 |*
 |*  SwDoc::GroupSelection / SwDoc::UnGroupSelection
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 26a2ad8..6c73ba1 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -163,7 +163,6 @@ struct _SaveRedline
 
 SV_DECL_PTRARR_DEL( _SaveRedlines, _SaveRedline*, 0 )
 
-SV_IMPL_VARARR( _SaveFlyArr, _SaveFly )
 SV_IMPL_PTRARR( _SaveRedlines, _SaveRedline* )
 
 bool lcl_MayOverwrite( const SwTxtNode *pNode, const xub_StrLen nPos )
@@ -191,7 +190,7 @@ void _RestFlyInRange( _SaveFlyArr & rArr, const SwNodeIndex& rSttIdx,
                       const SwNodeIndex* pInsertPos )
 {
     SwPosition aPos( rSttIdx );
-    for( sal_uInt16 n = 0; n < rArr.Count(); ++n )
+    for( size_t n = 0; n < rArr.size(); ++n )
     {
         // create new anchor
         _SaveFly& rSave = rArr[n];
@@ -234,7 +233,7 @@ void _SaveFlyInRange( const SwNodeRange& rRg, _SaveFlyArr& rArr )
         {
             _SaveFly aSave( pAPos->nNode.GetIndex() - rRg.aStart.GetIndex(),
                             pFmt, sal_False );
-            rArr.Insert( aSave, rArr.Count());
+            rArr.push_back( aSave );
             pFmt->DelFrms();
             rFmts.Remove( n--, 1 );
         }
@@ -295,7 +294,7 @@ void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos,
             {
                 _SaveFly aSave( pAPos->nNode.GetIndex() - rSttNdIdx.GetIndex(),
                                 pFmt, bInsPos );
-                rArr.Insert( aSave, rArr.Count());
+                rArr.push_back( aSave );
                 pFmt->DelFrms();
                 rFmts.Remove( n--, 1 );
             }
@@ -1188,7 +1187,7 @@ bool SwDoc::MoveNodeRange( SwNodeRange& rRange, SwNodeIndex& rPos,
     }
 
     // move the Flys to the new position
-    if( aSaveFlyArr.Count() )
+    if( !aSaveFlyArr.empty() )
         _RestFlyInRange( aSaveFlyArr, aIdx, NULL );
 
     // Add the Bookmarks back to the Document
diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx
index 4aabfba..97557f2 100644
--- a/sw/source/core/docnode/ndcopy.cxx
+++ b/sw/source/core/docnode/ndcopy.cxx
@@ -53,6 +53,8 @@
 #include <pagedesc.hxx>
 #include <poolfmt.hxx>
 #include <SwNodeNum.hxx>
+#include <set>
+#include <vector>
 
 #ifdef DBG_UTIL
 #define CHECK_TABLE(t) (t).CheckConsistency();
@@ -328,7 +330,7 @@ sal_Bool lcl_CopyTblLine( const SwTableLine*& rpLine, void* pPara );
 
 sal_Bool lcl_CopyTblBox( const SwTableBox*& rpBox, void* pPara )
 {
-    _CopyTable* pCT = (_CopyTable*)pPara;
+    _CopyTable* pCT = reinterpret_cast< _CopyTable* >(pPara);
 
     SwTableBoxFmt* pBoxFmt = (SwTableBoxFmt*)rpBox->GetFrmFmt();
     pCT->rMapArr.ForEach( lcl_SrchNew, &pBoxFmt );
@@ -392,7 +394,7 @@ sal_Bool lcl_CopyTblBox( const SwTableBox*& rpBox, void* pPara )
 
 sal_Bool lcl_CopyTblLine( const SwTableLine*& rpLine, void* pPara )
 {
-    _CopyTable* pCT = (_CopyTable*)pPara;
+    _CopyTable* pCT = reinterpret_cast< _CopyTable* >(pPara);
     SwTableLineFmt* pLineFmt = (SwTableLineFmt*)rpLine->GetFrmFmt();
     pCT->rMapArr.ForEach( lcl_SrchNew, &pLineFmt );
     if( pLineFmt == rpLine->GetFrmFmt() )   // ein neues anlegen ??
@@ -1403,7 +1405,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg,
     //            die Ordnungsnummer (wird nur im DrawModel verwaltet)
     //            beibehalten.
     SwDoc *const pDest = rStartIdx.GetNode().GetDoc();
-    _ZSortFlys aArr;
+    ::std::set< _ZSortFly > aSet;
     sal_uInt16 nArrLen = GetSpzFrmFmts()->Count();
 
     for ( sal_uInt16 n = 0; n < nArrLen; ++n )
@@ -1467,22 +1469,20 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg,
                 }
             }
             if( bAdd )
-                aArr.Insert( _ZSortFly( pFmt, pAnchor, nArrLen + aArr.Count() ));
+                aSet.insert( _ZSortFly( pFmt, pAnchor, nArrLen + aSet.size() ));
         }
     }
 
     //Alle kopierten (also die neu erzeugten) Rahmen in ein weiteres Array
     //stopfen. Dort sizten sie passend zu den Originalen, damit hinterher
     //die Chains entsprechend aufgebaut werden koennen.
-    SvPtrarr aNewArr( 10 );
+    ::std::vector< SwFrmFmt* > aVecSwFrmFmt;
 
-    for ( sal_uInt16 n = 0; n < aArr.Count(); ++n )
+    for (::std::set< _ZSortFly >::const_iterator it=aSet.begin() ; it != aSet.end(); it++ )
     {
-        const _ZSortFly& rZSortFly = aArr[ n ];
-
         // #i59964#
         // correct determination of new anchor position
-        SwFmtAnchor aAnchor( *rZSortFly.GetAnchor() );
+        SwFmtAnchor aAnchor( *(*it).GetAnchor() );
         SwPosition* pNewPos = (SwPosition*)aAnchor.GetCntntAnchor();
         // for at-paragraph and at-character anchored objects the new anchor
         // position can *not* be determined by the difference of the current
@@ -1571,7 +1571,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg,
         sal_Bool bMakeCpy = sal_True;
         if( pDest == this )
         {
-            const SwFmtCntnt& rCntnt = rZSortFly.GetFmt()->GetCntnt();
+            const SwFmtCntnt& rCntnt = (*it).GetFmt()->GetCntnt();
             const SwStartNode* pSNd;
             if( rCntnt.GetCntntIdx() &&
                 0 != ( pSNd = rCntnt.GetCntntIdx()->GetNode().GetStartNode() ) &&
@@ -1579,42 +1579,42 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg,
                 rStartIdx.GetIndex() < pSNd->EndOfSectionIndex() )
             {
                 bMakeCpy = sal_False;
-                aArr.Remove( n, 1 );
-                --n;
+                aSet.erase ( it );
             }
         }
 
         // Format kopieren und den neuen Anker setzen
         if( bMakeCpy )
-            aNewArr.Insert( pDest->CopyLayoutFmt( *rZSortFly.GetFmt(),
-                        aAnchor, false, true ), aNewArr.Count() );
+            aVecSwFrmFmt.push_back( pDest->CopyLayoutFmt( *(*it).GetFmt(),
+                        aAnchor, false, true ) );
     }
 
     //Alle chains, die im Original vorhanden sind, soweit wie moeglich wieder
     //aufbauen.
-    OSL_ENSURE( aArr.Count() == aNewArr.Count(), "Missing new Flys" );
-    if ( aArr.Count() == aNewArr.Count() )
+    OSL_ENSURE( aSet.size() == aVecSwFrmFmt.size(), "Missing new Flys" );
+    if ( aSet.size() == aVecSwFrmFmt.size() )
     {
-        for ( sal_uInt16 n = 0; n < aArr.Count(); ++n )
+        size_t n = 0;
+        for (::std::set< _ZSortFly >::const_iterator nIt=aSet.begin() ; nIt != aSet.end(); ++nIt, ++n )
         {
-            const SwFrmFmt *pFmt = aArr[n].GetFmt();
-            const SwFmtChain &rChain = pFmt->GetChain();
+            const SwFrmFmt *pFmtN = (*nIt).GetFmt();
+            const SwFmtChain &rChain = pFmtN->GetChain();
             int nCnt = 0 != rChain.GetPrev();
             nCnt += rChain.GetNext() ? 1: 0;
-            for ( sal_uInt16 k = 0; nCnt && k < aArr.Count(); ++k )
+            size_t k = 0;
+            for (::std::set< _ZSortFly >::const_iterator kIt=aSet.begin() ; kIt != aSet.end(); ++kIt, ++k )
             {
-                const _ZSortFly &rTmp = aArr[k];
-                const SwFrmFmt *pTmp = rTmp.GetFmt();
-                if ( rChain.GetPrev() == pTmp )
+                const SwFrmFmt *pFmtK = (*kIt).GetFmt();
+                if ( rChain.GetPrev() == pFmtK )
                 {
-                    ::lcl_ChainFmts( (SwFlyFrmFmt*)aNewArr[k],
-                                     (SwFlyFrmFmt*)aNewArr[n] );
+                    ::lcl_ChainFmts( dynamic_cast< SwFlyFrmFmt* >(aVecSwFrmFmt[k]),
+                                     dynamic_cast< SwFlyFrmFmt* >(aVecSwFrmFmt[n]) );
                     --nCnt;
                 }
-                else if ( rChain.GetNext() == pTmp )
+                else if ( rChain.GetNext() == pFmtK )
                 {
-                    ::lcl_ChainFmts( (SwFlyFrmFmt*)aNewArr[n],
-                                     (SwFlyFrmFmt*)aNewArr[k] );
+                    ::lcl_ChainFmts( dynamic_cast< SwFlyFrmFmt* >(aVecSwFrmFmt[n]),
+                                     dynamic_cast< SwFlyFrmFmt* >(aVecSwFrmFmt[k]) );
                     --nCnt;
                 }
             }
diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx
index 6e99ade..1e68cae 100644
--- a/sw/source/core/inc/mvsave.hxx
+++ b/sw/source/core/inc/mvsave.hxx
@@ -32,6 +32,7 @@
 #include <svl/svarray.hxx>
 #include <IDocumentMarkAccess.hxx>
 #include <vector>
+#include <deque>
 
 namespace sfx2 {
     class MetadatableUndo;
@@ -111,7 +112,7 @@ struct _SaveFly
     { }
 };
 
-SV_DECL_VARARR( _SaveFlyArr, _SaveFly, 0 )
+typedef ::std::deque< _SaveFly > _SaveFlyArr;
 
 void _RestFlyInRange( _SaveFlyArr& rArr, const SwNodeIndex& rSttIdx,
                       const SwNodeIndex* pInsPos );
@@ -182,8 +183,6 @@ public:
     const SwFmtAnchor* GetAnchor() const        { return pAnchor; }
 };
 
-SV_DECL_VARARR_SORT( _ZSortFlys, _ZSortFly, 0 )
-
 
 class SwTblNumFmtMerge
 {


More information about the Libreoffice-commits mailing list