summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-06-22 12:01:01 +0200
committerMichael Stahl <mstahl@redhat.com>2012-06-25 20:13:17 +0200
commitb570cc6f22bca9dfde82d72ac17534934260913c (patch)
tree0bf344447abc60ea197ec0391067242d34e98519 /sw
parent2b5aa5cf373aa933255c582716408d960a025503 (diff)
Convert SwShareBoxFmt and SwShareBoxFmts from Svptrarr to std::vector
Change-Id: I9f3b53992af8db54c6e8229c750143a1d5f047a7
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/tblrwcl.cxx26
-rw-r--r--sw/source/core/inc/tblrwcl.hxx10
2 files changed, 17 insertions, 19 deletions
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index 0bbc13739194..f56f878be7e1 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -4534,8 +4534,8 @@ sal_Bool SwTable::SetRowHeight( SwTableBox& rAktBox, sal_uInt16 eType,
SwFrmFmt* SwShareBoxFmt::GetFormat( long nWidth ) const
{
SwFrmFmt *pRet = 0, *pTmp;
- for( sal_uInt16 n = aNewFmts.Count(); n; )
- if( ( pTmp = (SwFrmFmt*)aNewFmts[ --n ])->GetFrmSize().GetWidth()
+ for( sal_uInt16 n = aNewFmts.size(); n; )
+ if( ( pTmp = aNewFmts[ --n ])->GetFrmSize().GetWidth()
== nWidth )
{
pRet = pTmp;
@@ -4550,8 +4550,8 @@ SwFrmFmt* SwShareBoxFmt::GetFormat( const SfxPoolItem& rItem ) const
sal_uInt16 nWhich = rItem.Which();
SwFrmFmt *pRet = 0, *pTmp;
const SfxPoolItem& rFrmSz = pOldFmt->GetFmtAttr( RES_FRM_SIZE, sal_False );
- for( sal_uInt16 n = aNewFmts.Count(); n; )
- if( SFX_ITEM_SET == ( pTmp = (SwFrmFmt*)aNewFmts[ --n ])->
+ for( sal_uInt16 n = aNewFmts.size(); n; )
+ if( SFX_ITEM_SET == ( pTmp = aNewFmts[ --n ])->
GetItemState( nWhich, sal_False, &pItem ) && *pItem == rItem &&
pTmp->GetFmtAttr( RES_FRM_SIZE, sal_False ) == rFrmSz )
{
@@ -4561,23 +4561,21 @@ SwFrmFmt* SwShareBoxFmt::GetFormat( const SfxPoolItem& rItem ) const
return pRet;
}
-void SwShareBoxFmt::AddFormat( const SwFrmFmt& rNew )
+void SwShareBoxFmt::AddFormat( SwFrmFmt& rNew )
{
- void* pFmt = (void*)&rNew;
- aNewFmts.Insert( pFmt, aNewFmts.Count() );
+ aNewFmts.push_back( &rNew );
}
-sal_Bool SwShareBoxFmt::RemoveFormat( const SwFrmFmt& rFmt )
+bool SwShareBoxFmt::RemoveFormat( const SwFrmFmt& rFmt )
{
// returns sal_True, if we can delete
if( pOldFmt == &rFmt )
return sal_True;
- void* p = (void*)&rFmt;
- sal_uInt16 nFnd = aNewFmts.GetPos( p );
- if( USHRT_MAX != nFnd )
- aNewFmts.Remove( nFnd );
- return 0 == aNewFmts.Count();
+ std::vector<SwFrmFmt*>::iterator it = std::find( aNewFmts.begin(), aNewFmts.end(), &rFmt );
+ if( aNewFmts.end() != it )
+ aNewFmts.erase( it );
+ return aNewFmts.empty();
}
SwShareBoxFmts::~SwShareBoxFmts()
@@ -4600,7 +4598,7 @@ SwFrmFmt* SwShareBoxFmts::GetFormat( const SwFrmFmt& rFmt,
: 0;
}
-void SwShareBoxFmts::AddFormat( const SwFrmFmt& rOld, const SwFrmFmt& rNew )
+void SwShareBoxFmts::AddFormat( const SwFrmFmt& rOld, SwFrmFmt& rNew )
{
{
sal_uInt16 nPos;
diff --git a/sw/source/core/inc/tblrwcl.hxx b/sw/source/core/inc/tblrwcl.hxx
index a7884e1d0d4c..bbd6cbd00e6c 100644
--- a/sw/source/core/inc/tblrwcl.hxx
+++ b/sw/source/core/inc/tblrwcl.hxx
@@ -159,20 +159,20 @@ void lcl_GC_Line_Border( const SwTableLine* pLine, _SwGCLineBorder* pGCPara );
class SwShareBoxFmt
{
const SwFrmFmt* pOldFmt;
- SvPtrarr aNewFmts;
+ std::vector<SwFrmFmt*> aNewFmts;
public:
SwShareBoxFmt( const SwFrmFmt& rFmt )
- : pOldFmt( &rFmt ), aNewFmts( 1 )
+ : pOldFmt( &rFmt ), aNewFmts()
{}
const SwFrmFmt& GetOldFormat() const { return *pOldFmt; }
SwFrmFmt* GetFormat( long nWidth ) const;
SwFrmFmt* GetFormat( const SfxPoolItem& rItem ) const;
- void AddFormat( const SwFrmFmt& rFmt );
+ void AddFormat( SwFrmFmt& rFmt );
// returnt sal_True, wenn geloescht werden kann
- sal_Bool RemoveFormat( const SwFrmFmt& rFmt );
+ bool RemoveFormat( const SwFrmFmt& rFmt );
};
@@ -192,7 +192,7 @@ public:
SwFrmFmt* GetFormat( const SwFrmFmt& rFmt, long nWidth ) const;
SwFrmFmt* GetFormat( const SwFrmFmt& rFmt, const SfxPoolItem& ) const;
- void AddFormat( const SwFrmFmt& rOld, const SwFrmFmt& rNew );
+ void AddFormat( const SwFrmFmt& rOld, SwFrmFmt& rNew );
void SetSize( SwTableBox& rBox, const SwFmtFrmSize& rSz );
void SetAttr( SwTableBox& rBox, const SfxPoolItem& rItem );