[Libreoffice-commits] core.git: sc/source

Katarina Behrens Katarina.Behrens at cib.de
Wed Jan 27 02:12:31 PST 2016


 sc/source/ui/dbgui/PivotLayoutDialog.cxx |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 0b9dd2446c33fda77fa18eec7ae86831af9c82e6
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Tue Jan 26 11:55:42 2016 +0100

    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 at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/sc/source/ui/dbgui/PivotLayoutDialog.cxx b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
index 83beb7e..f52fe4d 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;
         }
     }
 


More information about the Libreoffice-commits mailing list