diff options
author | Daisuke Nishino <niboshi000@gmail.com> | 2011-11-23 13:12:43 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-11-23 13:56:37 +0000 |
commit | 858b5b4f36a357fe7192e7c2ed9cc3cdfc81fd8f (patch) | |
tree | 963b3823812f1d3cdb1301036f50c8d194edefcb | |
parent | a9edd1267e42ba4e7814102bcaab6610d14bc3b8 (diff) |
SwSelBoxes: svarray -> std::map
31 files changed, 455 insertions, 501 deletions
diff --git a/sw/inc/swcrsr.hxx b/sw/inc/swcrsr.hxx index d99d52708fc1..f7bb24827935 100644 --- a/sw/inc/swcrsr.hxx +++ b/sw/inc/swcrsr.hxx @@ -283,9 +283,12 @@ public: virtual sal_Bool GotoTable( const String& rName ); void InsertBox( const SwTableBox& rTblBox ); - void DeleteBox( sal_uInt16 nPos ) { aSelBoxes.Remove( nPos ); bChg = sal_True; } - sal_uInt16 GetBoxesCount() const { return aSelBoxes.Count(); } + void DeleteBox( SwSelBoxes::const_iterator it ) { aSelBoxes.erase( it ); bChg = sal_True; } + void DeleteBox( SwSelBoxes::const_iterator itFirst, SwSelBoxes::const_iterator itLast ) { aSelBoxes.erase( itFirst, itLast ); bChg = sal_True; } + void DeleteAllBoxes() { DeleteBox(aSelBoxes.begin(), aSelBoxes.end()); } + sal_uInt16 GetBoxesCount() const { return aSelBoxes.size(); } const SwSelBoxes& GetBoxes() const { return aSelBoxes; } + SwSelBoxes& GetBoxes() { return aSelBoxes; } // Creates cursor for all boxes. SwCursor* MakeBoxSels( SwCursor* pAktCrsr ); diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx index 7e0157bdaa1f..4239bf6fcb21 100644 --- a/sw/inc/swtable.hxx +++ b/sw/inc/swtable.hxx @@ -34,6 +34,7 @@ #include <swtypes.hxx> #include <calbck.hxx> #include <swrect.hxx> +#include <frmfmt.hxx> #if OSL_DEBUG_LEVEL > 1 class SwStartNode; @@ -45,7 +46,6 @@ class SwStartNode; class SwFmt; class Color; -class SwFrmFmt; class SwTableFmt; class SwTableLineFmt; class SwTableBoxFmt; @@ -407,8 +407,7 @@ public: const SwTableLine *GetUpper() const { return pUpper; } void SetUpper( SwTableLine *pNew ) { pUpper = pNew; } - SwFrmFmt* GetFrmFmt() { return (SwFrmFmt*)GetRegisteredIn(); } - SwFrmFmt* GetFrmFmt() const { return (SwFrmFmt*)GetRegisteredIn(); } + SwFrmFmt* GetFrmFmt() const { return const_cast<SwFrmFmt*>(static_cast<const SwFrmFmt*>(GetRegisteredIn())); } // Creates its own FrmFmt if more boxes depend on it. SwFrmFmt* ClaimFrmFmt(); diff --git a/sw/inc/tblsel.hxx b/sw/inc/tblsel.hxx index 83c127bfa9ef..314ce4728cfa 100644 --- a/sw/inc/tblsel.hxx +++ b/sw/inc/tblsel.hxx @@ -33,6 +33,8 @@ #include <swrect.hxx> #include "swdllapi.h" +#include <map> + class SwCrsrShell; class SwCursor; class SwTableCursor; @@ -48,7 +50,30 @@ class SwUndoTblMerge; class SwCellFrm; SV_DECL_PTRARR( SwCellFrms, SwCellFrm*, 16, 16 ) -SV_DECL_PTRARR_SORT( SwSelBoxes, SwTableBoxPtr, 10, 20 ) + + +class SwSelBoxes : public std::map<sal_uLong, SwTableBox*> { + typedef std::map<sal_uLong, SwTableBox*> Base; +public: + using Base::insert; + using Base::find; + using Base::count; + + std::pair<iterator, bool> + insert(SwTableBox* pBox) { return Base::insert(std::make_pair(pBox->GetSttIdx(), pBox)); } + + iterator + insert(iterator it, SwTableBox* pBox) { return Base::insert(it, std::make_pair(pBox->GetSttIdx(), pBox)); } + + size_type + count(const SwTableBox* pBox) const { return Base::count(pBox->GetSttIdx()); } + + iterator + find(const SwTableBox* pBox) { return Base::find(pBox->GetSttIdx()); } + + const_iterator + find(const SwTableBox* pBox) const { return Base::find(pBox->GetSttIdx()); } +}; // Collects all boxes in table that are selected. diff --git a/sw/source/core/access/acccell.cxx b/sw/source/core/access/acccell.cxx index 83c61cf31801..57dc881515cc 100644 --- a/sw/source/core/access/acccell.cxx +++ b/sw/source/core/access/acccell.cxx @@ -76,7 +76,7 @@ sal_Bool SwAccessibleCell::IsSelected() static_cast< const SwCellFrm * >( GetFrm() ); SwTableBox *pBox = const_cast< SwTableBox *>( pCFrm->GetTabBox() ); //SVPtrArr! - bRet = pCSh->GetTableCrsr()->GetBoxes().Seek_Entry( pBox ); + bRet = ( 0 != pCSh->GetTableCrsr()->GetBoxes().count( pBox ) ); } } diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx index f235de1a04c9..d7d9a9c8f161 100644 --- a/sw/source/core/access/acctable.cxx +++ b/sw/source/core/access/acctable.cxx @@ -294,7 +294,7 @@ void SwAccessibleTableData_Impl::GetSelection( static_cast < const SwCellFrm * >( pLower ); SwTableBox *pBox = const_cast< SwTableBox *>( pCFrm->GetTabBox() ); //SVPtrArr! - if( !rSelBoxes.Seek_Entry( pBox ) ) + if( 0 == rSelBoxes.count( pBox ) ) { const Int32Set_Impl rRowsOrCols = bColumns ? maColumns : maRows; @@ -656,7 +656,7 @@ sal_Bool SwAccessibleTable::IsChildSelected( sal_Int32 nChildIndex ) const { const SwTableBox* pBox = GetTableBox( nChildIndex ); OSL_ENSURE( pBox != NULL, "We need the table box." ); - bRet = pSelBoxes->Seek_Entry( const_cast<SwTableBox*>( pBox ) ); + bRet = ( 0 != pSelBoxes->count( pBox ) ); } return bRet; @@ -1196,7 +1196,7 @@ sal_Bool SAL_CALL SwAccessibleTable::isAccessibleSelected( const SwCellFrm *pCFrm = static_cast < const SwCellFrm * >( pFrm ); SwTableBox *pBox = const_cast< SwTableBox *>( pCFrm->GetTabBox() ); //SVPtrArr! - bRet = pSelBoxes->Seek_Entry( pBox ); + bRet = ( 0 != pSelBoxes->count( pBox ) ); } } diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index a633bc0c7fa9..8b4fab89235a 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -2132,35 +2132,6 @@ SwTableCursor::SwTableCursor( const SwPosition &rPos, SwPaM* pRing ) SwTableCursor::~SwTableCursor() {} -sal_Bool lcl_SeekEntry( const SwSelBoxes& rTmp, const SwStartNode* pSrch, sal_uInt16& rFndPos ) -{ - sal_uLong nIdx = pSrch->GetIndex(); - - sal_uInt16 nO = rTmp.Count(); - if( nO > 0 ) - { - nO--; - sal_uInt16 nU = 0; - while( nU <= nO ) - { - sal_uInt16 nM = nU + ( nO - nU ) / 2; - if( rTmp[ nM ]->GetSttNd() == pSrch ) - { - rFndPos = nM; - return sal_True; - } - else if( rTmp[ nM ]->GetSttIdx() < nIdx ) - nU = nM + 1; - else if( nM == 0 ) - return sal_False; - else - nO = nM - 1; - } - } - return sal_False; -} - - SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr ) { if( bChg ) // ??? @@ -2179,12 +2150,10 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr ) // temp Kopie anlegen, damit alle Boxen, fuer die schon Cursor // existieren, entfernt werden koennen. - SwSelBoxes aTmp; - aTmp.Insert( &aSelBoxes ); + SwSelBoxes aTmp( aSelBoxes ); //Jetzt die Alten und die neuen abgleichen. SwNodes& rNds = pAktCrsr->GetDoc()->GetNodes(); - sal_uInt16 nPos; const SwStartNode* pSttNd; SwPaM* pCur = pAktCrsr; do { @@ -2194,31 +2163,34 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr ) pSttNd != pCur->GetMark()->nNode.GetNode().FindTableBoxStartNode() ) bDel = sal_True; - else if( lcl_SeekEntry( aTmp, pSttNd, nPos )) + else { - SwNodeIndex aIdx( *pSttNd, 1 ); - const SwNode* pNd = &aIdx.GetNode(); - if( !pNd->IsCntntNode() ) - pNd = rNds.GoNextSection( &aIdx, sal_True, sal_False ); - - SwPosition* pPos = pCur->GetMark(); - if( pNd != &pPos->nNode.GetNode() ) - pPos->nNode = *pNd; - pPos->nContent.Assign( (SwCntntNode*)pNd, 0 ); - - aIdx.Assign( *pSttNd->EndOfSectionNode(), - 1 ); - if( !( pNd = &aIdx.GetNode())->IsCntntNode() ) - pNd = rNds.GoPrevSection( &aIdx, sal_True, sal_False ); - - pPos = pCur->GetPoint(); - if( pNd != &pPos->nNode.GetNode() ) - pPos->nNode = *pNd; - pPos->nContent.Assign( (SwCntntNode*)pNd, ((SwCntntNode*)pNd)->Len() ); - - aTmp.Remove( nPos ); + SwSelBoxes::const_iterator it = aTmp.find(pSttNd->GetIndex()); + if( it != aTmp.end() ) { + SwNodeIndex aIdx( *pSttNd, 1 ); + const SwNode* pNd = &aIdx.GetNode(); + if( !pNd->IsCntntNode() ) + pNd = rNds.GoNextSection( &aIdx, sal_True, sal_False ); + + SwPosition* pPos = pCur->GetMark(); + if( pNd != &pPos->nNode.GetNode() ) + pPos->nNode = *pNd; + pPos->nContent.Assign( (SwCntntNode*)pNd, 0 ); + + aIdx.Assign( *pSttNd->EndOfSectionNode(), - 1 ); + if( !( pNd = &aIdx.GetNode())->IsCntntNode() ) + pNd = rNds.GoPrevSection( &aIdx, sal_True, sal_False ); + + pPos = pCur->GetPoint(); + if( pNd != &pPos->nNode.GetNode() ) + pPos->nNode = *pNd; + pPos->nContent.Assign( (SwCntntNode*)pNd, ((SwCntntNode*)pNd)->Len() ); + + aTmp.erase( it ); + } + else + bDel = sal_True; } - else - bDel = sal_True; pCur = (SwPaM*)pCur->GetNext(); if( bDel ) @@ -2232,9 +2204,9 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr ) } } while ( pAktCrsr != pCur ); - for( nPos = 0; nPos < aTmp.Count(); ++nPos ) + for( SwSelBoxes::const_iterator it = aTmp.begin(); it != aTmp.end(); ++it ) { - pSttNd = aTmp[ nPos ]->GetSttNd(); + pSttNd = it->second->GetSttNd(); SwNodeIndex aIdx( *pSttNd, 1 ); if( &aIdx.GetNodes() != &rNds ) @@ -2273,7 +2245,7 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr ) void SwTableCursor::InsertBox( const SwTableBox& rTblBox ) { SwTableBox* pBox = (SwTableBox*)&rTblBox; - aSelBoxes.Insert( pBox ); + aSelBoxes.insert( pBox ); bChg = sal_True; } @@ -2289,8 +2261,7 @@ bool SwTableCursor::NewTableSelection() pTableNode->GetTable().IsNewModel() ) { bRet = true; - SwSelBoxes aNew; - aNew.Insert( &aSelBoxes ); + SwSelBoxes aNew( aSelBoxes ); pTableNode->GetTable().CreateSelection( pStart, pEnd, aNew, SwTable::SEARCH_NONE, false ); ActualizeSelection( aNew ); @@ -2301,31 +2272,37 @@ bool SwTableCursor::NewTableSelection() void SwTableCursor::ActualizeSelection( const SwSelBoxes &rNew ) { - sal_uInt16 nOld = 0, nNew = 0; - while ( nOld < aSelBoxes.Count() && nNew < rNew.Count() ) + SwSelBoxes::const_iterator itOld = aSelBoxes.begin(); + SwSelBoxes::const_iterator itNew = rNew.begin(); + while ( itOld != aSelBoxes.end() && itNew != rNew.end() ) { - const SwTableBox* pPOld = *( aSelBoxes.GetData() + nOld ); - const SwTableBox* pPNew = *( rNew.GetData() + nNew ); + const SwTableBox* pPOld = itOld->second; + const SwTableBox* pPNew = itNew->second; if( pPOld == pPNew ) { // this box will stay - ++nOld; - ++nNew; + ++itOld; + ++itNew; } else if( pPOld->GetSttIdx() < pPNew->GetSttIdx() ) - DeleteBox( nOld ); // this box has to go + { + SwSelBoxes::const_iterator it = itOld; + ++itOld; + DeleteBox( it ); // this box has to go + } else { InsertBox( *pPNew ); // this is a new one - ++nOld; - ++nNew; + ++itOld; + ++itNew; } } - while( nOld < aSelBoxes.Count() ) - DeleteBox( nOld ); // some more to delete + // some more to delete + DeleteBox( itOld, aSelBoxes.end() ); - for( ; nNew < rNew.Count(); ++nNew ) // some more to insert - InsertBox( **( rNew.GetData() + nNew ) ); + // some more to insert + for( ; itNew != rNew.end(); ++itNew ) + InsertBox( *itNew->second ); } sal_Bool SwTableCursor::IsCrsrMovedUpdt() @@ -2364,14 +2341,12 @@ void SwTableCursor::ParkCrsr() sal_Bool SwTableCursor::HasReadOnlyBoxSel() const { - sal_Bool bRet = sal_False; - for( sal_uInt16 n = aSelBoxes.Count(); n; ) - if( aSelBoxes[ --n ]->GetFrmFmt()->GetProtect().IsCntntProtected() ) + for( SwSelBoxes::const_reverse_iterator it = aSelBoxes.rbegin(); it != aSelBoxes.rend(); ++it ) + if( it->second->GetFrmFmt()->GetProtect().IsCntntProtected() ) { - bRet = sal_True; - break; + return sal_True; } - return bRet; + return sal_False; } diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx index 680b2c01009a..24afa4630224 100644 --- a/sw/source/core/crsr/trvltbl.cxx +++ b/sw/source/core/crsr/trvltbl.cxx @@ -171,11 +171,11 @@ sal_Bool SwCrsrShell::_SelTblRowOrCol( bool bRow, bool bRowSimple ) { GetTblSel( *this, aBoxes, eType ); - if( !aBoxes.Count() ) + if( aBoxes.empty() ) return sal_False; - pStt = aBoxes[0]; - pEnd = aBoxes[aBoxes.Count() - 1]; + pStt = aBoxes.begin()->second; + pEnd = aBoxes.rbegin()->second; } // #i32329# Enhanced table selection else if ( pTable->IsNewModel() ) @@ -183,11 +183,11 @@ sal_Bool SwCrsrShell::_SelTblRowOrCol( bool bRow, bool bRowSimple ) const SwShellCrsr *pCrsr = _GetCrsr(); SwTable::SearchType eSearchType = bRow ? SwTable::SEARCH_ROW : SwTable::SEARCH_COL; pTable->CreateSelection( *pCrsr, aBoxes, eSearchType, bCheckProtected ); - if( !aBoxes.Count() ) + if( aBoxes.empty() ) return sal_False; - pStt = aBoxes[0]; - pEnd = aBoxes[aBoxes.Count() - 1]; + pStt = aBoxes.begin()->second; + pEnd = aBoxes.rbegin()->second; } else { @@ -219,13 +219,13 @@ sal_Bool SwCrsrShell::_SelTblRowOrCol( bool bRow, bool bRowSimple ) static_cast<const SwCellFrm*>(pEndFrm), aBoxes, bSelectUp ? 0 : &aCells, eType ); - if( !aBoxes.Count() || ( !bSelectUp && 4 != aCells.Count() ) ) + if( aBoxes.empty() || ( !bSelectUp && 4 != aCells.Count() ) ) return sal_False; if ( bSelectUp ) { - pStt = aBoxes[0]; - pEnd = aBoxes[aBoxes.Count() - 1]; + pStt = aBoxes.begin()->second; + pEnd = aBoxes.rbegin()->second; } else { diff --git a/sw/source/core/crsr/unocrsr.cxx b/sw/source/core/crsr/unocrsr.cxx index 5a5b5f89f4d3..95a1d1283663 100644 --- a/sw/source/core/crsr/unocrsr.cxx +++ b/sw/source/core/crsr/unocrsr.cxx @@ -242,10 +242,7 @@ void SwUnoTableCrsr::MakeBoxSels() if ( !bMakeTblCrsrs ) { - SwSelBoxes& rTmpBoxes = (SwSelBoxes&)GetBoxes(); - sal_uInt16 nCount = 0; - while( nCount < rTmpBoxes.Count() ) - DeleteBox( nCount ); + DeleteAllBoxes(); } if( IsChgd() ) diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 10c422b5ec6d..ca168f035b72 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -658,15 +658,15 @@ void SwShellTableCrsr::FillRects() { // Calculate the new rectangles. // JP 16.01.98: If the cursor is still "parked" do nothing!! - if( !aSelBoxes.Count() || bParked || + if( aSelBoxes.empty() || bParked || !GetPoint()->nNode.GetIndex() ) return; SwRegionRects aReg( GetShell()->VisArea() ); SwNodes& rNds = GetDoc()->GetNodes(); - for( sal_uInt16 n = 0; n < aSelBoxes.Count(); ++n ) + for( SwSelBoxes::iterator it = aSelBoxes.begin(); it != aSelBoxes.end(); ++it ) { - const SwStartNode* pSttNd = (*(aSelBoxes.GetData() + n ))->GetSttNd(); + const SwStartNode* pSttNd = it->second->GetSttNd(); const SwTableNode* pSelTblNd = pSttNd->FindTableNode(); SwNodeIndex aIdx( *pSttNd ); @@ -710,14 +710,14 @@ sal_Bool SwShellTableCrsr::IsInside( const Point& rPt ) const { // Calculate the new rectangles. // JP 16.01.98: If the cursor is still "parked" do nothing!! - if( !aSelBoxes.Count() || bParked || + if( aSelBoxes.empty() || bParked || !GetPoint()->nNode.GetIndex() ) return sal_False; SwNodes& rNds = GetDoc()->GetNodes(); - for( sal_uInt16 n = 0; n < aSelBoxes.Count(); ++n ) + for( SwSelBoxes::const_iterator it = aSelBoxes.begin(); it != aSelBoxes.end(); ++it ) { - SwNodeIndex aIdx( *(*(aSelBoxes.GetData() + n ))->GetSttNd() ); + SwNodeIndex aIdx( *it->second->GetSttNd() ); SwCntntNode* pCNd = rNds.GoNextSection( &aIdx, sal_True, sal_False ); if( !pCNd ) continue; diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index edcf01a53524..6ea2f5e8ef55 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -795,7 +795,7 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet, SwPosition aPos( aIndex ); aPos.nContent.Assign( pNode, 0 ); - if( pSelBoxes && pSelBoxes->Count() ) + if( pSelBoxes && !pSelBoxes->empty() ) { // Tabellenselection // kopiere Teile aus einer Tabelle: lege eine Tabelle mit der @@ -803,15 +803,14 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet, // selektierten Boxen. Die Groessen werden prozentual // korrigiert. - SwTableNode* pTblNd = (SwTableNode*)(*pSelBoxes)[0]-> - GetSttNd()->FindTableNode(); + const SwTableNode* pTblNd = pSelBoxes->begin()->second->GetSttNd()->FindTableNode(); if( !pTblNd ) break; - SwTable& rTbl = pTblNd->GetTable(); + const SwTable& rTbl = pTblNd->GetTable(); // ist die gesamte Tabelle selektiert ? - if( pSelBoxes->Count() == rTbl.GetTabSortBoxes().Count() ) + if( pSelBoxes->size() == rTbl.GetTabSortBoxes().Count() ) { // verschiebe die gesamte Tabelle SwNodeRange aRg( *pTblNd, 0, *pTblNd->EndOfSectionNode(), 1 ); diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 518860f8ae18..3f82578694bc 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -495,8 +495,8 @@ sal_Bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) sal_Bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) { // uebers SwDoc fuer Undo !! - OSL_ENSURE( rBoxes.Count(), "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = const_cast<SwTableNode*>( rBoxes.begin()->second->GetSttNd()->FindTableNode() ); if( !pTblNd ) return sal_False; @@ -563,8 +563,8 @@ sal_Bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) SwUndoSort* pUndoSort = 0; if (GetIDocumentUndoRedo().DoesUndo()) { - pUndoSort = new SwUndoSort( rBoxes[0]->GetSttIdx(), - rBoxes[rBoxes.Count()-1]->GetSttIdx(), + pUndoSort = new SwUndoSort( rBoxes.begin()->second->GetSttIdx(), + rBoxes.rbegin()->second->GetSttIdx(), *pTblNd, rOpt, aFlatBox.HasItemSets() ); GetIDocumentUndoRedo().AppendUndo(pUndoSort); } diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index d83bf854c645..53690ab58058 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -55,8 +55,8 @@ #include <fmtfsize.hxx> #include <list> -sal_Bool _FndCntntLine( const SwTableLine*& rpLine, void* pPara ); -sal_Bool _FndCntntBox( const SwTableBox*& rpBox, void* pPara ); +static sal_Bool _FndCntntLine( const SwTableLine*& rpLine, void* pPara ); +static sal_Bool _FndCntntBox( const SwTableBox*& rpBox, void* pPara ); void lcl_CpyBox( const SwTable& rCpyTbl, const SwTableBox* pCpyBox, SwTable& rDstTbl, SwTableBox* pDstBox, sal_Bool bDelCntnt, SwUndoTblCpyTbl* pUndo ); @@ -198,7 +198,7 @@ namespace { if( rFndBox.GetLines().Count() ) { - bool bNoSelection = rSelBoxes.Count() < 2; + bool bNoSelection = rSelBoxes.size() < 2; _FndLines &rFndLines = rFndBox.GetLines(); maCols.push_front(0); const SwTableLine* pLine = rFndLines[0]->GetLine(); @@ -323,13 +323,13 @@ namespace { BoxSpanInfo aInfo; if( pSelBoxes && - USHRT_MAX != pSelBoxes->GetPos( pBox ) ) + 0 != pSelBoxes->count( pBox ) ) { aInfo.mbSelected = true; if( mnStartCol == USHRT_MAX ) { mnStartCol = (sal_uInt16)maLines[nLine].size(); - if( pSelBoxes->Count() < 2 ) + if( pSelBoxes->size() < 2 ) { pSelBoxes = 0; aInfo.mbSelected = false; @@ -698,7 +698,7 @@ sal_Bool SwTable::InsNewTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBox if( aTarget.mnAddLine && IsNewModel() ) { SwSelBoxes aBoxes; - aBoxes.Insert( GetTabLines()[ GetTabLines().Count()-1 ]->GetTabBoxes()[0] ); + aBoxes.insert( GetTabLines()[ GetTabLines().Count()-1 ]->GetTabBoxes()[0] ); if( pUndo ) pUndo->InsertRow( *this, aBoxes, aTarget.mnAddLine ); else @@ -825,7 +825,7 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwNodeIndex& rSttBox, sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, SwUndoTblCpyTbl* pUndo ) { - OSL_ENSURE( rSelBoxes.Count(), "Missing selection" ); + OSL_ENSURE( !rSelBoxes.empty(), "Missing selection" ); SetHTMLTableLayout( 0 ); // MIB 9.7.97: HTML-Layout loeschen @@ -839,7 +839,7 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, SwTblNumFmtMerge aTNFM( *pCpyDoc, *pDoc ); - SwTableBox *pTmpBox, *pSttBox = (SwTableBox*)rSelBoxes[0]; + SwTableBox *pTmpBox, *pSttBox = rSelBoxes.begin()->second; sal_uInt16 nLn, nBx; _FndLine *pFLine, *pInsFLine = 0; @@ -878,7 +878,7 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, // sollte nicht mehr soviele Lines vorhanden sein, dann // teste, ob man durch einfuegen neuer zum Ziel kommt. Aber // nur wenn die SSelection eine Box umfasst !! - if( 1 < rSelBoxes.Count() ) + if( 1 < rSelBoxes.size() ) return sal_False; sal_uInt16 nNewLns = rCpyTbl.GetTabLines().Count() - @@ -1020,9 +1020,9 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, if( 1 == rCpyTbl.GetTabSortBoxes().Count() ) { SwTableBox *pTmpBx = rCpyTbl.GetTabSortBoxes()[0]; - for( sal_uInt16 n = 0; n < rSelBoxes.Count(); ++n ) + for( SwSelBoxes::const_iterator it = rSelBoxes.begin(); it != rSelBoxes.end(); ++it ) lcl_CpyBox( rCpyTbl, pTmpBx, *this, - (SwTableBox*)rSelBoxes[n], sal_True, pUndo ); + it->second, sal_True, pUndo ); } else for( nLn = 0; nLn < aFndBox.GetLines().Count(); ++nLn ) @@ -1045,11 +1045,11 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, sal_Bool _FndCntntBox( const SwTableBox*& rpBox, void* pPara ) { - SwTableBox* pBox = (SwTableBox*)rpBox; + SwTableBox* pBox = const_cast<SwTableBox*>(rpBox); if( rpBox->GetTabLines().Count() ) pBox->GetTabLines().ForEach( &_FndCntntLine, pPara ); else - ((SwSelBoxes*)pPara)->Insert( pBox ); + static_cast<SwSelBoxes*>(pPara)->insert( pBox ); return sal_True; } @@ -1069,7 +1069,7 @@ SwSelBoxes& SwTable::SelLineFromBox( const SwTableBox* pBox, pLine = pLine->GetUpper()->GetUpper(); // alle alten loeschen - rBoxes.Remove( sal_uInt16(0), rBoxes.Count() ); + rBoxes.clear(); pLine->GetTabBoxes().ForEach( &_FndCntntBox, &rBoxes ); return rBoxes; } diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 6ffb020064fa..8eab5a9cfe2d 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -524,8 +524,8 @@ SwRowFrm* GetRowFrm( SwTableLine& rLine ) sal_Bool SwTable::InsertCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, sal_Bool bBehind ) { - OSL_ENSURE( rBoxes.Count() && nCnt, "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + OSL_ENSURE( !rBoxes.empty() && nCnt, "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = const_cast<SwTableNode*>( rBoxes.begin()->second->GetSttNd()->FindTableNode() ); if( !pTblNd ) return sal_False; @@ -580,8 +580,8 @@ sal_Bool SwTable::InsertCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 n sal_Bool SwTable::_InsertRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, sal_Bool bBehind ) { - OSL_ENSURE( pDoc && rBoxes.Count() && nCnt, "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + OSL_ENSURE( pDoc && !rBoxes.empty() && nCnt, "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = const_cast<SwTableNode*>( rBoxes.begin()->second->GetSttNd()->FindTableNode() ); if( !pTblNd ) return sal_False; @@ -790,7 +790,7 @@ void lcl_LastBoxSetWidth( SwTableBoxes &rBoxes, const long nOffset, bFirst, rShareFmts ); //Die Box anpassen - SwFrmFmt *pBoxFmt = rBox.GetFrmFmt(); + const SwFrmFmt *pBoxFmt = rBox.GetFrmFmt(); SwFmtFrmSize aNew( pBoxFmt->GetFrmSize() ); aNew.SetWidth( aNew.GetWidth() + nOffset ); SwFrmFmt *pFmt = rShareFmts.GetFormat( *pBoxFmt, aNew ); @@ -944,7 +944,7 @@ void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* pUndo, SwTableBox* lcl_FndNxtPrvDelBox( const SwTableLines& rTblLns, SwTwips nBoxStt, SwTwips nBoxWidth, sal_uInt16 nLinePos, sal_Bool bNxt, - SwSelBoxes* pAllDelBoxes, sal_uInt16* pCurPos ) + SwSelBoxes* pAllDelBoxes, SwSelBoxes::iterator* pCurPos ) { SwTableBox* pFndBox = 0; do { @@ -981,16 +981,16 @@ SwTableBox* lcl_FndNxtPrvDelBox( const SwTableLines& rTblLns, else if( pAllDelBoxes ) { // falls der Vorganger auch geloscht wird, ist nicht zu tun - sal_uInt16 nFndPos; - if( !pAllDelBoxes->Seek_Entry( pFndBox, &nFndPos ) ) + SwSelBoxes::iterator it = pAllDelBoxes->find( pFndBox ); + if( it == pAllDelBoxes->end() ) break; // sonst noch mal weitersuchen // Die Box muessen wir aber nicht nochmal abpruefen - pFndBox = 0; - if( nFndPos <= *pCurPos ) + if( pFndBox->GetSttIdx() <= (*pCurPos)->second->GetSttIdx() ) --*pCurPos; - pAllDelBoxes->Remove( nFndPos ); + pFndBox = 0; + pAllDelBoxes->erase( it ); } } while( bNxt ? ( nLinePos + 1 < rTblLns.Count() ) : nLinePos ); return pFndBox; @@ -999,7 +999,7 @@ SwTableBox* lcl_FndNxtPrvDelBox( const SwTableLines& rTblLns, void lcl_SaveUpperLowerBorder( SwTable& rTbl, const SwTableBox& rBox, SwShareBoxFmts& rShareFmts, SwSelBoxes* pAllDelBoxes = 0, - sal_uInt16* pCurPos = 0 ) + SwSelBoxes::iterator* pCurPos = 0 ) { //JP 16.04.97: 2.Teil fuer Bug 36271 sal_Bool bChgd = sal_False; @@ -1079,9 +1079,9 @@ sal_Bool SwTable::DeleteSel( { OSL_ENSURE( pDoc, "No doc?" ); SwTableNode* pTblNd = 0; - if( rBoxes.Count() ) + if( !rBoxes.empty() ) { - pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode()); if( !pTblNd ) return sal_False; } @@ -1092,9 +1092,9 @@ sal_Bool SwTable::DeleteSel( _FndBox aFndBox( 0, 0 ); if ( bDelMakeFrms ) { - if( pMerged && pMerged->Count() ) + if( pMerged && !pMerged->empty() ) aFndBox.SetTableLines( *pMerged, *this ); - else if( rBoxes.Count() ) + else if( !rBoxes.empty() ) aFndBox.SetTableLines( rBoxes, *this ); aFndBox.DelFrms( *this ); } @@ -1104,11 +1104,10 @@ sal_Bool SwTable::DeleteSel( // erst die Umrandung umsetzen, dann loeschen if( bCorrBorder ) { - SwSelBoxes aBoxes; - aBoxes.Insert( &rBoxes ); - for( sal_uInt16 n = 0; n < aBoxes.Count(); ++n ) - ::lcl_SaveUpperLowerBorder( *this, *rBoxes[ n ], aShareFmts, - &aBoxes, &n ); + SwSelBoxes aBoxes( rBoxes ); + for( SwSelBoxes::iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) + ::lcl_SaveUpperLowerBorder( *this, *it->second, aShareFmts, + &aBoxes, &it ); } PrepareDelBoxes( rBoxes ); @@ -1116,18 +1115,16 @@ sal_Bool SwTable::DeleteSel( SwChartDataProvider *pPCD = pDoc->GetChartDataProvider(); // // delete boxes from last to first - for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) + for( SwSelBoxes::const_reverse_iterator it = rBoxes.rbegin(); it != rBoxes.rend(); ++it ) { - sal_uInt16 nIdx = rBoxes.Count() - 1 - n; - // first adapt the data-sequence for chart if necessary // (needed to move the implementation cursor properly to it's new // position which can't be done properly if the cell is already gone) if (pPCD && pTblNd) - pPCD->DeleteBox( &pTblNd->GetTable(), *rBoxes[nIdx] ); + pPCD->DeleteBox( &pTblNd->GetTable(), *it->second ); // ... then delete the boxes - _DeleteBox( *this, rBoxes[nIdx], pUndo, sal_True, bCorrBorder, &aShareFmts ); + _DeleteBox( *this, it->second, pUndo, sal_True, bCorrBorder, &aShareFmts ); } // dann raeume die Struktur aller Lines auf @@ -1148,8 +1145,8 @@ sal_Bool SwTable::DeleteSel( sal_Bool SwTable::OldSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, sal_Bool bSameHeight ) { - OSL_ENSURE( pDoc && rBoxes.Count() && nCnt, "keine gueltigen Werte" ); - SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + OSL_ENSURE( pDoc && !rBoxes.empty() && nCnt, "keine gueltigen Werte" ); + SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode()); if( !pTblNd ) return sal_False; @@ -1162,17 +1159,17 @@ sal_Bool SwTable::OldSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 // If the rows should get the same (min) height, we first have // to store the old row heights before deleting the frames - long* pRowHeights = 0; + std::vector<long> aRowHeights; if ( bSameHeight ) { - pRowHeights = new long[ rBoxes.Count() ]; - for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) + aRowHeights.reserve(rBoxes.size()); + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) { - SwTableBox* pSelBox = *( rBoxes.GetData() + n ); + SwTableBox* pSelBox = it->second; const SwRowFrm* pRow = GetRowFrm( *pSelBox->GetUpper() ); OSL_ENSURE( pRow, "wo ist der Frm von der SwTableLine?" ); SWRECTFN( pRow ) - pRowHeights[ n ] = (pRow->Frm().*fnRect->fnGetHeight)(); + aRowHeights.push_back((pRow->Frm().*fnRect->fnGetHeight)()); } } @@ -1181,9 +1178,10 @@ sal_Bool SwTable::OldSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 aFndBox.SetTableLines( rBoxes, *this ); aFndBox.DelFrms( *this ); - for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) + sal_uInt16 n = 0; + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it, ++n ) { - SwTableBox* pSelBox = *( rBoxes.GetData() + n ); + SwTableBox* pSelBox = it->second; OSL_ENSURE( pSelBox, "Box steht nicht in der Tabelle" ); // dann fuege in die Box nCnt neue Zeilen ein @@ -1197,7 +1195,7 @@ sal_Bool SwTable::OldSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 sal_Bool bChgLineSz = 0 != aFSz.GetHeight() || bSameHeight; if ( bChgLineSz ) - aFSz.SetHeight( ( bSameHeight ? pRowHeights[ n ] : aFSz.GetHeight() ) / + aFSz.SetHeight( ( bSameHeight ? aRowHeights[ n ] : aFSz.GetHeight() ) / (nCnt + 1) ); SwTableBox* pNewBox = new SwTableBox( pFrmFmt, nCnt, pInsLine ); @@ -1278,8 +1276,6 @@ sal_Bool SwTable::OldSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 pFrmFmt->ResetFmtAttr( RES_BOXATR_BEGIN, RES_BOXATR_END - 1 ); } - delete[] pRowHeights; - GCLines(); aFndBox.MakeFrms( *this ); @@ -1291,8 +1287,8 @@ sal_Bool SwTable::OldSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 sal_Bool SwTable::SplitCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt ) { - OSL_ENSURE( pDoc && rBoxes.Count() && nCnt, "keine gueltigen Werte" ); - SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + OSL_ENSURE( pDoc && !rBoxes.empty() && nCnt, "keine gueltigen Werte" ); + SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode()); if( !pTblNd ) return sal_False; @@ -1302,8 +1298,7 @@ sal_Bool SwTable::SplitCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nC pDoc->CreateChartInternalDataProviders( this ); SetHTMLTableLayout( 0 ); // MIB 9.7.97: HTML-Layout loeschen - SwSelBoxes aSelBoxes; - aSelBoxes.Insert(rBoxes.GetData(), rBoxes.Count()); + SwSelBoxes aSelBoxes( rBoxes ); ExpandSelection( aSelBoxes ); //Lines fuer das Layout-Update herausuchen. @@ -1314,9 +1309,9 @@ sal_Bool SwTable::SplitCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nC _CpyTabFrms aFrmArr; SvPtrarr aLastBoxArr; sal_uInt16 nFndPos; - for( sal_uInt16 n = 0; n < aSelBoxes.Count(); ++n ) + for( SwSelBoxes::const_iterator it = aSelBoxes.begin(); it != aSelBoxes.end(); ++it ) { - SwTableBox* pSelBox = *( aSelBoxes.GetData() + n ); + SwTableBox* pSelBox = it->second; OSL_ENSURE( pSelBox, "Box steht nicht in der Tabelle" ); // We don't want to split small table cells into very very small cells @@ -1730,8 +1725,8 @@ sal_Bool lcl_Merge_MoveLine( const _FndLine*& rpFndLine, void* pPara ) sal_Bool SwTable::OldMerge( SwDoc* pDoc, const SwSelBoxes& rBoxes, SwTableBox* pMergeBox, SwUndoTblMerge* pUndo ) { - OSL_ENSURE( rBoxes.Count() && pMergeBox, "keine gueltigen Werte" ); - SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + OSL_ENSURE( !rBoxes.empty() && pMergeBox, "keine gueltigen Werte" ); + SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode()); if( !pTblNd ) return sal_False; @@ -2741,7 +2736,7 @@ sal_Bool lcl_InsSelBox( SwTableLine* pLine, CR_SetBoxWidth& rParam, return sal_False; if( pBox->GetSttNd() ) - rParam.aBoxes.Insert( pBox ); + rParam.aBoxes.insert( pBox ); break; } @@ -3138,7 +3133,7 @@ sal_Bool lcl_DeleteBox_Rekursiv( CR_SetBoxWidth& rParam, SwTableBox& rBox, else { SwTableBox* pBox = &rBox; - rParam.aBoxes.Insert( pBox ); + rParam.aBoxes.insert( pBox ); } } else @@ -3489,7 +3484,7 @@ _FndBox* lcl_SaveInsDelData( CR_SetBoxWidth& rParam, SwUndo** ppUndo, // suche alle Boxen / Lines SwTable& rTbl = rParam.pTblNd->GetTable(); - if( !rParam.aBoxes.Count() ) + if( rParam.aBoxes.empty() ) { // erstmal die Boxen besorgen ! if( rParam.bBigger ) @@ -3501,8 +3496,7 @@ _FndBox* lcl_SaveInsDelData( CR_SetBoxWidth& rParam, SwUndo** ppUndo, } // loeschen der gesamten Tabelle verhindern - if( rParam.bBigger && rParam.aBoxes.Count() == - rTbl.GetTabSortBoxes().Count() ) + if( rParam.bBigger && rParam.aBoxes.size() == rTbl.GetTabSortBoxes().Count() ) return 0; _FndBox* pFndBox = new _FndBox( 0, 0 ); @@ -3645,8 +3639,7 @@ sal_Bool SwTable::SetColWidth( SwTableBox& rAktBox, sal_uInt16 eType, { pFndBox = ::lcl_SaveInsDelData( aParam, ppUndo, aTmpLst, nDistStt ); - if( aParam.bBigger && aParam.aBoxes.Count() == - aSortCntBoxes.Count() ) + if( aParam.bBigger && aParam.aBoxes.size() == aSortCntBoxes.Count() ) { // dies gesamte Tabelle soll geloescht werden!! GetFrmFmt()->GetDoc()->DeleteRowCol( aParam.aBoxes ); @@ -4028,11 +4021,10 @@ _FndBox* lcl_SaveInsDelData( CR_SetLineHeight& rParam, SwUndo** ppUndo, // suche alle Boxen / Lines SwTable& rTbl = rParam.pTblNd->GetTable(); - OSL_ENSURE( rParam.aBoxes.Count(), "ohne Boxen ist nichts zu machen!" ); + OSL_ENSURE( !rParam.aBoxes.empty(), "ohne Boxen ist nichts zu machen!" ); // loeschen der gesamten Tabelle verhindern - if( !rParam.bBigger && rParam.aBoxes.Count() == - rTbl.GetTabSortBoxes().Count() ) + if( !rParam.bBigger && rParam.aBoxes.size() == rTbl.GetTabSortBoxes().Count() ) return 0; _FndBox* pFndBox = new _FndBox( 0, 0 ); @@ -4251,7 +4243,7 @@ sal_Bool lcl_InsDelSelLine( SwTableLine* pLine, CR_SetLineHeight& rParam, return sal_False; if( pBox->GetSttNd() ) - rParam.aBoxes.Insert( pBox ); + rParam.aBoxes.insert( pBox ); else { for( sal_uInt16 i = pBox->GetTabLines().Count(); i; ) @@ -4346,7 +4338,7 @@ sal_Bool SwTable::SetRowHeight( SwTableBox& rAktBox, sal_uInt16 eType, { if( bInsDel ) { - if( !aParam.aBoxes.Count() ) + if( aParam.aBoxes.empty() ) ::lcl_InsDelSelLine( (*pLines)[ nBaseLinePos ], aParam, 0, sal_True ); @@ -4354,7 +4346,7 @@ sal_Bool SwTable::SetRowHeight( SwTableBox& rAktBox, sal_uInt16 eType, // delete complete table when last row is deleted if( !bBigger && - aParam.aBoxes.Count() == aSortCntBoxes.Count() ) + aParam.aBoxes.size() == aSortCntBoxes.Count() ) { GetFrmFmt()->GetDoc()->DeleteRowCol( aParam.aBoxes ); return sal_False; @@ -4432,7 +4424,7 @@ sal_Bool SwTable::SetRowHeight( SwTableBox& rAktBox, sal_uInt16 eType, // dann mal anpassen if( bInsDel ) { - if( !aParam.aBoxes.Count() ) + if( aParam.aBoxes.empty() ) ::lcl_InsDelSelLine( (*pLines)[ nBaseLinePos ], aParam, 0, sal_True ); pFndBox = ::lcl_SaveInsDelData( aParam, ppUndo, aTmpLst ); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 242f2859f809..17bc9f204486 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1665,7 +1665,7 @@ sal_Bool SwDoc::InsertCol( const SwCursor& rCursor, sal_uInt16 nCnt, sal_Bool bB ::GetTblSel( rCursor, aBoxes, nsSwTblSearchType::TBLSEARCH_COL ); sal_Bool bRet = sal_False; - if( aBoxes.Count() ) + if( !aBoxes.empty() ) bRet = InsertCol( aBoxes, nCnt, bBehind ); return bRet; } @@ -1673,8 +1673,8 @@ sal_Bool SwDoc::InsertCol( const SwCursor& rCursor, sal_uInt16 nCnt, sal_Bool bB sal_Bool SwDoc::InsertCol( const SwSelBoxes& rBoxes, sal_uInt16 nCnt, sal_Bool bBehind ) { // uebers SwDoc fuer Undo !! - OSL_ENSURE( rBoxes.Count(), "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode()); if( !pTblNd ) return sal_False; @@ -1728,7 +1728,7 @@ sal_Bool SwDoc::InsertRow( const SwCursor& rCursor, sal_uInt16 nCnt, sal_Bool bB GetTblSel( rCursor, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW ); sal_Bool bRet = sal_False; - if( aBoxes.Count() ) + if( !aBoxes.empty() ) bRet = InsertRow( aBoxes, nCnt, bBehind ); return bRet; } @@ -1736,8 +1736,8 @@ sal_Bool SwDoc::InsertRow( const SwCursor& rCursor, sal_uInt16 nCnt, sal_Bool bB sal_Bool SwDoc::InsertRow( const SwSelBoxes& rBoxes, sal_uInt16 nCnt, sal_Bool bBehind ) { // uebers SwDoc fuer Undo !! - OSL_ENSURE( rBoxes.Count(), "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode()); if( !pTblNd ) return sal_False; @@ -1925,8 +1925,8 @@ sal_Bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn ) return sal_False; // uebers SwDoc fuer Undo !! - OSL_ENSURE( rBoxes.Count(), "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode()); if( !pTblNd ) return sal_False; @@ -1934,8 +1934,7 @@ sal_Bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn ) return sal_False; ::ClearFEShellTabCols(); - SwSelBoxes aSelBoxes; - aSelBoxes.Insert(rBoxes.GetData(), rBoxes.Count()); + SwSelBoxes aSelBoxes( rBoxes ); SwTable &rTable = pTblNd->GetTable(); long nMin = 0; long nMax = 0; @@ -1949,10 +1948,10 @@ sal_Bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn ) // soll die gesamte Tabelle geloescht werden ?? const sal_uLong nTmpIdx1 = pTblNd->GetIndex(); - const sal_uLong nTmpIdx2 = aSelBoxes[ aSelBoxes.Count()-1 ]->GetSttNd()-> + const sal_uLong nTmpIdx2 = aSelBoxes.rbegin()->second->GetSttNd()-> EndOfSectionIndex()+1; - if( pTblNd->GetTable().GetTabSortBoxes().Count() == aSelBoxes.Count() && - aSelBoxes[0]->GetSttIdx()-1 == nTmpIdx1 && + if( pTblNd->GetTable().GetTabSortBoxes().Count() == aSelBoxes.size() && + aSelBoxes.begin()->second->GetSttIdx()-1 == nTmpIdx1 && nTmpIdx2 == pTblNd->EndOfSectionIndex() ) { sal_Bool bNewTxtNd = sal_False; @@ -2135,8 +2134,8 @@ sal_Bool SwDoc::SplitTbl( const SwSelBoxes& rBoxes, sal_Bool bVert, sal_uInt16 n sal_Bool bSameHeight ) { // uebers SwDoc fuer Undo !! - OSL_ENSURE( rBoxes.Count() && nCnt, "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + OSL_ENSURE( !rBoxes.empty() && nCnt, "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode()); if( !pTblNd ) return sal_False; @@ -2155,9 +2154,9 @@ sal_Bool SwDoc::SplitTbl( const SwSelBoxes& rBoxes, sal_Bool bVert, sal_uInt16 n aTmpLst.Insert( &rTbl.GetTabSortBoxes(), 0, rTbl.GetTabSortBoxes().Count() ); if( !bVert ) { - for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it) { - const SwStartNode* pSttNd = rBoxes[ n ]->GetSttNd(); + const SwStartNode* pSttNd = it->second->GetSttNd(); aNdsCnts.push_back( pSttNd->EndOfSectionIndex() - pSttNd->GetIndex() ); } @@ -2531,13 +2530,7 @@ bool FuzzyCompare::operator() ( long s1, long s2 ) const bool lcl_IsFrmInColumn( const SwCellFrm& rFrm, SwSelBoxes& rBoxes ) { - for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) - { - if ( rFrm.GetTabBox() == rBoxes[ i ] ) - return true; - } - - return false; + return 0 != rBoxes.count(rFrm.GetTabBox()); } // @@ -2933,8 +2926,7 @@ void SwCollectTblLineBoxes::AddToUndoHistory( const SwCntntNode& rNd ) void SwCollectTblLineBoxes::AddBox( const SwTableBox& rBox ) { aPosArr.push_back(nWidth); - SwTableBox* p = (SwTableBox*)&rBox; - aBoxes.Insert( p, aBoxes.Count() ); + aBoxes.push_back( &rBox ); nWidth = nWidth + (sal_uInt16)rBox.GetFrmFmt()->GetFrmSize().GetWidth(); } @@ -2966,10 +2958,10 @@ const SwTableBox* SwCollectTblLineBoxes::GetBoxOfPos( const SwTableBox& rBox ) sal_Bool SwCollectTblLineBoxes::Resize( sal_uInt16 nOffset, sal_uInt16 nOldWidth ) { - sal_uInt16 n; - - if( aPosArr.size() ) + if( !aPosArr.empty() ) { + sal_uInt16 n; + for( n = 0; n < aPosArr.size(); ++n ) { if( aPosArr[ n ] == nOffset ) @@ -2983,7 +2975,7 @@ sal_Bool SwCollectTblLineBoxes::Resize( sal_uInt16 nOffset, sal_uInt16 nOldWidth } aPosArr.erase(aPosArr.begin(), aPosArr.begin()+n); - aBoxes.Remove( 0, n ); + aBoxes.erase(aBoxes.begin(), aBoxes.begin()+n); // dann die Positionen der neuen Size anpassen for( n = 0; n < aPosArr.size(); ++n ) @@ -3709,8 +3701,8 @@ sal_Bool lcl_SetAFmtBox( const _FndBox*& rpBox, void *pPara ) // AutoFormat fuer die Tabelle/TabellenSelection sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt& rNew ) { - OSL_ENSURE( rBoxes.Count(), "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode()); if( !pTblNd ) return sal_False; @@ -3787,8 +3779,8 @@ sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt& // Erfrage wie attributiert ist sal_Bool SwDoc::GetTableAutoFmt( const SwSelBoxes& rBoxes, SwTableAutoFmt& rGet ) { - OSL_ENSURE( rBoxes.Count(), "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); + OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode()); if( !pTblNd ) return sal_False; @@ -4232,7 +4224,7 @@ sal_Bool SwDoc::InsCopyOfTbl( SwPosition& rInsPos, const SwSelBoxes& rBoxes, const SwTableNode* pSrcTblNd = pCpyTbl ? pCpyTbl->GetTableNode() - : rBoxes[ 0 ]->GetSttNd()->FindTableNode(); + : rBoxes.begin()->second->GetSttNd()->FindTableNode(); SwTableNode * pInsTblNd = rInsPos.nNode.GetNode().FindTableNode(); @@ -4317,7 +4309,7 @@ sal_Bool SwDoc::InsCopyOfTbl( SwPosition& rInsPos, const SwSelBoxes& rBoxes, // no complex into complex, but copy into or from new model is welcome if( ( !pSrcTblNd->GetTable().IsTblComplex() || pInsTblNd->GetTable().IsNewModel() ) - && ( bDelCpyDoc || rBoxes.Count() ) ) + && ( bDelCpyDoc || !rBoxes.empty() ) ) { // dann die Tabelle "relativ" kopieren const SwSelBoxes* pBoxes; @@ -4328,7 +4320,7 @@ sal_Bool SwDoc::InsCopyOfTbl( SwPosition& rInsPos, const SwSelBoxes& rBoxes, SwTableBox* pBox = pInsTblNd->GetTable().GetTblBox( pSttNd->GetIndex() ); OSL_ENSURE( pBox, "Box steht nicht in dieser Tabelle" ); - aBoxes.Insert( pBox ); + aBoxes.insert( pBox ); pBoxes = &aBoxes; } else @@ -4430,16 +4422,16 @@ sal_Bool SwDoc::UnProtectCells( const String& rName ) sal_Bool SwDoc::UnProtectCells( const SwSelBoxes& rBoxes ) { sal_Bool bChgd = sal_False; - if( rBoxes.Count() ) + if( !rBoxes.empty() ) { SwUndoAttrTbl *const pUndo = (GetIDocumentUndoRedo().DoesUndo()) - ? new SwUndoAttrTbl( *rBoxes[0]->GetSttNd()->FindTableNode() ) + ? new SwUndoAttrTbl( *rBoxes.begin()->second->GetSttNd()->FindTableNode() ) : 0; SvPtrarr aFmts( 16 ), aNewFmts( 16 ); - for( sal_uInt16 i = rBoxes.Count(); i; ) + for( SwSelBoxes::const_reverse_iterator it = rBoxes.rbegin(); it != rBoxes.rend(); ++it ) { - SwTableBox* pBox = rBoxes[ --i ]; + SwTableBox* pBox = it->second; SwFrmFmt* pBoxFmt = pBox->GetFrmFmt(); if( pBoxFmt->GetProtect().IsCntntProtected() ) { diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 2067dd31e643..d75ddd641956 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -148,12 +148,12 @@ sal_Bool lcl_GetBoxSel( const SwCursor& rCursor, SwSelBoxes& rBoxes, { SwTableBox* pBox = (SwTableBox*)pNd->FindTableNode()->GetTable(). GetTblBox( pNd->GetIndex() ); - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); } } while( bAllCrsr && pSttPam != ( pCurPam = (SwPaM*)pCurPam->GetNext()) ); } - return 0 != rBoxes.Count(); + return !rBoxes.empty(); } /*********************************************************************** @@ -245,7 +245,7 @@ void lcl_CollectLines( SvPtrarr &rArr, const SwCursor& rCursor, bool bRemoveLine return ; //Die selektierte Struktur kopieren. - const SwTable &rTable = aBoxes[0]->GetSttNd()->FindTableNode()->GetTable(); + const SwTable &rTable = aBoxes.begin()->second->GetSttNd()->FindTableNode()->GetTable(); LinesAndTable aPara( rArr, rTable ); _FndBox aFndBox( 0, 0 ); { @@ -1125,10 +1125,10 @@ void SwDoc::SetBoxAttr( const SwCursor& rCursor, const SfxPoolItem &rNew ) GetIDocumentUndoRedo().AppendUndo( new SwUndoAttrTbl(*pTblNd) ); } - SvPtrarr aFmtCmp( Max( sal_uInt8(255), sal_uInt8(aBoxes.Count()) ), 255 ); - for ( sal_uInt16 i = 0; i < aBoxes.Count(); ++i ) + SvPtrarr aFmtCmp( Max( sal_uInt8(255), sal_uInt8(aBoxes.size()) ), 255 ); + for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) { - SwTableBox *pBox = aBoxes[i]; + SwTableBox *pBox = it->second; SwFrmFmt *pNewFmt; if ( 0 != (pNewFmt = SwTblFmtCmp::FindNewFmt( aFmtCmp, pBox->GetFrmFmt(), 0 ))) @@ -1171,14 +1171,15 @@ sal_Bool SwDoc::GetBoxAttr( const SwCursor& rCursor, SfxPoolItem& rToFill ) cons bRet = sal_True; sal_Bool bOneFound = sal_False; const sal_uInt16 nWhich = rToFill.Which(); - for( sal_uInt16 i = 0; i < aBoxes.Count(); ++i ) + for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) { + SwTableBox* pBox = it->second; switch ( nWhich ) { case RES_BACKGROUND: { const SvxBrushItem &rBack = - aBoxes[i]->GetFrmFmt()->GetBackground(); + pBox->GetFrmFmt()->GetBackground(); if( !bOneFound ) { (SvxBrushItem&)rToFill = rBack; @@ -1192,7 +1193,7 @@ sal_Bool SwDoc::GetBoxAttr( const SwCursor& rCursor, SfxPoolItem& rToFill ) cons case RES_FRAMEDIR: { const SvxFrameDirectionItem& rDir = - aBoxes[i]->GetFrmFmt()->GetFrmDir(); + pBox->GetFrmFmt()->GetFrmDir(); if( !bOneFound ) { (SvxFrameDirectionItem&)rToFill = rDir; @@ -1204,7 +1205,7 @@ sal_Bool SwDoc::GetBoxAttr( const SwCursor& rCursor, SfxPoolItem& rToFill ) cons case RES_VERT_ORIENT: { const SwFmtVertOrient& rOrient = - aBoxes[i]->GetFrmFmt()->GetVertOrient(); + pBox->GetFrmFmt()->GetVertOrient(); if( !bOneFound ) { (SwFmtVertOrient&)rToFill = rOrient; @@ -1241,10 +1242,10 @@ sal_uInt16 SwDoc::GetBoxAlign( const SwCursor& rCursor ) const SwTableNode* pTblNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode(); SwSelBoxes aBoxes; if( pTblNd && ::lcl_GetBoxSel( rCursor, aBoxes )) - for( sal_uInt16 i = 0; i < aBoxes.Count(); ++i ) + for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) { const SwFmtVertOrient &rOri = - aBoxes[i]->GetFrmFmt()->GetVertOrient(); + it->second->GetFrmFmt()->GetVertOrient(); if( USHRT_MAX == nAlign ) nAlign = static_cast<sal_uInt16>(rOri.GetVertOrient()); else if( rOri.GetVertOrient() != nAlign ) diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index a559edc840a0..f4150868eb22 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -212,11 +212,11 @@ sal_Bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd ) SwTableNode* pTblNd; SwSelBoxes aBoxes; GetTblSel( *this, aBoxes ); - if( aBoxes.Count() && 0 != (pTblNd = (SwTableNode*)aBoxes[0] - ->GetSttNd()->FindTableNode() )) + if( !aBoxes.empty() && + NULL != (pTblNd = const_cast<SwTableNode*>(aBoxes.begin()->second->GetSttNd()->FindTableNode()) )) { // teste ob der TabellenName kopiert werden kann - sal_Bool bCpyTblNm = aBoxes.Count() == pTblNd->GetTable().GetTabSortBoxes().Count(); + sal_Bool bCpyTblNm = aBoxes.size() == pTblNd->GetTable().GetTabSortBoxes().Count(); if( bCpyTblNm ) { const String& rTblName = pTblNd->GetTable().GetFrmFmt()->GetName(); diff --git a/sw/source/core/edit/edtab.cxx b/sw/source/core/edit/edtab.cxx index edf9b2a9d150..11957424a52f 100644 --- a/sw/source/core/edit/edtab.cxx +++ b/sw/source/core/edit/edtab.cxx @@ -281,16 +281,16 @@ sal_Bool SwEditShell::GetTblBoxFormulaAttrs( SfxItemSet& rSet ) const if ( pFrm ) { SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox(); - aBoxes.Insert( pBox ); + aBoxes.insert( pBox ); } } while( sal_False ); } - for( sal_uInt16 n = 0; n < aBoxes.Count(); ++n ) + for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) { - const SwTableBox* pSelBox = aBoxes[ n ]; - const SwTableBoxFmt* pTblFmt = (SwTableBoxFmt*)pSelBox->GetFrmFmt(); - if( !n ) + const SwTableBox* pSelBox = it->second; + const SwTableBoxFmt* pTblFmt = static_cast<SwTableBoxFmt*>(pSelBox->GetFrmFmt()); + if( it == aBoxes.begin() ) { // Formeln in die externe Darstellung bringen! const SwTable& rTbl = pSelBox->GetSttNd()->FindTableNode()->GetTable(); @@ -323,7 +323,7 @@ void SwEditShell::SetTblBoxFormulaAttrs( const SfxItemSet& rSet ) if ( pFrm ) { SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox(); - aBoxes.Insert( pBox ); + aBoxes.insert( pBox ); } } while( sal_False ); } @@ -334,8 +334,8 @@ void SwEditShell::SetTblBoxFormulaAttrs( const SfxItemSet& rSet ) StartAllAction(); GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); - for( sal_uInt16 n = 0; n < aBoxes.Count(); ++n ) - GetDoc()->SetTblBoxFormulaAttrs( *aBoxes[ n ], rSet ); + for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) + GetDoc()->SetTblBoxFormulaAttrs( *it->second, rSet ); GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); EndAllAction(); } diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx index 1594f6c19133..5e7c1e434c85 100644 --- a/sw/source/core/fields/cellfml.cxx +++ b/sw/source/core/fields/cellfml.cxx @@ -349,10 +349,11 @@ void SwTableFormula::_MakeFormel( const SwTable& rTbl, String& rNewStr, rNewStr += '('; bool bDelim = false; - for( sal_uInt16 n = 0; n < aBoxes.Count() && - !pCalcPara->rCalc.IsCalcError(); ++n ) + for( SwSelBoxes::const_iterator it = aBoxes.begin(); + it != aBoxes.end() && !pCalcPara->rCalc.IsCalcError(); + ++it ) { - const SwTableBox* pTblBox = aBoxes[n]; + const SwTableBox* pTblBox = it->second; if ( pTblBox->getRowSpan() >= 1 ) { if( bDelim ) @@ -875,12 +876,11 @@ String lcl_BoxNmToRel( const SwTable& rTbl, const SwTableNode& rTblNd, sal_uInt16 SwTableFormula::GetBoxesOfFormula( const SwTable& rTbl, SwSelBoxes& rBoxes ) { - if( rBoxes.Count() ) - rBoxes.Remove( sal_uInt16(0), rBoxes.Count() ); + rBoxes.clear(); BoxNmToPtr( &rTbl ); ScanString( &SwTableFormula::_GetFmlBoxes, rTbl, &rBoxes ); - return rBoxes.Count(); + return rBoxes.size(); } void SwTableFormula::_GetFmlBoxes( const SwTable& rTbl, String& , @@ -912,10 +912,10 @@ void SwTableFormula::_GetFmlBoxes( const SwTable& rTbl, String& , // deren Werte SwSelBoxes aBoxes; GetBoxes( *pSttBox, *pEndBox, aBoxes ); - pBoxes->Insert( &aBoxes ); + pBoxes->insert( aBoxes.begin(), aBoxes.end() ); } else if( pSttBox ) // nur die StartBox ? - pBoxes->Insert( pSttBox ); + pBoxes->insert( pSttBox ); } void SwTableFormula::GetBoxes( const SwTableBox& rSttBox, @@ -960,14 +960,17 @@ void SwTableFormula::GetBoxes( const SwTableBox& rSttBox, break; // dann mal die Tabellenkoepfe raus: - for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) { - pLine = rBoxes[n]->GetUpper(); + pLine = it->second->GetUpper(); while( pLine->GetUpper() ) pLine = pLine->GetUpper()->GetUpper(); if( pTbl->IsHeadline( *pLine ) ) - rBoxes.Remove( n--, 1 ); + { + rBoxes.erase( it++ ); + --it; + } } } while( sal_False ); } diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index d7a3c126cb87..04732af589ea 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -594,8 +594,8 @@ sal_Bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, const SwTableNode* pTblNd; SwSelBoxes aBoxes; GetTblSel( *this, aBoxes ); - if( aBoxes.Count() && - 0 != (pTblNd = aBoxes[0]->GetSttNd()->FindTableNode()) ) + if( !aBoxes.empty() && + NULL != (pTblNd = aBoxes.begin()->second->GetSttNd()->FindTableNode()) ) { SwPosition* pDstPos = 0; if( this == pDestShell ) @@ -621,7 +621,7 @@ sal_Bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, bRet = pDestShell->GetDoc()->InsCopyOfTbl( *pDstPos, aBoxes,0, bIsMove && this == pDestShell && - aBoxes.Count() == pTblNd->GetTable(). + aBoxes.size() == pTblNd->GetTable(). GetTabSortBoxes().Count(), this != pDestShell ); @@ -865,7 +865,7 @@ sal_Bool SwFEShell::Paste( SwDoc* pClpDoc, sal_Bool bIncludingPageFrames ) SwTableBox* pBox = pDestNd->GetTable().GetTblBox( pSttNd->GetIndex() ); OSL_ENSURE( pBox, "Box steht nicht in dieser Tabelle" ); - aBoxes.Insert( pBox ); + aBoxes.insert( pBox ); } SwNodeIndex aNdIdx( *pDestNd->EndOfSectionNode()); diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 6662c479e4df..94f0062643e5 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -615,13 +615,13 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali if( IsTableMode() ) { GetTblSel( *this, aBoxes ); - if( aBoxes.Count() ) + if( !aBoxes.empty() ) { // die Crsr muessen noch aus dem Loeschbereich entfernt // werden. Setze sie immer hinter/auf die Tabelle; ueber die // Dokument-Position werden sie dann immer an die alte // Position gesetzt. - ParkCrsr( SwNodeIndex( *aBoxes[0]->GetSttNd() )); + ParkCrsr( SwNodeIndex( *aBoxes.begin()->second->GetSttNd() )); // #i127787# pCurCrsr will be deleted in ParkCrsr, // we better get the current pCurCrsr instead of working with the diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 77bfdaaf0946..d3585d3f4e91 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -223,10 +223,10 @@ sal_Bool SwFEShell::InsertRow( sal_uInt16 nCnt, sal_Bool bBehind ) SwSelBoxes aBoxes; GetTblSel( *this, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW ); - TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.Count() ); + TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.size() ); sal_Bool bRet = sal_False; - if ( aBoxes.Count() ) + if ( !aBoxes.empty() ) bRet = GetDoc()->InsertRow( aBoxes, nCnt, bBehind ); EndAllActionAndCall(); @@ -261,10 +261,10 @@ sal_Bool SwFEShell::InsertCol( sal_uInt16 nCnt, sal_Bool bBehind ) SwSelBoxes aBoxes; GetTblSel( *this, aBoxes, nsSwTblSearchType::TBLSEARCH_COL ); - TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.Count() ); + TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.size() ); sal_Bool bRet = sal_False; - if( aBoxes.Count() ) + if( !aBoxes.empty() ) bRet = GetDoc()->InsertCol( aBoxes, nCnt, bBehind ); EndAllActionAndCall(); @@ -316,9 +316,9 @@ sal_Bool SwFEShell::DeleteCol() sal_Bool bRet; SwSelBoxes aBoxes; GetTblSel( *this, aBoxes, nsSwTblSearchType::TBLSEARCH_COL ); - if ( aBoxes.Count() ) + if ( !aBoxes.empty() ) { - TblWait( aBoxes.Count(), pFrm, *GetDoc()->GetDocShell() ); + TblWait( aBoxes.size(), pFrm, *GetDoc()->GetDocShell() ); // die Crsr muessen noch aus dem Loesch Bereich entfernt // werden. Setze sie immer hinter/auf die Tabelle; ueber die @@ -363,9 +363,9 @@ sal_Bool SwFEShell::DeleteRow() SwSelBoxes aBoxes; GetTblSel( *this, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW ); - if( aBoxes.Count() ) + if( !aBoxes.empty() ) { - TblWait( aBoxes.Count(), pFrm, *GetDoc()->GetDocShell() ); + TblWait( aBoxes.size(), pFrm, *GetDoc()->GetDocShell() ); // die Crsr aus dem Loeschbereich entfernen. // Der Cursor steht danach: @@ -525,9 +525,9 @@ sal_Bool SwFEShell::SplitTab( sal_Bool bVert, sal_uInt16 nCnt, sal_Bool bSameHei sal_Bool bRet; SwSelBoxes aBoxes; GetTblSel( *this, aBoxes ); - if( aBoxes.Count() ) + if( !aBoxes.empty() ) { - TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.Count() ); + TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.size() ); // dann loesche doch die Spalten bRet = GetDoc()->SplitTbl( aBoxes, bVert, nCnt, bSameHeight ); @@ -939,12 +939,12 @@ sal_Bool SwFEShell::HasWholeTabSelection() const { SwSelBoxes aBoxes; ::GetTblSelCrs( *this, aBoxes ); - if( aBoxes.Count() ) + if( !aBoxes.empty() ) { const SwTableNode *pTblNd = IsCrsrInTbl(); - return ( pTblNd && aBoxes[0]->GetSttIdx()-1 == pTblNd-> + return ( pTblNd && aBoxes.begin()->second->GetSttIdx()-1 == pTblNd-> EndOfSectionNode()->StartOfSectionIndex() && - aBoxes[aBoxes.Count()-1]->GetSttNd()->EndOfSectionIndex()+1 + aBoxes.rbegin()->second->GetSttNd()->EndOfSectionIndex()+1 == pTblNd->EndOfSectionIndex() ); } } @@ -1032,12 +1032,12 @@ void SwFEShell::UnProtectCells() } while ( pFrm && !pFrm->IsCellFrm() ); if( pFrm ) { - SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox(); - aBoxes.Insert( pBox ); + SwTableBox *pBox = const_cast<SwTableBox*>(static_cast<SwCellFrm*>(pFrm)->GetTabBox()); + aBoxes.insert( pBox ); } } - if( aBoxes.Count() ) + if( !aBoxes.empty() ) GetDoc()->UnProtectCells( aBoxes ); EndAllActionAndCall(); @@ -1075,11 +1075,11 @@ sal_Bool SwFEShell::CanUnProtectCells() const } while ( pFrm && !pFrm->IsCellFrm() ); if( pFrm ) { - SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox(); - aBoxes.Insert( pBox ); + SwTableBox *pBox = const_cast<SwTableBox*>(static_cast<SwCellFrm*>(pFrm)->GetTabBox()); + aBoxes.insert( pBox ); } } - if( aBoxes.Count() ) + if( !aBoxes.empty() ) bUnProtectAvailable = ::HasProtectedCells( aBoxes ); } return bUnProtectAvailable; @@ -1236,20 +1236,20 @@ sal_Bool SwFEShell::IsAdjustCellWidthAllowed( sal_Bool bBalance ) const ::GetTblSelCrs( *this, aBoxes ); if ( bBalance ) - return aBoxes.Count() > 1; + return aBoxes.size() > 1; - if ( !aBoxes.Count() ) + if ( aBoxes.empty() ) { do { pFrm = pFrm->GetUpper(); } while ( !pFrm->IsCellFrm() ); - SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox(); - aBoxes.Insert( pBox ); + SwTableBox *pBox = const_cast<SwTableBox*>(static_cast<SwCellFrm*>(pFrm)->GetTabBox()); + aBoxes.insert( pBox ); } - for ( sal_uInt16 i = 0; i < aBoxes.Count(); ++i ) + for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) { - SwTableBox *pBox = aBoxes[i]; + SwTableBox *pBox = it->second; if ( pBox->GetSttNd() ) { SwNodeIndex aIdx( *pBox->GetSttNd(), 1 ); @@ -1289,13 +1289,12 @@ sal_Bool SwFEShell::SetTableAutoFmt( const SwTableAutoFmt& rNew ) const SwTableSortBoxes& rTBoxes = pTblNd->GetTable().GetTabSortBoxes(); for( sal_uInt16 n = 0; n < rTBoxes.Count(); ++n ) { - SwTableBox* pBox = rTBoxes[ n ]; - aBoxes.Insert( pBox ); + aBoxes.insert( rTBoxes[ n ] ); } } sal_Bool bRet; - if( aBoxes.Count() ) + if( !aBoxes.empty() ) { SET_CURR_SHELL( this ); StartAllAction(); @@ -1328,8 +1327,7 @@ sal_Bool SwFEShell::GetTableAutoFmt( SwTableAutoFmt& rGet ) const SwTableSortBoxes& rTBoxes = pTblNd->GetTable().GetTabSortBoxes(); for( sal_uInt16 n = 0; n < rTBoxes.Count(); ++n ) { - SwTableBox* pBox = rTBoxes[ n ]; - aBoxes.Insert( pBox ); + aBoxes.insert( rTBoxes[ n ] ); } } @@ -1361,9 +1359,9 @@ sal_Bool SwFEShell::DeleteTblSel() sal_Bool bRet; SwSelBoxes aBoxes; GetTblSelCrs( *this, aBoxes ); - if( aBoxes.Count() ) + if( !aBoxes.empty() ) { - TblWait( aBoxes.Count(), pFrm, *GetDoc()->GetDocShell() ); + TblWait( aBoxes.size(), pFrm, *GetDoc()->GetDocShell() ); // die Crsr muessen noch aus dem Loesch Bereich entfernt // werden. Setze sie immer hinter/auf die Tabelle; ueber die @@ -2348,9 +2346,10 @@ sal_Bool lcl_IsFormulaSelBoxes( const SwTable& rTbl, const SwTblBoxFormula& rFml { SwTblBoxFormula aTmp( rFml ); SwSelBoxes aBoxes; - for( sal_uInt16 nSelBoxes = aTmp.GetBoxesOfFormula( rTbl,aBoxes ); nSelBoxes; ) + aTmp.GetBoxesOfFormula( rTbl,aBoxes ); + for( SwSelBoxes::const_reverse_iterator it = aBoxes.rbegin(); it != aBoxes.rend(); ++it ) { - SwTableBox* pBox = aBoxes[ --nSelBoxes ]; + SwTableBox* pBox = it->second; sal_uInt16 i; for( i = 0; i < rCells.Count(); ++i ) if( rCells[ i ]->GetTabBox() == pBox ) diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 3ab37dbc3c28..8ab53d5beed6 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -77,42 +77,6 @@ #define DEL_ALL_EMPTY_BOXES -_SV_IMPL_SORTAR_ALG( SwSelBoxes, SwTableBoxPtr ) -sal_Bool SwSelBoxes::Seek_Entry( const SwTableBoxPtr rSrch, sal_uInt16* pFndPos ) const -{ - sal_uLong nIdx = rSrch->GetSttIdx(); - - sal_uInt16 nO = Count(), nM, nU = 0; - if( nO > 0 ) - { - nO--; - while( nU <= nO ) - { - nM = nU + ( nO - nU ) / 2; - if( (*this)[ nM ]->GetSttNd() == rSrch->GetSttNd() ) - { - if( pFndPos ) - *pFndPos = nM; - return sal_True; - } - else if( (*this)[ nM ]->GetSttIdx() < nIdx ) - nU = nM + 1; - else if( nM == 0 ) - { - if( pFndPos ) - *pFndPos = nU; - return sal_False; - } - else - nO = nM - 1; - } - } - if( pFndPos ) - *pFndPos = nU; - return sal_False; -} - - SV_IMPL_PTRARR( SwCellFrms, SwCellFrm* ) struct _CmpLPt @@ -183,25 +147,29 @@ const SwLayoutFrm *lcl_FindNextCellFrm( const SwLayoutFrm *pLay ) void GetTblSelCrs( const SwCrsrShell &rShell, SwSelBoxes& rBoxes ) { - if( rBoxes.Count() ) - rBoxes.Remove( sal_uInt16(0), rBoxes.Count() ); - if( rShell.IsTableMode() && ((SwCrsrShell&)rShell).UpdateTblSelBoxes()) - rBoxes.Insert( &rShell.GetTableCrsr()->GetBoxes() ); + rBoxes.clear(); + if( rShell.IsTableMode() && const_cast<SwCrsrShell&>(rShell).UpdateTblSelBoxes()) + { + const SwSelBoxes& rShellBoxes = rShell.GetTableCrsr()->GetBoxes(); + rBoxes.insert( rShellBoxes.begin(), rShellBoxes.end() ); + } } void GetTblSelCrs( const SwTableCursor& rTblCrsr, SwSelBoxes& rBoxes ) { - if( rBoxes.Count() ) - rBoxes.Remove( sal_uInt16(0), rBoxes.Count() ); + rBoxes.clear(); if( rTblCrsr.IsChgd() || !rTblCrsr.GetBoxesCount() ) { - SwTableCursor* pTCrsr = (SwTableCursor*)&rTblCrsr; + SwTableCursor* pTCrsr = const_cast<SwTableCursor*>(&rTblCrsr); pTCrsr->GetDoc()->GetCurrentLayout()->MakeTblCrsrs( *pTCrsr ); //swmod 080218 } if( rTblCrsr.GetBoxesCount() ) - rBoxes.Insert( &rTblCrsr.GetBoxes() ); + { + const SwSelBoxes& rCursorBoxes = rTblCrsr.GetBoxes(); + rBoxes.insert( rCursorBoxes.begin(), rCursorBoxes.end() ); + } } void GetTblSel( const SwCrsrShell& rShell, SwSelBoxes& rBoxes, @@ -276,7 +244,7 @@ void GetTblSel( const SwCursor& rCrsr, SwSelBoxes& rBoxes, // Zellenschutzt beachten ?? if( !bChkProtected || !pBox->GetFrmFmt()->GetProtect().IsCntntProtected() ) - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); } } } @@ -379,7 +347,7 @@ void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd, // Zellenschutzt beachten ?? if( !bChkProtected || !pBox->GetFrmFmt()->GetProtect().IsCntntProtected() ) - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); if ( pCells ) { @@ -472,8 +440,7 @@ void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd, break; } - i = 0; - rBoxes.Remove( i, rBoxes.Count() ); + rBoxes.clear(); --nLoopMax; } while( sal_True ); @@ -926,14 +893,14 @@ sal_Bool GetAutoSumSel( const SwCrsrShell& rShell, SwCellFrms& rBoxes ) sal_Bool HasProtectedCells( const SwSelBoxes& rBoxes ) { - sal_Bool bRet = sal_False; - for( sal_uInt16 n = 0, nCnt = rBoxes.Count(); n < nCnt; ++n ) - if( rBoxes[ n ]->GetFrmFmt()->GetProtect().IsCntntProtected() ) + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + { + if( it->second->GetFrmFmt()->GetProtect().IsCntntProtected() ) { - bRet = sal_True; - break; + return sal_True; } - return bRet; + } + return sal_False; } @@ -1000,8 +967,7 @@ sal_Bool IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam ) void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, SwTableBox** ppMergeBox, SwUndoTblMerge* pUndo ) { - if( rBoxes.Count() ) - rBoxes.Remove( sal_uInt16(0), rBoxes.Count() ); + rBoxes.clear(); //Zuerst lassen wir uns die Tabellen und die Rechtecke heraussuchen. OSL_ENSURE( rPam.GetCntntNode() && rPam.GetCntntNode( sal_False ), @@ -1081,7 +1047,7 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, pBox->GetFrmFmt()->SetFmtAttr( aNew ); // diese Box ist selektiert pLastBox = pBox; - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); aPosArr.Insert( _CmpLPt( (pCell->Frm().*fnRect->fnGetPos)(), pBox, bVert ) ); @@ -1098,7 +1064,7 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, { // diese Box ist selektiert pLastBox = pBox; - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); #if OSL_DEBUG_LEVEL > 1 Point aInsPoint( (pCell->Frm().*fnRect->fnGetPos)() ); #endif @@ -1149,7 +1115,7 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, // diese Box ist selektiert pLastBox = pBox; - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); aPosArr.Insert( _CmpLPt( (pCell->Frm().*fnRect->fnGetPos)(), pBox, bVert ) ); @@ -1193,7 +1159,7 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, pBox->GetFrmFmt()->SetFmtAttr( aNew ); pLastBox = pBox; - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); aPosArr.Insert( _CmpLPt( Point( rUnion.Left(), pCell->Frm().Top()), pBox, bVert )); @@ -1217,7 +1183,7 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, } // keine SSelection / keine gefundenen Boxen - if( 1 >= rBoxes.Count() ) + if( 1 >= rBoxes.size() ) return; // dann suche mal alle Boxen, die nebeneinander liegen, und verbinde @@ -1405,7 +1371,7 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, // lege schon mal die neue Box an { - SwTableBox* pTmpBox = rBoxes[0]; + SwTableBox* pTmpBox = rBoxes.begin()->second; SwTableLine* pInsLine = pTmpBox->GetUpper(); sal_uInt16 nInsPos = pInsLine->GetTabBoxes().C40_GETPOS( SwTableBox, pTmpBox ); @@ -1543,13 +1509,13 @@ sal_uInt16 CheckMergeSel( const SwPaM& rPam ) sal_uInt16 CheckMergeSel( const SwSelBoxes& rBoxes ) { sal_uInt16 eRet = TBLMERGE_NOSELECTION; - if( rBoxes.Count() ) + if( !rBoxes.empty() ) { eRet = TBLMERGE_OK; _FndBox aFndBox( 0, 0 ); _FndPara aPara( rBoxes, &aFndBox ); - const SwTableNode* pTblNd = aPara.rBoxes[0]->GetSttNd()->FindTableNode(); + const SwTableNode* pTblNd = aPara.rBoxes.begin()->second->GetSttNd()->FindTableNode(); ((SwTable&)pTblNd->GetTable()).GetTabLines().ForEach( &_FndLineCopyCol, &aPara ); if( aFndBox.GetLines().Count() ) @@ -2156,9 +2122,7 @@ sal_Bool _FndBoxCopyCol( const SwTableBox*& rpBox, void* pPara ) } else { - SwTableBoxPtr pSrch = (SwTableBoxPtr)rpBox; - sal_uInt16 nFndPos; - if( !pFndPara->rBoxes.Seek_Entry( pSrch, &nFndPos )) + if( 0 != pFndPara->rBoxes.count( rpBox ) ) { delete pFndBox; return sal_True; @@ -2197,9 +2161,9 @@ void _FndBox::SetTableLines( const SwSelBoxes &rBoxes, const SwTable &rTable ) sal_uInt16 nStPos = USHRT_MAX; sal_uInt16 nEndPos= 0; - for ( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) + for ( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) { - SwTableLine *pLine = rBoxes[i]->GetUpper(); + SwTableLine *pLine = it->second->GetUpper(); while ( pLine->GetUpper() ) pLine = pLine->GetUpper()->GetUpper(); const sal_uInt16 nPos = rTable.GetTabLines().GetPos( diff --git a/sw/source/core/inc/tblrwcl.hxx b/sw/source/core/inc/tblrwcl.hxx index fd9e0dfb0d8c..18a7f03fdb8d 100644 --- a/sw/source/core/inc/tblrwcl.hxx +++ b/sw/source/core/inc/tblrwcl.hxx @@ -85,7 +85,7 @@ SW_DLLPUBLIC void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* pUndo = 0 class SwCollectTblLineBoxes { std::vector<sal_uInt16> aPosArr; - SwSelBoxes_SAR aBoxes; + std::vector<const SwTableBox*> aBoxes; SwHistory* pHst; sal_uInt16 nMode, nWidth; sal_Bool bGetFromTop : 1; @@ -93,9 +93,8 @@ class SwCollectTblLineBoxes public: SwCollectTblLineBoxes( sal_Bool bTop, sal_uInt16 nMd = 0, SwHistory* pHist=0 ) - : aBoxes( 16, 16 ), - pHst( pHist ), nMode( nMd ), nWidth( 0 ), - bGetFromTop( bTop ), bGetValues( sal_True ) + : pHst( pHist ), nMode( nMd ), nWidth( 0 ), + bGetFromTop( bTop ), bGetValues( sal_True ) {} @@ -103,7 +102,7 @@ public: const SwTableBox* GetBoxOfPos( const SwTableBox& rBox ); void AddToUndoHistory( const SwCntntNode& rNd ); - sal_uInt16 Count() const { return aBoxes.Count(); } + sal_uInt16 Count() const { return aBoxes.size(); } const SwTableBox& GetBox( std::size_t nPos, sal_uInt16* pWidth = 0 ) const { // hier wird die EndPos der Spalte benoetigt! diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index 7261d37d586f..d82eb35f80a0 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -1950,7 +1950,7 @@ bool SwRootFrm::MakeTblCrsrs( SwTableCursor& rTblCrsr ) { SwTableBox* pInsBox = (SwTableBox*) ((SwCellFrm*)pCell)->GetTabBox(); - aNew.Insert( pInsBox ); + aNew.insert( pInsBox ); } if ( pCell->GetNext() ) { diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx index 24cedcb60fba..d7d8d87b3390 100644 --- a/sw/source/core/table/swnewtable.cxx +++ b/sw/source/core/table/swnewtable.cxx @@ -409,7 +409,7 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const { if( nCurrBox ) { - pBoxes->Insert( pBox ); + pBoxes->insert( pBox ); pInnerBox = pBox; pLeftBox = pLine->GetTabBoxes()[nCurrBox-1]; nDiff = nMin - nLeft; @@ -440,7 +440,7 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const } else if( nRight <= nMax ) { - pBoxes->Insert( pBox ); + pBoxes->insert( pBox ); if( nRow == nTop && nRowSpan < 0 ) { bOkay = false; @@ -459,7 +459,7 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const { if( nCurrBox+1 < nCount ) { - pBoxes->Insert( pBox ); + pBoxes->insert( pBox ); pInnerBox = pBox; pRightBox = pLine->GetTabBoxes()[nCurrBox+1]; nDiff = nRight - nMax; @@ -612,11 +612,11 @@ long lcl_InsertPosition( SwTable &rTable, std::vector<sal_uInt16>& rInsPos, { sal_Int32 nAddWidth = 0; long nCount = 0; - for( sal_uInt16 j = 0; j < rBoxes.Count(); ++j ) + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) { - SwTableBox *pBox = rBoxes[j]; + SwTableBox *pBox = it->second; SwTableLine* pLine = pBox->GetUpper(); - long nWidth = rBoxes[j]->GetFrmFmt()->GetFrmSize().GetWidth(); + long nWidth = pBox->GetFrmFmt()->GetFrmSize().GetWidth(); nAddWidth += nWidth; sal_uInt16 nCurrBox = pLine->GetTabBoxes().C40_GETPOS(SwTableBox, pBox ); sal_uInt16 nCurrLine = rTable.GetTabLines().C40_GETPOS(SwTableLine, pLine ); @@ -816,7 +816,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, if( !bNewModel ) { ::GetMergeSel( rPam, rBoxes, ppMergeBox, pUndo ); - return rBoxes.Count() > 1; + return rBoxes.size() > 1; } CHECK_TABLE( *this ) // We have to assert a "rectangular" box selection before we start to merge @@ -827,7 +827,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, // i.e. contiguous cells in contiguous rows bool bMerge = false; // will be set if any content is transferred from // a "not already overlapped" cell into the new master cell. - SwTableBox *pMergeBox = (*pSel->aBoxes[0])[0]; // the master cell box + SwTableBox *pMergeBox = pSel->aBoxes[0]->begin()->second; // the master cell box if( !pMergeBox ) return false; (*ppMergeBox) = pMergeBox; @@ -854,16 +854,16 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, { // The selected boxes in the current line const SwSelBoxes* pBoxes = pSel->aBoxes[ nCurrLine ]; - sal_uInt16 nColCount = pBoxes->Count(); + SwSelBoxes::const_iterator itTail = pBoxes->end(); --itTail; // Iteration over the selected cell in the current row - for( sal_uInt16 nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol ) + for( SwSelBoxes::const_iterator it = pBoxes->begin(); it != pBoxes->end(); ++it ) { - SwTableBox* pBox = (*pBoxes)[nCurrCol]; - rMerged.Insert( pBox ); + SwTableBox* pBox = it->second; + rMerged.insert( pBox ); // Only the first selected cell in every row will be alive, // the other will be deleted => put into rBoxes - if( nCurrCol ) - rBoxes.Insert( pBox ); + if( it != pBoxes->begin() ) + rBoxes.insert( pBox ); else { if( nCurrLine == 1 ) @@ -876,7 +876,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, bool bDoMerge = pBox != pMergeBox && pBox->getRowSpan() > 0; // The last box has to be in the last "column" of the selection // and it has to be a master cell - if( nCurrCol+1 == nColCount && pBox->getRowSpan() > 0 ) + if( it == itTail && pBox->getRowSpan() > 0 ) pLastBox = pBox; if( bDoMerge ) { @@ -914,7 +914,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, } // Only the cell of the first selected column will stay alive // and got a new row span - if( !nCurrCol ) + if( it == pBoxes->begin() ) pBox->setRowSpan( nRowSpan ); } if( nRowSpan > 0 ) // the master cell is done, from now on we set @@ -932,11 +932,10 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, for( sal_uInt16 nCurrLine = 0; nCurrLine < nLineCount; ++nCurrLine ) { const SwSelBoxes* pBoxes = pSel->aBoxes[ nCurrLine ]; - sal_uInt16 nColCount = pBoxes->Count(); - for( sal_uInt16 nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol ) + for( SwSelBoxes::const_iterator it = pBoxes->begin(); it != pBoxes->end(); ++it ) { - SwTableBox* pBox = (*pBoxes)[nCurrCol]; - if( nCurrCol ) + SwTableBox* pBox = it->second; + if( it != pBoxes->begin() ) { // Even this box will be deleted soon, // we have to correct the width to avoid side effects @@ -944,7 +943,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, pFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, 0, 0 ) ); } else - pBox->ChgFrmFmt( (SwTableBoxFmt*)pNewFmt ); + pBox->ChgFrmFmt( static_cast<SwTableBoxFmt*>(pNewFmt) ); } } if( pLastBox ) // Robust @@ -974,10 +973,10 @@ void SwTable::_FindSuperfluousRows( SwSelBoxes& rBoxes, { if( !pFirstLn || !pLastLn ) { - if( !rBoxes.Count() ) + if( rBoxes.empty() ) return; - pFirstLn = rBoxes[0]->GetUpper(); - pLastLn = rBoxes[ rBoxes.Count() - 1 ]->GetUpper(); + pFirstLn = rBoxes.begin()->second->GetUpper(); + pLastLn = rBoxes.rbegin()->second->GetUpper(); } sal_uInt16 nFirstLn = GetTabLines().C40_GETPOS(SwTableLine, pFirstLn ); sal_uInt16 nLastLn = GetTabLines().C40_GETPOS(SwTableLine, pLastLn ); @@ -991,7 +990,7 @@ void SwTable::_FindSuperfluousRows( SwSelBoxes& rBoxes, { SwTableBox *pBox = pLine->GetTabBoxes()[nCol]; if( pBox->getRowSpan() > 0 && - USHRT_MAX == rBoxes.GetPos( pBox ) ) + 0 == rBoxes.count( pBox ) ) { bSuperfl = false; break; @@ -1002,7 +1001,7 @@ void SwTable::_FindSuperfluousRows( SwSelBoxes& rBoxes, for( sal_uInt16 nCol = 0; nCol < nCols; ++nCol ) { SwTableBox* pBox = pLine->GetTabBoxes()[nCol]; - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); } } } @@ -1070,7 +1069,7 @@ void lcl_getAllMergedBoxes( const SwTable& rTable, SwSelBoxes& rBoxes, SwTableBo { SwTableBox* pBox = &rBox; OSL_ENSURE( pBox == &rBox.FindStartOfRowSpan( rTable, USHRT_MAX ), "Not a master box" ); - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); if( pBox->getRowSpan() == 1 ) return; const SwTableLine* pMyUpper = pBox->GetUpper(); @@ -1081,7 +1080,7 @@ void lcl_getAllMergedBoxes( const SwTable& rTable, SwSelBoxes& rBoxes, SwTableBo { pBox = lcl_LeftBorder2Box( nLeftBorder, rTable.GetTabLines()[nLine] ); if( pBox ) - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); }; } @@ -1094,7 +1093,7 @@ void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, sal_uInt16 nCnt, { SwSelBoxes aBoxes; lcl_getAllMergedBoxes( rTable, aBoxes, rBox ); - sal_uInt16 nCount = aBoxes.Count(); + sal_uInt16 nCount = aBoxes.size(); if( nCount < 2 ) return; if( nCnt > nCount ) @@ -1102,14 +1101,15 @@ void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, sal_uInt16 nCnt, sal_uInt16 *pSplitIdx = new sal_uInt16[ nCnt ]; if( bSameHeight ) { - SwTwips *pHeights = new SwTwips[ nCount ]; + std::vector<SwTwips> aHeights; SwTwips nHeight = 0; - for( sal_uInt16 i = 0; i < nCount; ++i ) + for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) { - SwTableLine* pLine = aBoxes[ i ]->GetUpper(); + SwTableLine* pLine = it->second->GetUpper(); SwFrmFmt *pRowFmt = pLine->GetFrmFmt(); - pHeights[ i ] = pRowFmt->GetFrmSize().GetHeight(); - nHeight += pHeights[ i ]; + SwTwips nH = pRowFmt->GetFrmSize().GetHeight(); + aHeights.push_back( nH ); + nHeight += nH; } SwTwips nSumH = 0; sal_uInt16 nIdx = 0; @@ -1117,24 +1117,29 @@ void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, sal_uInt16 nCnt, { SwTwips nSplit = ( i * nHeight ) / nCnt; while( nSumH < nSplit && nIdx < nCount ) - nSumH += pHeights[ nIdx++ ]; + nSumH += aHeights[ nIdx++ ]; pSplitIdx[ i - 1 ] = nIdx; } - delete[] pHeights; } else { - for( long i = 1; i <= nCnt; ++i ) - pSplitIdx[ i - 1 ] = (sal_uInt16)( ( i * nCount ) / nCnt ); + for( sal_uInt32 i = 1; i <= nCnt; ++i ) + pSplitIdx[ i - 1 ] = static_cast<sal_uInt16>( ( i * nCount ) / nCnt ); } sal_uInt16 nIdx = 0; - for( long i = 0; i < nCnt; ++i ) + SwSelBoxes::const_iterator it = aBoxes.begin(); + for( sal_uInt16 i = 0; i < nCnt; ++i ) { sal_uInt16 nNextIdx = pSplitIdx[ i ]; - aBoxes[ nIdx ]->setRowSpan( nNextIdx - nIdx ); - lcl_InvalidateCellFrm( *aBoxes[ nIdx ] ); - while( ++nIdx < nNextIdx ) - aBoxes[ nIdx ]->setRowSpan( nIdx - nNextIdx ); + it->second->setRowSpan( nNextIdx - nIdx ); + lcl_InvalidateCellFrm( *it->second ); + while( true ) { + ++nIdx; + ++it; + if( nIdx >= nNextIdx ) + break; + it->second->setRowSpan( nIdx - nNextIdx ); + } } delete[] pSplitIdx; } @@ -1147,7 +1152,7 @@ void lcl_FillSelBoxes( SwSelBoxes &rBoxes, SwTableLine &rLine ) sal_uInt16 nBoxCount = rLine.GetTabBoxes().Count(); sal_uInt16 nCurrBox; for( nCurrBox = 0; nCurrBox < nBoxCount; ++nCurrBox ) - rBoxes.Insert( rLine.GetTabBoxes()[nCurrBox] ); + rBoxes.insert( rLine.GetTabBoxes()[nCurrBox] ); } /** SwTable::InsertSpannedRow(..) inserts "superfluous" rows, i.e. rows containig @@ -1209,9 +1214,9 @@ void lcl_SophisticatedFillLineIndices( SwLineOffsetArray &rArr, { std::list< SwLineOffset > aBoxes; SwLineOffset aLnOfs( USHRT_MAX, USHRT_MAX ); - for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) { // Collect all end line indices and the row spans - const SwTableBox &rBox = rBoxes[ i ]->FindStartOfRowSpan( rTable ); + const SwTableBox &rBox = it->second->FindStartOfRowSpan( rTable ); OSL_ENSURE( rBox.getRowSpan() > 0, "Didn't I say 'StartOfRowSpan' ??" ); if( nCnt > rBox.getRowSpan() ) { @@ -1308,9 +1313,9 @@ sal_uInt16 lcl_CalculateSplitLineHeights( SwSplitLines &rCurr, SwSplitLines &rNe SwLineOffset aLnOfs( USHRT_MAX, USHRT_MAX ); sal_uInt16 nFirst = USHRT_MAX; // becomes the index of the first line sal_uInt16 nLast = 0; // becomes the index of the last line of the splitting - for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) { // Collect all pairs (start+end) of line indices to split - const SwTableBox &rBox = rBoxes[ i ]->FindStartOfRowSpan( rTable ); + const SwTableBox &rBox = it->second->FindStartOfRowSpan( rTable ); OSL_ENSURE( rBox.getRowSpan() > 0, "Didn't I say 'StartOfRowSpan' ??" ); const SwTableLine *pLine = rBox.GetUpper(); const sal_uInt16 nStart = rTable.GetTabLines().C40_GETPOS( SwTableLine, pLine ); @@ -1365,10 +1370,10 @@ sal_uInt16 lcl_LineIndex( const SwTable& rTable, const SwSelBoxes& rBoxes, { sal_uInt16 nDirect = USHRT_MAX; sal_uInt16 nSpan = USHRT_MAX; - for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) { - SwTableBox *pBox = rBoxes[i]; - const SwTableLine* pLine = rBoxes[i]->GetUpper(); + const SwTableBox* pBox = it->second; + const SwTableLine* pLine = pBox->GetUpper(); sal_uInt16 nPos = rTable.GetTabLines().C40_GETPOS( SwTableLine, pLine ); if( USHRT_MAX != nPos ) { @@ -1461,17 +1466,18 @@ sal_Bool SwTable::NewSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 } } - std::set< sal_uInt16> aIndices; - for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) + std::vector<SwTableBox*> aBoxes; + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) { - OSL_ENSURE( rBoxes[i]->getRowSpan() != 1, "Forgot to split?" ); - if( rBoxes[i]->getRowSpan() > 1 ) - aIndices.insert( i ); + OSL_ENSURE( it->second->getRowSpan() != 1, "Forgot to split?" ); + if( it->second->getRowSpan() > 1 ) + aBoxes.push_back( it->second ); } - std::set< sal_uInt16 >::iterator pCurrBox = aIndices.begin(); - while( pCurrBox != aIndices.end() ) - lcl_UnMerge( *this, *rBoxes[*pCurrBox++], nCnt, bSameHeight ); + for( std::vector<SwTableBox*>::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) + { + lcl_UnMerge( *this, **it, nCnt, bSameHeight ); + } CHECK_TABLE( *this ) //Layout updaten @@ -1550,9 +1556,9 @@ void SwTable::PrepareDelBoxes( const SwSelBoxes& rBoxes ) { if( IsNewModel() ) { - for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) { - SwTableBox* pBox = rBoxes[i]; + SwTableBox* pBox = it->second; long nRowSpan = pBox->getRowSpan(); if( nRowSpan != 1 && pBox->GetFrmFmt()->GetFrmSize().GetWidth() ) { @@ -1630,9 +1636,9 @@ void lcl_SearchSelBox( const SwTable &rTable, SwSelBoxes& rBoxes, long nMin, lon ( !bChkProtected || !pBox->GetFrmFmt()->GetProtect().IsCntntProtected() ) ) { - sal_uInt16 nOldCnt = rBoxes.Count(); - rBoxes.Insert( pBox ); - if( bColumn && nRowSpan != 1 && nOldCnt < rBoxes.Count() ) + sal_uInt16 nOldCnt = rBoxes.size(); + rBoxes.insert( pBox ); + if( bColumn && nRowSpan != 1 && nOldCnt < rBoxes.size() ) { SwTableBox *pMasterBox = pBox->getRowSpan() > 0 ? pBox : &pBox->FindStartOfRowSpan( rTable, USHRT_MAX ); @@ -1669,12 +1675,8 @@ void SwTable::CreateSelection( const SwPaM& rPam, SwSelBoxes& rBoxes, void SwTable::CreateSelection( const SwNode* pStartNd, const SwNode* pEndNd, SwSelBoxes& rBoxes, const SearchType eSearch, bool bChkProtected ) const { - // SwSelBoxes aKeepBoxes; - if( rBoxes.Count() ) - { - // aKeepBoxes.Insert( &rBoxes ); - rBoxes.Remove( sal_uInt16(0), rBoxes.Count() ); - } + rBoxes.clear(); + // Looking for start and end of the selection given by SwNode-pointer sal_uInt16 nLines = aLines.Count(); // nTop becomes the line number of the upper box @@ -1701,7 +1703,7 @@ void SwTable::CreateSelection( const SwNode* pStartNd, const SwNode* pEndNd, { if( !bChkProtected || !pBox->GetFrmFmt()->GetProtect().IsCntntProtected() ) - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); if( nFound ) { nBottom = nRow; @@ -1744,7 +1746,7 @@ void SwTable::CreateSelection( const SwNode* pStartNd, const SwNode* pEndNd, OSL_ENSURE( pBox, "Missing table box" ); if( pBox->getRowSpan() > 0 && ( !bChkProtected || !pBox->GetFrmFmt()->GetProtect().IsCntntProtected() ) ) - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); } } return; @@ -1806,13 +1808,12 @@ void SwTable::ExpandColumnSelection( SwSelBoxes& rBoxes, long &rMin, long &rMax OSL_ENSURE( bNewModel, "Don't call me for old tables" ); rMin = 0; rMax = 0; - if( !aLines.Count() || !rBoxes.Count() ) + if( !aLines.Count() || rBoxes.empty() ) return; sal_uInt16 nLineCnt = aLines.Count(); - sal_uInt16 nBoxCnt = rBoxes.Count(); - sal_uInt16 nBox = 0; - for( sal_uInt16 nRow = 0; nRow < nLineCnt && nBox < nBoxCnt; ++nRow ) + SwSelBoxes::iterator it = rBoxes.begin(); + for( sal_uInt16 nRow = 0; nRow < nLineCnt && it != rBoxes.end(); ++nRow ) { SwTableLine* pLine = aLines[nRow]; OSL_ENSURE( pLine, "Missing table line" ); @@ -1821,15 +1822,15 @@ void SwTable::ExpandColumnSelection( SwSelBoxes& rBoxes, long &rMin, long &rMax { SwTableBox* pBox = pLine->GetTabBoxes()[nCol]; OSL_ENSURE( pBox, "Missing table box" ); - if( pBox == rBoxes[nBox] ) + if( pBox == it->second ) { - lcl_CheckMinMax( rMin, rMax, *pLine, nCol, nBox == 0 ); - if( ++nBox >= nBoxCnt ) + lcl_CheckMinMax( rMin, rMax, *pLine, nCol, it == rBoxes.begin() ); + if( ++it == rBoxes.end() ) break; } } } - nBox = 0; + for( sal_uInt16 nRow = 0; nRow < nLineCnt; ++nRow ) { SwTableLine* pLine = aLines[nRow]; @@ -1842,7 +1843,7 @@ void SwTable::ExpandColumnSelection( SwSelBoxes& rBoxes, long &rMin, long &rMax SwTableBox* pBox = pLine->GetTabBoxes()[nCurrBox]; nRight += pBox->GetFrmFmt()->GetFrmSize().GetWidth(); if( nLeft >= rMin && nRight <= rMax ) - rBoxes.Insert( pBox ); + rBoxes.insert( pBox ); } } } @@ -1904,9 +1905,9 @@ void SwTable::PrepareDeleteCol( long nMin, long nMax ) void SwTable::ExpandSelection( SwSelBoxes& rBoxes ) const { - for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) { - SwTableBox *pBox = rBoxes[i]; + SwTableBox *pBox = it->second; long nRowSpan = pBox->getRowSpan(); if( nRowSpan != 1 ) { diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 013566cfed71..4e64a3ffca42 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -1579,11 +1579,11 @@ SwUndoTblNdsChg::SwUndoTblNdsChg( SwUndoId nAction, void SwUndoTblNdsChg::ReNewBoxes( const SwSelBoxes& rBoxes ) { - if( rBoxes.Count() != aBoxes.size() ) + if( rBoxes.size() != aBoxes.size() ) { aBoxes.clear(); - for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) - aBoxes.insert( rBoxes[n]->GetSttIdx() ); + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + aBoxes.insert( it->second->GetSttIdx() ); } } @@ -1656,7 +1656,7 @@ void SwUndoTblNdsChg::SaveNewBoxes( const SwTableNode& rTblNd, OSL_ENSURE( ! IsDelBox(), "falsche Action" ); pNewSttNds.reset( new std::set<_BoxMove> ); - OSL_ENSURE( rTbl.IsNewModel() || rOld.Count() + nCount * rBoxes.Count() == rTblBoxes.Count(), + OSL_ENSURE( rTbl.IsNewModel() || rOld.Count() + nCount * rBoxes.size() == rTblBoxes.Count(), "unexpected boxes" ); OSL_ENSURE( rOld.Count() <= rTblBoxes.Count(), "more unexpected boxes" ); for( sal_uInt16 n = 0, i = 0; i < rTblBoxes.Count(); ++i ) @@ -1681,9 +1681,9 @@ void SwUndoTblNdsChg::SaveNewBoxes( const SwTableNode& rTblNd, const SwTableLine* pBoxLine = pBox->GetUpper(); sal_uInt16 nLineDiff = lcl_FindParentLines(rTbl,*pBox).C40_GETPOS(SwTableLine,pBoxLine); sal_uInt16 nLineNo = 0; - for( sal_uInt16 j = 0; j < rBoxes.Count(); ++j ) + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) { - pCheckBox = rBoxes[j]; + pCheckBox = it->second; if( pCheckBox->GetUpper()->GetUpper() == pBox->GetUpper()->GetUpper() ) { const SwTableLine* pCheckLine = pCheckBox->GetUpper(); @@ -1704,8 +1704,12 @@ void SwUndoTblNdsChg::SaveNewBoxes( const SwTableNode& rTblNd, // find out how many nodes the source box used to have // (to help determine bNodesMoved flag below) sal_uInt16 nNdsPos = 0; - while( rBoxes[ nNdsPos ] != pSourceBox ) + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + { + if( it->second == pSourceBox ) + break; ++nNdsPos; + } sal_uLong nNodes = rNodeCnts[ nNdsPos ]; // When a new table cell is created, it either gets a new @@ -1873,7 +1877,7 @@ void SwUndoTblNdsChg::RedoImpl(::sw::UndoRedoContext & rContext) for( std::set<sal_uLong>::iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) { SwTableBox* pBox = pTblNd->GetTable().GetTblBox( *it ); - aSelBoxes.Insert( pBox ); + aSelBoxes.insert( pBox ); } // SelBoxes erzeugen und InsertCell/-Row/SplitTbl aufrufen @@ -2033,7 +2037,7 @@ CHECKTABLE(pTblNd->GetTable()) pCpyBox->GetUpper() ); rLnBoxes.C40_INSERT( SwTableBox, pBox, rLnBoxes.Count() ); - aSelBoxes.Insert( pBox ); + aSelBoxes.insert( pBox ); } CHECKTABLE(pTblNd->GetTable()) @@ -2171,16 +2175,16 @@ void SwUndoTblMerge::MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& r void SwUndoTblMerge::SetSelBoxes( const SwSelBoxes& rBoxes ) { // die Selektion merken - for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) - aBoxes.insert( rBoxes[n]->GetSttIdx() ); + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + aBoxes.insert( it->second->GetSttIdx() ); // als Trennung fuers einfuegen neuer Boxen nach dem Verschieben! aNewSttNds.push_back( (sal_uLong)0 ); // The new table model does not delete overlapped cells (by row span), // so the rBoxes array might be empty even some cells have been merged. - if( rBoxes.Count() ) - nTblNode = rBoxes[ 0 ]->GetSttNd()->FindTableNode()->GetIndex(); + if( !rBoxes.empty() ) + nTblNode = rBoxes.begin()->second->GetSttNd()->FindTableNode()->GetIndex(); } void SwUndoTblMerge::SaveCollection( const SwTableBox& rBox ) diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 253d412d4fd9..41a294c30d9a 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -1691,12 +1691,12 @@ void SwChartDataProvider::AddRowCols( if (rTable.IsTblComplex()) return; - const sal_uInt16 nBoxes = rBoxes.Count(); + const sal_uInt16 nBoxes = rBoxes.size(); if (nBoxes < 1 || nLines < 1) return; - SwTableBox* pFirstBox = *( rBoxes.GetData() + 0 ); - SwTableBox* pLastBox = *( rBoxes.GetData() + nBoxes - 1 ); + SwTableBox* pFirstBox = rBoxes.begin()->second; + SwTableBox* pLastBox = rBoxes.rbegin()->second; if (pFirstBox && pLastBox) { diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 834954e0caf7..ce1da24326ec 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1535,8 +1535,8 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt& rTableFmt, const SwTableCursor* } const SwSelBoxes& rBoxes = pTableSelection->GetBoxes(); SwTableCursor* pTableCrsr = dynamic_cast<SwTableCursor*>(pUnoCrsr); - for(sal_uInt16 i = 0; i < rBoxes.Count(); i++) - pTableCrsr->InsertBox( *rBoxes.GetObject(i) ); + for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + pTableCrsr->InsertBox( *it->second ); pUnoCrsr->Add(&aCrsrDepend); SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); @@ -1705,9 +1705,7 @@ sal_Bool SwXTextTableCursor::mergeRange(void) throw( uno::RuntimeException ) bRet = TBLMERGE_OK == pTblCrsr->GetDoc()->MergeTbl(*pTblCrsr); if(bRet) { - sal_uInt16 nCount = pTblCrsr->GetBoxesCount(); - while(nCount--) - pTblCrsr->DeleteBox(nCount); + pTblCrsr->DeleteAllBoxes(); } } pTblCrsr->MakeBoxSels(); @@ -2384,7 +2382,10 @@ void SwXTextTable::dispose(void) throw( uno::RuntimeException ) SwTable* pTable = SwTable::FindTable( pFmt ); SwTableSortBoxes& rBoxes = pTable->GetTabSortBoxes(); SwSelBoxes aSelBoxes; - aSelBoxes.Insert(rBoxes.GetData(), rBoxes.Count()); + for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i) + { + aSelBoxes.insert( rBoxes[i] ); + } pFmt->GetDoc()->DeleteRowCol(aSelBoxes); } else @@ -2952,8 +2953,7 @@ void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes(); for( sal_uInt16 n = 0; n < rTBoxes.Count(); ++n ) { - SwTableBox* pBox = rTBoxes[ n ]; - aBoxes.Insert( pBox ); + aBoxes.insert( rTBoxes[ n ] ); } UnoActionContext aContext( pFmt->GetDoc() ); pFmt->GetDoc()->SortTbl(aBoxes, aSortOpt); @@ -2980,8 +2980,7 @@ void SwXTextTable::autoFormat(const OUString& aName) throw( lang::IllegalArgumen const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes(); for( sal_uInt16 n = 0; n < rTBoxes.Count(); ++n ) { - SwTableBox* pBox = rTBoxes[ n ]; - aBoxes.Insert( pBox ); + aBoxes.insert( rTBoxes[ n ] ); } UnoActionContext aContext( pFmt->GetDoc() ); pFmt->GetDoc()->SetTableAutoFmt( aBoxes, *aAutoFmtTbl[i] ); diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 26adf8456b73..20fd820f29c0 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -803,7 +803,7 @@ sal_uLong SwWriter::Write( WriterRef& rxWriter, const String* pRealFileName ) // lasse ueber das Layout die Boxen suchen SwSelBoxes aBoxes; GetTblSel( *pShell, aBoxes ); - SwTableNode* pTblNd = (SwTableNode*)aBoxes[0]->GetSttNd()->StartOfSectionNode(); + SwTableNode* pTblNd = const_cast<SwTableNode*>( static_cast<const SwTableNode*>(aBoxes.begin()->second->GetSttNd()->StartOfSectionNode()) ); SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfExtras(), 2 ); SwCntntNode *pNd = aIdx.GetNode().GetCntntNode(); OSL_ENSURE( pNd, "Node not found" ); diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index afb26ca8569f..357e45083b8f 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -1504,7 +1504,7 @@ void SwFltOutDoc::NextTableRow() { // duplicate row: SwSelBoxes aSelBoxes; - aSelBoxes.Insert( pTableBox ); + aSelBoxes.insert( pTableBox ); GetDoc().InsertRow(aSelBoxes); usTableX = 0; SeekCell(++usTableY, usTableX, sal_True); @@ -1621,7 +1621,7 @@ void SwFltOutDoc::DeleteCell(sal_uInt16 nCell /* = USHRT_MAX */) SwTableBox* pTableBox = GetBox(usTableY, nCell); if(pTableBox){ SwSelBoxes aSelBoxes; - aSelBoxes.Insert( pTableBox ); + aSelBoxes.insert( pTableBox ); GetDoc().DeleteRowCol(aSelBoxes); usTableX--; } diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index 174428498183..550a925ea9ed 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -82,7 +82,7 @@ using namespace ::com::sun::star; -class WW8SelBoxInfo: public SwSelBoxes_SAR +class WW8SelBoxInfo: public SwSelBoxes { private: WW8SelBoxInfo(const WW8SelBoxInfo&); @@ -2752,18 +2752,20 @@ void WW8TabDesc::FinishSwTable() for (sal_uInt16 iGr = 0; iGr < pMergeGroups->Count(); ++iGr) { pActMGroup = (*pMergeGroups)[ iGr ]; - nActBoxCount = pActMGroup->Count(); + nActBoxCount = pActMGroup->size(); - if( ( 1 < nActBoxCount ) && pActMGroup && (*pActMGroup)[ 0 ] ) + if( ( 1 < nActBoxCount ) && pActMGroup && pActMGroup->begin()->second ) { - const sal_uInt16 nRowSpan = pActMGroup->Count(); - for (sal_uInt16 n = 0; n < nRowSpan; ++n) + const sal_uInt16 nRowSpan = pActMGroup->size(); + sal_uInt16 n = 0; + for( SwSelBoxes::const_iterator it = pActMGroup->begin(); it != pActMGroup->end(); ++it ) { - SwTableBox* pCurrentBox = (*pActMGroup)[n]; + SwTableBox* pCurrentBox = it->second; const long nRowSpanSet = n == 0 ? nRowSpan : ((-1) * (nRowSpan - n)); pCurrentBox->setRowSpan( nRowSpanSet ); + ++n; } } } @@ -3351,10 +3353,10 @@ SwTableBox* WW8TabDesc::UpdateTableMergeGroup( WW8_TCell& rCell, if( pTheMergeGroup ) { // aktuelle Box der Merge-Gruppe hinzufuegen - pTheMergeGroup->Insert( pActBox, pTheMergeGroup->Count() ); + pTheMergeGroup->insert( pTheMergeGroup->end(), pActBox ); // Target-Box zurueckmelden - pResult = (*pTheMergeGroup)[ 0 ]; + pResult = pTheMergeGroup->begin()->second; } } return pResult; |