Kaydet (Commit) eb834824 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Michael Stahl

Convert SV_DECL_PTRARR_DEL(SwXMLTableRows_Impl) to boost::ptr_vector

üst 9cfab5c6
...@@ -1270,14 +1270,12 @@ public: ...@@ -1270,14 +1270,12 @@ public:
typedef SwXMLTableRow_Impl* SwXMLTableRowPtr; typedef boost::ptr_vector<SwXMLTableRow_Impl> SwXMLTableRows_Impl;
SV_DECL_PTRARR_DEL(SwXMLTableRows_Impl,SwXMLTableRowPtr,5)
SV_IMPL_PTRARR(SwXMLTableRows_Impl,SwXMLTableRowPtr)
SwXMLTableCell_Impl *SwXMLTableContext::GetCell( sal_uInt32 nRow, SwXMLTableCell_Impl *SwXMLTableContext::GetCell( sal_uInt32 nRow,
sal_uInt32 nCol ) const sal_uInt32 nCol ) const
{ {
return (*pRows)[(sal_uInt16)nRow]->GetCell( (sal_uInt16)nCol ); return (*pRows)[(sal_uInt16)nRow].GetCell( (sal_uInt16)nCol );
} }
TYPEINIT1( SwXMLTableContext, XMLTextTableContext ); TYPEINIT1( SwXMLTableContext, XMLTextTableContext );
...@@ -1612,7 +1610,7 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName, ...@@ -1612,7 +1610,7 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName,
// into the current row. // into the current row.
if( nCurRow > 0UL && nColSpan > 1UL ) if( nCurRow > 0UL && nColSpan > 1UL )
{ {
SwXMLTableRow_Impl *pCurRow = (*pRows)[(sal_uInt16)nCurRow]; SwXMLTableRow_Impl *pCurRow = &(*pRows)[(sal_uInt16)nCurRow];
sal_uInt32 nLastCol = GetColumnCount() < nColsReq ? GetColumnCount() sal_uInt32 nLastCol = GetColumnCount() < nColsReq ? GetColumnCount()
: nColsReq; : nColsReq;
for( i=nCurCol+1UL; i<nLastCol; i++ ) for( i=nCurCol+1UL; i<nLastCol; i++ )
...@@ -1643,23 +1641,22 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName, ...@@ -1643,23 +1641,22 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName,
aColumnWidths.push_back( ColumnWidthInfo(MINLAY, sal_True) ); aColumnWidths.push_back( ColumnWidthInfo(MINLAY, sal_True) );
} }
// adjust columns in *all* rows, if columns must be inserted // adjust columns in *all* rows, if columns must be inserted
for( i=0; i<pRows->Count(); i++ ) for( i=0; i<pRows->size(); i++ )
(*pRows)[(sal_uInt16)i]->Expand( nColsReq, i<nCurRow ); (*pRows)[(sal_uInt16)i].Expand( nColsReq, i<nCurRow );
} }
// Add rows // Add rows
if( pRows->Count() < nRowsReq ) if( pRows->size() < nRowsReq )
{ {
OUString aStyleName2; OUString aStyleName2;
for( i = pRows->Count(); i < nRowsReq; ++i ) for( i = pRows->size(); i < nRowsReq; ++i )
pRows->Insert( new SwXMLTableRow_Impl(aStyleName2, GetColumnCount()), pRows->push_back( new SwXMLTableRow_Impl(aStyleName2, GetColumnCount()) );
pRows->Count() );
} }
OUString sStyleName( rStyleName ); OUString sStyleName( rStyleName );
if( sStyleName.isEmpty() ) if( sStyleName.isEmpty() )
{ {
sStyleName = ((*pRows)[(sal_uInt16)nCurRow])->GetDefaultCellStyleName(); sStyleName = (*pRows)[(sal_uInt16)nCurRow].GetDefaultCellStyleName();
if( sStyleName.isEmpty() && HasColumnDefaultCellStyleNames() ) if( sStyleName.isEmpty() && HasColumnDefaultCellStyleNames() )
{ {
sStyleName = GetColumnDefaultCellStyleName( nCurCol ); sStyleName = GetColumnDefaultCellStyleName( nCurCol );
...@@ -1701,19 +1698,18 @@ void SwXMLTableContext::InsertRow( const OUString& rStyleName, ...@@ -1701,19 +1698,18 @@ void SwXMLTableContext::InsertRow( const OUString& rStyleName,
if( 0==nCurRow && 0UL == GetColumnCount() ) if( 0==nCurRow && 0UL == GetColumnCount() )
InsertColumn( USHRT_MAX, sal_True ); InsertColumn( USHRT_MAX, sal_True );
if( nCurRow < pRows->Count() ) if( nCurRow < pRows->size() )
{ {
// The current row has already been inserted because of a row span // The current row has already been inserted because of a row span
// of a previous row. // of a previous row.
(*pRows)[(sal_uInt16)nCurRow]->Set( (*pRows)[(sal_uInt16)nCurRow].Set(
rStyleName, rDfltCellStyleName, i_rXmlId ); rStyleName, rDfltCellStyleName, i_rXmlId );
} }
else else
{ {
// add a new row // add a new row
pRows->Insert( new SwXMLTableRow_Impl( rStyleName, GetColumnCount(), pRows->push_back( new SwXMLTableRow_Impl( rStyleName, GetColumnCount(),
&rDfltCellStyleName, i_rXmlId ), &rDfltCellStyleName, i_rXmlId ) );
pRows->Count() );
} }
// We start at the first column ... // We start at the first column ...
...@@ -1729,7 +1725,7 @@ void SwXMLTableContext::InsertRow( const OUString& rStyleName, ...@@ -1729,7 +1725,7 @@ void SwXMLTableContext::InsertRow( const OUString& rStyleName,
void SwXMLTableContext::InsertRepRows( sal_uInt32 nCount ) void SwXMLTableContext::InsertRepRows( sal_uInt32 nCount )
{ {
const SwXMLTableRow_Impl *pSrcRow = (*pRows)[(sal_uInt16)nCurRow-1]; const SwXMLTableRow_Impl *pSrcRow = &(*pRows)[(sal_uInt16)nCurRow-1];
while( nCount > 1 && IsInsertRowPossible() ) while( nCount > 1 && IsInsertRowPossible() )
{ {
InsertRow( pSrcRow->GetStyleName(), pSrcRow->GetDefaultCellStyleName(), InsertRow( pSrcRow->GetStyleName(), pSrcRow->GetDefaultCellStyleName(),
...@@ -1776,7 +1772,7 @@ const SwStartNode *SwXMLTableContext::GetPrevStartNode( sal_uInt32 nRow, ...@@ -1776,7 +1772,7 @@ const SwStartNode *SwXMLTableContext::GetPrevStartNode( sal_uInt32 nRow,
if( GetColumnCount() == nCol ) if( GetColumnCount() == nCol )
{ {
// The last cell is the right one here. // The last cell is the right one here.
pPrevCell = GetCell( pRows->Count()-1U, GetColumnCount()-1UL ); pPrevCell = GetCell( pRows->size()-1U, GetColumnCount()-1UL );
} }
else if( 0UL == nRow ) else if( 0UL == nRow )
{ {
...@@ -1789,7 +1785,7 @@ const SwStartNode *SwXMLTableContext::GetPrevStartNode( sal_uInt32 nRow, ...@@ -1789,7 +1785,7 @@ const SwStartNode *SwXMLTableContext::GetPrevStartNode( sal_uInt32 nRow,
{ {
// If there is a previous cell in the current row that is not spanned // If there is a previous cell in the current row that is not spanned
// from the previous row, its the right one. // from the previous row, its the right one.
const SwXMLTableRow_Impl *pPrevRow = (*pRows)[(sal_uInt16)nRow-1U]; const SwXMLTableRow_Impl *pPrevRow = &(*pRows)[(sal_uInt16)nRow-1U];
sal_uInt32 i = nCol; sal_uInt32 i = nCol;
while( !pPrevCell && i > 0UL ) while( !pPrevCell && i > 0UL )
{ {
...@@ -1848,7 +1844,7 @@ void SwXMLTableContext::ReplaceWithEmptyCell( sal_uInt32 nRow, sal_uInt32 nCol, ...@@ -1848,7 +1844,7 @@ void SwXMLTableContext::ReplaceWithEmptyCell( sal_uInt32 nRow, sal_uInt32 nCol,
for( sal_uInt32 i=nRow; i<nLastRow; i++ ) for( sal_uInt32 i=nRow; i<nLastRow; i++ )
{ {
SwXMLTableRow_Impl *pRow = (*pRows)[(sal_uInt16)i]; SwXMLTableRow_Impl *pRow = &(*pRows)[(sal_uInt16)i];
for( sal_uInt32 j=nCol; j<nLastCol; j++ ) for( sal_uInt32 j=nCol; j<nLastCol; j++ )
pRow->GetCell( j )->SetStartNode( pSttNd ); pRow->GetCell( j )->SetStartNode( pSttNd );
} }
...@@ -1967,7 +1963,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper, ...@@ -1967,7 +1963,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper,
{ {
// Could the table be splitted behind the current row? // Could the table be splitted behind the current row?
sal_Bool bSplit = sal_True; sal_Bool bSplit = sal_True;
SwXMLTableRow_Impl *pRow = (*pRows)[(sal_uInt16)i]; SwXMLTableRow_Impl *pRow = &(*pRows)[(sal_uInt16)i];
for( sal_uInt32 j=nLeftCol; j<nRightCol; j++ ) for( sal_uInt32 j=nLeftCol; j<nRightCol; j++ )
{ {
bSplit = ( 1UL == pRow->GetCell(j)->GetRowSpan() ); bSplit = ( 1UL == pRow->GetCell(j)->GetRowSpan() );
...@@ -1995,7 +1991,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper, ...@@ -1995,7 +1991,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper,
while( nStartRow < nBottomRow ) while( nStartRow < nBottomRow )
{ {
sal_uInt32 nMaxRowSpan = 0UL; sal_uInt32 nMaxRowSpan = 0UL;
SwXMLTableRow_Impl *pStartRow = (*pRows)[(sal_uInt16)nStartRow]; SwXMLTableRow_Impl *pStartRow = &(*pRows)[(sal_uInt16)nStartRow];
SwXMLTableCell_Impl *pCell; SwXMLTableCell_Impl *pCell;
for( i=nLeftCol; i<nRightCol; i++ ) for( i=nLeftCol; i<nRightCol; i++ )
if( ( pCell=pStartRow->GetCell(i), if( ( pCell=pStartRow->GetCell(i),
...@@ -2006,7 +2002,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper, ...@@ -2006,7 +2002,7 @@ SwTableBox *SwXMLTableContext::MakeTableBox( SwTableLine *pUpper,
if( nStartRow<nBottomRow ) if( nStartRow<nBottomRow )
{ {
SwXMLTableRow_Impl *pPrevRow = SwXMLTableRow_Impl *pPrevRow =
(*pRows)[(sal_uInt16)nStartRow-1U]; &(*pRows)[(sal_uInt16)nStartRow-1U];
i = nLeftCol; i = nLeftCol;
while( i < nRightCol ) while( i < nRightCol )
{ {
...@@ -2218,7 +2214,7 @@ SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper, ...@@ -2218,7 +2214,7 @@ SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper,
pFrmFmt->SetFmtAttr( aFillOrder ); pFrmFmt->SetFmtAttr( aFillOrder );
const SfxItemSet *pAutoItemSet = 0; const SfxItemSet *pAutoItemSet = 0;
const OUString& rStyleName = (*pRows)[(sal_uInt16)nTopRow]->GetStyleName(); const OUString& rStyleName = (*pRows)[(sal_uInt16)nTopRow].GetStyleName();
if( 1UL == (nBottomRow - nTopRow) && if( 1UL == (nBottomRow - nTopRow) &&
!rStyleName.isEmpty() && !rStyleName.isEmpty() &&
GetSwImport().FindAutomaticStyle( GetSwImport().FindAutomaticStyle(
...@@ -2234,7 +2230,7 @@ SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper, ...@@ -2234,7 +2230,7 @@ SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper,
while( nStartCol < nRightCol ) while( nStartCol < nRightCol )
{ {
for( sal_uInt32 nRow=nTopRow; nRow<nBottomRow; nRow++ ) for( sal_uInt32 nRow=nTopRow; nRow<nBottomRow; nRow++ )
(*pRows)[(sal_uInt16)nRow]->SetSplitable( sal_True ); (*pRows)[(sal_uInt16)nRow].SetSplitable( sal_True );
sal_uInt32 nCol = nStartCol; sal_uInt32 nCol = nStartCol;
sal_uInt32 nSplitCol = nRightCol; sal_uInt32 nSplitCol = nRightCol;
...@@ -2259,10 +2255,10 @@ SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper, ...@@ -2259,10 +2255,10 @@ SwTableLine *SwXMLTableContext::MakeTableLine( SwTableBox *pUpper,
SwXMLTableCell_Impl *pCell = GetCell(nRow,nCol); SwXMLTableCell_Impl *pCell = GetCell(nRow,nCol);
// Could the table fragment be splitted horizontally behind // Could the table fragment be splitted horizontally behind
// the current line? // the current line?
sal_Bool bHoriSplit = (*pRows)[(sal_uInt16)nRow]->IsSplitable() && sal_Bool bHoriSplit = (*pRows)[(sal_uInt16)nRow].IsSplitable() &&
nRow+1UL < nBottomRow && nRow+1UL < nBottomRow &&
1UL == pCell->GetRowSpan(); 1UL == pCell->GetRowSpan();
(*pRows)[(sal_uInt16)nRow]->SetSplitable( bHoriSplit ); (*pRows)[(sal_uInt16)nRow].SetSplitable( bHoriSplit );
// Could the table fragment be splitted vertically behind the // Could the table fragment be splitted vertically behind the
// current column (uptp the current line? // current column (uptp the current line?
...@@ -2404,9 +2400,9 @@ void SwXMLTableContext::_MakeTable( SwTableBox *pBox ) ...@@ -2404,9 +2400,9 @@ void SwXMLTableContext::_MakeTable( SwTableBox *pBox )
// If there are empty rows (because of some row span of previous rows) // If there are empty rows (because of some row span of previous rows)
// the have to be deleted. The previous rows have to be truncated. // the have to be deleted. The previous rows have to be truncated.
if( pRows->Count() > nCurRow ) if( pRows->size() > nCurRow )
{ {
SwXMLTableRow_Impl *pPrevRow = (*pRows)[(sal_uInt16)nCurRow-1U]; SwXMLTableRow_Impl *pPrevRow = &(*pRows)[(sal_uInt16)nCurRow-1U];
SwXMLTableCell_Impl *pCell; SwXMLTableCell_Impl *pCell;
for( sal_uLong i = 0; i < aColumnWidths.size(); ++i ) for( sal_uLong i = 0; i < aColumnWidths.size(); ++i )
{ {
...@@ -2415,11 +2411,11 @@ void SwXMLTableContext::_MakeTable( SwTableBox *pBox ) ...@@ -2415,11 +2411,11 @@ void SwXMLTableContext::_MakeTable( SwTableBox *pBox )
FixRowSpan( nCurRow-1UL, i, 1UL ); FixRowSpan( nCurRow-1UL, i, 1UL );
} }
} }
for( sal_uLong i = pRows->Count()-1UL; i>=nCurRow; --i ) for( sal_uLong i = pRows->size()-1UL; i>=nCurRow; --i )
pRows->DeleteAndDestroy( (sal_uInt16)i ); pRows->pop_back();
} }
if( 0UL == pRows->Count() ) if( pRows->empty() )
{ {
OUString aStyleName2; OUString aStyleName2;
InsertCell( aStyleName2, 1U, nCols, InsertTableSection() ); InsertCell( aStyleName2, 1U, nCols, InsertTableSection() );
...@@ -2626,14 +2622,14 @@ void SwXMLTableContext::_MakeTable( SwTableBox *pBox ) ...@@ -2626,14 +2622,14 @@ void SwXMLTableContext::_MakeTable( SwTableBox *pBox )
: pTableNode->GetTable().GetTabLines(); : pTableNode->GetTable().GetTabLines();
sal_uInt32 nStartRow = 0UL; sal_uInt32 nStartRow = 0UL;
sal_uInt32 nRows = pRows->Count(); sal_uInt32 nRows = pRows->size();
for(sal_uInt32 i=0UL; i<nRows; ++i ) for(sal_uInt32 i=0UL; i<nRows; ++i )
{ {
// Could we split the table behind the current line? // Could we split the table behind the current line?
sal_Bool bSplit = sal_True; sal_Bool bSplit = sal_True;
if ( bHasSubTables ) if ( bHasSubTables )
{ {
SwXMLTableRow_Impl *pRow = (*pRows)[(sal_uInt16)i]; SwXMLTableRow_Impl *pRow = &(*pRows)[(sal_uInt16)i];
for( sal_uInt32 j=0UL; j<nCols; j++ ) for( sal_uInt32 j=0UL; j<nCols; j++ )
{ {
bSplit = ( 1UL == pRow->GetCell(j)->GetRowSpan() ); bSplit = ( 1UL == pRow->GetCell(j)->GetRowSpan() );
...@@ -2661,7 +2657,7 @@ void SwXMLTableContext::MakeTable() ...@@ -2661,7 +2657,7 @@ void SwXMLTableContext::MakeTable()
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
// #i97274# handle invalid tables // #i97274# handle invalid tables
if (!pRows || !pRows->Count() || !GetColumnCount()) if (!pRows || pRows->empty() || !GetColumnCount())
{ {
OSL_FAIL("invalid table: no cells; deleting..."); OSL_FAIL("invalid table: no cells; deleting...");
pTableNode->GetDoc()->DeleteSection( pTableNode ); pTableNode->GetDoc()->DeleteSection( pTableNode );
...@@ -2804,8 +2800,8 @@ void SwXMLTableContext::MakeTable() ...@@ -2804,8 +2800,8 @@ void SwXMLTableContext::MakeTable()
pFrmFmt->UnlockModify(); pFrmFmt->UnlockModify();
for( sal_uInt16 i=0; i<pRows->Count(); i++ ) for( sal_uInt16 i=0; i<pRows->size(); i++ )
(*pRows)[i]->Dispose(); (*pRows)[i].Dispose();
// now that table is complete, change into DDE table (if appropriate) // now that table is complete, change into DDE table (if appropriate)
if (NULL != pDDESource) if (NULL != pDDESource)
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
// STL include // STL include
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <vector> #include <vector>
#include <svl/svstdarr.hxx> #include <svl/svstdarr.hxx>
...@@ -44,7 +45,8 @@ class SwStartNode; ...@@ -44,7 +45,8 @@ class SwStartNode;
class SwTableBoxFmt; class SwTableBoxFmt;
class SwTableLineFmt; class SwTableLineFmt;
class SwXMLTableCell_Impl; class SwXMLTableCell_Impl;
class SwXMLTableRows_Impl; class SwXMLTableRow_Impl;
typedef boost::ptr_vector<SwXMLTableRow_Impl> SwXMLTableRows_Impl;
class SwXMLDDETableContext_Impl; class SwXMLDDETableContext_Impl;
class TableBoxIndexHasher; class TableBoxIndexHasher;
class TableBoxIndex; class TableBoxIndex;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment