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

Katarina Behrens Katarina.Behrens at cib.de
Wed Feb 3 21:38:03 UTC 2016


 sc/source/ui/dbgui/PivotLayoutDialog.cxx |   25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

New commits:
commit c0fa223db5f5c55ffb76dbb10b0e8187962f0cd8
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Tue Feb 2 17:35:03 2016 +0100

    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 at cib.de>
    Tested-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 f52fe4d..1ed0e93 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;
         }


More information about the Libreoffice-commits mailing list