diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-01-26 11:55:42 +0100 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-01-27 10:11:53 +0000 |
commit | 0b9dd2446c33fda77fa18eec7ae86831af9c82e6 (patch) | |
tree | 380fd62551b6f9e11b401fb1eaefb55c0b35cbcc /sc/source/ui/dbgui | |
parent | 3a90e37a929f167e42c1841a6164a1d092cb7505 (diff) |
tdf#89308: Delete old copy of pivot table on moving destination
except for the case when origin of the new range lies within
the old range (Calc doesn't update the table then, this needs
to be fixed separately)
Change-Id: I554a347a94df830ac1fd651c30cf8e83279cdef8
Reviewed-on: https://gerrit.libreoffice.org/21804
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'sc/source/ui/dbgui')
-rw-r--r-- | sc/source/ui/dbgui/PivotLayoutDialog.cxx | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sc/source/ui/dbgui/PivotLayoutDialog.cxx b/sc/source/ui/dbgui/PivotLayoutDialog.cxx index 83beb7ecf05a..f52fe4d980e1 100644 --- a/sc/source/ui/dbgui/PivotLayoutDialog.cxx +++ b/sc/source/ui/dbgui/PivotLayoutDialog.cxx @@ -17,6 +17,7 @@ #include "rangeutl.hxx" #include "uiitems.hxx" #include "dputil.hxx" +#include "dbdocfun.hxx" #include <vector> @@ -490,6 +491,8 @@ void ScPivotLayoutDialog::ApplyChanges() ApplySaveData(aSaveData); ApplyLabelData(aSaveData); + ScDPObject *pOldDPObj = mpDocument->GetDPAtCursor( maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab); + const ScRange& rOldRange = pOldDPObj->GetOutRange(); ScRange aDestinationRange; bool bToNewSheet = false; @@ -503,6 +506,7 @@ void ScPivotLayoutDialog::ApplyChanges() ScPivotItem aPivotItem(nWhichPivot, &aSaveData, &aDestinationRange, bToNewSheet); mpViewData->GetViewShell()->SetDialogDPObject(&maPivotTableObject); + SfxDispatcher* pDispatcher = GetBindings().GetDispatcher(); SfxCallMode nCallMode = SfxCallMode::SLOT | SfxCallMode::RECORD; const SfxPoolItem* pResult = pDispatcher->Execute(SID_PIVOT_TABLE, nCallMode, &aPivotItem, nullptr, 0); @@ -510,9 +514,22 @@ void ScPivotLayoutDialog::ApplyChanges() if (pResult != nullptr) { const SfxBoolItem* pItem = reinterpret_cast<const SfxBoolItem*>(pResult); + if (pItem) { - return; + // 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) ) + { + ScDPObject *pDPObj = mpDocument->GetDPAtCursor( maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab); + ScDBDocFunc aFunc( *(mpViewData->GetDocShell() )); + aFunc.RemovePivotTable( *pDPObj, true, false); + mpViewData->GetView()->CursorPosChanged(); + } + return; } } |