From e0bc1551d73113668c854fc4ccd545773c6fe303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Fri, 4 May 2012 16:51:52 +0100 Subject: [PATCH] Revert conversion to std::map 3af0c948254751eade9bff772b849720747c5494 868bd3b778b6c7b970c67d1dacc469967f69e551 b2e84f9a40fda7821d4e658f9102bcbc783a1ba3 7264d2767095150944ff1e6999c71be1dbdc6f83 858b5b4f36a357fe7192e7c2ed9cc3cdfc81fd8f The problem is that a paragraph gets added to the document after the TableBox selection is created, which changes the node ids of the following paragraphs in the TableBox but the map has used cached SttNd value as its index, so it can't recognize nodes using the new index. This worked in the old implementation because that was effectively a sorted-vector. --- sw/inc/swcrsr.hxx | 7 +- sw/inc/swtable.hxx | 5 +- sw/inc/tblsel.hxx | 40 +-------- sw/source/core/access/acccell.cxx | 2 +- sw/source/core/access/acctable.cxx | 6 +- sw/source/core/crsr/swcrsr.cxx | 134 ++++++++++++++++------------ sw/source/core/crsr/trvltbl.cxx | 18 ++-- sw/source/core/crsr/unocrsr.cxx | 5 +- sw/source/core/crsr/viscrs.cxx | 12 ++-- sw/source/core/doc/doclay.cxx | 10 ++- sw/source/core/doc/docsort.cxx | 8 +- sw/source/core/doc/tblcpy.cxx | 28 +++--- sw/source/core/doc/tblrwcl.cxx | 112 +++++++++++++----------- sw/source/core/docnode/ndtbl.cxx | 74 +++++++++------- sw/source/core/docnode/ndtbl1.cxx | 25 +++--- sw/source/core/edit/edglss.cxx | 6 +- sw/source/core/edit/edtab.cxx | 16 ++-- sw/source/core/fields/cellfml.cxx | 25 +++--- sw/source/core/frmedt/fecopy.cxx | 8 +- sw/source/core/frmedt/fefly1.cxx | 4 +- sw/source/core/frmedt/fetab.cxx | 67 +++++++------- sw/source/core/frmedt/tblsel.cxx | 102 ++++++++++++++------- sw/source/core/inc/tblrwcl.hxx | 9 +- sw/source/core/layout/trvlfrm.cxx | 2 +- sw/source/core/table/swnewtable.cxx | 167 +++++++++++++++++------------------ sw/source/core/undo/untbl.cxx | 30 +++---- sw/source/core/unocore/unochart.cxx | 6 +- sw/source/core/unocore/unotbl.cxx | 19 ++-- sw/source/filter/basflt/shellio.cxx | 2 +- sw/source/filter/ww1/fltshell.cxx | 4 +- sw/source/filter/ww8/ww8par2.cxx | 18 ++-- 31 files changed, 502 insertions(+), 469 deletions(-) diff --git a/sw/inc/swcrsr.hxx b/sw/inc/swcrsr.hxx index 9bb433a..d99d527 100644 --- a/sw/inc/swcrsr.hxx +++ b/sw/inc/swcrsr.hxx @@ -283,12 +283,9 @@ public: virtual sal_Bool GotoTable( const String& rName ); void InsertBox( const SwTableBox& rTblBox ); - void DeleteBox( SwSelBoxes::iterator it ) { aSelBoxes.erase( it ); bChg = sal_True; } - void DeleteBox( SwSelBoxes::iterator itFirst, SwSelBoxes::iterator itLast ) { aSelBoxes.erase( itFirst, itLast ); bChg = sal_True; } - void DeleteAllBoxes() { DeleteBox(aSelBoxes.begin(), aSelBoxes.end()); } - sal_uInt16 GetBoxesCount() const { return aSelBoxes.size(); } + void DeleteBox( sal_uInt16 nPos ) { aSelBoxes.Remove( nPos ); bChg = sal_True; } + sal_uInt16 GetBoxesCount() const { return aSelBoxes.Count(); } 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 73df08c..56cba82 100644 --- a/sw/inc/swtable.hxx +++ b/sw/inc/swtable.hxx @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -42,6 +41,7 @@ class SwStartNode; class SwFmt; class Color; +class SwFrmFmt; class SwTableFmt; class SwTableLineFmt; class SwTableBoxFmt; @@ -406,7 +406,8 @@ public: const SwTableLine *GetUpper() const { return pUpper; } void SetUpper( SwTableLine *pNew ) { pUpper = pNew; } - SwFrmFmt* GetFrmFmt() const { return const_cast(static_cast(GetRegisteredIn())); } + SwFrmFmt* GetFrmFmt() { return (SwFrmFmt*)GetRegisteredIn(); } + SwFrmFmt* GetFrmFmt() const { return (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 668988a..83c127b 100644 --- a/sw/inc/tblsel.hxx +++ b/sw/inc/tblsel.hxx @@ -33,8 +33,6 @@ #include #include "swdllapi.h" -#include - class SwCrsrShell; class SwCursor; class SwTableCursor; @@ -50,43 +48,7 @@ class SwUndoTblMerge; class SwCellFrm; SV_DECL_PTRARR( SwCellFrms, SwCellFrm*, 16, 16 ) - - -class SwSelBoxes : private std::map -{ - typedef std::map Base; -public: - using Base::begin; - using Base::clear; - using Base::count; - using Base::const_iterator; - using Base::const_reverse_iterator; - using Base::empty; - using Base::end; - using Base::erase; - using Base::find; - using Base::insert; - using Base::iterator; - using Base::rbegin; - using Base::rend; - using Base::reverse_iterator; - using Base::size; - - std::pair - 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()); } -}; +SV_DECL_PTRARR_SORT( SwSelBoxes, SwTableBoxPtr, 10, 20 ) // 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 4df813f..b70b397 100644 --- a/sw/source/core/access/acccell.cxx +++ b/sw/source/core/access/acccell.cxx @@ -74,7 +74,7 @@ sal_Bool SwAccessibleCell::IsSelected() static_cast< const SwCellFrm * >( GetFrm() ); SwTableBox *pBox = const_cast< SwTableBox *>( pCFrm->GetTabBox() ); //SVPtrArr! - bRet = ( 0 != pCSh->GetTableCrsr()->GetBoxes().count( pBox ) ); + bRet = pCSh->GetTableCrsr()->GetBoxes().Seek_Entry( pBox ); } } diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx index 96c0b7b..93f378a 100644 --- a/sw/source/core/access/acctable.cxx +++ b/sw/source/core/access/acctable.cxx @@ -292,7 +292,7 @@ void SwAccessibleTableData_Impl::GetSelection( static_cast < const SwCellFrm * >( pLower ); SwTableBox *pBox = const_cast< SwTableBox *>( pCFrm->GetTabBox() ); //SVPtrArr! - if( 0 == rSelBoxes.count( pBox ) ) + if( !rSelBoxes.Seek_Entry( pBox ) ) { const Int32Set_Impl rRowsOrCols = bColumns ? maColumns : maRows; @@ -654,7 +654,7 @@ sal_Bool SwAccessibleTable::IsChildSelected( sal_Int32 nChildIndex ) const { const SwTableBox* pBox = GetTableBox( nChildIndex ); OSL_ENSURE( pBox != NULL, "We need the table box." ); - bRet = ( 0 != pSelBoxes->count( pBox ) ); + bRet = pSelBoxes->Seek_Entry( const_cast( pBox ) ); } return bRet; @@ -1194,7 +1194,7 @@ sal_Bool SAL_CALL SwAccessibleTable::isAccessibleSelected( const SwCellFrm *pCFrm = static_cast < const SwCellFrm * >( pFrm ); SwTableBox *pBox = const_cast< SwTableBox *>( pCFrm->GetTabBox() ); //SVPtrArr! - bRet = ( 0 != pSelBoxes->count( pBox ) ); + bRet = pSelBoxes->Seek_Entry( pBox ); } } diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 6150204..8c24b30 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -2130,6 +2130,35 @@ 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 ) // ??? @@ -2148,10 +2177,12 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr ) // temp Kopie anlegen, damit alle Boxen, fuer die schon Cursor // existieren, entfernt werden koennen. - SwSelBoxes aTmp( aSelBoxes ); + SwSelBoxes aTmp; + aTmp.Insert( &aSelBoxes ); //Jetzt die Alten und die neuen abgleichen. SwNodes& rNds = pAktCrsr->GetDoc()->GetNodes(); + sal_uInt16 nPos; const SwStartNode* pSttNd; SwPaM* pCur = pAktCrsr; do { @@ -2161,35 +2192,31 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr ) pSttNd != pCur->GetMark()->nNode.GetNode().FindTableBoxStartNode() ) bDel = sal_True; - else + else if( lcl_SeekEntry( aTmp, pSttNd, nPos )) { - SwSelBoxes::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; + 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 ); } + else + bDel = sal_True; pCur = (SwPaM*)pCur->GetNext(); if( bDel ) @@ -2203,9 +2230,9 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* pAktCrsr ) } } while ( pAktCrsr != pCur ); - for( SwSelBoxes::const_iterator it = aTmp.begin(); it != aTmp.end(); ++it ) + for( nPos = 0; nPos < aTmp.Count(); ++nPos ) { - pSttNd = it->second->GetSttNd(); + pSttNd = aTmp[ nPos ]->GetSttNd(); SwNodeIndex aIdx( *pSttNd, 1 ); if( &aIdx.GetNodes() != &rNds ) @@ -2244,7 +2271,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; } @@ -2260,7 +2287,8 @@ bool SwTableCursor::NewTableSelection() pTableNode->GetTable().IsNewModel() ) { bRet = true; - SwSelBoxes aNew( aSelBoxes ); + SwSelBoxes aNew; + aNew.Insert( &aSelBoxes ); pTableNode->GetTable().CreateSelection( pStart, pEnd, aNew, SwTable::SEARCH_NONE, false ); ActualizeSelection( aNew ); @@ -2271,37 +2299,31 @@ bool SwTableCursor::NewTableSelection() void SwTableCursor::ActualizeSelection( const SwSelBoxes &rNew ) { - SwSelBoxes::iterator itOld = aSelBoxes.begin(); - SwSelBoxes::const_iterator itNew = rNew.begin(); - while ( itOld != aSelBoxes.end() && itNew != rNew.end() ) + sal_uInt16 nOld = 0, nNew = 0; + while ( nOld < aSelBoxes.Count() && nNew < rNew.Count() ) { - const SwTableBox* pPOld = itOld->second; - const SwTableBox* pPNew = itNew->second; + const SwTableBox* pPOld = *( aSelBoxes.GetData() + nOld ); + const SwTableBox* pPNew = *( rNew.GetData() + nNew ); if( pPOld == pPNew ) { // this box will stay - ++itOld; - ++itNew; + ++nOld; + ++nNew; } else if( pPOld->GetSttIdx() < pPNew->GetSttIdx() ) - { - SwSelBoxes::iterator it = itOld; - ++itOld; - DeleteBox( it ); // this box has to go - } + DeleteBox( nOld ); // this box has to go else { InsertBox( *pPNew ); // this is a new one - ++itOld; - ++itNew; + ++nOld; + ++nNew; } } - // some more to delete - DeleteBox( itOld, aSelBoxes.end() ); + while( nOld < aSelBoxes.Count() ) + DeleteBox( nOld ); // some more to delete - // some more to insert - for( ; itNew != rNew.end(); ++itNew ) - InsertBox( *itNew->second ); + for( ; nNew < rNew.Count(); ++nNew ) // some more to insert + InsertBox( **( rNew.GetData() + nNew ) ); } sal_Bool SwTableCursor::IsCrsrMovedUpdt() @@ -2340,12 +2362,14 @@ void SwTableCursor::ParkCrsr() sal_Bool SwTableCursor::HasReadOnlyBoxSel() const { - for( SwSelBoxes::const_reverse_iterator it = aSelBoxes.rbegin(); it != aSelBoxes.rend(); ++it ) - if( it->second->GetFrmFmt()->GetProtect().IsCntntProtected() ) + sal_Bool bRet = sal_False; + for( sal_uInt16 n = aSelBoxes.Count(); n; ) + if( aSelBoxes[ --n ]->GetFrmFmt()->GetProtect().IsCntntProtected() ) { - return sal_True; + bRet = sal_True; + break; } - return sal_False; + return bRet; } diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx index cae5aa8..a1f3801 100644 --- a/sw/source/core/crsr/trvltbl.cxx +++ b/sw/source/core/crsr/trvltbl.cxx @@ -169,11 +169,11 @@ sal_Bool SwCrsrShell::_SelTblRowOrCol( bool bRow, bool bRowSimple ) { GetTblSel( *this, aBoxes, eType ); - if( aBoxes.empty() ) + if( !aBoxes.Count() ) return sal_False; - pStt = aBoxes.begin()->second; - pEnd = aBoxes.rbegin()->second; + pStt = aBoxes[0]; + pEnd = aBoxes[aBoxes.Count() - 1]; } // #i32329# Enhanced table selection else if ( pTable->IsNewModel() ) @@ -181,11 +181,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.empty() ) + if( !aBoxes.Count() ) return sal_False; - pStt = aBoxes.begin()->second; - pEnd = aBoxes.rbegin()->second; + pStt = aBoxes[0]; + pEnd = aBoxes[aBoxes.Count() - 1]; } else { @@ -217,13 +217,13 @@ sal_Bool SwCrsrShell::_SelTblRowOrCol( bool bRow, bool bRowSimple ) static_cast(pEndFrm), aBoxes, bSelectUp ? 0 : &aCells, eType ); - if( aBoxes.empty() || ( !bSelectUp && 4 != aCells.Count() ) ) + if( !aBoxes.Count() || ( !bSelectUp && 4 != aCells.Count() ) ) return sal_False; if ( bSelectUp ) { - pStt = aBoxes.begin()->second; - pEnd = aBoxes.rbegin()->second; + pStt = aBoxes[0]; + pEnd = aBoxes[aBoxes.Count() - 1]; } else { diff --git a/sw/source/core/crsr/unocrsr.cxx b/sw/source/core/crsr/unocrsr.cxx index 00d95c0..03e66c3 100644 --- a/sw/source/core/crsr/unocrsr.cxx +++ b/sw/source/core/crsr/unocrsr.cxx @@ -240,7 +240,10 @@ void SwUnoTableCrsr::MakeBoxSels() if ( !bMakeTblCrsrs ) { - DeleteAllBoxes(); + SwSelBoxes& rTmpBoxes = (SwSelBoxes&)GetBoxes(); + sal_uInt16 nCount = 0; + while( nCount < rTmpBoxes.Count() ) + DeleteBox( nCount ); } if( IsChgd() ) diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index cbefb9f..2df5fff 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -644,15 +644,15 @@ void SwShellTableCrsr::FillRects() { // Calculate the new rectangles. // JP 16.01.98: If the cursor is still "parked" do nothing!! - if( aSelBoxes.empty() || bParked || + if( !aSelBoxes.Count() || bParked || !GetPoint()->nNode.GetIndex() ) return; SwRegionRects aReg( GetShell()->VisArea() ); SwNodes& rNds = GetDoc()->GetNodes(); - for( SwSelBoxes::iterator it = aSelBoxes.begin(); it != aSelBoxes.end(); ++it ) + for( sal_uInt16 n = 0; n < aSelBoxes.Count(); ++n ) { - const SwStartNode* pSttNd = it->second->GetSttNd(); + const SwStartNode* pSttNd = (*(aSelBoxes.GetData() + n ))->GetSttNd(); const SwTableNode* pSelTblNd = pSttNd->FindTableNode(); SwNodeIndex aIdx( *pSttNd ); @@ -696,14 +696,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.empty() || bParked || + if( !aSelBoxes.Count() || bParked || !GetPoint()->nNode.GetIndex() ) return sal_False; SwNodes& rNds = GetDoc()->GetNodes(); - for( SwSelBoxes::const_iterator it = aSelBoxes.begin(); it != aSelBoxes.end(); ++it ) + for( sal_uInt16 n = 0; n < aSelBoxes.Count(); ++n ) { - SwNodeIndex aIdx( *it->second->GetSttNd() ); + SwNodeIndex aIdx( *(*(aSelBoxes.GetData() + n ))->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 59377f9..5ede6a7 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -784,21 +784,23 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet, SwPosition aPos( aIndex ); aPos.nContent.Assign( pNode, 0 ); - if( pSelBoxes && !pSelBoxes->empty() ) + if( pSelBoxes && pSelBoxes->Count() ) { // Table selection // Copy parts of a table: create a table with the same width as the // original one and move (copy and delete) the selected boxes. // The size is corrected on a percentage basis. - const SwTableNode* pTblNd = pSelBoxes->begin()->second->GetSttNd()->FindTableNode(); + SwTableNode* pTblNd = (SwTableNode*)(*pSelBoxes)[0]-> + GetSttNd()->FindTableNode(); + if( !pTblNd ) break; - const SwTable& rTbl = pTblNd->GetTable(); + SwTable& rTbl = pTblNd->GetTable(); // Did we select the whole table? - if( pSelBoxes->size() == rTbl.GetTabSortBoxes().Count() ) + if( pSelBoxes->Count() == rTbl.GetTabSortBoxes().Count() ) { // move the whole table SwNodeRange aRg( *pTblNd, 0, *pTblNd->EndOfSectionNode(), 1 ); diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 6e1ae9d..ea2ea70 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -493,8 +493,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.empty(), "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = const_cast( rBoxes.begin()->second->GetSttNd()->FindTableNode() ); + OSL_ENSURE( rBoxes.Count(), "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; @@ -561,8 +561,8 @@ sal_Bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) SwUndoSort* pUndoSort = 0; if (GetIDocumentUndoRedo().DoesUndo()) { - pUndoSort = new SwUndoSort( rBoxes.begin()->second->GetSttIdx(), - rBoxes.rbegin()->second->GetSttIdx(), + pUndoSort = new SwUndoSort( rBoxes[0]->GetSttIdx(), + rBoxes[rBoxes.Count()-1]->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 2ddd590..24bfe8f 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -53,8 +53,8 @@ #include #include -static sal_Bool _FndCntntLine( const SwTableLine*& rpLine, void* pPara ); -static sal_Bool _FndCntntBox( const SwTableBox*& rpBox, void* pPara ); +sal_Bool _FndCntntLine( const SwTableLine*& rpLine, void* pPara ); +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 ); @@ -196,7 +196,7 @@ namespace { if( rFndBox.GetLines().Count() ) { - bool bNoSelection = rSelBoxes.size() < 2; + bool bNoSelection = rSelBoxes.Count() < 2; _FndLines &rFndLines = rFndBox.GetLines(); maCols.push_front(0); const SwTableLine* pLine = rFndLines[0]->GetLine(); @@ -321,13 +321,13 @@ namespace { BoxSpanInfo aInfo; if( pSelBoxes && - 0 != pSelBoxes->count( pBox ) ) + USHRT_MAX != pSelBoxes->GetPos( pBox ) ) { aInfo.mbSelected = true; if( mnStartCol == USHRT_MAX ) { mnStartCol = (sal_uInt16)maLines[nLine].size(); - if( pSelBoxes->size() < 2 ) + if( pSelBoxes->Count() < 2 ) { pSelBoxes = 0; aInfo.mbSelected = false; @@ -696,7 +696,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 @@ -823,7 +823,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.empty(), "Missing selection" ); + OSL_ENSURE( rSelBoxes.Count(), "Missing selection" ); SetHTMLTableLayout( 0 ); // MIB 9.7.97: HTML-Layout loeschen @@ -837,7 +837,7 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, SwTblNumFmtMerge aTNFM( *pCpyDoc, *pDoc ); - SwTableBox *pTmpBox, *pSttBox = rSelBoxes.begin()->second; + SwTableBox *pTmpBox, *pSttBox = (SwTableBox*)rSelBoxes[0]; sal_uInt16 nLn, nBx; _FndLine *pFLine, *pInsFLine = 0; @@ -876,7 +876,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.size() ) + if( 1 < rSelBoxes.Count() ) return sal_False; sal_uInt16 nNewLns = rCpyTbl.GetTabLines().Count() - @@ -1018,9 +1018,9 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, if( 1 == rCpyTbl.GetTabSortBoxes().Count() ) { SwTableBox *pTmpBx = rCpyTbl.GetTabSortBoxes()[0]; - for( SwSelBoxes::const_iterator it = rSelBoxes.begin(); it != rSelBoxes.end(); ++it ) + for( sal_uInt16 n = 0; n < rSelBoxes.Count(); ++n ) lcl_CpyBox( rCpyTbl, pTmpBx, *this, - it->second, sal_True, pUndo ); + (SwTableBox*)rSelBoxes[n], sal_True, pUndo ); } else for( nLn = 0; nLn < aFndBox.GetLines().Count(); ++nLn ) @@ -1043,11 +1043,11 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, sal_Bool _FndCntntBox( const SwTableBox*& rpBox, void* pPara ) { - SwTableBox* pBox = const_cast(rpBox); + SwTableBox* pBox = (SwTableBox*)rpBox; if( rpBox->GetTabLines().Count() ) pBox->GetTabLines().ForEach( &_FndCntntLine, pPara ); else - static_cast(pPara)->insert( pBox ); + ((SwSelBoxes*)pPara)->Insert( pBox ); return sal_True; } @@ -1067,7 +1067,7 @@ SwSelBoxes& SwTable::SelLineFromBox( const SwTableBox* pBox, pLine = pLine->GetUpper()->GetUpper(); // alle alten loeschen - rBoxes.clear(); + rBoxes.Remove( sal_uInt16(0), rBoxes.Count() ); pLine->GetTabBoxes().ForEach( &_FndCntntBox, &rBoxes ); return rBoxes; } diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 5f17e31..61385ae 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -522,8 +522,8 @@ SwRowFrm* GetRowFrm( SwTableLine& rLine ) sal_Bool SwTable::InsertCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, sal_Bool bBehind ) { - OSL_ENSURE( !rBoxes.empty() && nCnt, "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = const_cast( rBoxes.begin()->second->GetSttNd()->FindTableNode() ); + OSL_ENSURE( rBoxes.Count() && nCnt, "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; @@ -578,8 +578,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.empty() && nCnt, "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = const_cast( rBoxes.begin()->second->GetSttNd()->FindTableNode() ); + OSL_ENSURE( pDoc && rBoxes.Count() && nCnt, "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; @@ -788,7 +788,7 @@ void lcl_LastBoxSetWidth( SwTableBoxes &rBoxes, const long nOffset, bFirst, rShareFmts ); //Die Box anpassen - const SwFrmFmt *pBoxFmt = rBox.GetFrmFmt(); + SwFrmFmt *pBoxFmt = rBox.GetFrmFmt(); SwFmtFrmSize aNew( pBoxFmt->GetFrmSize() ); aNew.SetWidth( aNew.GetWidth() + nOffset ); SwFrmFmt *pFmt = rShareFmts.GetFormat( *pBoxFmt, aNew ); @@ -942,7 +942,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, SwSelBoxes::iterator* pCurPos ) + SwSelBoxes* pAllDelBoxes, sal_uInt16* pCurPos ) { SwTableBox* pFndBox = 0; do { @@ -979,16 +979,16 @@ SwTableBox* lcl_FndNxtPrvDelBox( const SwTableLines& rTblLns, else if( pAllDelBoxes ) { // falls der Vorganger auch geloscht wird, ist nicht zu tun - SwSelBoxes::iterator it = pAllDelBoxes->find( pFndBox ); - if( it == pAllDelBoxes->end() ) + sal_uInt16 nFndPos; + if( !pAllDelBoxes->Seek_Entry( pFndBox, &nFndPos ) ) break; // sonst noch mal weitersuchen // Die Box muessen wir aber nicht nochmal abpruefen - if( pFndBox->GetSttIdx() <= (*pCurPos)->second->GetSttIdx() ) - --*pCurPos; pFndBox = 0; - pAllDelBoxes->erase( it ); + if( nFndPos <= *pCurPos ) + --*pCurPos; + pAllDelBoxes->Remove( nFndPos ); } } while( bNxt ? ( nLinePos + 1 < rTblLns.Count() ) : nLinePos ); return pFndBox; @@ -997,7 +997,7 @@ SwTableBox* lcl_FndNxtPrvDelBox( const SwTableLines& rTblLns, void lcl_SaveUpperLowerBorder( SwTable& rTbl, const SwTableBox& rBox, SwShareBoxFmts& rShareFmts, SwSelBoxes* pAllDelBoxes = 0, - SwSelBoxes::iterator* pCurPos = 0 ) + sal_uInt16* pCurPos = 0 ) { //JP 16.04.97: 2.Teil fuer Bug 36271 sal_Bool bChgd = sal_False; @@ -1077,9 +1077,9 @@ sal_Bool SwTable::DeleteSel( { OSL_ENSURE( pDoc, "No doc?" ); SwTableNode* pTblNd = 0; - if( !rBoxes.empty() ) + if( rBoxes.Count() ) { - pTblNd = const_cast(rBoxes.begin()->second->GetSttNd()->FindTableNode()); + pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; } @@ -1090,9 +1090,9 @@ sal_Bool SwTable::DeleteSel( _FndBox aFndBox( 0, 0 ); if ( bDelMakeFrms ) { - if( pMerged && !pMerged->empty() ) + if( pMerged && pMerged->Count() ) aFndBox.SetTableLines( *pMerged, *this ); - else if( !rBoxes.empty() ) + else if( rBoxes.Count() ) aFndBox.SetTableLines( rBoxes, *this ); aFndBox.DelFrms( *this ); } @@ -1102,10 +1102,11 @@ sal_Bool SwTable::DeleteSel( // erst die Umrandung umsetzen, dann loeschen if( bCorrBorder ) { - SwSelBoxes aBoxes( rBoxes ); - for( SwSelBoxes::iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) - ::lcl_SaveUpperLowerBorder( *this, *it->second, aShareFmts, - &aBoxes, &it ); + SwSelBoxes aBoxes; + aBoxes.Insert( &rBoxes ); + for( sal_uInt16 n = 0; n < aBoxes.Count(); ++n ) + ::lcl_SaveUpperLowerBorder( *this, *rBoxes[ n ], aShareFmts, + &aBoxes, &n ); } PrepareDelBoxes( rBoxes ); @@ -1113,16 +1114,18 @@ sal_Bool SwTable::DeleteSel( SwChartDataProvider *pPCD = pDoc->GetChartDataProvider(); // // delete boxes from last to first - for( SwSelBoxes::const_reverse_iterator it = rBoxes.rbegin(); it != rBoxes.rend(); ++it ) + for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) { + 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(), *it->second ); + pPCD->DeleteBox( &pTblNd->GetTable(), *rBoxes[nIdx] ); // ... then delete the boxes - _DeleteBox( *this, it->second, pUndo, sal_True, bCorrBorder, &aShareFmts ); + _DeleteBox( *this, rBoxes[nIdx], pUndo, sal_True, bCorrBorder, &aShareFmts ); } // dann raeume die Struktur aller Lines auf @@ -1143,8 +1146,8 @@ sal_Bool SwTable::DeleteSel( sal_Bool SwTable::OldSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, sal_Bool bSameHeight ) { - OSL_ENSURE( pDoc && !rBoxes.empty() && nCnt, "keine gueltigen Werte" ); - SwTableNode* pTblNd = const_cast(rBoxes.begin()->second->GetSttNd()->FindTableNode()); + OSL_ENSURE( pDoc && rBoxes.Count() && nCnt, "keine gueltigen Werte" ); + SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; @@ -1157,17 +1160,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 - std::vector aRowHeights; + long* pRowHeights = 0; if ( bSameHeight ) { - aRowHeights.reserve(rBoxes.size()); - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + pRowHeights = new long[ rBoxes.Count() ]; + for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) { - SwTableBox* pSelBox = it->second; + SwTableBox* pSelBox = *( rBoxes.GetData() + n ); const SwRowFrm* pRow = GetRowFrm( *pSelBox->GetUpper() ); OSL_ENSURE( pRow, "wo ist der Frm von der SwTableLine?" ); SWRECTFN( pRow ) - aRowHeights.push_back((pRow->Frm().*fnRect->fnGetHeight)()); + pRowHeights[ n ] = (pRow->Frm().*fnRect->fnGetHeight)(); } } @@ -1176,10 +1179,9 @@ sal_Bool SwTable::OldSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 aFndBox.SetTableLines( rBoxes, *this ); aFndBox.DelFrms( *this ); - sal_uInt16 n = 0; - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it, ++n ) + for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) { - SwTableBox* pSelBox = it->second; + SwTableBox* pSelBox = *( rBoxes.GetData() + n ); OSL_ENSURE( pSelBox, "Box steht nicht in der Tabelle" ); // dann fuege in die Box nCnt neue Zeilen ein @@ -1193,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 ? aRowHeights[ n ] : aFSz.GetHeight() ) / + aFSz.SetHeight( ( bSameHeight ? pRowHeights[ n ] : aFSz.GetHeight() ) / (nCnt + 1) ); SwTableBox* pNewBox = new SwTableBox( pFrmFmt, nCnt, pInsLine ); @@ -1274,6 +1276,8 @@ 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 ); @@ -1285,8 +1289,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.empty() && nCnt, "keine gueltigen Werte" ); - SwTableNode* pTblNd = const_cast(rBoxes.begin()->second->GetSttNd()->FindTableNode()); + OSL_ENSURE( pDoc && rBoxes.Count() && nCnt, "keine gueltigen Werte" ); + SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; @@ -1296,7 +1300,8 @@ 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( rBoxes ); + SwSelBoxes aSelBoxes; + aSelBoxes.Insert(rBoxes.GetData(), rBoxes.Count()); ExpandSelection( aSelBoxes ); //Lines fuer das Layout-Update herausuchen. @@ -1307,9 +1312,9 @@ sal_Bool SwTable::SplitCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 nC _CpyTabFrms aFrmArr; SvPtrarr aLastBoxArr; sal_uInt16 nFndPos; - for( SwSelBoxes::const_iterator it = aSelBoxes.begin(); it != aSelBoxes.end(); ++it ) + for( sal_uInt16 n = 0; n < aSelBoxes.Count(); ++n ) { - SwTableBox* pSelBox = it->second; + SwTableBox* pSelBox = *( aSelBoxes.GetData() + n ); OSL_ENSURE( pSelBox, "Box steht nicht in der Tabelle" ); // We don't want to split small table cells into very very small cells @@ -1723,8 +1728,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.empty() && pMergeBox, "keine gueltigen Werte" ); - SwTableNode* pTblNd = const_cast(rBoxes.begin()->second->GetSttNd()->FindTableNode()); + OSL_ENSURE( rBoxes.Count() && pMergeBox, "keine gueltigen Werte" ); + SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; @@ -2734,7 +2739,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; } @@ -3131,7 +3136,7 @@ sal_Bool lcl_DeleteBox_Rekursiv( CR_SetBoxWidth& rParam, SwTableBox& rBox, else { SwTableBox* pBox = &rBox; - rParam.aBoxes.insert( pBox ); + rParam.aBoxes.Insert( pBox ); } } else @@ -3480,7 +3485,7 @@ _FndBox* lcl_SaveInsDelData( CR_SetBoxWidth& rParam, SwUndo** ppUndo, // suche alle Boxen / Lines SwTable& rTbl = rParam.pTblNd->GetTable(); - if( rParam.aBoxes.empty() ) + if( !rParam.aBoxes.Count() ) { // erstmal die Boxen besorgen ! if( rParam.bBigger ) @@ -3492,7 +3497,8 @@ _FndBox* lcl_SaveInsDelData( CR_SetBoxWidth& rParam, SwUndo** ppUndo, } // loeschen der gesamten Tabelle verhindern - if( rParam.bBigger && rParam.aBoxes.size() == rTbl.GetTabSortBoxes().Count() ) + if( rParam.bBigger && rParam.aBoxes.Count() == + rTbl.GetTabSortBoxes().Count() ) return 0; _FndBox* pFndBox = new _FndBox( 0, 0 ); @@ -3635,7 +3641,8 @@ sal_Bool SwTable::SetColWidth( SwTableBox& rAktBox, sal_uInt16 eType, { pFndBox = ::lcl_SaveInsDelData( aParam, ppUndo, aTmpLst, nDistStt ); - if( aParam.bBigger && aParam.aBoxes.size() == aSortCntBoxes.Count() ) + if( aParam.bBigger && aParam.aBoxes.Count() == + aSortCntBoxes.Count() ) { // dies gesamte Tabelle soll geloescht werden!! GetFrmFmt()->GetDoc()->DeleteRowCol( aParam.aBoxes ); @@ -4017,10 +4024,11 @@ _FndBox* lcl_SaveInsDelData( CR_SetLineHeight& rParam, SwUndo** ppUndo, // suche alle Boxen / Lines SwTable& rTbl = rParam.pTblNd->GetTable(); - OSL_ENSURE( !rParam.aBoxes.empty(), "ohne Boxen ist nichts zu machen!" ); + OSL_ENSURE( rParam.aBoxes.Count(), "ohne Boxen ist nichts zu machen!" ); // loeschen der gesamten Tabelle verhindern - if( !rParam.bBigger && rParam.aBoxes.size() == rTbl.GetTabSortBoxes().Count() ) + if( !rParam.bBigger && rParam.aBoxes.Count() == + rTbl.GetTabSortBoxes().Count() ) return 0; _FndBox* pFndBox = new _FndBox( 0, 0 ); @@ -4239,7 +4247,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; ) @@ -4334,7 +4342,7 @@ sal_Bool SwTable::SetRowHeight( SwTableBox& rAktBox, sal_uInt16 eType, { if( bInsDel ) { - if( aParam.aBoxes.empty() ) + if( !aParam.aBoxes.Count() ) ::lcl_InsDelSelLine( (*pLines)[ nBaseLinePos ], aParam, 0, sal_True ); @@ -4342,7 +4350,7 @@ sal_Bool SwTable::SetRowHeight( SwTableBox& rAktBox, sal_uInt16 eType, // delete complete table when last row is deleted if( !bBigger && - aParam.aBoxes.size() == aSortCntBoxes.Count() ) + aParam.aBoxes.Count() == aSortCntBoxes.Count() ) { GetFrmFmt()->GetDoc()->DeleteRowCol( aParam.aBoxes ); return sal_False; @@ -4420,7 +4428,7 @@ sal_Bool SwTable::SetRowHeight( SwTableBox& rAktBox, sal_uInt16 eType, // dann mal anpassen if( bInsDel ) { - if( aParam.aBoxes.empty() ) + if( !aParam.aBoxes.Count() ) ::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 981f3c3..ca006bc 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1671,7 +1671,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.empty() ) + if( aBoxes.Count() ) bRet = InsertCol( aBoxes, nCnt, bBehind ); return bRet; } @@ -1679,8 +1679,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.empty(), "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = const_cast(rBoxes.begin()->second->GetSttNd()->FindTableNode()); + OSL_ENSURE( rBoxes.Count(), "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; @@ -1734,7 +1734,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.empty() ) + if( aBoxes.Count() ) bRet = InsertRow( aBoxes, nCnt, bBehind ); return bRet; } @@ -1742,8 +1742,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.empty(), "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = const_cast(rBoxes.begin()->second->GetSttNd()->FindTableNode()); + OSL_ENSURE( rBoxes.Count(), "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; @@ -1931,8 +1931,8 @@ sal_Bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn ) return sal_False; // uebers SwDoc fuer Undo !! - OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = const_cast(rBoxes.begin()->second->GetSttNd()->FindTableNode()); + OSL_ENSURE( rBoxes.Count(), "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; @@ -1940,7 +1940,8 @@ sal_Bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn ) return sal_False; ::ClearFEShellTabCols(); - SwSelBoxes aSelBoxes( rBoxes ); + SwSelBoxes aSelBoxes; + aSelBoxes.Insert(rBoxes.GetData(), rBoxes.Count()); SwTable &rTable = pTblNd->GetTable(); long nMin = 0; long nMax = 0; @@ -1954,10 +1955,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.rbegin()->second->GetSttNd()-> + const sal_uLong nTmpIdx2 = aSelBoxes[ aSelBoxes.Count()-1 ]->GetSttNd()-> EndOfSectionIndex()+1; - if( pTblNd->GetTable().GetTabSortBoxes().Count() == aSelBoxes.size() && - aSelBoxes.begin()->second->GetSttIdx()-1 == nTmpIdx1 && + if( pTblNd->GetTable().GetTabSortBoxes().Count() == aSelBoxes.Count() && + aSelBoxes[0]->GetSttIdx()-1 == nTmpIdx1 && nTmpIdx2 == pTblNd->EndOfSectionIndex() ) { sal_Bool bNewTxtNd = sal_False; @@ -2140,8 +2141,8 @@ sal_Bool SwDoc::SplitTbl( const SwSelBoxes& rBoxes, sal_Bool bVert, sal_uInt16 n sal_Bool bSameHeight ) { // uebers SwDoc fuer Undo !! - OSL_ENSURE( !rBoxes.empty() && nCnt, "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = const_cast(rBoxes.begin()->second->GetSttNd()->FindTableNode()); + OSL_ENSURE( rBoxes.Count() && nCnt, "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; @@ -2160,9 +2161,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( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it) + for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) { - const SwStartNode* pSttNd = it->second->GetSttNd(); + const SwStartNode* pSttNd = rBoxes[ n ]->GetSttNd(); aNdsCnts.push_back( pSttNd->EndOfSectionIndex() - pSttNd->GetIndex() ); } @@ -2536,7 +2537,13 @@ bool FuzzyCompare::operator() ( long s1, long s2 ) const bool lcl_IsFrmInColumn( const SwCellFrm& rFrm, SwSelBoxes& rBoxes ) { - return 0 != rBoxes.count(rFrm.GetTabBox()); + for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) + { + if ( rFrm.GetTabBox() == rBoxes[ i ] ) + return true; + } + + return false; } // @@ -2932,7 +2939,8 @@ void SwCollectTblLineBoxes::AddToUndoHistory( const SwCntntNode& rNd ) void SwCollectTblLineBoxes::AddBox( const SwTableBox& rBox ) { aPosArr.push_back(nWidth); - aBoxes.push_back( &rBox ); + SwTableBox* p = (SwTableBox*)&rBox; + aBoxes.Insert( p, aBoxes.Count() ); nWidth = nWidth + (sal_uInt16)rBox.GetFrmFmt()->GetFrmSize().GetWidth(); } @@ -2964,10 +2972,10 @@ const SwTableBox* SwCollectTblLineBoxes::GetBoxOfPos( const SwTableBox& rBox ) sal_Bool SwCollectTblLineBoxes::Resize( sal_uInt16 nOffset, sal_uInt16 nOldWidth ) { - if( !aPosArr.empty() ) - { - sal_uInt16 n; + sal_uInt16 n; + if( aPosArr.size() ) + { for( n = 0; n < aPosArr.size(); ++n ) { if( aPosArr[ n ] == nOffset ) @@ -2981,7 +2989,7 @@ sal_Bool SwCollectTblLineBoxes::Resize( sal_uInt16 nOffset, sal_uInt16 nOldWidth } aPosArr.erase(aPosArr.begin(), aPosArr.begin()+n); - aBoxes.erase(aBoxes.begin(), aBoxes.begin()+n); + aBoxes.Remove( 0, n ); // dann die Positionen der neuen Size anpassen for( n = 0; n < aPosArr.size(); ++n ) @@ -3707,8 +3715,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.empty(), "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = const_cast(rBoxes.begin()->second->GetSttNd()->FindTableNode()); + OSL_ENSURE( rBoxes.Count(), "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; @@ -3785,8 +3793,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.empty(), "keine gueltige Box-Liste" ); - SwTableNode* pTblNd = const_cast(rBoxes.begin()->second->GetSttNd()->FindTableNode()); + OSL_ENSURE( rBoxes.Count(), "keine gueltige Box-Liste" ); + SwTableNode* pTblNd = (SwTableNode*)rBoxes[0]->GetSttNd()->FindTableNode(); if( !pTblNd ) return sal_False; @@ -4230,7 +4238,7 @@ sal_Bool SwDoc::InsCopyOfTbl( SwPosition& rInsPos, const SwSelBoxes& rBoxes, const SwTableNode* pSrcTblNd = pCpyTbl ? pCpyTbl->GetTableNode() - : rBoxes.begin()->second->GetSttNd()->FindTableNode(); + : rBoxes[ 0 ]->GetSttNd()->FindTableNode(); SwTableNode * pInsTblNd = rInsPos.nNode.GetNode().FindTableNode(); @@ -4315,7 +4323,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.empty() ) ) + && ( bDelCpyDoc || rBoxes.Count() ) ) { // dann die Tabelle "relativ" kopieren const SwSelBoxes* pBoxes; @@ -4326,7 +4334,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 @@ -4428,16 +4436,16 @@ sal_Bool SwDoc::UnProtectCells( const String& rName ) sal_Bool SwDoc::UnProtectCells( const SwSelBoxes& rBoxes ) { sal_Bool bChgd = sal_False; - if( !rBoxes.empty() ) + if( rBoxes.Count() ) { SwUndoAttrTbl *const pUndo = (GetIDocumentUndoRedo().DoesUndo()) - ? new SwUndoAttrTbl( *rBoxes.begin()->second->GetSttNd()->FindTableNode() ) + ? new SwUndoAttrTbl( *rBoxes[0]->GetSttNd()->FindTableNode() ) : 0; SvPtrarr aFmts( 16 ), aNewFmts( 16 ); - for( SwSelBoxes::const_reverse_iterator it = rBoxes.rbegin(); it != rBoxes.rend(); ++it ) + for( sal_uInt16 i = rBoxes.Count(); i; ) { - SwTableBox* pBox = it->second; + SwTableBox* pBox = rBoxes[ --i ]; 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 4524a58..2e4c1c5 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -146,12 +146,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 !rBoxes.empty(); + return 0 != rBoxes.Count(); } /*********************************************************************** @@ -243,7 +243,7 @@ void lcl_CollectLines( SvPtrarr &rArr, const SwCursor& rCursor, bool bRemoveLine return ; //Die selektierte Struktur kopieren. - const SwTable &rTable = aBoxes.begin()->second->GetSttNd()->FindTableNode()->GetTable(); + const SwTable &rTable = aBoxes[0]->GetSttNd()->FindTableNode()->GetTable(); LinesAndTable aPara( rArr, rTable ); _FndBox aFndBox( 0, 0 ); { @@ -1123,10 +1123,10 @@ void SwDoc::SetBoxAttr( const SwCursor& rCursor, const SfxPoolItem &rNew ) GetIDocumentUndoRedo().AppendUndo( new SwUndoAttrTbl(*pTblNd) ); } - SvPtrarr aFmtCmp( Max( sal_uInt8(255), sal_uInt8(aBoxes.size()) ), 255 ); - for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) + SvPtrarr aFmtCmp( Max( sal_uInt8(255), sal_uInt8(aBoxes.Count()) ), 255 ); + for ( sal_uInt16 i = 0; i < aBoxes.Count(); ++i ) { - SwTableBox *pBox = it->second; + SwTableBox *pBox = aBoxes[i]; SwFrmFmt *pNewFmt; if ( 0 != (pNewFmt = SwTblFmtCmp::FindNewFmt( aFmtCmp, pBox->GetFrmFmt(), 0 ))) @@ -1169,15 +1169,14 @@ 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( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) + for( sal_uInt16 i = 0; i < aBoxes.Count(); ++i ) { - SwTableBox* pBox = it->second; switch ( nWhich ) { case RES_BACKGROUND: { const SvxBrushItem &rBack = - pBox->GetFrmFmt()->GetBackground(); + aBoxes[i]->GetFrmFmt()->GetBackground(); if( !bOneFound ) { (SvxBrushItem&)rToFill = rBack; @@ -1191,7 +1190,7 @@ sal_Bool SwDoc::GetBoxAttr( const SwCursor& rCursor, SfxPoolItem& rToFill ) cons case RES_FRAMEDIR: { const SvxFrameDirectionItem& rDir = - pBox->GetFrmFmt()->GetFrmDir(); + aBoxes[i]->GetFrmFmt()->GetFrmDir(); if( !bOneFound ) { (SvxFrameDirectionItem&)rToFill = rDir; @@ -1203,7 +1202,7 @@ sal_Bool SwDoc::GetBoxAttr( const SwCursor& rCursor, SfxPoolItem& rToFill ) cons case RES_VERT_ORIENT: { const SwFmtVertOrient& rOrient = - pBox->GetFrmFmt()->GetVertOrient(); + aBoxes[i]->GetFrmFmt()->GetVertOrient(); if( !bOneFound ) { (SwFmtVertOrient&)rToFill = rOrient; @@ -1240,10 +1239,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( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) + for( sal_uInt16 i = 0; i < aBoxes.Count(); ++i ) { const SwFmtVertOrient &rOri = - it->second->GetFrmFmt()->GetVertOrient(); + aBoxes[i]->GetFrmFmt()->GetVertOrient(); if( USHRT_MAX == nAlign ) nAlign = static_cast(rOri.GetVertOrient()); else if( rOri.GetVertOrient() != nAlign ) diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index d02ed2a..9288277 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -210,11 +210,11 @@ sal_Bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd ) SwTableNode* pTblNd; SwSelBoxes aBoxes; GetTblSel( *this, aBoxes ); - if( !aBoxes.empty() && - NULL != (pTblNd = const_cast(aBoxes.begin()->second->GetSttNd()->FindTableNode()) )) + if( aBoxes.Count() && 0 != (pTblNd = (SwTableNode*)aBoxes[0] + ->GetSttNd()->FindTableNode() )) { // teste ob der TabellenName kopiert werden kann - sal_Bool bCpyTblNm = aBoxes.size() == pTblNd->GetTable().GetTabSortBoxes().Count(); + sal_Bool bCpyTblNm = aBoxes.Count() == 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 863b75b..5d45e15 100644 --- a/sw/source/core/edit/edtab.cxx +++ b/sw/source/core/edit/edtab.cxx @@ -279,16 +279,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( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) + for( sal_uInt16 n = 0; n < aBoxes.Count(); ++n ) { - const SwTableBox* pSelBox = it->second; - const SwTableBoxFmt* pTblFmt = static_cast(pSelBox->GetFrmFmt()); - if( it == aBoxes.begin() ) + const SwTableBox* pSelBox = aBoxes[ n ]; + const SwTableBoxFmt* pTblFmt = (SwTableBoxFmt*)pSelBox->GetFrmFmt(); + if( !n ) { // Formeln in die externe Darstellung bringen! const SwTable& rTbl = pSelBox->GetSttNd()->FindTableNode()->GetTable(); @@ -321,7 +321,7 @@ void SwEditShell::SetTblBoxFormulaAttrs( const SfxItemSet& rSet ) if ( pFrm ) { SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox(); - aBoxes.insert( pBox ); + aBoxes.Insert( pBox ); } } while( sal_False ); } @@ -332,8 +332,8 @@ void SwEditShell::SetTblBoxFormulaAttrs( const SfxItemSet& rSet ) StartAllAction(); GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); - for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) - GetDoc()->SetTblBoxFormulaAttrs( *it->second, rSet ); + for( sal_uInt16 n = 0; n < aBoxes.Count(); ++n ) + GetDoc()->SetTblBoxFormulaAttrs( *aBoxes[ n ], 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 5d9241e..7453a30 100644 --- a/sw/source/core/fields/cellfml.cxx +++ b/sw/source/core/fields/cellfml.cxx @@ -347,11 +347,10 @@ void SwTableFormula::_MakeFormel( const SwTable& rTbl, String& rNewStr, rNewStr += '('; bool bDelim = false; - for( SwSelBoxes::iterator it = aBoxes.begin(); - it != aBoxes.end() && !pCalcPara->rCalc.IsCalcError(); - ++it ) + for( sal_uInt16 n = 0; n < aBoxes.Count() && + !pCalcPara->rCalc.IsCalcError(); ++n ) { - const SwTableBox* pTblBox = it->second; + const SwTableBox* pTblBox = aBoxes[n]; if ( pTblBox->getRowSpan() >= 1 ) { if( bDelim ) @@ -874,11 +873,12 @@ String lcl_BoxNmToRel( const SwTable& rTbl, const SwTableNode& rTblNd, sal_uInt16 SwTableFormula::GetBoxesOfFormula( const SwTable& rTbl, SwSelBoxes& rBoxes ) { - rBoxes.clear(); + if( rBoxes.Count() ) + rBoxes.Remove( sal_uInt16(0), rBoxes.Count() ); BoxNmToPtr( &rTbl ); ScanString( &SwTableFormula::_GetFmlBoxes, rTbl, &rBoxes ); - return rBoxes.size(); + return rBoxes.Count(); } void SwTableFormula::_GetFmlBoxes( const SwTable& rTbl, String& , @@ -910,10 +910,10 @@ void SwTableFormula::_GetFmlBoxes( const SwTable& rTbl, String& , // deren Werte SwSelBoxes aBoxes; GetBoxes( *pSttBox, *pEndBox, aBoxes ); - pBoxes->insert( aBoxes.begin(), aBoxes.end() ); + pBoxes->Insert( &aBoxes ); } else if( pSttBox ) // nur die StartBox ? - pBoxes->insert( pSttBox ); + pBoxes->Insert( pSttBox ); } void SwTableFormula::GetBoxes( const SwTableBox& rSttBox, @@ -958,17 +958,14 @@ void SwTableFormula::GetBoxes( const SwTableBox& rSttBox, break; // dann mal die Tabellenkoepfe raus: - for( SwSelBoxes::iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) { - pLine = it->second->GetUpper(); + pLine = rBoxes[n]->GetUpper(); while( pLine->GetUpper() ) pLine = pLine->GetUpper()->GetUpper(); if( pTbl->IsHeadline( *pLine ) ) - { - rBoxes.erase( it++ ); - --it; - } + rBoxes.Remove( n--, 1 ); } } while( sal_False ); } diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index e3056be..722f069 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -592,8 +592,8 @@ sal_Bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, const SwTableNode* pTblNd; SwSelBoxes aBoxes; GetTblSel( *this, aBoxes ); - if( !aBoxes.empty() && - NULL != (pTblNd = aBoxes.begin()->second->GetSttNd()->FindTableNode()) ) + if( aBoxes.Count() && + 0 != (pTblNd = aBoxes[0]->GetSttNd()->FindTableNode()) ) { SwPosition* pDstPos = 0; if( this == pDestShell ) @@ -619,7 +619,7 @@ sal_Bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt, bRet = pDestShell->GetDoc()->InsCopyOfTbl( *pDstPos, aBoxes,0, bIsMove && this == pDestShell && - aBoxes.size() == pTblNd->GetTable(). + aBoxes.Count() == pTblNd->GetTable(). GetTabSortBoxes().Count(), this != pDestShell ); @@ -863,7 +863,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 473f6f3..c291542 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -613,13 +613,13 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali if( IsTableMode() ) { GetTblSel( *this, aBoxes ); - if( !aBoxes.empty() ) + if( aBoxes.Count() ) { // 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.begin()->second->GetSttNd() )); + ParkCrsr( SwNodeIndex( *aBoxes[0]->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 10e7e8a..a4bde74 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -221,10 +221,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.size() ); + TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.Count() ); sal_Bool bRet = sal_False; - if ( !aBoxes.empty() ) + if ( aBoxes.Count() ) bRet = GetDoc()->InsertRow( aBoxes, nCnt, bBehind ); EndAllActionAndCall(); @@ -259,10 +259,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.size() ); + TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.Count() ); sal_Bool bRet = sal_False; - if( !aBoxes.empty() ) + if( aBoxes.Count() ) bRet = GetDoc()->InsertCol( aBoxes, nCnt, bBehind ); EndAllActionAndCall(); @@ -314,9 +314,9 @@ sal_Bool SwFEShell::DeleteCol() sal_Bool bRet; SwSelBoxes aBoxes; GetTblSel( *this, aBoxes, nsSwTblSearchType::TBLSEARCH_COL ); - if ( !aBoxes.empty() ) + if ( aBoxes.Count() ) { - TblWait( aBoxes.size(), pFrm, *GetDoc()->GetDocShell() ); + TblWait( aBoxes.Count(), pFrm, *GetDoc()->GetDocShell() ); // die Crsr muessen noch aus dem Loesch Bereich entfernt // werden. Setze sie immer hinter/auf die Tabelle; ueber die @@ -361,9 +361,9 @@ sal_Bool SwFEShell::DeleteRow() SwSelBoxes aBoxes; GetTblSel( *this, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW ); - if( !aBoxes.empty() ) + if( aBoxes.Count() ) { - TblWait( aBoxes.size(), pFrm, *GetDoc()->GetDocShell() ); + TblWait( aBoxes.Count(), pFrm, *GetDoc()->GetDocShell() ); // die Crsr aus dem Loeschbereich entfernen. // Der Cursor steht danach: @@ -523,9 +523,9 @@ sal_Bool SwFEShell::SplitTab( sal_Bool bVert, sal_uInt16 nCnt, sal_Bool bSameHei sal_Bool bRet; SwSelBoxes aBoxes; GetTblSel( *this, aBoxes ); - if( !aBoxes.empty() ) + if( aBoxes.Count() ) { - TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.size() ); + TblWait( nCnt, pFrm, *GetDoc()->GetDocShell(), aBoxes.Count() ); // dann loesche doch die Spalten bRet = GetDoc()->SplitTbl( aBoxes, bVert, nCnt, bSameHeight ); @@ -937,12 +937,12 @@ sal_Bool SwFEShell::HasWholeTabSelection() const { SwSelBoxes aBoxes; ::GetTblSelCrs( *this, aBoxes ); - if( !aBoxes.empty() ) + if( aBoxes.Count() ) { const SwTableNode *pTblNd = IsCrsrInTbl(); - return ( pTblNd && aBoxes.begin()->second->GetSttIdx()-1 == pTblNd-> + return ( pTblNd && aBoxes[0]->GetSttIdx()-1 == pTblNd-> EndOfSectionNode()->StartOfSectionIndex() && - aBoxes.rbegin()->second->GetSttNd()->EndOfSectionIndex()+1 + aBoxes[aBoxes.Count()-1]->GetSttNd()->EndOfSectionIndex()+1 == pTblNd->EndOfSectionIndex() ); } } @@ -1030,12 +1030,12 @@ void SwFEShell::UnProtectCells() } while ( pFrm && !pFrm->IsCellFrm() ); if( pFrm ) { - SwTableBox *pBox = const_cast(static_cast(pFrm)->GetTabBox()); - aBoxes.insert( pBox ); + SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox(); + aBoxes.Insert( pBox ); } } - if( !aBoxes.empty() ) + if( aBoxes.Count() ) GetDoc()->UnProtectCells( aBoxes ); EndAllActionAndCall(); @@ -1073,11 +1073,11 @@ sal_Bool SwFEShell::CanUnProtectCells() const } while ( pFrm && !pFrm->IsCellFrm() ); if( pFrm ) { - SwTableBox *pBox = const_cast(static_cast(pFrm)->GetTabBox()); - aBoxes.insert( pBox ); + SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox(); + aBoxes.Insert( pBox ); } } - if( !aBoxes.empty() ) + if( aBoxes.Count() ) bUnProtectAvailable = ::HasProtectedCells( aBoxes ); } return bUnProtectAvailable; @@ -1234,20 +1234,20 @@ sal_Bool SwFEShell::IsAdjustCellWidthAllowed( sal_Bool bBalance ) const ::GetTblSelCrs( *this, aBoxes ); if ( bBalance ) - return aBoxes.size() > 1; + return aBoxes.Count() > 1; - if ( aBoxes.empty() ) + if ( !aBoxes.Count() ) { do { pFrm = pFrm->GetUpper(); } while ( !pFrm->IsCellFrm() ); - SwTableBox *pBox = const_cast(static_cast(pFrm)->GetTabBox()); - aBoxes.insert( pBox ); + SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox(); + aBoxes.Insert( pBox ); } - for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) + for ( sal_uInt16 i = 0; i < aBoxes.Count(); ++i ) { - SwTableBox *pBox = it->second; + SwTableBox *pBox = aBoxes[i]; if ( pBox->GetSttNd() ) { SwNodeIndex aIdx( *pBox->GetSttNd(), 1 ); @@ -1287,12 +1287,13 @@ sal_Bool SwFEShell::SetTableAutoFmt( const SwTableAutoFmt& rNew ) const SwTableSortBoxes& rTBoxes = pTblNd->GetTable().GetTabSortBoxes(); for( sal_uInt16 n = 0; n < rTBoxes.Count(); ++n ) { - aBoxes.insert( rTBoxes[ n ] ); + SwTableBox* pBox = rTBoxes[ n ]; + aBoxes.Insert( pBox ); } } sal_Bool bRet; - if( !aBoxes.empty() ) + if( aBoxes.Count() ) { SET_CURR_SHELL( this ); StartAllAction(); @@ -1325,7 +1326,8 @@ sal_Bool SwFEShell::GetTableAutoFmt( SwTableAutoFmt& rGet ) const SwTableSortBoxes& rTBoxes = pTblNd->GetTable().GetTabSortBoxes(); for( sal_uInt16 n = 0; n < rTBoxes.Count(); ++n ) { - aBoxes.insert( rTBoxes[ n ] ); + SwTableBox* pBox = rTBoxes[ n ]; + aBoxes.Insert( pBox ); } } @@ -1357,9 +1359,9 @@ sal_Bool SwFEShell::DeleteTblSel() sal_Bool bRet; SwSelBoxes aBoxes; GetTblSelCrs( *this, aBoxes ); - if( !aBoxes.empty() ) + if( aBoxes.Count() ) { - TblWait( aBoxes.size(), pFrm, *GetDoc()->GetDocShell() ); + TblWait( aBoxes.Count(), pFrm, *GetDoc()->GetDocShell() ); // die Crsr muessen noch aus dem Loesch Bereich entfernt // werden. Setze sie immer hinter/auf die Tabelle; ueber die @@ -2344,10 +2346,9 @@ sal_Bool lcl_IsFormulaSelBoxes( const SwTable& rTbl, const SwTblBoxFormula& rFml { SwTblBoxFormula aTmp( rFml ); SwSelBoxes aBoxes; - aTmp.GetBoxesOfFormula( rTbl, aBoxes ); - for( SwSelBoxes::reverse_iterator it = aBoxes.rbegin(); it != aBoxes.rend(); ++it ) + for( sal_uInt16 nSelBoxes = aTmp.GetBoxesOfFormula( rTbl,aBoxes ); nSelBoxes; ) { - SwTableBox* pBox = it->second; + SwTableBox* pBox = aBoxes[ --nSelBoxes ]; 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 4d18a40..dee1760 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -75,6 +75,42 @@ #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 @@ -145,29 +181,25 @@ const SwLayoutFrm *lcl_FindNextCellFrm( const SwLayoutFrm *pLay ) void GetTblSelCrs( const SwCrsrShell &rShell, SwSelBoxes& rBoxes ) { - rBoxes.clear(); - if( rShell.IsTableMode() && const_cast(rShell).UpdateTblSelBoxes()) - { - const SwSelBoxes& rShellBoxes = rShell.GetTableCrsr()->GetBoxes(); - rBoxes.insert( rShellBoxes.begin(), rShellBoxes.end() ); - } + if( rBoxes.Count() ) + rBoxes.Remove( sal_uInt16(0), rBoxes.Count() ); + if( rShell.IsTableMode() && ((SwCrsrShell&)rShell).UpdateTblSelBoxes()) + rBoxes.Insert( &rShell.GetTableCrsr()->GetBoxes() ); } void GetTblSelCrs( const SwTableCursor& rTblCrsr, SwSelBoxes& rBoxes ) { - rBoxes.clear(); + if( rBoxes.Count() ) + rBoxes.Remove( sal_uInt16(0), rBoxes.Count() ); if( rTblCrsr.IsChgd() || !rTblCrsr.GetBoxesCount() ) { - SwTableCursor* pTCrsr = const_cast(&rTblCrsr); + SwTableCursor* pTCrsr = (SwTableCursor*)&rTblCrsr; pTCrsr->GetDoc()->GetCurrentLayout()->MakeTblCrsrs( *pTCrsr ); //swmod 080218 } if( rTblCrsr.GetBoxesCount() ) - { - const SwSelBoxes& rCursorBoxes = rTblCrsr.GetBoxes(); - rBoxes.insert( rCursorBoxes.begin(), rCursorBoxes.end() ); - } + rBoxes.Insert( &rTblCrsr.GetBoxes() ); } void GetTblSel( const SwCrsrShell& rShell, SwSelBoxes& rBoxes, @@ -242,7 +274,7 @@ void GetTblSel( const SwCursor& rCrsr, SwSelBoxes& rBoxes, // Zellenschutzt beachten ?? if( !bChkProtected || !pBox->GetFrmFmt()->GetProtect().IsCntntProtected() ) - rBoxes.insert( pBox ); + rBoxes.Insert( pBox ); } } } @@ -345,7 +377,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 ) { @@ -438,7 +470,8 @@ void GetTblSel( const SwLayoutFrm* pStart, const SwLayoutFrm* pEnd, break; } - rBoxes.clear(); + i = 0; + rBoxes.Remove( i, rBoxes.Count() ); --nLoopMax; } while( sal_True ); @@ -891,14 +924,14 @@ sal_Bool GetAutoSumSel( const SwCrsrShell& rShell, SwCellFrms& rBoxes ) sal_Bool HasProtectedCells( const SwSelBoxes& rBoxes ) { - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) - { - if( it->second->GetFrmFmt()->GetProtect().IsCntntProtected() ) + sal_Bool bRet = sal_False; + for( sal_uInt16 n = 0, nCnt = rBoxes.Count(); n < nCnt; ++n ) + if( rBoxes[ n ]->GetFrmFmt()->GetProtect().IsCntntProtected() ) { - return sal_True; + bRet = sal_True; + break; } - } - return sal_False; + return bRet; } @@ -965,7 +998,8 @@ sal_Bool IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam ) void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, SwTableBox** ppMergeBox, SwUndoTblMerge* pUndo ) { - rBoxes.clear(); + if( rBoxes.Count() ) + rBoxes.Remove( sal_uInt16(0), rBoxes.Count() ); //Zuerst lassen wir uns die Tabellen und die Rechtecke heraussuchen. OSL_ENSURE( rPam.GetCntntNode() && rPam.GetCntntNode( sal_False ), @@ -1045,7 +1079,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 ) ); @@ -1062,7 +1096,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 @@ -1113,7 +1147,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 ) ); @@ -1157,7 +1191,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 )); @@ -1181,7 +1215,7 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, } // keine SSelection / keine gefundenen Boxen - if( 1 >= rBoxes.size() ) + if( 1 >= rBoxes.Count() ) return; // dann suche mal alle Boxen, die nebeneinander liegen, und verbinde @@ -1369,7 +1403,7 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, // lege schon mal die neue Box an { - SwTableBox* pTmpBox = rBoxes.begin()->second; + SwTableBox* pTmpBox = rBoxes[0]; SwTableLine* pInsLine = pTmpBox->GetUpper(); sal_uInt16 nInsPos = pInsLine->GetTabBoxes().C40_GETPOS( SwTableBox, pTmpBox ); @@ -1507,13 +1541,13 @@ sal_uInt16 CheckMergeSel( const SwPaM& rPam ) sal_uInt16 CheckMergeSel( const SwSelBoxes& rBoxes ) { sal_uInt16 eRet = TBLMERGE_NOSELECTION; - if( !rBoxes.empty() ) + if( rBoxes.Count() ) { eRet = TBLMERGE_OK; _FndBox aFndBox( 0, 0 ); _FndPara aPara( rBoxes, &aFndBox ); - const SwTableNode* pTblNd = aPara.rBoxes.begin()->second->GetSttNd()->FindTableNode(); + const SwTableNode* pTblNd = aPara.rBoxes[0]->GetSttNd()->FindTableNode(); ((SwTable&)pTblNd->GetTable()).GetTabLines().ForEach( &_FndLineCopyCol, &aPara ); if( aFndBox.GetLines().Count() ) @@ -2120,7 +2154,9 @@ sal_Bool _FndBoxCopyCol( const SwTableBox*& rpBox, void* pPara ) } else { - if( 0 == pFndPara->rBoxes.count( rpBox ) ) + SwTableBoxPtr pSrch = (SwTableBoxPtr)rpBox; + sal_uInt16 nFndPos; + if( !pFndPara->rBoxes.Seek_Entry( pSrch, &nFndPos )) { delete pFndBox; return sal_True; @@ -2159,9 +2195,9 @@ void _FndBox::SetTableLines( const SwSelBoxes &rBoxes, const SwTable &rTable ) sal_uInt16 nStPos = USHRT_MAX; sal_uInt16 nEndPos= 0; - for ( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + for ( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) { - SwTableLine *pLine = it->second->GetUpper(); + SwTableLine *pLine = rBoxes[i]->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 1db055b..4beb8a8 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 aPosArr; - std::vector aBoxes; + SwSelBoxes_SAR aBoxes; SwHistory* pHst; sal_uInt16 nMode, nWidth; sal_Bool bGetFromTop : 1; @@ -93,8 +93,9 @@ class SwCollectTblLineBoxes public: SwCollectTblLineBoxes( sal_Bool bTop, sal_uInt16 nMd = 0, SwHistory* pHist=0 ) - : pHst( pHist ), nMode( nMd ), nWidth( 0 ), - bGetFromTop( bTop ), bGetValues( sal_True ) + : aBoxes( 16, 16 ), + pHst( pHist ), nMode( nMd ), nWidth( 0 ), + bGetFromTop( bTop ), bGetValues( sal_True ) {} @@ -102,7 +103,7 @@ public: const SwTableBox* GetBoxOfPos( const SwTableBox& rBox ); void AddToUndoHistory( const SwCntntNode& rNd ); - sal_uInt16 Count() const { return aBoxes.size(); } + sal_uInt16 Count() const { return aBoxes.Count(); } 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 d2c3d4e..76994b0 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -1947,7 +1947,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 2bba4e2..5681bca 100644 --- a/sw/source/core/table/swnewtable.cxx +++ b/sw/source/core/table/swnewtable.cxx @@ -407,7 +407,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; @@ -438,7 +438,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; @@ -457,7 +457,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; @@ -610,11 +610,11 @@ long lcl_InsertPosition( SwTable &rTable, std::vector& rInsPos, { sal_Int32 nAddWidth = 0; long nCount = 0; - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + for( sal_uInt16 j = 0; j < rBoxes.Count(); ++j ) { - SwTableBox *pBox = it->second; + SwTableBox *pBox = rBoxes[j]; SwTableLine* pLine = pBox->GetUpper(); - long nWidth = pBox->GetFrmFmt()->GetFrmSize().GetWidth(); + long nWidth = rBoxes[j]->GetFrmFmt()->GetFrmSize().GetWidth(); nAddWidth += nWidth; sal_uInt16 nCurrBox = pLine->GetTabBoxes().C40_GETPOS(SwTableBox, pBox ); sal_uInt16 nCurrLine = rTable.GetTabLines().C40_GETPOS(SwTableLine, pLine ); @@ -814,7 +814,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, if( !bNewModel ) { ::GetMergeSel( rPam, rBoxes, ppMergeBox, pUndo ); - return rBoxes.size() > 1; + return rBoxes.Count() > 1; } CHECK_TABLE( *this ) // We have to assert a "rectangular" box selection before we start to merge @@ -825,7 +825,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]->begin()->second; // the master cell box + SwTableBox *pMergeBox = (*pSel->aBoxes[0])[0]; // the master cell box if( !pMergeBox ) return false; (*ppMergeBox) = pMergeBox; @@ -852,16 +852,16 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, { // The selected boxes in the current line const SwSelBoxes* pBoxes = pSel->aBoxes[ nCurrLine ]; - SwSelBoxes::const_iterator itTail = pBoxes->end(); --itTail; + sal_uInt16 nColCount = pBoxes->Count(); // Iteration over the selected cell in the current row - for( SwSelBoxes::const_iterator it = pBoxes->begin(); it != pBoxes->end(); ++it ) + for( sal_uInt16 nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol ) { - SwTableBox* pBox = it->second; - rMerged.insert( pBox ); + SwTableBox* pBox = (*pBoxes)[nCurrCol]; + rMerged.Insert( pBox ); // Only the first selected cell in every row will be alive, // the other will be deleted => put into rBoxes - if( it != pBoxes->begin() ) - rBoxes.insert( pBox ); + if( nCurrCol ) + rBoxes.Insert( pBox ); else { if( nCurrLine == 1 ) @@ -874,7 +874,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( it == itTail && pBox->getRowSpan() > 0 ) + if( nCurrCol+1 == nColCount && pBox->getRowSpan() > 0 ) pLastBox = pBox; if( bDoMerge ) { @@ -912,7 +912,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( it == pBoxes->begin() ) + if( !nCurrCol ) pBox->setRowSpan( nRowSpan ); } if( nRowSpan > 0 ) // the master cell is done, from now on we set @@ -930,10 +930,11 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, for( sal_uInt16 nCurrLine = 0; nCurrLine < nLineCount; ++nCurrLine ) { const SwSelBoxes* pBoxes = pSel->aBoxes[ nCurrLine ]; - for( SwSelBoxes::const_iterator it = pBoxes->begin(); it != pBoxes->end(); ++it ) + sal_uInt16 nColCount = pBoxes->Count(); + for( sal_uInt16 nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol ) { - SwTableBox* pBox = it->second; - if( it != pBoxes->begin() ) + SwTableBox* pBox = (*pBoxes)[nCurrCol]; + if( nCurrCol ) { // Even this box will be deleted soon, // we have to correct the width to avoid side effects @@ -941,7 +942,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, pFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, 0, 0 ) ); } else - pBox->ChgFrmFmt( static_cast(pNewFmt) ); + pBox->ChgFrmFmt( (SwTableBoxFmt*)pNewFmt ); } } if( pLastBox ) // Robust @@ -971,10 +972,10 @@ void SwTable::_FindSuperfluousRows( SwSelBoxes& rBoxes, { if( !pFirstLn || !pLastLn ) { - if( rBoxes.empty() ) + if( !rBoxes.Count() ) return; - pFirstLn = rBoxes.begin()->second->GetUpper(); - pLastLn = rBoxes.rbegin()->second->GetUpper(); + pFirstLn = rBoxes[0]->GetUpper(); + pLastLn = rBoxes[ rBoxes.Count() - 1 ]->GetUpper(); } sal_uInt16 nFirstLn = GetTabLines().C40_GETPOS(SwTableLine, pFirstLn ); sal_uInt16 nLastLn = GetTabLines().C40_GETPOS(SwTableLine, pLastLn ); @@ -988,7 +989,7 @@ void SwTable::_FindSuperfluousRows( SwSelBoxes& rBoxes, { SwTableBox *pBox = pLine->GetTabBoxes()[nCol]; if( pBox->getRowSpan() > 0 && - 0 == rBoxes.count( pBox ) ) + USHRT_MAX == rBoxes.GetPos( pBox ) ) { bSuperfl = false; break; @@ -999,7 +1000,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 ); } } } @@ -1067,7 +1068,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(); @@ -1078,7 +1079,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 ); }; } @@ -1091,7 +1092,7 @@ void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, sal_uInt16 nCnt, { SwSelBoxes aBoxes; lcl_getAllMergedBoxes( rTable, aBoxes, rBox ); - sal_uInt16 nCount = aBoxes.size(); + sal_uInt16 nCount = aBoxes.Count(); if( nCount < 2 ) return; if( nCnt > nCount ) @@ -1099,15 +1100,14 @@ void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, sal_uInt16 nCnt, sal_uInt16 *pSplitIdx = new sal_uInt16[ nCnt ]; if( bSameHeight ) { - std::vector aHeights; + SwTwips *pHeights = new SwTwips[ nCount ]; SwTwips nHeight = 0; - for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) + for( sal_uInt16 i = 0; i < nCount; ++i ) { - SwTableLine* pLine = it->second->GetUpper(); + SwTableLine* pLine = aBoxes[ i ]->GetUpper(); SwFrmFmt *pRowFmt = pLine->GetFrmFmt(); - SwTwips nH = pRowFmt->GetFrmSize().GetHeight(); - aHeights.push_back( nH ); - nHeight += nH; + pHeights[ i ] = pRowFmt->GetFrmSize().GetHeight(); + nHeight += pHeights[ i ]; } SwTwips nSumH = 0; sal_uInt16 nIdx = 0; @@ -1115,29 +1115,24 @@ void lcl_UnMerge( const SwTable& rTable, SwTableBox& rBox, sal_uInt16 nCnt, { SwTwips nSplit = ( i * nHeight ) / nCnt; while( nSumH < nSplit && nIdx < nCount ) - nSumH += aHeights[ nIdx++ ]; + nSumH += pHeights[ nIdx++ ]; pSplitIdx[ i - 1 ] = nIdx; } + delete[] pHeights; } else { - for( sal_uInt32 i = 1; i <= nCnt; ++i ) - pSplitIdx[ i - 1 ] = static_cast( ( i * nCount ) / nCnt ); + for( long i = 1; i <= nCnt; ++i ) + pSplitIdx[ i - 1 ] = (sal_uInt16)( ( i * nCount ) / nCnt ); } sal_uInt16 nIdx = 0; - SwSelBoxes::const_iterator it = aBoxes.begin(); - for( sal_uInt16 i = 0; i < nCnt; ++i ) + for( long i = 0; i < nCnt; ++i ) { sal_uInt16 nNextIdx = pSplitIdx[ i ]; - it->second->setRowSpan( nNextIdx - nIdx ); - lcl_InvalidateCellFrm( *it->second ); - while( true ) { - ++nIdx; - ++it; - if( nIdx >= nNextIdx ) - break; - it->second->setRowSpan( nIdx - nNextIdx ); - } + aBoxes[ nIdx ]->setRowSpan( nNextIdx - nIdx ); + lcl_InvalidateCellFrm( *aBoxes[ nIdx ] ); + while( ++nIdx < nNextIdx ) + aBoxes[ nIdx ]->setRowSpan( nIdx - nNextIdx ); } delete[] pSplitIdx; } @@ -1150,7 +1145,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 @@ -1212,9 +1207,9 @@ void lcl_SophisticatedFillLineIndices( SwLineOffsetArray &rArr, { std::list< SwLineOffset > aBoxes; SwLineOffset aLnOfs( USHRT_MAX, USHRT_MAX ); - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) { // Collect all end line indices and the row spans - const SwTableBox &rBox = it->second->FindStartOfRowSpan( rTable ); + const SwTableBox &rBox = rBoxes[ i ]->FindStartOfRowSpan( rTable ); OSL_ENSURE( rBox.getRowSpan() > 0, "Didn't I say 'StartOfRowSpan' ??" ); if( nCnt > rBox.getRowSpan() ) { @@ -1311,9 +1306,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( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) { // Collect all pairs (start+end) of line indices to split - const SwTableBox &rBox = it->second->FindStartOfRowSpan( rTable ); + const SwTableBox &rBox = rBoxes[ i ]->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 ); @@ -1368,10 +1363,10 @@ sal_uInt16 lcl_LineIndex( const SwTable& rTable, const SwSelBoxes& rBoxes, { sal_uInt16 nDirect = USHRT_MAX; sal_uInt16 nSpan = USHRT_MAX; - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) { - const SwTableBox* pBox = it->second; - const SwTableLine* pLine = pBox->GetUpper(); + SwTableBox *pBox = rBoxes[i]; + const SwTableLine* pLine = rBoxes[i]->GetUpper(); sal_uInt16 nPos = rTable.GetTabLines().C40_GETPOS( SwTableLine, pLine ); if( USHRT_MAX != nPos ) { @@ -1464,18 +1459,17 @@ sal_Bool SwTable::NewSplitRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 } } - std::vector aBoxes; - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + std::set< sal_uInt16> aIndices; + for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) { - OSL_ENSURE( it->second->getRowSpan() != 1, "Forgot to split?" ); - if( it->second->getRowSpan() > 1 ) - aBoxes.push_back( it->second ); + OSL_ENSURE( rBoxes[i]->getRowSpan() != 1, "Forgot to split?" ); + if( rBoxes[i]->getRowSpan() > 1 ) + aIndices.insert( i ); } - for( std::vector::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it ) - { - lcl_UnMerge( *this, **it, nCnt, bSameHeight ); - } + std::set< sal_uInt16 >::iterator pCurrBox = aIndices.begin(); + while( pCurrBox != aIndices.end() ) + lcl_UnMerge( *this, *rBoxes[*pCurrBox++], nCnt, bSameHeight ); CHECK_TABLE( *this ) //Layout updaten @@ -1554,9 +1548,9 @@ void SwTable::PrepareDelBoxes( const SwSelBoxes& rBoxes ) { if( IsNewModel() ) { - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) { - SwTableBox* pBox = it->second; + SwTableBox* pBox = rBoxes[i]; long nRowSpan = pBox->getRowSpan(); if( nRowSpan != 1 && pBox->GetFrmFmt()->GetFrmSize().GetWidth() ) { @@ -1634,9 +1628,9 @@ void lcl_SearchSelBox( const SwTable &rTable, SwSelBoxes& rBoxes, long nMin, lon ( !bChkProtected || !pBox->GetFrmFmt()->GetProtect().IsCntntProtected() ) ) { - sal_uInt16 nOldCnt = rBoxes.size(); - rBoxes.insert( pBox ); - if( bColumn && nRowSpan != 1 && nOldCnt < rBoxes.size() ) + sal_uInt16 nOldCnt = rBoxes.Count(); + rBoxes.Insert( pBox ); + if( bColumn && nRowSpan != 1 && nOldCnt < rBoxes.Count() ) { SwTableBox *pMasterBox = pBox->getRowSpan() > 0 ? pBox : &pBox->FindStartOfRowSpan( rTable, USHRT_MAX ); @@ -1673,8 +1667,12 @@ 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 { - rBoxes.clear(); - + // SwSelBoxes aKeepBoxes; + if( rBoxes.Count() ) + { + // aKeepBoxes.Insert( &rBoxes ); + rBoxes.Remove( sal_uInt16(0), rBoxes.Count() ); + } // 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 +1699,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 +1742,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,12 +1804,13 @@ 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.empty() ) + if( !aLines.Count() || !rBoxes.Count() ) return; sal_uInt16 nLineCnt = aLines.Count(); - SwSelBoxes::iterator it = rBoxes.begin(); - for( sal_uInt16 nRow = 0; nRow < nLineCnt && it != rBoxes.end(); ++nRow ) + sal_uInt16 nBoxCnt = rBoxes.Count(); + sal_uInt16 nBox = 0; + for( sal_uInt16 nRow = 0; nRow < nLineCnt && nBox < nBoxCnt; ++nRow ) { SwTableLine* pLine = aLines[nRow]; OSL_ENSURE( pLine, "Missing table line" ); @@ -1820,15 +1819,15 @@ void SwTable::ExpandColumnSelection( SwSelBoxes& rBoxes, long &rMin, long &rMax { SwTableBox* pBox = pLine->GetTabBoxes()[nCol]; OSL_ENSURE( pBox, "Missing table box" ); - if( pBox == it->second ) + if( pBox == rBoxes[nBox] ) { - lcl_CheckMinMax( rMin, rMax, *pLine, nCol, it == rBoxes.begin() ); - if( ++it == rBoxes.end() ) + lcl_CheckMinMax( rMin, rMax, *pLine, nCol, nBox == 0 ); + if( ++nBox >= nBoxCnt ) break; } } } - + nBox = 0; for( sal_uInt16 nRow = 0; nRow < nLineCnt; ++nRow ) { SwTableLine* pLine = aLines[nRow]; @@ -1841,7 +1840,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 ); } } } @@ -1903,9 +1902,9 @@ void SwTable::PrepareDeleteCol( long nMin, long nMax ) void SwTable::ExpandSelection( SwSelBoxes& rBoxes ) const { - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i ) { - SwTableBox *pBox = it->second; + SwTableBox *pBox = rBoxes[i]; long nRowSpan = pBox->getRowSpan(); if( nRowSpan != 1 ) { diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 96351fb..641c000 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -1577,11 +1577,11 @@ SwUndoTblNdsChg::SwUndoTblNdsChg( SwUndoId nAction, void SwUndoTblNdsChg::ReNewBoxes( const SwSelBoxes& rBoxes ) { - if( rBoxes.size() != aBoxes.size() ) + if( rBoxes.Count() != aBoxes.size() ) { aBoxes.clear(); - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) - aBoxes.insert( it->second->GetSttIdx() ); + for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) + aBoxes.insert( rBoxes[n]->GetSttIdx() ); } } @@ -1654,7 +1654,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.size() == rTblBoxes.Count(), + OSL_ENSURE( rTbl.IsNewModel() || rOld.Count() + nCount * rBoxes.Count() == rTblBoxes.Count(), "unexpected boxes" ); OSL_ENSURE( rOld.Count() <= rTblBoxes.Count(), "more unexpected boxes" ); for( sal_uInt16 n = 0, i = 0; i < rTblBoxes.Count(); ++i ) @@ -1679,9 +1679,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( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) + for( sal_uInt16 j = 0; j < rBoxes.Count(); ++j ) { - pCheckBox = it->second; + pCheckBox = rBoxes[j]; if( pCheckBox->GetUpper()->GetUpper() == pBox->GetUpper()->GetUpper() ) { const SwTableLine* pCheckLine = pCheckBox->GetUpper(); @@ -1702,12 +1702,8 @@ 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; - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) - { - if( it->second == pSourceBox ) - break; + while( rBoxes[ nNdsPos ] != pSourceBox ) ++nNdsPos; - } sal_uLong nNodes = rNodeCnts[ nNdsPos ]; // When a new table cell is created, it either gets a new @@ -1875,7 +1871,7 @@ void SwUndoTblNdsChg::RedoImpl(::sw::UndoRedoContext & rContext) for( std::set::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 @@ -2035,7 +2031,7 @@ CHECKTABLE(pTblNd->GetTable()) pCpyBox->GetUpper() ); rLnBoxes.C40_INSERT( SwTableBox, pBox, rLnBoxes.Count() ); - aSelBoxes.insert( pBox ); + aSelBoxes.Insert( pBox ); } CHECKTABLE(pTblNd->GetTable()) @@ -2173,16 +2169,16 @@ void SwUndoTblMerge::MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& r void SwUndoTblMerge::SetSelBoxes( const SwSelBoxes& rBoxes ) { // die Selektion merken - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) - aBoxes.insert( it->second->GetSttIdx() ); + for( sal_uInt16 n = 0; n < rBoxes.Count(); ++n ) + aBoxes.insert( rBoxes[n]->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.empty() ) - nTblNode = rBoxes.begin()->second->GetSttNd()->FindTableNode()->GetIndex(); + if( rBoxes.Count() ) + nTblNode = rBoxes[ 0 ]->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 6aa5247..a2a3620 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -1689,12 +1689,12 @@ void SwChartDataProvider::AddRowCols( if (rTable.IsTblComplex()) return; - const sal_uInt16 nBoxes = rBoxes.size(); + const sal_uInt16 nBoxes = rBoxes.Count(); if (nBoxes < 1 || nLines < 1) return; - SwTableBox* pFirstBox = rBoxes.begin()->second; - SwTableBox* pLastBox = rBoxes.rbegin()->second; + SwTableBox* pFirstBox = *( rBoxes.GetData() + 0 ); + SwTableBox* pLastBox = *( rBoxes.GetData() + nBoxes - 1 ); if (pFirstBox && pLastBox) { diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 0078bd7..12c90c0 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1531,8 +1531,8 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt& rTableFmt, const SwTableCursor* } const SwSelBoxes& rBoxes = pTableSelection->GetBoxes(); SwTableCursor* pTableCrsr = dynamic_cast(pUnoCrsr); - for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) - pTableCrsr->InsertBox( *it->second ); + for(sal_uInt16 i = 0; i < rBoxes.Count(); i++) + pTableCrsr->InsertBox( *rBoxes.GetObject(i) ); pUnoCrsr->Add(&aCrsrDepend); SwUnoTableCrsr* pTblCrsr = dynamic_cast(pUnoCrsr); @@ -1701,7 +1701,9 @@ sal_Bool SwXTextTableCursor::mergeRange(void) throw( uno::RuntimeException ) bRet = TBLMERGE_OK == pTblCrsr->GetDoc()->MergeTbl(*pTblCrsr); if(bRet) { - pTblCrsr->DeleteAllBoxes(); + sal_uInt16 nCount = pTblCrsr->GetBoxesCount(); + while(nCount--) + pTblCrsr->DeleteBox(nCount); } } pTblCrsr->MakeBoxSels(); @@ -2378,10 +2380,7 @@ void SwXTextTable::dispose(void) throw( uno::RuntimeException ) SwTable* pTable = SwTable::FindTable( pFmt ); SwTableSortBoxes& rBoxes = pTable->GetTabSortBoxes(); SwSelBoxes aSelBoxes; - for( sal_uInt16 i = 0; i < rBoxes.Count(); ++i) - { - aSelBoxes.insert( rBoxes[i] ); - } + aSelBoxes.Insert(rBoxes.GetData(), rBoxes.Count()); pFmt->GetDoc()->DeleteRowCol(aSelBoxes); } else @@ -2949,7 +2948,8 @@ void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes(); for( sal_uInt16 n = 0; n < rTBoxes.Count(); ++n ) { - aBoxes.insert( rTBoxes[ n ] ); + SwTableBox* pBox = rTBoxes[ n ]; + aBoxes.Insert( pBox ); } UnoActionContext aContext( pFmt->GetDoc() ); pFmt->GetDoc()->SortTbl(aBoxes, aSortOpt); @@ -2976,7 +2976,8 @@ void SwXTextTable::autoFormat(const OUString& aName) throw( lang::IllegalArgumen const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes(); for( sal_uInt16 n = 0; n < rTBoxes.Count(); ++n ) { - aBoxes.insert( rTBoxes[ n ] ); + SwTableBox* pBox = rTBoxes[ n ]; + aBoxes.Insert( pBox ); } 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 dc5c8a7..5fe2355 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -805,7 +805,7 @@ sal_uLong SwWriter::Write( WriterRef& rxWriter, const String* pRealFileName ) // lasse ueber das Layout die Boxen suchen SwSelBoxes aBoxes; GetTblSel( *pShell, aBoxes ); - SwTableNode* pTblNd = const_cast( static_cast(aBoxes.begin()->second->GetSttNd()->StartOfSectionNode()) ); + SwTableNode* pTblNd = (SwTableNode*)aBoxes[0]->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 19c3abc..42beaa1 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -1495,7 +1495,7 @@ void SwFltOutDoc::NextTableRow() { // duplicate row: SwSelBoxes aSelBoxes; - aSelBoxes.insert( pTableBox ); + aSelBoxes.Insert( pTableBox ); GetDoc().InsertRow(aSelBoxes); usTableX = 0; SeekCell(++usTableY, usTableX, sal_True); @@ -1612,7 +1612,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 c6702c5..3b7ad4a 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -80,7 +80,7 @@ using namespace ::com::sun::star; -class WW8SelBoxInfo: public SwSelBoxes +class WW8SelBoxInfo: public SwSelBoxes_SAR { private: WW8SelBoxInfo(const WW8SelBoxInfo&); @@ -2748,20 +2748,18 @@ void WW8TabDesc::FinishSwTable() for (sal_uInt16 iGr = 0; iGr < pMergeGroups->Count(); ++iGr) { pActMGroup = (*pMergeGroups)[ iGr ]; - nActBoxCount = pActMGroup->size(); + nActBoxCount = pActMGroup->Count(); - if( ( 1 < nActBoxCount ) && pActMGroup && pActMGroup->begin()->second ) + if( ( 1 < nActBoxCount ) && pActMGroup && (*pActMGroup)[ 0 ] ) { - const sal_uInt16 nRowSpan = pActMGroup->size(); - sal_uInt16 n = 0; - for( SwSelBoxes::const_iterator it = pActMGroup->begin(); it != pActMGroup->end(); ++it ) + const sal_uInt16 nRowSpan = pActMGroup->Count(); + for (sal_uInt16 n = 0; n < nRowSpan; ++n) { - SwTableBox* pCurrentBox = it->second; + SwTableBox* pCurrentBox = (*pActMGroup)[n]; const long nRowSpanSet = n == 0 ? nRowSpan : ((-1) * (nRowSpan - n)); pCurrentBox->setRowSpan( nRowSpanSet ); - ++n; } } } @@ -3349,10 +3347,10 @@ SwTableBox* WW8TabDesc::UpdateTableMergeGroup( WW8_TCell& rCell, if( pTheMergeGroup ) { // aktuelle Box der Merge-Gruppe hinzufuegen - pTheMergeGroup->insert( pTheMergeGroup->end(), pActBox ); + pTheMergeGroup->Insert( pActBox, pTheMergeGroup->Count() ); // Target-Box zurueckmelden - pResult = pTheMergeGroup->begin()->second; + pResult = (*pTheMergeGroup)[ 0 ]; } } return pResult; -- 1.7.7.6