diff options
-rw-r--r-- | sw/inc/tblsel.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/doc/docsort.cxx | 38 | ||||
-rw-r--r-- | sw/source/core/doc/tblcpy.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/doc/tblrwcl.cxx | 165 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 61 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl1.cxx | 18 | ||||
-rw-r--r-- | sw/source/core/frmedt/fetab.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/frmedt/tblsel.cxx | 38 | ||||
-rw-r--r-- | sw/source/core/inc/tblrwcl.hxx | 8 | ||||
-rw-r--r-- | sw/source/ui/misc/srtdlg.cxx | 7 |
10 files changed, 191 insertions, 184 deletions
diff --git a/sw/inc/tblsel.hxx b/sw/inc/tblsel.hxx index fc2d33db4f1f..daac46b2a0a1 100644 --- a/sw/inc/tblsel.hxx +++ b/sw/inc/tblsel.hxx @@ -35,6 +35,7 @@ #include <map> #include <deque> +#include <boost/ptr_container/ptr_vector.hpp> class SwCrsrShell; class SwCursor; @@ -194,7 +195,7 @@ class _FndBox; class _FndLine; typedef std::vector<_FndBox*> _FndBoxes; -SV_DECL_PTRARR_DEL( _FndLines, _FndLine*,10 ) +typedef boost::ptr_vector<_FndLine> _FndLines; class _FndBox { diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 2a4a414163dd..1f0766756641 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -505,7 +505,7 @@ sal_Bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) pTblNd->GetTable().GetTabLines().ForEach( &_FndLineCopyCol, &aPara );; } - if(!aFndBox.GetLines().Count()) + if(aFndBox.GetLines().empty()) return sal_False; if( !IsIgnoreRedline() && GetRedlineTbl().Count() ) @@ -517,11 +517,11 @@ sal_Bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) // Uppermost selected Cell _FndLines& rLines = aFndBox.GetLines(); - while( nStart < rLines.Count() ) + while( nStart < rLines.size() ) { // Respect Split Merge nesting, // extract the upper most - SwTableLine* pLine = rLines[nStart]->GetLine(); + SwTableLine* pLine = rLines[nStart].GetLine(); while ( pLine->GetUpper() ) pLine = pLine->GetUpper()->GetUpper(); @@ -531,7 +531,7 @@ sal_Bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) break; } // Are all selected in the HeaderLine? -> no Offset - if( nStart == rLines.Count() ) + if( nStart == rLines.size() ) nStart = 0; } @@ -804,9 +804,9 @@ sal_Bool FlatFndBox::CheckLineSymmetry(const _FndBox& rBox) sal_uInt16 nBoxes(0); // Iterate over Lines - for(sal_uInt16 i=0; i < rLines.Count(); ++i) + for(sal_uInt16 i=0; i < rLines.size(); ++i) { // A List's Box - _FndLine* pLn = rLines[i]; + const _FndLine* pLn = &rLines[i]; const _FndBoxes& rBoxes = pLn->GetBoxes(); // Amount of Boxes of all Lines is uneven -> no symmetry @@ -836,10 +836,10 @@ sal_Bool FlatFndBox::CheckBoxSymmetry(const _FndLine& rLn) const _FndLines& rLines = pBox->GetLines(); // Amount of Boxes of all Lines is uneven -> no symmetry - if( i && nLines != rLines.Count() ) + if( i && nLines != rLines.size() ) return sal_False; - nLines = rLines.Count(); + nLines = rLines.size(); if( nLines && !CheckLineSymmetry( *pBox ) ) return sal_False; } @@ -853,18 +853,18 @@ sal_uInt16 FlatFndBox::GetColCount(const _FndBox& rBox) { const _FndLines& rLines = rBox.GetLines(); // Iterate over Lines - if( !rLines.Count() ) + if( rLines.empty() ) return 1; sal_uInt16 nSum = 0; - for( sal_uInt16 i=0; i < rLines.Count(); ++i ) + for( sal_uInt16 i=0; i < rLines.size(); ++i ) { // The Boxes of a Line sal_uInt16 nCount = 0; - const _FndBoxes& rBoxes = rLines[i]->GetBoxes(); + const _FndBoxes& rBoxes = rLines[i].GetBoxes(); for( sal_uInt16 j=0; j < rBoxes.size(); ++j ) // Iterate recursively over the Lines - nCount += rBoxes[j]->GetLines().Count() + nCount += rBoxes[j]->GetLines().size() ? GetColCount(*rBoxes[j]) : 1; if( nSum < nCount ) @@ -879,16 +879,16 @@ sal_uInt16 FlatFndBox::GetColCount(const _FndBox& rBox) sal_uInt16 FlatFndBox::GetRowCount(const _FndBox& rBox) { const _FndLines& rLines = rBox.GetLines(); - if( !rLines.Count() ) + if( rLines.empty() ) return 1; sal_uInt16 nLines = 0; - for(sal_uInt16 i=0; i < rLines.Count(); ++i) + for(sal_uInt16 i=0; i < rLines.size(); ++i) { // The Boxes of a Line - const _FndBoxes& rBoxes = rLines[i]->GetBoxes(); + const _FndBoxes& rBoxes = rLines[i].GetBoxes(); sal_uInt16 nLn = 1; for(sal_uInt16 j=0; j < rBoxes.size(); ++j) - if( rBoxes[j]->GetLines().Count() ) + if( rBoxes[j]->GetLines().size() ) // Iterate recursively over the Lines nLn = Max(GetRowCount(*rBoxes[j]), nLn); @@ -907,17 +907,17 @@ void FlatFndBox::FillFlat(const _FndBox& rBox, sal_Bool bLastBox) // Iterate over Lines sal_uInt16 nOldRow = nRow; - for( sal_uInt16 i=0; i < rLines.Count(); ++i ) + for( sal_uInt16 i=0; i < rLines.size(); ++i ) { // The Boxes of a Line - const _FndBoxes& rBoxes = rLines[i]->GetBoxes(); + const _FndBoxes& rBoxes = rLines[i].GetBoxes(); sal_uInt16 nOldCol = nCol; for( sal_uInt16 j = 0; j < rBoxes.size(); ++j ) { // Check the Box if it's an atomic one const _FndBox* pBox = rBoxes[ j ]; - if( !pBox->GetLines().Count() ) + if( !pBox->GetLines().size() ) { // save it sal_uInt16 nOff = nRow * nCols + nCol; diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index bd9d3eb61371..1901a10608da 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -193,17 +193,17 @@ namespace LineStructure::size_type nMinSize ) : mnStartCol(USHRT_MAX), mnAddLine(0) { - if( rFndBox.GetLines().Count() ) + if( !rFndBox.GetLines().empty() ) { bool bNoSelection = rSelBoxes.size() < 2; _FndLines &rFndLines = rFndBox.GetLines(); maCols.push_front(0); - const SwTableLine* pLine = rFndLines[0]->GetLine(); + const SwTableLine* pLine = rFndLines.front().GetLine(); sal_uInt16 nStartLn = rTable.GetTabLines().C40_GETPOS( SwTableLine, pLine ); sal_uInt16 nEndLn = nStartLn; - if( rFndLines.Count() > 1 ) + if( rFndLines.size() > 1 ) { - pLine = rFndLines[ rFndLines.Count()-1 ]->GetLine(); + pLine = rFndLines.back().GetLine(); nEndLn = rTable.GetTabLines().C40_GETPOS( SwTableLine, pLine ); } if( nStartLn < USHRT_MAX && nEndLn < USHRT_MAX ) @@ -225,7 +225,7 @@ namespace _FndLine *pInsLine = new _FndLine( pLine2, &rFndBox ); _FndBox *pFndBox = new _FndBox( pTmpBox, pInsLine ); pInsLine->GetBoxes().insert(pInsLine->GetBoxes().begin(), pFndBox); - rFndLines.C40_INSERT( _FndLine, pInsLine, rFndLines.Count() ); + rFndLines.push_back( pInsLine ); } } maLines.resize( nEndLn - nStartLn + 1 ); @@ -854,13 +854,13 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, sal_uInt16 nSttLine = GetTabLines().C40_GETPOS( SwTableLine, pSttLine ); _FndBox* pFndBox; - sal_uInt16 nFndCnt = aFndBox.GetLines().Count(); + sal_uInt16 nFndCnt = aFndBox.GetLines().size(); if( !nFndCnt ) return sal_False; // Check if we have enough space for all Lines and Boxes sal_uInt16 nTstLns = 0; - pFLine = aFndBox.GetLines()[ 0 ]; + pFLine = &aFndBox.GetLines().front(); pSttLine = pFLine->GetLine(); nSttLine = GetTabLines().C40_GETPOS( SwTableLine, pSttLine ); // Do we have as many rows, actually? @@ -925,7 +925,7 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, for( nLn = 0; nLn < nTstLns; ++nLn ) { // We have enough rows, so check the Boxes per row - pFLine = aFndBox.GetLines()[ nLn % nFndCnt ]; + pFLine = &aFndBox.GetLines()[ nLn % nFndCnt ]; SwTableLine* pLine = pFLine->GetLine(); pSttBox = pFLine->GetBoxes()[0]->GetBox(); nSttBox = pLine->GetTabBoxes().C40_GETPOS( SwTableBox, pSttBox ); @@ -958,7 +958,7 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, pFndBox = new _FndBox( pTmpBox, pInsFLine ); pInsFLine->GetBoxes().insert( pInsFLine->GetBoxes().begin() + nBx, pFndBox ); } - aFndBox.GetLines().C40_INSERT( _FndLine, pInsFLine, nLn ); + aFndBox.GetLines().insert( aFndBox.GetLines().begin() + nLn, pInsFLine ); } else if( pFLine->GetBoxes().size() == 1 ) { @@ -996,7 +996,7 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, } } - if( !aFndBox.GetLines().Count() ) + if( aFndBox.GetLines().empty() ) return sal_False; } @@ -1019,9 +1019,9 @@ sal_Bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, it->second, sal_True, pUndo ); } else - for( nLn = 0; nLn < aFndBox.GetLines().Count(); ++nLn ) + for( nLn = 0; nLn < aFndBox.GetLines().size(); ++nLn ) { - pFLine = aFndBox.GetLines()[ nLn ]; + pFLine = &aFndBox.GetLines()[ nLn ]; SwTableLine* pCpyLn = rCpyTbl.GetTabLines()[ nLn % rCpyTbl.GetTabLines().Count() ]; for( nBx = 0; nBx < pFLine->GetBoxes().size(); ++nBx ) diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index b92b0723409c..7e6b2b892584 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -60,6 +60,7 @@ #include <tblrwcl.hxx> #include <unochart.hxx> #include <boost/shared_ptr.hpp> +#include <boost/foreach.hpp> #include <switerator.hxx> using namespace com::sun::star; @@ -346,7 +347,7 @@ sal_Bool lcl_CopyCol( _FndBox* pFndBox, _CpyPara* pCpyPara ) bool bDiffCount = false; if( pBox->GetTabLines().Count() ) { - pCmpLine = pFndBox->GetLines()[ 0 ]; + pCmpLine = &pFndBox->GetLines().front(); if ( pCmpLine->GetBoxes().size() != pCmpLine->GetLine()->GetTabBoxes().Count() ) bDiffCount = true; } @@ -395,15 +396,16 @@ sal_Bool lcl_CopyCol( _FndBox* pFndBox, _CpyPara* pCpyPara ) aFindFrm.pNewFrmFmt = (SwTableBoxFmt*)pBox->GetFrmFmt(); } - if( pFndBox->GetLines().Count() ) + if( !pFndBox->GetLines().empty() ) { pBox = new SwTableBox( aFindFrm.pNewFrmFmt, - pFndBox->GetLines().Count(), pCpyPara->pInsLine ); + pFndBox->GetLines().size(), pCpyPara->pInsLine ); pCpyPara->pInsLine->GetTabBoxes().C40_INSERT( SwTableBox, pBox, pCpyPara->nInsPos++); _CpyPara aPara( *pCpyPara, pBox ); aPara.nDelBorderFlag &= 7; - pFndBox->GetLines().ForEach( &lcl_CopyRow, &aPara ); + BOOST_FOREACH( _FndLine& rFndLine, pFndBox->GetLines() ) + lcl_CopyRow( rFndLine, &aPara ); } else { @@ -450,12 +452,11 @@ sal_Bool lcl_CopyCol( _FndBox* pFndBox, _CpyPara* pCpyPara ) return sal_True; } -sal_Bool lcl_CopyRow( const _FndLine*& rpFndLine, void* pPara ) +sal_Bool lcl_CopyRow( const _FndLine& rFndLine, _CpyPara* pCpyPara ) { - _CpyPara* pCpyPara = (_CpyPara*)pPara; SwTableLine* pNewLine = new SwTableLine( - (SwTableLineFmt*)rpFndLine->GetLine()->GetFrmFmt(), - rpFndLine->GetBoxes().size(), pCpyPara->pInsBox ); + (SwTableLineFmt*)rFndLine.GetLine()->GetFrmFmt(), + rFndLine.GetBoxes().size(), pCpyPara->pInsBox ); if( pCpyPara->pInsBox ) { pCpyPara->pInsBox->GetTabLines().C40_INSERT( SwTableLine, pNewLine, pCpyPara->nInsPos++ ); @@ -467,8 +468,8 @@ sal_Bool lcl_CopyRow( const _FndLine*& rpFndLine, void* pPara ) } _CpyPara aPara( *pCpyPara, pNewLine ); - for (_FndBoxes::const_iterator it = ((_FndLine*)rpFndLine)->GetBoxes().begin(); - it != ((_FndLine*)rpFndLine)->GetBoxes().end(); ++it) + for (_FndBoxes::const_iterator it = rFndLine.GetBoxes().begin(); + it != rFndLine.GetBoxes().end(); ++it) lcl_CopyCol(*it, &aPara); pCpyPara->nDelBorderFlag &= 0xf8; @@ -484,8 +485,8 @@ void lcl_InsCol( _FndLine* pFndLn, _CpyPara& rCpyPara, sal_uInt16 nCpyCnt, !( pFBox = pFndLn->GetBoxes()[ 0 ] )->GetBox()->GetSttNd() ) { // A Box with multiple Lines, so insert into these Lines - for( sal_uInt16 n = 0; n < pFBox->GetLines().Count(); ++n ) - lcl_InsCol( pFBox->GetLines()[ n ], rCpyPara, nCpyCnt, bBehind ); + for( sal_uInt16 n = 0; n < pFBox->GetLines().size(); ++n ) + lcl_InsCol( &pFBox->GetLines()[ n ], rCpyPara, nCpyCnt, bBehind ); } else { @@ -536,7 +537,7 @@ sal_Bool SwTable::InsertCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 n _FndPara aPara( rBoxes, &aFndBox ); GetTabLines().ForEach( &_FndLineCopyCol, &aPara ); } - if( !aFndBox.GetLines().Count() ) + if( aFndBox.GetLines().empty() ) return sal_False; SetHTMLTableLayout( 0 ); // Delete HTML Layout @@ -551,8 +552,8 @@ sal_Bool SwTable::InsertCol( SwDoc* pDoc, const SwSelBoxes& rBoxes, sal_uInt16 n _CpyTabFrms aTabFrmArr; _CpyPara aCpyPara( pTblNd, nCnt, aTabFrmArr ); - for( sal_uInt16 n = 0; n < aFndBox.GetLines().Count(); ++n ) - lcl_InsCol( aFndBox.GetLines()[ n ], aCpyPara, nCnt, bBehind ); + for( sal_uInt16 n = 0; n < aFndBox.GetLines().size(); ++n ) + lcl_InsCol( &aFndBox.GetLines()[ n ], aCpyPara, nCnt, bBehind ); // clean up this Line's structure once again, generally all of them GCLines(); @@ -587,7 +588,7 @@ sal_Bool SwTable::_InsertRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, _FndPara aPara( rBoxes, &aFndBox ); GetTabLines().ForEach( &_FndLineCopyCol, &aPara ); } - if( !aFndBox.GetLines().Count() ) + if( aFndBox.GetLines().empty() ) return sal_False; SetHTMLTableLayout( 0 ); // Delete HTML Layout @@ -595,12 +596,12 @@ sal_Bool SwTable::_InsertRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, _FndBox* pFndBox = &aFndBox; { _FndLine* pFndLine; - while( 1 == pFndBox->GetLines().Count() && - 1 == ( pFndLine = pFndBox->GetLines()[ 0 ])->GetBoxes().size() ) + while( 1 == pFndBox->GetLines().size() && + 1 == ( pFndLine = &pFndBox->GetLines()[ 0 ])->GetBoxes().size() ) { // Don't go down too far! One Line with Box needs to remain! - _FndBox* pTmpBox = pFndLine->GetBoxes()[ 0 ]; - if( pTmpBox->GetLines().Count() ) + _FndBox* pTmpBox = pFndLine->GetBoxes().front(); + if( !pTmpBox->GetLines().empty() ) pFndBox = pTmpBox; else break; @@ -624,7 +625,7 @@ sal_Bool SwTable::_InsertRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, _CpyPara aCpyPara( pTblNd, 0, aTabFrmArr ); SwTableLine* pLine = pFndBox->GetLines()[ bBehind ? - pFndBox->GetLines().Count()-1 : 0 ]->GetLine(); + pFndBox->GetLines().size()-1 : 0 ].GetLine(); if( &aFndBox == pFndBox ) aCpyPara.nInsPos = GetTabLines().C40_GETPOS( SwTableLine, pLine ); else @@ -645,7 +646,8 @@ sal_Bool SwTable::_InsertRow( SwDoc* pDoc, const SwSelBoxes& rBoxes, { if( bBehind ) aCpyPara.nDelBorderFlag = 1; - pFndBox->GetLines().ForEach( &lcl_CopyRow, &aCpyPara ); + BOOST_FOREACH( _FndLine& rFndLine, pFndBox->GetLines() ) + lcl_CopyRow( rFndLine, &aCpyPara ); } // clean up this Line's structure once again, generally all of them @@ -682,7 +684,7 @@ sal_Bool _FndBoxAppendRowBox( const SwTableBox*& rpBox, void* pPara ) { _FndPara aPara( *pFndPara, pFndBox ); pFndBox->GetBox()->GetTabLines().ForEach( &_FndBoxAppendRowLine, &aPara ); - if( !pFndBox->GetLines().Count() ) + if( pFndBox->GetLines().empty() ) delete pFndBox; } else @@ -698,8 +700,7 @@ sal_Bool _FndBoxAppendRowLine( const SwTableLine*& rpLine, void* pPara ) pFndLine->GetLine()->GetTabBoxes().ForEach( &_FndBoxAppendRowBox, &aPara ); if( pFndLine->GetBoxes().size() ) { - pFndPara->pFndBox->GetLines().C40_INSERT( _FndLine, pFndLine, - pFndPara->pFndBox->GetLines().Count() ); + pFndPara->pFndBox->GetLines().push_back( pFndLine ); } else delete pFndLine; @@ -722,7 +723,7 @@ sal_Bool SwTable::AppendRow( SwDoc* pDoc, sal_uInt16 nCnt ) _FndBoxAppendRowLine( pLLine, &aPara ); } - if( !aFndBox.GetLines().Count() ) + if( aFndBox.GetLines().empty() ) return sal_False; SetHTMLTableLayout( 0 ); // Delete HTML Layout @@ -744,7 +745,8 @@ sal_Bool SwTable::AppendRow( SwDoc* pDoc, sal_uInt16 nCnt ) for( sal_uInt16 nCpyCnt = 0; nCpyCnt < nCnt; ++nCpyCnt ) { aCpyPara.nDelBorderFlag = 1; - aFndBox.GetLines().ForEach( &lcl_CopyRow, &aCpyPara ); + BOOST_FOREACH( _FndLine& rFndLine, aFndBox.GetLines() ) + lcl_CopyRow( rFndLine, &aCpyPara ); } // Clean up this Line's structure once again, generally all of them @@ -1479,7 +1481,7 @@ sal_Bool lcl_Merge_MoveBox( _FndBox* pFndBox, _InsULPara* pULPara ) { SwTableBoxes* pBoxes; - sal_uInt16 nStt = 0, nEnd = pFndBox->GetLines().Count(); + sal_uInt16 nStt = 0, nEnd = pFndBox->GetLines().size(); sal_uInt16 nInsPos = USHRT_MAX; if( !pULPara->bUL_LR ) // Left/Right { @@ -1502,10 +1504,10 @@ sal_Bool lcl_Merge_MoveBox( _FndBox* pFndBox, _InsULPara* pULPara ) } } // Upper/Lower and still deeper? - else if( pFndBox->GetLines().Count() ) + else if( !pFndBox->GetLines().empty() ) { // Only search the Line from which we need to move - nStt = pULPara->bUL ? 0 : pFndBox->GetLines().Count()-1; + nStt = pULPara->bUL ? 0 : pFndBox->GetLines().size()-1; nEnd = nStt+1; } @@ -1518,8 +1520,9 @@ sal_Bool lcl_Merge_MoveBox( _FndBox* pFndBox, _InsULPara* pULPara ) (SwTableBoxFmt*)pFndBox->GetBox()->GetFrmFmt(), 0, pULPara->pInsLine ); _InsULPara aPara( *pULPara ); aPara.pInsBox = pBox; - pFndBox->GetLines().ForEach( nStt, nEnd, - &lcl_Merge_MoveLine, &aPara ); + for ( _FndLines::const_iterator it = pFndBox->GetLines().begin() + nStt; + it != pFndBox->GetLines().begin() + nEnd; ++it ) + lcl_Merge_MoveLine(*it, &aPara ); if( pBox->GetTabLines().Count() ) { if( USHRT_MAX == nInsPos ) @@ -1533,24 +1536,23 @@ sal_Bool lcl_Merge_MoveBox( _FndBox* pFndBox, _InsULPara* pULPara ) return sal_True; } -sal_Bool lcl_Merge_MoveLine( const _FndLine*& rpFndLine, void* pPara ) +sal_Bool lcl_Merge_MoveLine( const _FndLine& rFndLine, _InsULPara* pULPara ) { - _InsULPara* pULPara = (_InsULPara*)pPara; SwTableLines* pLines; - sal_uInt16 nStt = 0, nEnd = rpFndLine->GetBoxes().size(); + sal_uInt16 nStt = 0, nEnd = rFndLine.GetBoxes().size(); sal_uInt16 nInsPos = USHRT_MAX; if( pULPara->bUL_LR ) // UpperLower ? { sal_uInt16 nPos; - SwTableLine* pFndLn = (SwTableLine*)rpFndLine->GetLine(); + SwTableLine* pFndLn = (SwTableLine*)rFndLine.GetLine(); pLines = pFndLn->GetUpper() ? &pFndLn->GetUpper()->GetTabLines() : &pULPara->pTblNd->GetTable().GetTabLines(); - SwTableBox* pLBx = rpFndLine->GetBoxes()[0]->GetBox(); - SwTableBox* pRBx = rpFndLine->GetBoxes()[ - rpFndLine->GetBoxes().size()-1]->GetBox(); + SwTableBox* pLBx = rFndLine.GetBoxes()[0]->GetBox(); + SwTableBox* pRBx = rFndLine.GetBoxes()[ + rFndLine.GetBoxes().size()-1]->GetBox(); sal_uInt16 nLeft = pFndLn->GetTabBoxes().C40_GETPOS( SwTableBox, pLBx ); sal_uInt16 nRight = pFndLn->GetTabBoxes().C40_GETPOS( SwTableBox, pRBx ); @@ -1687,16 +1689,16 @@ sal_Bool lcl_Merge_MoveLine( const _FndLine*& rpFndLine, void* pPara ) else { // Find only the Line from which we need to move - nStt = pULPara->bUL ? 0 : rpFndLine->GetBoxes().size()-1; + nStt = pULPara->bUL ? 0 : rFndLine.GetBoxes().size()-1; nEnd = nStt+1; } pLines = &pULPara->pInsBox->GetTabLines(); SwTableLine* pNewLine = new SwTableLine( - (SwTableLineFmt*)rpFndLine->GetLine()->GetFrmFmt(), 0, pULPara->pInsBox ); + (SwTableLineFmt*)rFndLine.GetLine()->GetFrmFmt(), 0, pULPara->pInsBox ); _InsULPara aPara( *pULPara ); // kopieren aPara.pInsLine = pNewLine; - _FndBoxes& rLineBoxes = ((_FndLine*)rpFndLine)->GetBoxes(); + const _FndBoxes& rLineBoxes = rFndLine.GetBoxes(); for (_FndBoxes::const_iterator it = rLineBoxes.begin() + nStt; it != rLineBoxes.begin() + nEnd; ++it) lcl_Merge_MoveBox(*it, &aPara); @@ -1727,7 +1729,7 @@ sal_Bool SwTable::OldMerge( SwDoc* pDoc, const SwSelBoxes& rBoxes, _FndPara aPara( rBoxes, &aFndBox ); GetTabLines().ForEach( &_FndLineCopyCol, &aPara ); } - if( !aFndBox.GetLines().Count() ) + if( aFndBox.GetLines().empty() ) return sal_False; // TL_CHART2: splitting/merging of a number of cells or rows will usually make @@ -1745,12 +1747,12 @@ sal_Bool SwTable::OldMerge( SwDoc* pDoc, const SwSelBoxes& rBoxes, aFndBox.DelFrms( *this ); _FndBox* pFndBox = &aFndBox; - while( 1 == pFndBox->GetLines().Count() && - 1 == pFndBox->GetLines()[0]->GetBoxes().size() ) - pFndBox = pFndBox->GetLines()[0]->GetBoxes().front(); + while( 1 == pFndBox->GetLines().size() && + 1 == pFndBox->GetLines().front().GetBoxes().size() ) + pFndBox = pFndBox->GetLines().front().GetBoxes().front(); SwTableLine* pInsLine = new SwTableLine( - (SwTableLineFmt*)pFndBox->GetLines()[0]->GetLine()->GetFrmFmt(), 0, + (SwTableLineFmt*)pFndBox->GetLines().front().GetLine()->GetFrmFmt(), 0, !pFndBox->GetUpper() ? 0 : pFndBox->GetBox() ); pInsLine->ClaimFrmFmt()->ResetFmtAttr( RES_FRM_SIZE ); @@ -1758,7 +1760,7 @@ sal_Bool SwTable::OldMerge( SwDoc* pDoc, const SwSelBoxes& rBoxes, SwTableLines* pLines = pFndBox->GetUpper() ? &pFndBox->GetBox()->GetTabLines() : &GetTabLines(); - SwTableLine* pNewLine = pFndBox->GetLines()[0]->GetLine(); + SwTableLine* pNewLine = pFndBox->GetLines().front().GetLine(); sal_uInt16 nInsPos = pLines->C40_GETPOS( SwTableLine, pNewLine ); pLines->C40_INSERT( SwTableLine, pInsLine, nInsPos ); @@ -1776,21 +1778,23 @@ sal_Bool SwTable::OldMerge( SwDoc* pDoc, const SwSelBoxes& rBoxes, _InsULPara aPara( pTblNd, sal_True, sal_True, pLeftBox, pMergeBox, pRightBox, pInsLine ); // Move the overlapping upper/lower Lines of the selected Area - _FndBoxes& rLineBoxes = pFndBox->GetLines()[0]->GetBoxes(); + _FndBoxes& rLineBoxes = pFndBox->GetLines().front().GetBoxes(); for (_FndBoxes::const_iterator it = rLineBoxes.begin(); it != rLineBoxes.end(); ++it) lcl_Merge_MoveBox(*it, &aPara); aPara.SetLower( pInsLine ); - sal_uInt16 nEnd = pFndBox->GetLines().Count()-1; - rLineBoxes = pFndBox->GetLines()[nEnd]->GetBoxes(); + sal_uInt16 nEnd = pFndBox->GetLines().size()-1; + rLineBoxes = pFndBox->GetLines()[nEnd].GetBoxes(); for (_FndBoxes::const_iterator it = rLineBoxes.begin(); it != rLineBoxes.end(); ++it) lcl_Merge_MoveBox(*it, &aPara); // Move the Boxes extending into the selected Area from left/right aPara.SetLeft( pLeftBox ); - pFndBox->GetLines().ForEach( &lcl_Merge_MoveLine, &aPara ); + BOOST_FOREACH(_FndLine& rFndLine, pFndBox->GetLines() ) + lcl_Merge_MoveLine( rFndLine, &aPara ); aPara.SetRight( pRightBox ); - pFndBox->GetLines().ForEach( &lcl_Merge_MoveLine, &aPara ); + BOOST_FOREACH(_FndLine& rFndLine, pFndBox->GetLines() ) + lcl_Merge_MoveLine( rFndLine, &aPara ); if( !pLeftBox->GetTabLines().Count() ) _DeleteBox( *this, pLeftBox, 0, sal_False, sal_False ); @@ -1850,8 +1854,8 @@ sal_uInt16 lcl_GetBoxOffset( const _FndBox& rBox ) { // Find the first Box const _FndBox* pFirstBox = &rBox; - while( pFirstBox->GetLines().Count() ) - pFirstBox = pFirstBox->GetLines()[ 0 ]->GetBoxes()[ 0 ]; + while( !pFirstBox->GetLines().empty() ) + pFirstBox = pFirstBox->GetLines().front().GetBoxes().front(); sal_uInt16 nRet = 0; // Calculate the position relative to above via the Lines @@ -1878,7 +1882,7 @@ sal_uInt16 lcl_GetLineWidth( const _FndLine& rLine ) void lcl_CalcNewWidths( const _FndLines& rFndLines, _CpyPara& rPara ) { rPara.pWidths.reset(); - sal_uInt16 nLineCount = rFndLines.Count(); + sal_uInt16 nLineCount = rFndLines.size(); if( nLineCount ) { rPara.pWidths = boost::shared_ptr< std::vector< std::vector< sal_uLong > > > @@ -1888,7 +1892,7 @@ void lcl_CalcNewWidths( const _FndLines& rFndLines, _CpyPara& rPara ) for( sal_uInt16 nLine = 0; nLine < nLineCount; ++nLine ) { std::vector< sal_uLong > &rWidth = (*rPara.pWidths.get())[ nLine ]; - const _FndLine *pFndLine = rFndLines[ nLine ]; + const _FndLine *pFndLine = &rFndLines[ nLine ]; if( pFndLine && pFndLine->GetBoxes().size() ) { const SwTableLine *pLine = pFndLine->GetLine(); @@ -1897,7 +1901,7 @@ void lcl_CalcNewWidths( const _FndLines& rFndLines, _CpyPara& rPara ) sal_uInt16 nBoxCount = pLine->GetTabBoxes().Count(); sal_uLong nPos = 0; // The first selected box... - const SwTableBox *pSel = pFndLine->GetBoxes()[0]->GetBox(); + const SwTableBox *pSel = pFndLine->GetBoxes().front()->GetBox(); sal_uInt16 nBox = 0; // Sum up the width of all boxes before the first selected box while( nBox < nBoxCount ) @@ -2009,14 +2013,15 @@ sal_Bool lcl_CopyBoxToDoc( _FndBox* pFndBox, _CpyPara* pCpyPara ) } SwTableBox* pBox; - if( pFndBox->GetLines().Count() ) + if( !pFndBox->GetLines().empty() ) { pBox = new SwTableBox( aFindFrm.pNewFrmFmt, - pFndBox->GetLines().Count(), pCpyPara->pInsLine ); + pFndBox->GetLines().size(), pCpyPara->pInsLine ); pCpyPara->pInsLine->GetTabBoxes().C40_INSERT( SwTableBox, pBox, pCpyPara->nInsPos++ ); _CpyPara aPara( *pCpyPara, pBox ); aPara.nNewSize = nSize; // get the size - pFndBox->GetLines().ForEach( &lcl_CopyLineToDoc, &aPara ); + BOOST_FOREACH(_FndLine& rFndLine, pFndBox->GetLines() ) + lcl_CopyLineToDoc( rFndLine, &aPara ); } else { @@ -2081,25 +2086,23 @@ sal_Bool lcl_CopyBoxToDoc( _FndBox* pFndBox, _CpyPara* pCpyPara ) return sal_True; } -sal_Bool lcl_CopyLineToDoc( const _FndLine*& rpFndLine, void* pPara ) +sal_Bool lcl_CopyLineToDoc( const _FndLine& rFndLine, _CpyPara* pCpyPara ) { - _CpyPara* pCpyPara = (_CpyPara*)pPara; - // Find the Frame Format in the list of all Frame Formats - _CpyTabFrm aFindFrm( (SwTableBoxFmt*)rpFndLine->GetLine()->GetFrmFmt() ); + _CpyTabFrm aFindFrm( (SwTableBoxFmt*)rFndLine.GetLine()->GetFrmFmt() ); sal_uInt16 nFndPos; if( !pCpyPara->rTabFrmArr.Seek_Entry( aFindFrm, &nFndPos )) { // It doesn't exist yet, so copy it aFindFrm.pNewFrmFmt = (SwTableBoxFmt*)pCpyPara->pDoc->MakeTableLineFmt(); - aFindFrm.pNewFrmFmt->CopyAttrs( *rpFndLine->GetLine()->GetFrmFmt() ); + aFindFrm.pNewFrmFmt->CopyAttrs( *rFndLine.GetLine()->GetFrmFmt() ); pCpyPara->rTabFrmArr.Insert( aFindFrm ); } else aFindFrm = pCpyPara->rTabFrmArr[ nFndPos ]; SwTableLine* pNewLine = new SwTableLine( (SwTableLineFmt*)aFindFrm.pNewFrmFmt, - rpFndLine->GetBoxes().size(), pCpyPara->pInsBox ); + rFndLine.GetBoxes().size(), pCpyPara->pInsBox ); if( pCpyPara->pInsBox ) { pCpyPara->pInsBox->GetTabLines().C40_INSERT( SwTableLine, pNewLine, pCpyPara->nInsPos++ ); @@ -2117,25 +2120,25 @@ sal_Bool lcl_CopyLineToDoc( const _FndLine*& rpFndLine, void* pPara ) aPara.nOldSize = 0; // will not be used aPara.nBoxIdx = 1; } - else if( rpFndLine->GetBoxes().size() == - rpFndLine->GetLine()->GetTabBoxes().Count() ) + else if( rFndLine.GetBoxes().size() == + rFndLine.GetLine()->GetTabBoxes().Count() ) { // Get the Parent's size const SwFrmFmt* pFmt; - if( rpFndLine->GetLine()->GetUpper() ) - pFmt = rpFndLine->GetLine()->GetUpper()->GetFrmFmt(); + if( rFndLine.GetLine()->GetUpper() ) + pFmt = rFndLine.GetLine()->GetUpper()->GetFrmFmt(); else pFmt = pCpyPara->pTblNd->GetTable().GetFrmFmt(); aPara.nOldSize = pFmt->GetFrmSize().GetWidth(); } else // Calculate it - for( sal_uInt16 n = 0; n < rpFndLine->GetBoxes().size(); ++n ) - aPara.nOldSize += rpFndLine->GetBoxes()[n] + for( sal_uInt16 n = 0; n < rFndLine.GetBoxes().size(); ++n ) + aPara.nOldSize += rFndLine.GetBoxes()[n] ->GetBox()->GetFrmFmt()->GetFrmSize().GetWidth(); - _FndBoxes& rBoxes = ((_FndLine*)rpFndLine)->GetBoxes(); + const _FndBoxes& rBoxes = rFndLine.GetBoxes(); for (_FndBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it) lcl_CopyBoxToDoc(*it, &aPara); if( pCpyPara->pTblNd->GetTable().IsNewModel() ) @@ -2156,7 +2159,7 @@ sal_Bool SwTable::CopyHeadlineIntoTable( SwTableNode& rTblNd ) _FndPara aPara( aSelBoxes, &aFndBox ); ((SwTableLines&)GetTabLines()).ForEach( &_FndLineCopyCol, &aPara ); } - if( !aFndBox.GetLines().Count() ) + if( aFndBox.GetLines().empty() ) return sal_False; { @@ -2172,7 +2175,8 @@ sal_Bool SwTable::CopyHeadlineIntoTable( SwTableNode& rTblNd ) // Copy if( IsNewModel() ) lcl_CalcNewWidths( aFndBox.GetLines(), aPara ); - aFndBox.GetLines().ForEach( &lcl_CopyLineToDoc, &aPara ); + BOOST_FOREACH( _FndLine& rFndLine, aFndBox.GetLines() ) + lcl_CopyLineToDoc( rFndLine, &aPara ); if( rTblNd.GetTable().IsNewModel() ) { // The copied line must not contain any row span attributes > 1 SwTableLine* pLine = rTblNd.GetTable().GetTabLines()[0]; @@ -2199,7 +2203,7 @@ sal_Bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos, _FndPara aPara( rSelBoxes, &aFndBox ); ((SwTableLines&)GetTabLines()).ForEach( &_FndLineCopyCol, &aPara ); } - if( !aFndBox.GetLines().Count() ) + if( aFndBox.GetLines().empty() ) return sal_False; // First copy the PoolTemplates for the Table, so that the Tables are @@ -2265,11 +2269,12 @@ sal_Bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos, if( IsNewModel() ) lcl_CalcNewWidths( aFndBox.GetLines(), aPara ); // Copy - aFndBox.GetLines().ForEach( &lcl_CopyLineToDoc, &aPara ); + BOOST_FOREACH( _FndLine& rFndLine, aFndBox.GetLines() ) + lcl_CopyLineToDoc( rFndLine, &aPara ); // Set the "right" margin above/below { - _FndLine* pFndLn = aFndBox.GetLines()[ 0 ]; + _FndLine* pFndLn = &aFndBox.GetLines().front(); SwTableLine* pLn = pFndLn->GetLine(); const SwTableLine* pTmp = pLn; sal_uInt16 nLnPos = GetTabLines().GetPos( pTmp ); @@ -2290,7 +2295,7 @@ sal_Bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos, } } - pFndLn = aFndBox.GetLines()[ aFndBox.GetLines().Count() -1 ]; + pFndLn = &aFndBox.GetLines().back(); pLn = pFndLn->GetLine(); pTmp = pLn; nLnPos = GetTabLines().GetPos( pTmp ); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 013ccef39137..8e33dddc391c 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -94,6 +94,7 @@ #include <rootfrm.hxx> #include <fldupde.hxx> #include <switerator.hxx> +#include <boost/foreach.hpp> #ifdef DBG_UTIL #define CHECK_TABLE(t) (t).CheckConsistency(); #else @@ -1819,7 +1820,7 @@ sal_Bool SwDoc::DeleteRow( const SwCursor& rCursor ) pTblNd->GetTable().GetTabLines().ForEach( &_FndLineCopyCol, &aPara ); } - if( !aFndBox.GetLines().Count() ) + if( !aFndBox.GetLines().size() ) return sal_False; SwEditShell* pESh = GetEditShell(); @@ -1830,17 +1831,16 @@ sal_Bool SwDoc::DeleteRow( const SwCursor& rCursor ) } _FndBox* pFndBox = &aFndBox; - while( 1 == pFndBox->GetLines().Count() && - 1 == pFndBox->GetLines()[0]->GetBoxes().size() ) + while( 1 == pFndBox->GetLines().size() && + 1 == pFndBox->GetLines().front().GetBoxes().size() ) { - _FndBox* pTmp = pFndBox->GetLines()[0]->GetBoxes()[0]; + _FndBox* pTmp = pFndBox->GetLines().front().GetBoxes()[0]; if( pTmp->GetBox()->GetSttNd() ) break; // das ist sonst zu weit pFndBox = pTmp; } - SwTableLine* pDelLine = pFndBox->GetLines()[ - pFndBox->GetLines().Count()-1 ]->GetLine(); + SwTableLine* pDelLine = pFndBox->GetLines().back().GetLine(); SwTableBox* pDelBox = pDelLine->GetTabBoxes()[ pDelLine->GetTabBoxes().Count() - 1 ]; while( !pDelBox->GetSttNd() ) @@ -1857,7 +1857,7 @@ sal_Bool SwDoc::DeleteRow( const SwCursor& rCursor ) if( !pNextBox ) // keine nachfolgende? dann die vorhergehende { - pDelLine = pFndBox->GetLines()[ 0 ]->GetLine(); + pDelLine = pFndBox->GetLines().front().GetLine(); pDelBox = pDelLine->GetTabBoxes()[ 0 ]; while( !pDelBox->GetSttNd() ) pDelBox = pDelBox->GetTabLines()[0]->GetTabBoxes()[0]; @@ -3640,13 +3640,13 @@ struct _SetAFmtTabPara // forward deklarieren damit sich die Lines und Boxen rekursiv aufrufen // koennen. sal_Bool lcl_SetAFmtBox( _FndBox* pBox, _SetAFmtTabPara *pSetPara ); -sal_Bool lcl_SetAFmtLine( const _FndLine*&, void *pPara ); +sal_Bool lcl_SetAFmtLine( const _FndLine&, _SetAFmtTabPara *pPara ); -sal_Bool lcl_SetAFmtLine( const _FndLine*& rpLine, void *pPara ) +sal_Bool lcl_SetAFmtLine( const _FndLine& rLine, _SetAFmtTabPara *pPara ) { - for (_FndBoxes::const_iterator it = ((_FndLine*&)rpLine)->GetBoxes().begin(); - it != ((_FndLine*&)rpLine)->GetBoxes().end(); ++it) - lcl_SetAFmtBox(*it, (_SetAFmtTabPara *)pPara); + for (_FndBoxes::const_iterator it = rLine.GetBoxes().begin(); + it != rLine.GetBoxes().end(); ++it) + lcl_SetAFmtBox(*it, pPara); return sal_True; } @@ -3696,7 +3696,8 @@ sal_Bool lcl_SetAFmtBox( _FndBox* pBox, _SetAFmtTabPara *pSetPara ) } } else - pBox->GetLines().ForEach( &lcl_SetAFmtLine, pSetPara ); + BOOST_FOREACH( _FndLine& rFndLine, pBox->GetLines() ) + lcl_SetAFmtLine( rFndLine, pSetPara ); if( !pBox->GetUpper()->GetUpper() ) // eine BaseLine ++pSetPara->nCurBox; @@ -3718,17 +3719,17 @@ sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt& _FndPara aPara( rBoxes, &aFndBox ); pTblNd->GetTable().GetTabLines().ForEach( &_FndLineCopyCol, &aPara ); } - if( !aFndBox.GetLines().Count() ) + if( aFndBox.GetLines().empty() ) return sal_False; pTblNd->GetTable().SetHTMLTableLayout( 0 ); _FndBox* pFndBox = &aFndBox; - while( 1 == pFndBox->GetLines().Count() && - 1 == pFndBox->GetLines()[0]->GetBoxes().size() ) - pFndBox = pFndBox->GetLines()[0]->GetBoxes()[0]; + while( 1 == pFndBox->GetLines().size() && + 1 == pFndBox->GetLines().front().GetBoxes().size() ) + pFndBox = pFndBox->GetLines().front().GetBoxes()[0]; - if( !pFndBox->GetLines().Count() ) // eine zu weit? (nur 1 sel.Box) + if( pFndBox->GetLines().empty() ) // eine zu weit? (nur 1 sel.Box) pFndBox = pFndBox->GetUpper()->GetUpper(); @@ -3746,9 +3747,9 @@ sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt& _FndLines& rFLns = pFndBox->GetLines(); _FndLine* pLine; - for( sal_uInt16 n = 0; n < rFLns.Count(); ++n ) + for( sal_uInt16 n = 0; n < rFLns.size(); ++n ) { - pLine = rFLns[n]; + pLine = &rFLns[n]; // Upper auf 0 setzen (Base-Line simulieren!) _FndBox* pSaveBox = pLine->GetUpper(); @@ -3756,7 +3757,7 @@ sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt& if( !n ) aPara.nAFmtLine = 0; - else if( n+1 == rFLns.Count() ) + else if( n+1 == rFLns.size() ) aPara.nAFmtLine = 3; else aPara.nAFmtLine = (sal_uInt8)(1 + ((n-1) & 1 )); @@ -3798,28 +3799,28 @@ sal_Bool SwDoc::GetTableAutoFmt( const SwSelBoxes& rBoxes, SwTableAutoFmt& rGet _FndPara aPara( rBoxes, &aFndBox ); pTblNd->GetTable().GetTabLines().ForEach( &_FndLineCopyCol, &aPara ); } - if( !aFndBox.GetLines().Count() ) + if( aFndBox.GetLines().empty() ) return sal_False; _FndBox* pFndBox = &aFndBox; - while( 1 == pFndBox->GetLines().Count() && - 1 == pFndBox->GetLines()[0]->GetBoxes().size() ) - pFndBox = pFndBox->GetLines()[0]->GetBoxes()[0]; + while( 1 == pFndBox->GetLines().size() && + 1 == pFndBox->GetLines().front().GetBoxes().size() ) + pFndBox = pFndBox->GetLines().front().GetBoxes()[0]; - if( !pFndBox->GetLines().Count() ) // eine zu weit? (nur 1 sel.Box) + if( pFndBox->GetLines().empty() ) // eine zu weit? (nur 1 sel.Box) pFndBox = pFndBox->GetUpper()->GetUpper(); _FndLines& rFLns = pFndBox->GetLines(); sal_uInt16 aLnArr[4]; aLnArr[0] = 0; - aLnArr[1] = 1 < rFLns.Count() ? 1 : 0; - aLnArr[2] = 2 < rFLns.Count() ? 2 : aLnArr[1]; - aLnArr[3] = rFLns.Count() - 1; + aLnArr[1] = 1 < rFLns.size() ? 1 : 0; + aLnArr[2] = 2 < rFLns.size() ? 2 : aLnArr[1]; + aLnArr[3] = rFLns.size() - 1; for( sal_uInt8 nLine = 0; nLine < 4; ++nLine ) { - _FndLine& rLine = *rFLns[ aLnArr[ nLine ] ]; + _FndLine& rLine = rFLns[ aLnArr[ nLine ] ]; sal_uInt16 aBoxArr[4]; aBoxArr[0] = 0; diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 76fc94d9d5ea..053b50310f77 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -57,6 +57,7 @@ #include "undobj.hxx" #include "switerator.hxx" #include <UndoTable.hxx> +#include <boost/foreach.hpp> using ::editeng::SvxBorderLine; using namespace ::com::sun::star; @@ -200,20 +201,21 @@ struct LinesAndTable }; -sal_Bool _FindLine( const _FndLine*& rpLine, void* pPara ); +sal_Bool _FindLine( const _FndLine& rLine, LinesAndTable* pPara ); sal_Bool _FindBox( _FndBox* pBox, LinesAndTable* pPara ) { - if ( pBox->GetLines().Count() ) + if ( !pBox->GetLines().empty() ) { pPara->bInsertLines = sal_True; - pBox->GetLines().ForEach( _FindLine, pPara ); + BOOST_FOREACH( _FndLine& rFndLine, pBox->GetLines() ) + _FindLine( rFndLine, pPara ); if ( pPara->bInsertLines ) { const SwTableLines &rLines = pBox->GetBox() ? pBox->GetBox()->GetTabLines() : pPara->rTable.GetTabLines(); - if ( pBox->GetLines().Count() == rLines.Count() ) + if ( pBox->GetLines().size() == rLines.Count() ) { for ( sal_uInt16 i = 0; i < rLines.Count(); ++i ) ::InsertLine( pPara->rLines, @@ -229,11 +231,11 @@ sal_Bool _FindBox( _FndBox* pBox, LinesAndTable* pPara ) return sal_True; } -sal_Bool _FindLine( const _FndLine*& rpLine, void* pPara ) +sal_Bool _FindLine( const _FndLine& rLine, LinesAndTable* pPara ) { - for (_FndBoxes::const_iterator it = ((_FndLine*)rpLine)->GetBoxes().begin(); - it != ((_FndLine*)rpLine)->GetBoxes().end(); ++it) - _FindBox(*it, (LinesAndTable *)pPara); + for (_FndBoxes::const_iterator it = rLine.GetBoxes().begin(); + it != rLine.GetBoxes().end(); ++it) + _FindBox(*it, pPara); return sal_True; } diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index e12408ed84fa..0f06afb152d4 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -380,7 +380,7 @@ sal_Bool SwFEShell::DeleteRow() pTblNd->GetTable().GetTabLines().ForEach( &_FndLineCopyCol, &aPara ); } - if( !aFndBox.GetLines().Count() ) + if( aFndBox.GetLines().empty() ) { EndAllActionAndCall(); return sal_False; @@ -389,17 +389,16 @@ sal_Bool SwFEShell::DeleteRow() KillPams(); _FndBox* pFndBox = &aFndBox; - while( 1 == pFndBox->GetLines().Count() && - 1 == pFndBox->GetLines()[0]->GetBoxes().size() ) + while( 1 == pFndBox->GetLines().size() && + 1 == pFndBox->GetLines().front().GetBoxes().size() ) { - _FndBox* pTmp = pFndBox->GetLines()[0]->GetBoxes()[0]; + _FndBox* pTmp = pFndBox->GetLines().front().GetBoxes()[0]; if( pTmp->GetBox()->GetSttNd() ) break; // otherwise too far pFndBox = pTmp; } - SwTableLine* pDelLine = pFndBox->GetLines()[ - pFndBox->GetLines().Count()-1 ]->GetLine(); + SwTableLine* pDelLine = pFndBox->GetLines().back().GetLine(); SwTableBox* pDelBox = pDelLine->GetTabBoxes()[ pDelLine->GetTabBoxes().Count() - 1 ]; while( !pDelBox->GetSttNd() ) @@ -416,7 +415,7 @@ sal_Bool SwFEShell::DeleteRow() if( !pNextBox ) // no next? then the previous { - pDelLine = pFndBox->GetLines()[ 0 ]->GetLine(); + pDelLine = pFndBox->GetLines().front().GetLine(); pDelBox = pDelLine->GetTabBoxes()[ 0 ]; while( !pDelBox->GetSttNd() ) pDelBox = pDelBox->GetTabLines()[0]->GetTabBoxes()[0]; diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 3aa7c43d5671..69b384bae2c4 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -57,6 +57,7 @@ #include <frmtool.hxx> #include <switerator.hxx> #include <deque> +#include <boost/foreach.hpp> // see also swtable.cxx #define COLFUZZY 20L @@ -103,8 +104,6 @@ struct _CmpLPt SV_DECL_VARARR_SORT( _MergePos, _CmpLPt, 0 ) SV_IMPL_VARARR_SORT( _MergePos, _CmpLPt ) -SV_IMPL_PTRARR( _FndLines, _FndLine* ) - struct _Sort_CellFrm { @@ -1451,23 +1450,24 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, static sal_Bool lcl_CheckCol( _FndBox* pFndBox, sal_Bool* pPara ); -static sal_Bool lcl_CheckRow( const _FndLine*& rpFndLine, void* pPara ) +static sal_Bool lcl_CheckRow( const _FndLine& rFndLine, sal_Bool* pPara ) { - for (_FndBoxes::const_iterator it = ((_FndLine*)rpFndLine)->GetBoxes().begin(); - it != ((_FndLine*)rpFndLine)->GetBoxes().end(); ++it) - lcl_CheckCol(*it, (sal_Bool*)pPara); - return *(sal_Bool*)pPara; + for (_FndBoxes::const_iterator it = rFndLine.GetBoxes().begin(); + it != rFndLine.GetBoxes().end(); ++it) + lcl_CheckCol(*it, pPara); + return *pPara; } static sal_Bool lcl_CheckCol( _FndBox* pFndBox, sal_Bool* pPara ) { if( !pFndBox->GetBox()->GetSttNd() ) { - if( pFndBox->GetLines().Count() != + if( pFndBox->GetLines().size() != pFndBox->GetBox()->GetTabLines().Count() ) *pPara = sal_False; else - pFndBox->GetLines().ForEach( &lcl_CheckRow, pPara ); + BOOST_FOREACH( _FndLine& rFndLine, pFndBox->GetLines() ) + lcl_CheckRow( rFndLine, pPara ); } // is box protected ?? else if( pFndBox->GetBox()->GetFrmFmt()->GetProtect().IsCntntProtected() ) @@ -1506,21 +1506,22 @@ sal_uInt16 CheckMergeSel( const SwSelBoxes& rBoxes ) const SwTableNode* pTblNd = aPara.rBoxes.begin()->second->GetSttNd()->FindTableNode(); ((SwTable&)pTblNd->GetTable()).GetTabLines().ForEach( &_FndLineCopyCol, &aPara ); - if( aFndBox.GetLines().Count() ) + if( !aFndBox.GetLines().empty() ) { sal_Bool bMergeSelOk = sal_True; _FndBox* pFndBox = &aFndBox; _FndLine* pFndLine = 0; - while( pFndBox && 1 == pFndBox->GetLines().Count() ) + while( pFndBox && 1 == pFndBox->GetLines().size() ) { - pFndLine = pFndBox->GetLines()[0]; + pFndLine = &pFndBox->GetLines().front(); if( 1 == pFndLine->GetBoxes().size() ) pFndBox = pFndLine->GetBoxes().front(); else pFndBox = 0; } if( pFndBox ) - pFndBox->GetLines().ForEach( &lcl_CheckRow, &bMergeSelOk ); + BOOST_FOREACH( _FndLine& rFndLine, pFndBox->GetLines() ) + lcl_CheckRow( rFndLine, &bMergeSelOk ); else if( pFndLine ) for (_FndBoxes::const_iterator it = pFndLine->GetBoxes().begin(); it != pFndLine->GetBoxes().end(); ++it) @@ -2101,7 +2102,7 @@ sal_Bool _FndBoxCopyCol( const SwTableBox*& rpBox, void* pPara ) { _FndPara aPara( *pFndPara, pFndBox ); pFndBox->GetBox()->GetTabLines().ForEach( &_FndLineCopyCol, &aPara ); - if( !pFndBox->GetLines().Count() ) + if( pFndBox->GetLines().empty() ) { delete pFndBox; return sal_True; @@ -2127,8 +2128,7 @@ sal_Bool _FndLineCopyCol( const SwTableLine*& rpLine, void* pPara ) pFndLine->GetLine()->GetTabBoxes().ForEach( &_FndBoxCopyCol, &aPara ); if( pFndLine->GetBoxes().size() ) { - pFndPara->pFndBox->GetLines().C40_INSERT( _FndLine, pFndLine, - pFndPara->pFndBox->GetLines().Count() ); + pFndPara->pFndBox->GetLines().push_back( pFndLine ); } else delete pFndLine; @@ -2176,16 +2176,16 @@ void _FndBox::SetTableLines( const SwTable &rTable ) // of the SwTable are in FndBox. In order to use 0 for 'no line' // we adjust the positions by 1. - if( !GetLines().Count() ) + if( GetLines().empty() ) return; - SwTableLine* pTmpLine = GetLines()[0]->GetLine(); + SwTableLine* pTmpLine = GetLines().front().GetLine(); sal_uInt16 nPos = rTable.GetTabLines().C40_GETPOS( SwTableLine, pTmpLine ); OSL_ENSURE( USHRT_MAX != nPos, "Line steht nicht in der Tabelle" ); if( nPos ) pLineBefore = rTable.GetTabLines()[ nPos - 1 ]; - pTmpLine = GetLines()[GetLines().Count()-1]->GetLine(); + pTmpLine = GetLines().back().GetLine(); nPos = rTable.GetTabLines().C40_GETPOS( SwTableLine, pTmpLine ); OSL_ENSURE( USHRT_MAX != nPos, "Line steht nicht in der Tabelle" ); if( ++nPos < rTable.GetTabLines().Count() ) diff --git a/sw/source/core/inc/tblrwcl.hxx b/sw/source/core/inc/tblrwcl.hxx index 746fd49467b5..93b0d143fb76 100644 --- a/sw/source/core/inc/tblrwcl.hxx +++ b/sw/source/core/inc/tblrwcl.hxx @@ -47,19 +47,21 @@ class SwCntntNode; class SfxPoolItem; class SwShareBoxFmts; class SwFmtFrmSize; +class _CpyPara; +class _InsULPara; // Funktions Deklarationen: -sal_Bool lcl_CopyRow( const _FndLine*& rpFndLine, void* pPara ); +sal_Bool lcl_CopyRow( const _FndLine& rFndLine, _CpyPara* pCpyPara ); sal_Bool lcl_CopyCol( const _FndBox*& rpFndBox, void* pPara ); sal_Bool lcl_MergeGCBox( const SwTableBox*& rpBox, void* pPara ); sal_Bool lcl_MergeGCLine( const SwTableLine*& rpLine, void* pPara ); sal_Bool lcl_Merge_MoveBox( const _FndBox*& rpFndBox, void* pPara ); -sal_Bool lcl_Merge_MoveLine( const _FndLine*& rpFndLine, void* pPara ); +sal_Bool lcl_Merge_MoveLine( const _FndLine& rFndLine, _InsULPara* pULPara ); sal_Bool lcl_CopyBoxToDoc( const _FndBox*& rpFndBox, void* pPara ); -sal_Bool lcl_CopyLineToDoc( const _FndLine*& rpFndLn, void* pPara ); +sal_Bool lcl_CopyLineToDoc( const _FndLine& rpFndLn, _CpyPara* pPara ); sal_Bool lcl_BoxSetHeadCondColl( const SwTableBox*& rpBox, void* pPara ); sal_Bool lcl_LineSetHeadCondColl( const SwTableLine*& rpLine, void* pPara ); diff --git a/sw/source/ui/misc/srtdlg.cxx b/sw/source/ui/misc/srtdlg.cxx index c0615119e012..a1ef0698edff 100644 --- a/sw/source/ui/misc/srtdlg.cxx +++ b/sw/source/ui/misc/srtdlg.cxx @@ -53,9 +53,6 @@ #include <tblsel.hxx> #include <sfx2/request.hxx> -// sw/inc/tblsel.hxx -SV_IMPL_PTRARR( _FndLines, _FndLine* ) - static sal_Bool bCheck1 = sal_True; static sal_Bool bCheck2 = sal_False; static sal_Bool bCheck3 = sal_False; @@ -111,11 +108,11 @@ sal_Bool lcl_GetSelTbl( SwWrtShell &rSh, sal_uInt16& rX, sal_uInt16& rY ) const SwTable& rTbl = pTblNd->GetTable(); ((SwTableLines&)rTbl.GetTabLines()).ForEach( &_FndLineCopyCol, &aPara ); } - rX = aFndBox.GetLines().Count(); + rX = aFndBox.GetLines().size(); if( !rX ) return sal_False; - rY = aFndBox.GetLines()[0]->GetBoxes().size(); + rY = aFndBox.GetLines().front().GetBoxes().size(); return sal_True; } |