Convert SV_DECL_PTRARR_DEL(_SwTableAutoFmtTbl) to boost::ptr_vector

Change-Id: I1c92f9d77723979a9d16e9114282dec8d3566de6
This commit is contained in:
Noel Grandin
2012-05-09 14:24:47 +02:00
committed by Michael Stahl
parent b16ce6e60f
commit 60473b5eca
6 changed files with 42 additions and 49 deletions

View File

@@ -305,8 +305,7 @@ public:
sal_Bool Save( SvStream& rStream, sal_uInt16 fileVersion ) const;
};
typedef SwTableAutoFmt* SwTableAutoFmtPtr ;
SV_DECL_PTRARR_DEL( _SwTableAutoFmtTbl, SwTableAutoFmtPtr, 1 )
typedef boost::ptr_vector<SwTableAutoFmt> _SwTableAutoFmtTbl;
class SW_DLLPUBLIC SwTableAutoFmtTbl : public _SwTableAutoFmtTbl
{

View File

@@ -97,9 +97,6 @@ SwBoxAutoFmt* SwTableAutoFmt::pDfltBoxAutoFmt = 0;
#define sAutoTblFmtName "autotbl.fmt"
// SwTable AutoFormat Table
SV_IMPL_PTRARR( _SwTableAutoFmtTbl, SwTableAutoFmt* )
namespace
{
/// Begins a writer-specific data block. Call before serializing any writer-specific properties.
@@ -1084,7 +1081,7 @@ SwTableAutoFmtTbl::SwTableAutoFmtTbl()
((SwBoxAutoFmt&)pNew->GetBoxFmt( i )).SetBox( aBox );
}
Insert( pNew, Count() );
push_back( pNew );
}
sal_Bool SwTableAutoFmtTbl::Load()
@@ -1164,7 +1161,7 @@ sal_Bool SwTableAutoFmtTbl::Load( SvStream& rStream )
bRet = pNew->Load( rStream, aVersions );
if( bRet )
{
Insert( pNew, Count() );
push_back( pNew );
}
else
{
@@ -1199,14 +1196,14 @@ sal_Bool SwTableAutoFmtTbl::Save( SvStream& rStream ) const
bRet = 0 == rStream.GetError();
// Write this version number for all attributes
(*this)[ 0 ]->GetBoxFmt( 0 ).SaveVersionNo( rStream, AUTOFORMAT_FILE_VERSION );
(*this)[ 0 ].GetBoxFmt( 0 ).SaveVersionNo( rStream, AUTOFORMAT_FILE_VERSION );
rStream << (sal_uInt16)(Count() - 1);
rStream << (sal_uInt16)(size() - 1);
bRet = 0 == rStream.GetError();
for( sal_uInt16 i = 1; bRet && i < Count(); ++i )
for( sal_uInt16 i = 1; bRet && i < size(); ++i )
{
SwTableAutoFmt* pFmt = (*this)[ i ];
const SwTableAutoFmt* pFmt = &(*this)[ i ];
bRet = pFmt->Save( rStream, AUTOFORMAT_FILE_VERSION );
}
}

View File

@@ -2966,8 +2966,8 @@ void SwXTextTable::autoFormat(const OUString& aName) throw( lang::IllegalArgumen
String sAutoFmtName(aName);
SwTableAutoFmtTbl aAutoFmtTbl;
aAutoFmtTbl.Load();
for( sal_uInt16 i = aAutoFmtTbl.Count(); i; )
if( sAutoFmtName == aAutoFmtTbl[ --i ]->GetName() )
for( sal_uInt16 i = aAutoFmtTbl.size(); i; )
if( sAutoFmtName == aAutoFmtTbl[ --i ].GetName() )
{
SwSelBoxes aBoxes;
const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
@@ -2977,7 +2977,7 @@ void SwXTextTable::autoFormat(const OUString& aName) throw( lang::IllegalArgumen
aBoxes.Insert( pBox );
}
UnoActionContext aContext( pFmt->GetDoc() );
pFmt->GetDoc()->SetTableAutoFmt( aBoxes, *aAutoFmtTbl[i] );
pFmt->GetDoc()->SetTableAutoFmt( aBoxes, aAutoFmtTbl[i] );
break;
}
}

View File

@@ -120,9 +120,6 @@ using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::beans;
// tblafmt.hxx
SV_IMPL_PTRARR( _SwTableAutoFmtTbl, SwTableAutoFmt* )
const char cDBFldStart = '<';
const char cDBFldEnd = '>';
@@ -1830,10 +1827,10 @@ void SwInsertDBColAutoPilot::Load()
// then load the AutoFmt file and look for Autoformat first
SwTableAutoFmtTbl aAutoFmtTbl;
aAutoFmtTbl.Load();
for( sal_uInt16 nAutoFmt = aAutoFmtTbl.Count(); nAutoFmt; )
if( sTmp == aAutoFmtTbl[ --nAutoFmt ]->GetName() )
for( sal_uInt16 nAutoFmt = aAutoFmtTbl.size(); nAutoFmt; )
if( sTmp == aAutoFmtTbl[ --nAutoFmt ].GetName() )
{
pTAutoFmt = new SwTableAutoFmt( *aAutoFmtTbl[ nAutoFmt ] );
pTAutoFmt = new SwTableAutoFmt( aAutoFmtTbl[ nAutoFmt ] );
break;
}
}

View File

@@ -804,9 +804,9 @@ void SwBaseShell::Execute(SfxRequest &rReq)
pAutoFmtTbl = new SwTableAutoFmtTbl;
pAutoFmtTbl->Load();
for( sal_uInt16 i = 0, nCount = pAutoFmtTbl->Count(); i < nCount; i++ )
for( sal_uInt16 i = 0, nCount = pAutoFmtTbl->size(); i < nCount; i++ )
{
SwTableAutoFmt* pFmt = (*pAutoFmtTbl)[ i ];
SwTableAutoFmt* pFmt = &(*pAutoFmtTbl)[ i ];
if( pFmt->GetName() == sAutoFmt )
{
pTAFmt = pFmt;
@@ -2598,11 +2598,11 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest )
{
SwTableAutoFmtTbl aTableTbl;
aTableTbl.Load();
for ( sal_uInt16 n=0; n<aTableTbl.Count(); n++ )
for ( sal_uInt16 n=0; n<aTableTbl.size(); n++ )
{
if ( aTableTbl[n]->GetName() == aAutoName )
if ( aTableTbl[n].GetName() == aAutoName )
{
pTAFmt = new SwTableAutoFmt( *aTableTbl[n] );
pTAFmt = new SwTableAutoFmt( aTableTbl[n] );
break;
}
}

View File

@@ -259,9 +259,9 @@ void SwAutoFormatDlg::Init( const SwTableAutoFmt* pSelFmt )
nIndex = 255;
}
for( sal_uInt8 i = 0, nCount = (sal_uInt8)pTableTbl->Count(); i < nCount; i++ )
for( sal_uInt8 i = 0, nCount = (sal_uInt8)pTableTbl->size(); i < nCount; i++ )
{
SwTableAutoFmt* pFmt = (*pTableTbl)[ i ];
SwTableAutoFmt* pFmt = &(*pTableTbl)[ i ];
aLbFormat.InsertEntry( pFmt->GetName() );
if( pSelFmt && pFmt->GetName() == pSelFmt->GetName() )
nIndex = i;
@@ -297,9 +297,9 @@ void SwAutoFormatDlg::FillAutoFmtOfIndex( SwTableAutoFmt*& rToFill ) const
if( 255 != nIndex )
{
if( rToFill )
*rToFill = *(*pTableTbl)[ nIndex ];
*rToFill = (*pTableTbl)[ nIndex ];
else
rToFill = new SwTableAutoFmt( *(*pTableTbl)[ nIndex ] );
rToFill = new SwTableAutoFmt( (*pTableTbl)[ nIndex ] );
}
else
delete rToFill, rToFill = 0;
@@ -313,7 +313,7 @@ void SwAutoFormatDlg::FillAutoFmtOfIndex( SwTableAutoFmt*& rToFill ) const
IMPL_LINK( SwAutoFormatDlg, CheckHdl, Button *, pBtn )
{
SwTableAutoFmtPtr pData = (*pTableTbl)[nIndex];
SwTableAutoFmt* pData = &(*pTableTbl)[nIndex];
sal_Bool bCheck = ((CheckBox*)pBtn)->IsChecked(), bDataChgd = sal_True;
if( pBtn == &aBtnNumFormat )
@@ -362,24 +362,24 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, AddHdl)
if( aFormatName.Len() > 0 )
{
sal_uInt16 n;
for( n = 0; n < pTableTbl->Count(); ++n )
if( (*pTableTbl)[n]->GetName() == aFormatName )
for( n = 0; n < pTableTbl->size(); ++n )
if( (*pTableTbl)[n].GetName() == aFormatName )
break;
if( n >= pTableTbl->Count() )
if( n >= pTableTbl->size() )
{
// Format mit dem Namen noch nicht vorhanden, also
// aufnehmen
SwTableAutoFmtPtr pNewData = new
SwTableAutoFmt* pNewData = new
SwTableAutoFmt( aFormatName );
pShell->GetTableAutoFmt( *pNewData );
// Sortiert einfuegen!!
for( n = 1; n < pTableTbl->Count(); ++n )
if( (*pTableTbl)[ n ]->GetName() > aFormatName )
for( n = 1; n < pTableTbl->size(); ++n )
if( (*pTableTbl)[ n ].GetName() > aFormatName )
break;
pTableTbl->Insert( pNewData, n );
pTableTbl->insert( pTableTbl->begin() + n, pNewData );
aLbFormat.InsertEntry( aFormatName, nDfltStylePos + n );
aLbFormat.SelectEntryPos( nDfltStylePos + n );
bFmtInserted = sal_True;
@@ -427,7 +427,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, RemoveHdl)
aLbFormat.RemoveEntry( nDfltStylePos + nIndex );
aLbFormat.SelectEntryPos( nDfltStylePos + nIndex-1 );
pTableTbl->DeleteAndDestroy( nIndex );
pTableTbl->erase( pTableTbl->begin() + nIndex );
nIndex--;
if( !nIndex )
@@ -466,27 +466,27 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, RenameHdl)
if ( aFormatName.Len() > 0 )
{
sal_uInt16 n;
for( n = 0; n < pTableTbl->Count(); ++n )
if ((*pTableTbl)[n]->GetName() == aFormatName)
for( n = 0; n < pTableTbl->size(); ++n )
if ((*pTableTbl)[n].GetName() == aFormatName)
break;
if( n >= pTableTbl->Count() )
if( n >= pTableTbl->size() )
{
// Format mit dem Namen noch nicht vorhanden, also
// umbenennen
aLbFormat.RemoveEntry( nDfltStylePos + nIndex );
SwTableAutoFmtPtr p = (*pTableTbl)[ nIndex ];
pTableTbl->Remove( nIndex );
SwTableAutoFmt* p = &(*pTableTbl)[ nIndex ];
pTableTbl->erase( pTableTbl->begin() + nIndex );
p->SetName( aFormatName );
// Sortiert einfuegen!!
for( n = 1; n < pTableTbl->Count(); ++n )
if( (*pTableTbl)[ n ]->GetName() > aFormatName )
for( n = 1; n < pTableTbl->size(); ++n )
if( (*pTableTbl)[ n ].GetName() > aFormatName )
break;
pTableTbl->Insert( p, n );
pTableTbl->insert( pTableTbl->begin() + n, p );
aLbFormat.InsertEntry( aFormatName, nDfltStylePos + n );
aLbFormat.SelectEntryPos( nDfltStylePos + n );
@@ -526,9 +526,9 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, SelFmtHdl)
if( nSelPos >= nDfltStylePos )
{
nIndex = nSelPos - nDfltStylePos;
pWndPreview->NotifyChange( *(*pTableTbl)[nIndex] );
pWndPreview->NotifyChange( (*pTableTbl)[nIndex] );
bBtnEnable = 0 != nIndex;
UpdateChecks( *(*pTableTbl)[nIndex], sal_True );
UpdateChecks( (*pTableTbl)[nIndex], sal_True );
}
else
{
@@ -557,7 +557,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, SelFmtHdl)
IMPL_LINK_NOARG_INLINE_START(SwAutoFormatDlg, OkHdl)
{
if( bSetAutoFmt )
pShell->SetTableAutoFmt( *(*pTableTbl)[ nIndex ] );
pShell->SetTableAutoFmt( (*pTableTbl)[ nIndex ] );
EndDialog( RET_OK );
return sal_True;
}