Kaydet (Commit) 5a4796f7 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Michael Stahl

Convert SV_DECL_PTRARR_DEL(SwUnoCrsrTbl) to std::set

Change-Id: I0d79505e2d97b1f8608e6d6e72b317bfaa344b1d
üst 49f78145
......@@ -30,7 +30,9 @@
#include <com/sun/star/i18n/ForbiddenCharacters.hpp>
#include <vector>
#include <set>
#include <algorithm>
#include <svl/svarray.hxx>
class SwFieldType;
class SwFmt;
......@@ -51,7 +53,6 @@ namespace com { namespace sun { namespace star { namespace i18n {
}}}}
#include <swtypes.hxx>
#include <svl/svarray.hxx>
// provides some methods for generic operations on lists that contain
// SwFmt* subclasses.
......@@ -174,8 +175,11 @@ public:
using _SwRedlineTbl::GetPos;
};
typedef SwUnoCrsr* SwUnoCrsrPtr;
SV_DECL_PTRARR_DEL( SwUnoCrsrTbl, SwUnoCrsrPtr, 0 )
class SwUnoCrsrTbl : public std::set<SwUnoCrsr*> {
public:
// the destructor will free all objects still in the set
~SwUnoCrsrTbl();
};
class SwOLENodes : public std::vector<SwOLENode*> {};
......
......@@ -32,8 +32,6 @@
#include <docary.hxx>
#include <rootfrm.hxx>
SV_IMPL_PTRARR( SwUnoCrsrTbl, SwUnoCrsrPtr )
IMPL_FIXEDMEMPOOL_NEWDEL( SwUnoCrsr )
SwUnoCrsr::SwUnoCrsr( const SwPosition &rPos, SwPaM* pRing )
......@@ -51,12 +49,9 @@ SwUnoCrsr::~SwUnoCrsr()
{
// then remove cursor from array
SwUnoCrsrTbl& rTbl = (SwUnoCrsrTbl&)pDoc->GetUnoCrsrTbl();
sal_uInt16 nDelPos = rTbl.GetPos( this );
if( USHRT_MAX != nDelPos )
rTbl.Remove( nDelPos );
else {
OSL_ENSURE( !this, "UNO cursor not anymore in array" );
if( !rTbl.erase( this ) )
{
OSL_ENSURE( !this, "UNO Cursor nicht mehr im Array" );
}
}
......@@ -258,4 +253,13 @@ void SwUnoTableCrsr::MakeBoxSels()
}
}
SwUnoCrsrTbl::~SwUnoCrsrTbl()
{
while (!empty())
{
delete *begin();
erase( begin() );
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -2662,7 +2662,7 @@ SwUnoCrsr* SwDoc::CreateUnoCrsr( const SwPosition& rPos, sal_Bool bTblCrsr )
else
pNew = new SwUnoCrsr( rPos );
pUnoCrsrTbl->Insert( pNew, pUnoCrsrTbl->Count() );
pUnoCrsrTbl->insert( pNew );
return pNew;
}
......
......@@ -1418,15 +1418,15 @@ void _SaveCntntIdx(SwDoc* pDoc,
{
aSave.SetTypeAndCount( 0x400, 0 );
const SwUnoCrsrTbl& rTbl = pDoc->GetUnoCrsrTbl();
for( sal_uInt16 n = 0; n < rTbl.Count(); ++n )
for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it )
{
FOREACHPAM_START( rTbl[ n ] )
FOREACHPAM_START( *it )
lcl_ChkPaM( rSaveArr, nNode, nCntnt, *PCURCRSR, aSave, sal_False );
aSave.IncCount();
FOREACHPAM_END()
SwUnoTableCrsr* pUnoTblCrsr =
dynamic_cast<SwUnoTableCrsr*>(rTbl[ n ]);
dynamic_cast<SwUnoTableCrsr*>(*it);
if( pUnoTblCrsr )
{
FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() )
......@@ -1558,9 +1558,9 @@ void _RestoreCntntIdx(SwDoc* pDoc,
{
sal_uInt16 nCnt = 0;
const SwUnoCrsrTbl& rTbl = pDoc->GetUnoCrsrTbl();
for( sal_uInt16 i = 0; i < rTbl.Count(); ++i )
for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it )
{
FOREACHPAM_START( rTbl[ i ] )
FOREACHPAM_START( *it )
if( aSave.GetCount() == nCnt )
{
pPos = &PCURCRSR->GetBound( 0x0400 ==
......@@ -1573,7 +1573,7 @@ void _RestoreCntntIdx(SwDoc* pDoc,
break;
SwUnoTableCrsr* pUnoTblCrsr =
dynamic_cast<SwUnoTableCrsr*>(rTbl[ i ]);
dynamic_cast<SwUnoTableCrsr*>(*it);
if ( pUnoTblCrsr )
{
FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() )
......@@ -1718,9 +1718,9 @@ void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr,
{
sal_uInt16 nCnt = 0;
const SwUnoCrsrTbl& rTbl = pDoc->GetUnoCrsrTbl();
for( sal_uInt16 i = 0; i < rTbl.Count(); ++i )
for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it )
{
FOREACHPAM_START( rTbl[ i ] )
FOREACHPAM_START( *it )
if( aSave.GetCount() == nCnt )
{
pPos = &PCURCRSR->GetBound( 0x0400 ==
......@@ -1733,7 +1733,7 @@ void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr,
break;
SwUnoTableCrsr* pUnoTblCrsr =
dynamic_cast<SwUnoTableCrsr*>(rTbl[ i ]);
dynamic_cast<SwUnoTableCrsr*>(*it);
if ( pUnoTblCrsr )
{
FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() )
......
......@@ -153,9 +153,9 @@ void PaMCorrAbs( const SwPaM& rRange,
{
SwUnoCrsrTbl& rTbl = const_cast<SwUnoCrsrTbl&>(pDoc->GetUnoCrsrTbl());
for( sal_uInt16 n = 0; n < rTbl.Count(); ++n )
for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it )
{
SwUnoCrsr *const pUnoCursor = rTbl[ n ];
SwUnoCrsr *const pUnoCursor = *it;
bool bChange = false; // has the UNO cursor been corrected?
......@@ -172,7 +172,7 @@ void PaMCorrAbs( const SwPaM& rRange,
FOREACHPAM_END()
SwUnoTableCrsr *const pUnoTblCrsr =
dynamic_cast<SwUnoTableCrsr *>(rTbl[ n ]);
dynamic_cast<SwUnoTableCrsr *>(*it);
if( pUnoTblCrsr )
{
FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() )
......@@ -298,14 +298,14 @@ void PaMCorrRel( const SwNodeIndex &rOldNode,
}
{
SwUnoCrsrTbl& rTbl = (SwUnoCrsrTbl&)pDoc->GetUnoCrsrTbl();
for( sal_uInt16 n = 0; n < rTbl.Count(); ++n )
for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it )
{
FOREACHPAM_START( rTbl[ n ] )
FOREACHPAM_START( *it )
lcl_PaMCorrRel1( PCURCRSR, pOldNode, aNewPos, nCntIdx );
FOREACHPAM_END()
SwUnoTableCrsr* pUnoTblCrsr =
dynamic_cast<SwUnoTableCrsr*>(rTbl[ n ]);
dynamic_cast<SwUnoTableCrsr*>(*it);
if( pUnoTblCrsr )
{
FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() )
......
......@@ -249,7 +249,7 @@ SwDoc::SwDoc()
maListStyleLists(),
pRedlineTbl( new SwRedlineTbl ),
pAutoFmtRedlnComment( 0 ),
pUnoCrsrTbl( new SwUnoCrsrTbl( 0 ) ),
pUnoCrsrTbl( new SwUnoCrsrTbl() ),
pPgPViewPrtData( 0 ),
pExtInputRing( 0 ),
pLayouter( 0 ),
......
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