Kaydet (Commit) db515895 authored tarafından Bartosz Kosiorek's avatar Bartosz Kosiorek Kaydeden (comit) Fridrich Štrba

Convert SVARRAY SORT into STL set

üst 51cfbf0c
......@@ -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
......
......@@ -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
......
......@@ -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;
}
}
......
......@@ -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
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment