diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-06 12:58:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-06 14:20:20 +0200 |
commit | 8f719de217b1079bd985b3bc63bbfa97069483bc (patch) | |
tree | cb15a422b7df468d913cb0815d628f7c0bc4fd9b /svx/source/table/tablemodel.cxx | |
parent | bfc298d02ca6275588d5897d97ced9498a3e91aa (diff) |
loplugin:flatten in svx
Change-Id: I31f33a5f693d5fdb8282181c5bd7f31971efe784
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100236
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/table/tablemodel.cxx')
-rw-r--r-- | svx/source/table/tablemodel.cxx | 526 |
1 files changed, 263 insertions, 263 deletions
diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx index 464f862c0947..f121f1ee9ee2 100644 --- a/svx/source/table/tablemodel.cxx +++ b/svx/source/table/tablemodel.cxx @@ -115,30 +115,30 @@ TableModel::TableModel( SdrTableObj* pTableObj, const TableModelRef& xSourceTabl , mbNotifyPending( false ) , mnNotifyLock( 0 ) { - if( xSourceTable.is() ) - { - const sal_Int32 nColCount = xSourceTable->getColumnCountImpl(); - const sal_Int32 nRowCount = xSourceTable->getRowCountImpl(); + if( !xSourceTable.is() ) + return; - init( nColCount, nRowCount ); + const sal_Int32 nColCount = xSourceTable->getColumnCountImpl(); + const sal_Int32 nRowCount = xSourceTable->getRowCountImpl(); - sal_Int32 nRows = nRowCount; - while( nRows-- ) - (*maRows[nRows]) = *xSourceTable->maRows[nRows]; + init( nColCount, nRowCount ); - sal_Int32 nColumns = nColCount; - while( nColumns-- ) - (*maColumns[nColumns]) = *xSourceTable->maColumns[nColumns]; + sal_Int32 nRows = nRowCount; + while( nRows-- ) + (*maRows[nRows]) = *xSourceTable->maRows[nRows]; - // copy cells - for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) + sal_Int32 nColumns = nColCount; + while( nColumns-- ) + (*maColumns[nColumns]) = *xSourceTable->maColumns[nColumns]; + + // copy cells + for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) + { + for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) { - for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) - { - CellRef xTargetCell( getCell( nCol, nRow ) ); - if( xTargetCell.is() ) - xTargetCell->cloneFrom( xSourceTable->getCell( nCol, nRow ) ); - } + CellRef xTargetCell( getCell( nCol, nRow ) ); + if( xTargetCell.is() ) + xTargetCell->cloneFrom( xSourceTable->getCell( nCol, nRow ) ); } } } @@ -594,79 +594,79 @@ CellRef TableModel::createCell() void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount ) { - if( nCount && mpTableObj ) - { - try - { - SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); - TableModelNotifyGuard aGuard( this ); - nIndex = insert_range<ColumnVector,ColumnVector::iterator,TableColumnRef>( maColumns, nIndex, nCount ); + if( !(nCount && mpTableObj) ) + return; - sal_Int32 nRows = getRowCountImpl(); - while( nRows-- ) - maRows[nRows]->insertColumns( nIndex, nCount, nullptr ); + try + { + SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); + TableModelNotifyGuard aGuard( this ); + nIndex = insert_range<ColumnVector,ColumnVector::iterator,TableColumnRef>( maColumns, nIndex, nCount ); - ColumnVector aNewColumns(nCount); - for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) - { - TableColumnRef xNewCol( new TableColumn( this, nIndex+nOffset ) ); - maColumns[nIndex+nOffset] = xNewCol; - aNewColumns[nOffset] = xNewCol; - } + sal_Int32 nRows = getRowCountImpl(); + while( nRows-- ) + maRows[nRows]->insertColumns( nIndex, nCount, nullptr ); - const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); + ColumnVector aNewColumns(nCount); + for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) + { + TableColumnRef xNewCol( new TableColumn( this, nIndex+nOffset ) ); + maColumns[nIndex+nOffset] = xNewCol; + aNewColumns[nOffset] = xNewCol; + } - if( bUndo ) - { - rModel.BegUndo( SvxResId(STR_TABLE_INSCOL) ); - rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); + const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); - TableModelRef xThis( this ); + if( bUndo ) + { + rModel.BegUndo( SvxResId(STR_TABLE_INSCOL) ); + rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); - nRows = getRowCountImpl(); - CellVector aNewCells( nCount * nRows ); - CellVector::iterator aCellIter( aNewCells.begin() ); + TableModelRef xThis( this ); - nRows = getRowCountImpl(); - for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) - { - for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) - (*aCellIter++) = getCell( nIndex + nOffset, nRow ); - } + nRows = getRowCountImpl(); + CellVector aNewCells( nCount * nRows ); + CellVector::iterator aCellIter( aNewCells.begin() ); - rModel.AddUndo( std::make_unique<InsertColUndo>( xThis, nIndex, aNewColumns, aNewCells ) ); + nRows = getRowCountImpl(); + for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) + { + for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) + (*aCellIter++) = getCell( nIndex + nOffset, nRow ); } - const sal_Int32 nRowCount = getRowCountImpl(); - // check if cells merge over new columns - for( sal_Int32 nCol = 0; nCol < nIndex; ++nCol ) + rModel.AddUndo( std::make_unique<InsertColUndo>( xThis, nIndex, aNewColumns, aNewCells ) ); + } + + const sal_Int32 nRowCount = getRowCountImpl(); + // check if cells merge over new columns + for( sal_Int32 nCol = 0; nCol < nIndex; ++nCol ) + { + for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) { - for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) + CellRef xCell( getCell( nCol, nRow ) ); + sal_Int32 nColSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getColumnSpan() : 1; + if( (nColSpan != 1) && ((nColSpan + nCol ) > nIndex) ) { - CellRef xCell( getCell( nCol, nRow ) ); - sal_Int32 nColSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getColumnSpan() : 1; - if( (nColSpan != 1) && ((nColSpan + nCol ) > nIndex) ) - { - // cell merges over newly created columns, so add the new columns to the merged cell - const sal_Int32 nRowSpan = xCell->getRowSpan(); - nColSpan += nCount; - merge( nCol, nRow, nColSpan, nRowSpan ); - } + // cell merges over newly created columns, so add the new columns to the merged cell + const sal_Int32 nRowSpan = xCell->getRowSpan(); + nColSpan += nCount; + merge( nCol, nRow, nColSpan, nRowSpan ); } } + } - if( bUndo ) - rModel.EndUndo(); + if( bUndo ) + rModel.EndUndo(); - rModel.SetChanged(); - } - catch( Exception& ) - { - OSL_FAIL("sdr::table::TableModel::insertColumns(), exception caught!"); - } - updateColumns(); - setModified(true); + rModel.SetChanged(); + } + catch( Exception& ) + { + OSL_FAIL("sdr::table::TableModel::insertColumns(), exception caught!"); } + updateColumns(); + setModified(true); } @@ -674,168 +674,168 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount ) { sal_Int32 nColCount = getColumnCountImpl(); - if( mpTableObj && nCount && (nIndex >= 0) && (nIndex < nColCount) ) + if( !(mpTableObj && nCount && (nIndex >= 0) && (nIndex < nColCount)) ) + return; + + try { - try - { - TableModelNotifyGuard aGuard( this ); + TableModelNotifyGuard aGuard( this ); - // clip removed columns to columns actually available - if( (nIndex + nCount) > nColCount ) - nCount = nColCount - nIndex; + // clip removed columns to columns actually available + if( (nIndex + nCount) > nColCount ) + nCount = nColCount - nIndex; - sal_Int32 nRows = getRowCountImpl(); - SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); - const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); + sal_Int32 nRows = getRowCountImpl(); + SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); + const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); + + if( bUndo ) + { + rModel.BegUndo( SvxResId(STR_UNDO_COL_DELETE) ); + rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); - if( bUndo ) + TableModelRef xThis( this ); + ColumnVector aRemovedCols( nCount ); + sal_Int32 nOffset; + for( nOffset = 0; nOffset < nCount; ++nOffset ) { - rModel.BegUndo( SvxResId(STR_UNDO_COL_DELETE) ); - rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); + aRemovedCols[nOffset] = maColumns[nIndex+nOffset]; + } - TableModelRef xThis( this ); - ColumnVector aRemovedCols( nCount ); - sal_Int32 nOffset; + CellVector aRemovedCells( nCount * nRows ); + CellVector::iterator aCellIter( aRemovedCells.begin() ); + for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) + { for( nOffset = 0; nOffset < nCount; ++nOffset ) - { - aRemovedCols[nOffset] = maColumns[nIndex+nOffset]; - } - - CellVector aRemovedCells( nCount * nRows ); - CellVector::iterator aCellIter( aRemovedCells.begin() ); - for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) - { - for( nOffset = 0; nOffset < nCount; ++nOffset ) - (*aCellIter++) = getCell( nIndex + nOffset, nRow ); - } - - rModel.AddUndo( std::make_unique<RemoveColUndo>( xThis, nIndex, aRemovedCols, aRemovedCells ) ); + (*aCellIter++) = getCell( nIndex + nOffset, nRow ); } - // only rows before and inside the removed rows are considered - nColCount = nIndex + nCount + 1; + rModel.AddUndo( std::make_unique<RemoveColUndo>( xThis, nIndex, aRemovedCols, aRemovedCells ) ); + } - const sal_Int32 nRowCount = getRowCountImpl(); + // only rows before and inside the removed rows are considered + nColCount = nIndex + nCount + 1; - // first check merged cells before and inside the removed rows - for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) + const sal_Int32 nRowCount = getRowCountImpl(); + + // first check merged cells before and inside the removed rows + for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) + { + for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) { - for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) - { - CellRef xCell( getCell( nCol, nRow ) ); - sal_Int32 nColSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getColumnSpan() : 1; - if( nColSpan <= 1 ) - continue; + CellRef xCell( getCell( nCol, nRow ) ); + sal_Int32 nColSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getColumnSpan() : 1; + if( nColSpan <= 1 ) + continue; - if( nCol >= nIndex ) + if( nCol >= nIndex ) + { + // current cell is inside the removed columns + if( (nCol + nColSpan) > ( nIndex + nCount ) ) { - // current cell is inside the removed columns - if( (nCol + nColSpan) > ( nIndex + nCount ) ) + // current cells merges with columns after the removed columns + const sal_Int32 nRemove = nCount - nCol + nIndex; + + CellRef xTargetCell( getCell( nIndex + nCount, nRow ) ); + if( xTargetCell.is() ) { - // current cells merges with columns after the removed columns - const sal_Int32 nRemove = nCount - nCol + nIndex; - - CellRef xTargetCell( getCell( nIndex + nCount, nRow ) ); - if( xTargetCell.is() ) - { - if( bUndo ) - xTargetCell->AddUndo(); - xTargetCell->merge( nColSpan - nRemove, xCell->getRowSpan() ); - xTargetCell->replaceContentAndFormating( xCell ); - } + if( bUndo ) + xTargetCell->AddUndo(); + xTargetCell->merge( nColSpan - nRemove, xCell->getRowSpan() ); + xTargetCell->replaceContentAndFormating( xCell ); } } - else if( nColSpan > (nIndex - nCol) ) - { - // current cells spans inside the removed columns, so adjust - const sal_Int32 nRemove = ::std::min( nCount, nCol + nColSpan - nIndex ); - if( bUndo ) - xCell->AddUndo(); - xCell->merge( nColSpan - nRemove, xCell->getRowSpan() ); - } + } + else if( nColSpan > (nIndex - nCol) ) + { + // current cells spans inside the removed columns, so adjust + const sal_Int32 nRemove = ::std::min( nCount, nCol + nColSpan - nIndex ); + if( bUndo ) + xCell->AddUndo(); + xCell->merge( nColSpan - nRemove, xCell->getRowSpan() ); } } + } - // now remove the columns - remove_range<ColumnVector,ColumnVector::iterator>( maColumns, nIndex, nCount ); - while( nRows-- ) - maRows[nRows]->removeColumns( nIndex, nCount ); - - if( bUndo ) - rModel.EndUndo(); + // now remove the columns + remove_range<ColumnVector,ColumnVector::iterator>( maColumns, nIndex, nCount ); + while( nRows-- ) + maRows[nRows]->removeColumns( nIndex, nCount ); - rModel.SetChanged(); - } - catch( Exception& ) - { - OSL_FAIL("sdr::table::TableModel::removeColumns(), exception caught!"); - } + if( bUndo ) + rModel.EndUndo(); - updateColumns(); - setModified(true); + rModel.SetChanged(); } + catch( Exception& ) + { + OSL_FAIL("sdr::table::TableModel::removeColumns(), exception caught!"); + } + + updateColumns(); + setModified(true); } void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount ) { - if( nCount && mpTableObj ) - { - SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); - const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); + if( !(nCount && mpTableObj) ) + return; - try - { - TableModelNotifyGuard aGuard( this ); + SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); + const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); - nIndex = insert_range<RowVector,RowVector::iterator,TableRowRef>( maRows, nIndex, nCount ); + try + { + TableModelNotifyGuard aGuard( this ); - RowVector aNewRows(nCount); - const sal_Int32 nColCount = getColumnCountImpl(); - for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) - { - TableRowRef xNewRow( new TableRow( this, nIndex+nOffset, nColCount ) ); - maRows[nIndex+nOffset] = xNewRow; - aNewRows[nOffset] = xNewRow; - } + nIndex = insert_range<RowVector,RowVector::iterator,TableRowRef>( maRows, nIndex, nCount ); - if( bUndo ) - { - rModel.BegUndo( SvxResId(STR_TABLE_INSROW) ); - rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); - TableModelRef xThis( this ); - rModel.AddUndo( std::make_unique<InsertRowUndo>( xThis, nIndex, aNewRows ) ); - } + RowVector aNewRows(nCount); + const sal_Int32 nColCount = getColumnCountImpl(); + for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) + { + TableRowRef xNewRow( new TableRow( this, nIndex+nOffset, nColCount ) ); + maRows[nIndex+nOffset] = xNewRow; + aNewRows[nOffset] = xNewRow; + } + + if( bUndo ) + { + rModel.BegUndo( SvxResId(STR_TABLE_INSROW) ); + rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); + TableModelRef xThis( this ); + rModel.AddUndo( std::make_unique<InsertRowUndo>( xThis, nIndex, aNewRows ) ); + } - // check if cells merge over new columns - for( sal_Int32 nRow = 0; nRow < nIndex; ++nRow ) + // check if cells merge over new columns + for( sal_Int32 nRow = 0; nRow < nIndex; ++nRow ) + { + for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) { - for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) + CellRef xCell( getCell( nCol, nRow ) ); + sal_Int32 nRowSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getRowSpan() : 1; + if( (nRowSpan > 1) && ((nRowSpan + nRow) > nIndex) ) { - CellRef xCell( getCell( nCol, nRow ) ); - sal_Int32 nRowSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getRowSpan() : 1; - if( (nRowSpan > 1) && ((nRowSpan + nRow) > nIndex) ) - { - // cell merges over newly created columns, so add the new columns to the merged cell - const sal_Int32 nColSpan = xCell->getColumnSpan(); - nRowSpan += nCount; - merge( nCol, nRow, nColSpan, nRowSpan ); - } + // cell merges over newly created columns, so add the new columns to the merged cell + const sal_Int32 nColSpan = xCell->getColumnSpan(); + nRowSpan += nCount; + merge( nCol, nRow, nColSpan, nRowSpan ); } } } - catch( Exception& ) - { - OSL_FAIL("sdr::table::TableModel::insertRows(), exception caught!"); - } - if( bUndo ) - rModel.EndUndo(); + } + catch( Exception& ) + { + OSL_FAIL("sdr::table::TableModel::insertRows(), exception caught!"); + } + if( bUndo ) + rModel.EndUndo(); - rModel.SetChanged(); + rModel.SetChanged(); - updateRows(); - setModified(true); - } + updateRows(); + setModified(true); } @@ -843,93 +843,93 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount ) { sal_Int32 nRowCount = getRowCountImpl(); - if( mpTableObj && nCount && (nIndex >= 0) && (nIndex < nRowCount) ) - { - SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); - const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); + if( !(mpTableObj && nCount && (nIndex >= 0) && (nIndex < nRowCount)) ) + return; - try - { - TableModelNotifyGuard aGuard( this ); + SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); + const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); - // clip removed rows to rows actually available - if( (nIndex + nCount) > nRowCount ) - nCount = nRowCount - nIndex; + try + { + TableModelNotifyGuard aGuard( this ); - if( bUndo ) - { - rModel.BegUndo( SvxResId(STR_UNDO_ROW_DELETE) ); - rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); + // clip removed rows to rows actually available + if( (nIndex + nCount) > nRowCount ) + nCount = nRowCount - nIndex; - TableModelRef xThis( this ); + if( bUndo ) + { + rModel.BegUndo( SvxResId(STR_UNDO_ROW_DELETE) ); + rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); - RowVector aRemovedRows( nCount ); - for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) - aRemovedRows[nOffset] = maRows[nIndex+nOffset]; + TableModelRef xThis( this ); - rModel.AddUndo( std::make_unique<RemoveRowUndo>( xThis, nIndex, aRemovedRows ) ); - } + RowVector aRemovedRows( nCount ); + for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) + aRemovedRows[nOffset] = maRows[nIndex+nOffset]; - // only rows before and inside the removed rows are considered - nRowCount = nIndex + nCount + 1; + rModel.AddUndo( std::make_unique<RemoveRowUndo>( xThis, nIndex, aRemovedRows ) ); + } - const sal_Int32 nColCount = getColumnCountImpl(); + // only rows before and inside the removed rows are considered + nRowCount = nIndex + nCount + 1; - // first check merged cells before and inside the removed rows - for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) + const sal_Int32 nColCount = getColumnCountImpl(); + + // first check merged cells before and inside the removed rows + for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) + { + for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) { - for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) - { - CellRef xCell( getCell( nCol, nRow ) ); - sal_Int32 nRowSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getRowSpan() : 1; - if( nRowSpan <= 1 ) - continue; + CellRef xCell( getCell( nCol, nRow ) ); + sal_Int32 nRowSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getRowSpan() : 1; + if( nRowSpan <= 1 ) + continue; - if( nRow >= nIndex ) + if( nRow >= nIndex ) + { + // current cell is inside the removed rows + if( (nRow + nRowSpan) > (nIndex + nCount) ) { - // current cell is inside the removed rows - if( (nRow + nRowSpan) > (nIndex + nCount) ) + // current cells merges with rows after the removed rows + const sal_Int32 nRemove = nCount - nRow + nIndex; + + CellRef xTargetCell( getCell( nCol, nIndex + nCount ) ); + if( xTargetCell.is() ) { - // current cells merges with rows after the removed rows - const sal_Int32 nRemove = nCount - nRow + nIndex; - - CellRef xTargetCell( getCell( nCol, nIndex + nCount ) ); - if( xTargetCell.is() ) - { - if( bUndo ) - xTargetCell->AddUndo(); - xTargetCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove ); - xTargetCell->replaceContentAndFormating( xCell ); - } + if( bUndo ) + xTargetCell->AddUndo(); + xTargetCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove ); + xTargetCell->replaceContentAndFormating( xCell ); } } - else if( nRowSpan > (nIndex - nRow) ) - { - // current cells spans inside the removed rows, so adjust - const sal_Int32 nRemove = ::std::min( nCount, nRow + nRowSpan - nIndex ); - if( bUndo ) - xCell->AddUndo(); - xCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove ); - } + } + else if( nRowSpan > (nIndex - nRow) ) + { + // current cells spans inside the removed rows, so adjust + const sal_Int32 nRemove = ::std::min( nCount, nRow + nRowSpan - nIndex ); + if( bUndo ) + xCell->AddUndo(); + xCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove ); } } + } - // now remove the rows - remove_range<RowVector,RowVector::iterator>( maRows, nIndex, nCount ); - - if( bUndo ) - rModel.EndUndo(); + // now remove the rows + remove_range<RowVector,RowVector::iterator>( maRows, nIndex, nCount ); - rModel.SetChanged(); - } - catch( Exception& ) - { - OSL_FAIL("sdr::table::TableModel::removeRows(), exception caught!"); - } + if( bUndo ) + rModel.EndUndo(); - updateRows(); - setModified(true); + rModel.SetChanged(); } + catch( Exception& ) + { + OSL_FAIL("sdr::table::TableModel::removeRows(), exception caught!"); + } + + updateRows(); + setModified(true); } |