diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-02-02 17:35:03 +0100 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-02-03 21:37:24 +0000 |
commit | c0fa223db5f5c55ffb76dbb10b0e8187962f0cd8 (patch) | |
tree | c0d1b1ae1f624d3bce092d98f41eeb14e390475d /sc/source/ui/dbgui | |
parent | aaa7b7c87dc0d685e2a0edf2763aaeacd2d6e579 (diff) |
tdf#97437: Don't crash when creating new pivot table
regression from 0b9dd2446c33fda77 -- *sigh* most of the time is
the old pivot table not there.
Change-Id: I85ea03780f175aa6e4fb6859497b6dda12fa7d11
Reviewed-on: https://gerrit.libreoffice.org/22057
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Tested-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'sc/source/ui/dbgui')
-rw-r--r-- | sc/source/ui/dbgui/PivotLayoutDialog.cxx | 25 |
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; } |