summaryrefslogtreecommitdiff
path: root/svx/source/table/tablemodel.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/table/tablemodel.cxx')
-rw-r--r--svx/source/table/tablemodel.cxx74
1 files changed, 35 insertions, 39 deletions
diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx
index 033af2477a45..812e3de7fe26 100644
--- a/svx/source/table/tablemodel.cxx
+++ b/svx/source/table/tablemodel.cxx
@@ -554,7 +554,7 @@ void TableModel::unlockBroadcasts()
void TableModel::notifyModification()
{
::osl::MutexGuard guard( m_aMutex );
- if( (mnNotifyLock == 0) && mpTableObj && mpTableObj->GetModel() )
+ if( (mnNotifyLock == 0) && mpTableObj )
{
mbNotifyPending = false;
@@ -602,8 +602,7 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
{
try
{
- SdrModel* pModel = mpTableObj->GetModel();
-
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
TableModelNotifyGuard aGuard( this );
nIndex = insert_range<ColumnVector,ColumnVector::iterator,TableColumnRef>( maColumns, nIndex, nCount );
@@ -619,11 +618,12 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
aNewColumns[nOffset] = xNewCol;
}
- const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
+
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
- pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
+ rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
@@ -638,7 +638,7 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
(*aCellIter++) = getCell( nIndex + nOffset, nRow );
}
- pModel->AddUndo( new InsertColUndo( xThis, nIndex, aNewColumns, aNewCells ) );
+ rModel.AddUndo( new InsertColUndo( xThis, nIndex, aNewColumns, aNewCells ) );
}
const sal_Int32 nRowCount = getRowCountImpl();
@@ -660,11 +660,9 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
}
if( bUndo )
- pModel->EndUndo();
-
- if( pModel )
- pModel->SetChanged();
+ rModel.EndUndo();
+ rModel.SetChanged();
}
catch( Exception& )
{
@@ -691,14 +689,13 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
nCount = nColCount - nIndex;
sal_Int32 nRows = getRowCountImpl();
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
- SdrModel* pModel = mpTableObj->GetModel();
-
- const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_UNDO_COL_DELETE) );
- pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ rModel.BegUndo( ImpGetResStr(STR_UNDO_COL_DELETE) );
+ rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
ColumnVector aRemovedCols( nCount );
@@ -716,7 +713,7 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
(*aCellIter++) = getCell( nIndex + nOffset, nRow );
}
- pModel->AddUndo( new RemoveColUndo( xThis, nIndex, aRemovedCols, aRemovedCells ) );
+ rModel.AddUndo( new RemoveColUndo( xThis, nIndex, aRemovedCols, aRemovedCells ) );
}
// only rows before and inside the removed rows are considered
@@ -769,10 +766,9 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
maRows[nRows]->removeColumns( nIndex, nCount );
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
}
catch( Exception& )
{
@@ -789,8 +785,9 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
{
if( nCount && mpTableObj )
{
- SdrModel* pModel = mpTableObj->GetModel();
- const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
+
try
{
TableModelNotifyGuard aGuard( this );
@@ -808,10 +805,10 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_TABLE_INSROW) );
- pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_INSROW) );
+ rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
- pModel->AddUndo( new InsertRowUndo( xThis, nIndex, aNewRows ) );
+ rModel.AddUndo( new InsertRowUndo( xThis, nIndex, aNewRows ) );
}
// check if cells merge over new columns
@@ -836,10 +833,9 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
OSL_FAIL("sdr::table::TableModel::insertRows(), exception caught!");
}
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
updateRows();
setModified(true);
@@ -853,8 +849,8 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
if( mpTableObj && nCount && (nIndex >= 0) && (nIndex < nRowCount) )
{
- SdrModel* pModel = mpTableObj->GetModel();
- const bool bUndo = pModel && mpTableObj->IsInserted()&& pModel->IsUndoEnabled();
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
try
{
@@ -866,8 +862,8 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_UNDO_ROW_DELETE) );
- pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ rModel.BegUndo( ImpGetResStr(STR_UNDO_ROW_DELETE) );
+ rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
@@ -875,7 +871,7 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset )
aRemovedRows[nOffset] = maRows[nIndex+nOffset];
- pModel->AddUndo( new RemoveRowUndo( xThis, nIndex, aRemovedRows ) );
+ rModel.AddUndo( new RemoveRowUndo( xThis, nIndex, aRemovedRows ) );
}
// only rows before and inside the removed rows are considered
@@ -926,10 +922,9 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
remove_range<RowVector,RowVector::iterator>( maRows, nIndex, nCount );
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
}
catch( Exception& )
{
@@ -1050,10 +1045,11 @@ void TableModel::optimize()
void TableModel::merge( sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan )
{
- SdrModel* pModel = mpTableObj->GetModel();
-
- const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ if(nullptr == mpTableObj)
+ return;
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
const sal_Int32 nLastRow = nRow + nRowSpan;
const sal_Int32 nLastCol = nCol + nColSpan;