summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2012-03-15 07:26:54 +0100
committerFridrich Štrba <fridrich.strba@bluewin.ch>2012-03-22 12:30:36 +0100
commitdb51589575d37ca608067ad9904dcc6a09651e8c (patch)
tree230ebb57028e5ef7c574182498aa007c0100d766 /sw
parent51cfbf0cfaec395a99a00f2c20fcba96de9a4427 (diff)
Convert SVARRAY SORT into STL set
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/docdraw.cxx3
-rw-r--r--sw/source/core/doc/docedt.cxx9
-rw-r--r--sw/source/core/docnode/ndcopy.cxx56
-rw-r--r--sw/source/core/inc/mvsave.hxx5
4 files changed, 34 insertions, 39 deletions
diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx
index 2d5671c41f73..cbff06442cd2 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 26a2ad86f9f6..6c73ba1f81a3 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 4aabfbaab488..97557f2ab348 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 6e99ade46633..1e68caece132 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
{