summaryrefslogtreecommitdiff
path: root/svx/source/table
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2009-06-04 16:21:29 +0000
committerKurt Zenker <kz@openoffice.org>2009-06-04 16:21:29 +0000
commit2dc34235a216d86471e459a42ab429e207436a20 (patch)
tree5bf7a3a1110dd6b5297ff42d89449e99629a942e /svx/source/table
parent46ba9cbfdc49baeaba4037f8f1a679f1aefe0d5d (diff)
CWS-TOOLING: integrate CWS clnoundo
2009-05-18 09:40:22 +0200 wg r271998 : i102011 2009-04-28 12:20:24 +0200 cl r271318 : CWS-TOOLING: rebase CWS clnoundo to trunk@270723 (milestone: DEV300:m46) 2009-04-02 11:37:14 +0200 cl r270388 : #i100371# check valid positions all the time to avoid crashes during model lock 2009-03-30 13:02:27 +0200 cl r270219 : #i100371# do not create undo actions in drawing layer during load 2009-03-30 12:59:41 +0200 cl r270218 : #i100371# do not create undo actions in drawing layer during load 2009-03-30 12:55:06 +0200 cl r270217 : #i100371# do not create undo actions in drawing layer during load 2009-03-30 12:53:27 +0200 cl r270216 : #i100371# do not create undo actions in drawing layer during load 2009-03-30 12:49:28 +0200 cl r270215 : #i100371# added EnableUndo() and IsUndoEnabled()
Diffstat (limited to 'svx/source/table')
-rw-r--r--svx/source/table/cell.cxx2
-rw-r--r--svx/source/table/svdotable.cxx2
-rw-r--r--svx/source/table/tablecolumn.cxx12
-rw-r--r--svx/source/table/tablecontroller.cxx79
-rw-r--r--svx/source/table/tablelayouter.cxx42
-rw-r--r--svx/source/table/tablelayouter.hxx1
-rw-r--r--svx/source/table/tablemodel.cxx44
-rw-r--r--svx/source/table/tablerow.cxx15
8 files changed, 118 insertions, 79 deletions
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index e9e6a60da7..cdd55c9d62 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -743,7 +743,7 @@ void Cell::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
void Cell::AddUndo()
{
SdrObject& rObj = GetObject();
- if( rObj.IsInserted() && GetModel() )
+ if( rObj.IsInserted() && GetModel() && GetModel()->IsUndoEnabled() )
{
CellRef xCell( this );
GetModel()->AddUndo( new CellUndo( &rObj, xCell ) );
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 211afa5ff4..1a83e03611 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -2106,7 +2106,7 @@ void SdrTableObj::EndTextEdit(SdrOutliner& rOutl)
{
if(rOutl.IsModified())
{
- if( GetModel() )
+ if( GetModel() && GetModel()->IsUndoEnabled() )
GetModel()->AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*this) );
OutlinerParaObject* pNewText = 0;
diff --git a/svx/source/table/tablecolumn.cxx b/svx/source/table/tablecolumn.cxx
index 10a95a4095..024f858303 100644
--- a/svx/source/table/tablecolumn.cxx
+++ b/svx/source/table/tablecolumn.cxx
@@ -161,8 +161,10 @@ void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& a
bool bOk = false;
bool bChange = false;
+ SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
+
TableColumnUndo* pUndo = 0;
- if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() )
+ if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && pModel && pModel->IsUndoEnabled() )
{
TableColumnRef xThis( this );
pUndo = new TableColumnUndo( xThis );
@@ -228,12 +230,8 @@ void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& a
{
if( pUndo )
{
- SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
- if( pModel )
- {
- pModel->AddUndo( pUndo );
- pUndo = 0;
- }
+ pModel->AddUndo( pUndo );
+ pUndo = 0;
}
mxTableModel->setModified(sal_True);
}
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index ab5d250ada..c07bb66512 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -520,13 +520,15 @@ void SvxTableController::onInsert( sal_uInt16 nSId )
const OUString sSize( RTL_CONSTASCII_USTRINGPARAM( "Size" ) );
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+
switch( nSId )
{
case SID_TABLE_INSERT_COL:
{
TableModelNotifyGuard aGuard( mxTable.get() );
- if( mpModel )
+ if( bUndo )
{
mpModel->BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
@@ -544,11 +546,11 @@ void SvxTableController::onInsert( sal_uInt16 nSId )
getPropertyValue( sSize ) );
}
- if( mpModel )
- {
+ if( bUndo )
mpModel->EndUndo();
+
+ if( mpModel )
mpModel->SetChanged();
- }
aStart.mnCol = aEnd.mnCol+1;
aStart.mnRow = 0;
@@ -561,7 +563,7 @@ void SvxTableController::onInsert( sal_uInt16 nSId )
{
TableModelNotifyGuard aGuard( mxTable.get() );
- if( mpModel )
+ if( bUndo )
{
mpModel->BegUndo( ImpGetResStr(STR_TABLE_INSROW ) );
mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
@@ -579,9 +581,12 @@ void SvxTableController::onInsert( sal_uInt16 nSId )
getPropertyValue( sSize ) );
}
- if( mpModel )
+ if( bUndo )
mpModel->EndUndo();
+ if( mpModel )
+ mpModel->SetChanged();
+
aStart.mnCol = 0;
aStart.mnRow = aEnd.mnRow+1;
aEnd.mnCol = mxTable->getColumnCount() - 1;
@@ -843,9 +848,13 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
// found table style with the same name
Reference< XIndexAccess > xNewTableStyle( xTableFamilyAccess->getByName( pArg->GetValue() ), UNO_QUERY_THROW );
- pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE) );
+ const bool bUndo = pModel->IsUndoEnabled();
- pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ if( bUndo )
+ {
+ pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE) );
+ pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ }
/*
const sal_Int32 nRowCount = mxTable->getRowCount();
@@ -857,7 +866,8 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
if( xCell.is() )
{
- xCell->AddUndo();
+ if( bUndo )
+ xCell->AddUndo();
xCell->setAllPropertiesToDefault();
}
}
@@ -870,7 +880,9 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
*/
pTableObj->setTableStyle( xNewTableStyle );
- pModel->EndUndo();
+
+ if( bUndo )
+ pModel->EndUndo();
}
}
catch( Exception& e )
@@ -913,10 +925,18 @@ void SvxTableController::SetTableStyleSettings( const SfxItemSet* pArgs )
if( aSettings == pTableObj->getTableStyleSettings() )
return;
- pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE_SETTINGS) );
- pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ const bool bUndo = pModel->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE_SETTINGS) );
+ pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ }
+
pTableObj->setTableStyleSettings( aSettings );
- pModel->EndUndo();
+
+ if( bUndo )
+ pModel->EndUndo();
}
void SvxTableController::SetVertical( sal_uInt16 nSId )
@@ -1000,7 +1020,8 @@ void SvxTableController::SplitMarkedCells()
{
TableModelNotifyGuard aGuard( mxTable.get() );
- if( mpModel )
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if( bUndo )
{
mpModel->BegUndo( ImpGetResStr(STR_TABLE_SPLIT) );
mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
@@ -1015,11 +1036,11 @@ void SvxTableController::SplitMarkedCells()
xRange->split( nCount, 0 );
}
- if( mpModel )
- {
+ if( bUndo )
mpModel->EndUndo();
+
+ if( mpModel )
mpModel->SetChanged();
- }
}
aEnd.mnRow += mxTable->getRowCount() - nRowCount;
aEnd.mnCol += mxTable->getColumnCount() - nColCount;
@@ -1034,7 +1055,8 @@ void SvxTableController::DistributeColumns()
SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() );
if( pTableObj )
{
- if( mpModel )
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if( bUndo )
{
mpModel->BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_COLUMNS) );
mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
@@ -1044,7 +1066,7 @@ void SvxTableController::DistributeColumns()
getSelectedCells( aStart, aEnd );
pTableObj->DistributeColumns( aStart.mnCol, aEnd.mnCol );
- if( mpModel )
+ if( bUndo )
mpModel->EndUndo();
}
}
@@ -1054,7 +1076,8 @@ void SvxTableController::DistributeRows()
SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() );
if( pTableObj )
{
- if( mpModel )
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if( bUndo )
{
mpModel->BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_ROWS) );
mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
@@ -1064,7 +1087,7 @@ void SvxTableController::DistributeRows()
getSelectedCells( aStart, aEnd );
pTableObj->DistributeRows( aStart.mnRow, aEnd.mnRow );
- if( mpModel )
+ if( bUndo )
mpModel->EndUndo();
}
}
@@ -1543,7 +1566,8 @@ void SvxTableController::MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, s
Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( nFirstCol, nFirstRow,nLastCol, nLastRow ) ), UNO_QUERY_THROW );
if( xRange->isMergeable() )
{
- if( mpModel )
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if( bUndo )
{
mpModel->BegUndo( ImpGetResStr(STR_TABLE_MERGE) );
mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*mxTableObj.get()) );
@@ -1551,7 +1575,7 @@ void SvxTableController::MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, s
xRange->merge();
- if( mpModel )
+ if( bUndo )
mpModel->EndUndo();
}
}
@@ -2257,7 +2281,9 @@ void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bR
{
if( mxTable.is() )
{
- if( mpModel )
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+
+ if( bUndo )
mpModel->BegUndo( ImpGetResStr(STR_TABLE_NUMFORMAT) );
CellPos aStart, aEnd;
@@ -2281,7 +2307,8 @@ void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bR
CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
if( xCell.is() )
{
- xCell->AddUndo();
+ if( bUndo )
+ xCell->AddUndo();
xCell->SetMergedItemSetAndBroadcast(aAttr, bReplaceAll);
}
}
@@ -2294,7 +2321,7 @@ void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bR
UpdateTableShape();
- if( mpModel )
+ if( bUndo )
mpModel->EndUndo();
}
diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx
index 2972fb0be5..06293ea226 100644
--- a/svx/source/table/tablelayouter.cxx
+++ b/svx/source/table/tablelayouter.cxx
@@ -98,19 +98,21 @@ basegfx::B2ITuple TableLayouter::getCellSize( const CellPos& rPos ) const
{
CellPos aPos( rPos );
- sal_Int32 nRowSpan = xCell->getRowSpan()-1;
- do
+ sal_Int32 nRowCount = getRowCount();
+ sal_Int32 nRowSpan = std::max( xCell->getRowSpan(), (sal_Int32)1 );
+ while( nRowSpan && (aPos.mnRow < nRowCount) )
{
height += maRows[aPos.mnRow++].mnSize;
+ nRowSpan--;
}
- while( nRowSpan-- );
- sal_Int32 nColSpan = xCell->getColumnSpan()-1;
- do
+ sal_Int32 nColCount = getColumnCount();
+ sal_Int32 nColSpan = std::max( xCell->getColumnSpan(), (sal_Int32)1 );
+ while( nColSpan && (aPos.mnCol < nColCount ) )
{
width += maColumns[aPos.mnCol++].mnSize;
+ nColSpan--;
}
- while( nColSpan-- );
}
}
catch( Exception& )
@@ -127,7 +129,7 @@ bool TableLayouter::getCellArea( const CellPos& rPos, basegfx::B2IRectangle& rAr
try
{
CellRef xCell( getCell( rPos ) );
- if( xCell.is() && !xCell->isMerged() )
+ if( xCell.is() && !xCell->isMerged() && isValid(rPos) )
{
const basegfx::B2ITuple aCellSize( getCellSize( rPos ) );
@@ -149,7 +151,7 @@ bool TableLayouter::getCellArea( const CellPos& rPos, basegfx::B2IRectangle& rAr
sal_Int32 TableLayouter::getRowHeight( sal_Int32 nRow )
{
- if( (nRow >= 0) && (nRow < getRowCount()) )
+ if( isValidRow(nRow) )
return maRows[nRow].mnSize;
else
return 0;
@@ -159,18 +161,21 @@ sal_Int32 TableLayouter::getRowHeight( sal_Int32 nRow )
void TableLayouter::setRowHeight( sal_Int32 nRow, sal_Int32 nHeight )
{
- const sal_Int32 nCount = getRowCount();
-
- DBG_ASSERT( (nRow >= 0) && (nRow < nCount), "TableLayouter::setRowHeight(), row out of range!" );
- if( (nRow >= 0) && (nRow < nCount) && (nHeight != maRows[nRow].mnSize) )
+ if( isValidRow(nRow) )
+ {
maRows[nRow].mnSize = nHeight;
+ }
+ else
+ {
+ DBG_ERROR( "TableLayouter::setRowHeight(), row out of range!" );
+ }
}
// -----------------------------------------------------------------------------
sal_Int32 TableLayouter::getColumnWidth( sal_Int32 nColumn )
{
- if( (nColumn >= 0) && (nColumn < getColumnCount()) )
+ if( isValidColumn(nColumn) )
return maColumns[nColumn].mnSize;
else
return 0;
@@ -180,11 +185,10 @@ sal_Int32 TableLayouter::getColumnWidth( sal_Int32 nColumn )
void TableLayouter::setColumnWidth( sal_Int32 nColumn, sal_Int32 nWidth )
{
- const sal_Int32 nCount = getColumnCount();
-
- DBG_ASSERT( (nColumn >= 0) && (nColumn < nCount), "TableLayouter::setColumnWidth(), column out of range!" );
- if( (nColumn >= 0) && (nColumn < nCount) )
+ if( isValidColumn(nColumn) )
maColumns[nColumn].mnSize = nWidth;
+ else
+ DBG_ERROR( "TableLayouter::setColumnWidth(), column out of range!" );
}
// -----------------------------------------------------------------------------
@@ -1149,7 +1153,7 @@ void TableLayouter::SetWritingMode( com::sun::star::text::WritingMode eWritingMo
sal_Int32 TableLayouter::getColumnStart( sal_Int32 nColumn ) const
{
- if( (nColumn >= 0) && (nColumn < getColumnCount()) )
+ if( isValidColumn(nColumn) )
return maColumns[nColumn].mnPos;
else
return 0;
@@ -1159,7 +1163,7 @@ sal_Int32 TableLayouter::getColumnStart( sal_Int32 nColumn ) const
sal_Int32 TableLayouter::getRowStart( sal_Int32 nRow ) const
{
- if( (nRow >= 0) && (nRow < getRowCount()) )
+ if( isValidRow(nRow) )
return maRows[nRow].mnPos;
else
return 0;
diff --git a/svx/source/table/tablelayouter.hxx b/svx/source/table/tablelayouter.hxx
index 0c7d146a78..f1bb421cbe 100644
--- a/svx/source/table/tablelayouter.hxx
+++ b/svx/source/table/tablelayouter.hxx
@@ -140,6 +140,7 @@ private:
inline bool isValidColumn( sal_Int32 nColumn ) const { return (nColumn >= 0) && (nColumn < static_cast<sal_Int32>( maColumns.size())); }
inline bool isValidRow( sal_Int32 nRow ) const { return (nRow >= 0) && (nRow < static_cast<sal_Int32>( maRows.size())); }
+ inline bool isValid( const CellPos& rPos ) const { return isValidColumn( rPos.mnCol ) && isValidRow( rPos.mnRow ); }
void ClearBorderLayout();
void ClearBorderLayout(BorderLineMap& rMap);
diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx
index d0400ff59b..d74147ce5c 100644
--- a/svx/source/table/tablemodel.cxx
+++ b/svx/source/table/tablemodel.cxx
@@ -749,7 +749,8 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
aNewColumns[nOffset] = xNewCol;
}
- if( pModel && mpTableObj->IsInserted() )
+ const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ if( bUndo )
{
pModel->BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
@@ -783,7 +784,7 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
// cell merges over newly created columns, so add the new columns to the merged cell
const sal_Int32 nRowSpan = xCell->getRowSpan();
nColSpan += nCount;
- if( pModel && mpTableObj->IsInserted() )
+ if( bUndo )
xCell->AddUndo();
xCell->merge( nColSpan, nRowSpan );
// set newly inserted cells to merged state
@@ -800,7 +801,7 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
}
}
- if( pModel && mpTableObj->IsInserted() )
+ if( bUndo )
pModel->EndUndo();
}
@@ -832,7 +833,9 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
sal_Int32 nRows = getRowCountImpl();
SdrModel* pModel = mpTableObj->GetModel();
- if( pModel && mpTableObj->IsInserted() )
+
+ const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ if( bUndo )
{
pModel->BegUndo( ImpGetResStr(STR_UNDO_COL_DELETE) );
pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
@@ -882,7 +885,8 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
CellRef xTargetCell( getCell( nIndex + nCount, nRow ) );
if( xTargetCell.is() )
{
- xTargetCell->AddUndo();
+ if( bUndo )
+ xTargetCell->AddUndo();
xTargetCell->merge( nColSpan - nRemove, xCell->getRowSpan() );
xTargetCell->replaceContentAndFormating( xCell );
}
@@ -892,7 +896,7 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
{
// current cells spans inside the removed columns, so adjust
const sal_Int32 nRemove = ::std::min( nCount, nCol + nColSpan - nIndex );
- if( mpTableObj->IsInserted() )
+ if( bUndo )
xCell->AddUndo();
xCell->merge( nColSpan - nRemove, xCell->getRowSpan() );
}
@@ -904,7 +908,7 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
while( nRows-- )
maRows[nRows]->removeColumns( nIndex, nCount );
- if( pModel && mpTableObj->IsInserted() )
+ if( bUndo )
pModel->EndUndo();
}
catch( Exception& )
@@ -924,7 +928,7 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
if( nCount && mpTableObj )
{
SdrModel* pModel = mpTableObj->GetModel();
- bool bBegUndo = false;
+ const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
try
{
TableModelNotifyGuard aGuard( this );
@@ -940,13 +944,12 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
aNewRows[nOffset] = xNewRow;
}
- if( pModel && mpTableObj->IsInserted() )
- {
+ if( bUndo )
+ {
pModel->BegUndo( ImpGetResStr(STR_TABLE_INSROW) );
pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
pModel->AddUndo( new InsertRowUndo( xThis, nIndex, aNewRows ) );
- bBegUndo = true;
}
// check if cells merge over new columns
@@ -961,7 +964,8 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
// cell merges over newly created columns, so add the new columns to the merged cell
const sal_Int32 nColSpan = xCell->getColumnSpan();
nRowSpan += nCount;
- xCell->AddUndo();
+ if( bUndo )
+ xCell->AddUndo();
xCell->merge( nColSpan, nRowSpan );
// set newly inserted cells to merged state
@@ -982,7 +986,7 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
{
DBG_ERROR("sdr::table::TableModel::insertRows(), exception caught!");
}
- if( pModel && bBegUndo )
+ if( bUndo )
pModel->EndUndo();
updateRows();
@@ -998,6 +1002,9 @@ 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();
+
try
{
TableModelNotifyGuard aGuard( this );
@@ -1006,8 +1013,7 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
if( (nIndex + nCount) > nRowCount )
nCount = nRowCount - nIndex;
- SdrModel* pModel = mpTableObj->GetModel();
- if( pModel && mpTableObj->IsInserted() )
+ if( bUndo )
{
pModel->BegUndo( ImpGetResStr(STR_UNDO_ROW_DELETE) );
pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
@@ -1047,7 +1053,8 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
CellRef xTargetCell( getCell( nCol, nIndex + nCount ) );
if( xTargetCell.is() )
{
- xTargetCell->AddUndo();
+ if( bUndo )
+ xTargetCell->AddUndo();
xTargetCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove );
xTargetCell->replaceContentAndFormating( xCell );
}
@@ -1057,7 +1064,8 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
{
// current cells spans inside the removed rows, so adjust
const sal_Int32 nRemove = ::std::min( nCount, nRow + nRowSpan - nIndex );
- xCell->AddUndo();
+ if( bUndo )
+ xCell->AddUndo();
xCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove );
}
}
@@ -1066,7 +1074,7 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
// now remove the rows
remove_range<RowVector,RowVector::iterator>( maRows, nIndex, nCount );
- if( pModel )
+ if( bUndo )
pModel->EndUndo();
}
catch( Exception& )
diff --git a/svx/source/table/tablerow.cxx b/svx/source/table/tablerow.cxx
index 27f5b60438..df71084374 100644
--- a/svx/source/table/tablerow.cxx
+++ b/svx/source/table/tablerow.cxx
@@ -233,7 +233,12 @@ void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aVal
bool bChange = false;
TableRowUndo* pUndo = 0;
- if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() )
+
+ SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
+
+ const bool bUndo = mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && pModel && pModel->IsUndoEnabled();
+
+ if( bUndo )
{
TableRowRef xThis( this );
pUndo = new TableRowUndo( xThis );
@@ -300,12 +305,8 @@ void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aVal
{
if( pUndo )
{
- SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
- if( pModel )
- {
- pModel->AddUndo( pUndo );
- pUndo = 0;
- }
+ pModel->AddUndo( pUndo );
+ pUndo = 0;
}
mxTableModel->setModified(sal_True);
}