summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/ui/dbgui/PivotLayoutDialog.cxx25
1 files changed, 14 insertions, 11 deletions
diff --git a/sc/source/ui/dbgui/PivotLayoutDialog.cxx b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
index f52fe4d980e1..1ed0e93f0b66 100644
--- a/sc/source/ui/dbgui/PivotLayoutDialog.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
@@ -492,7 +492,6 @@ void ScPivotLayoutDialog::ApplyChanges()
ApplyLabelData(aSaveData);
ScDPObject *pOldDPObj = mpDocument->GetDPAtCursor( maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
- const ScRange& rOldRange = pOldDPObj->GetOutRange();
ScRange aDestinationRange;
bool bToNewSheet = false;
@@ -517,17 +516,21 @@ void ScPivotLayoutDialog::ApplyChanges()
if (pItem)
{
- // User wants to move existing pivot table to another (non-overlapping)
- // range or to a new sheet
- // FIXME: if the new range overlaps with the old one, the table actually doesn't move
- // and shouldn't therefore be deleted
- if ( !rOldRange.In( aDestinationRange )
- || (bToNewSheet && !mbNewPivotTable) )
+ // existing pivot table might have moved to a new range or a new sheet
+ if ( pOldDPObj != nullptr )
{
- ScDPObject *pDPObj = mpDocument->GetDPAtCursor( maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
- ScDBDocFunc aFunc( *(mpViewData->GetDocShell() ));
- aFunc.RemovePivotTable( *pDPObj, true, false);
- mpViewData->GetView()->CursorPosChanged();
+ const ScRange& rOldRange = pOldDPObj->GetOutRange();
+
+ // FIXME: if the new range overlaps with the old one, the table actually doesn't move
+ // and shouldn't therefore be deleted
+ if ( ( ( rOldRange != aDestinationRange ) && !rOldRange.In( aDestinationRange ) )
+ || bToNewSheet )
+ {
+ ScDPObject *pDPObj = mpDocument->GetDPAtCursor( maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
+ ScDBDocFunc aFunc( *(mpViewData->GetDocShell() ));
+ aFunc.RemovePivotTable( *pDPObj, true, false);
+ mpViewData->GetView()->CursorPosChanged();
+ }
}
return;
}