Kaydet (Commit) c0fa223d authored tarafından Katarina Behrens's avatar Katarina Behrens

tdf#97437: Don't crash when creating new pivot table

regression from 0b9dd244 -- *sigh* most of the time is
the old pivot table not there.

Change-Id: I85ea03780f175aa6e4fb6859497b6dda12fa7d11
Reviewed-on: https://gerrit.libreoffice.org/22057Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
Tested-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst aaa7b7c8
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment