diff options
author | Abhilash Singh <abhilash300singh@gmail.com> | 2016-12-11 12:31:32 +0530 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-01-03 13:28:27 +0000 |
commit | 65d10c4dedbf72f87888e14984393c222a5b31f9 (patch) | |
tree | b6a120ccb84232948aac12b1617b1fa3cee60572 | |
parent | 81aef113056270ce65f9dee5fe31b6f60617973c (diff) |
tdf#87111 Warn about data loss when deleting source data of pivot table
Change-Id: I59ab7551494622b8f1e68bfd9ef5e7ae19e65aee
Reviewed-on: https://gerrit.libreoffice.org/31852
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | sc/inc/globstr.hrc | 4 | ||||
-rw-r--r-- | sc/source/ui/src/globstr.src | 4 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshf.cxx | 47 |
3 files changed, 48 insertions, 7 deletions
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc index e06d9215c6bb..68d48d9e7da5 100644 --- a/sc/inc/globstr.hrc +++ b/sc/inc/globstr.hrc @@ -710,7 +710,9 @@ #define STR_BOOLEAN_VALUE 542 #define STR_TEXT 543 -#define SC_GLOBSTR_STR_COUNT 545 /**< the count of permanently resident strings */ +#define STR_QUERY_PIVOTTABLE_DELTAB 545 + +#define SC_GLOBSTR_STR_COUNT 546 /**< the count of permanently resident strings */ #endif diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src index 357c377775af..b11808fc0a89 100644 --- a/sc/source/ui/src/globstr.src +++ b/sc/source/ui/src/globstr.src @@ -2109,6 +2109,10 @@ Resource RID_GLOBSTR { Text [ en-US ] = "Text"; }; + String STR_QUERY_PIVOTTABLE_DELTAB + { + Text [ en-US ] = "The selected sheet(s) contain source data of related pivot tables that will be lost. Are you sure you want to delete the selected sheet(s)?"; + }; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index a62c76e2d6e3..d5b8c904a726 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -43,6 +43,8 @@ #include "globstr.hrc" #include "docfunc.hxx" #include "eventuno.hxx" +#include "dpobject.hxx" +#include "dpshttab.hxx" #include "scabstdlg.hxx" @@ -593,12 +595,45 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) bool bDoIt = bHasIndex; if (!bDoIt) { - // no parameter given, ask for confirmation - bDoIt = ( RET_YES == - ScopedVclPtrInstance<QueryBox>( GetDialogParent(), - WinBits( WB_YES_NO | WB_DEF_YES ), - ScGlobal::GetRscString(STR_QUERY_DELTAB) - )->Execute() ); + bool bTabWithPivotTable = false; + if (pDoc->HasPivotTable()) + { + const ScDPCollection* pDPs = pDoc->GetDPCollection(); + if (pDPs) + { + const ScMarkData::MarkedTabsType& rSelectedTabs = rViewData.GetMarkData().GetSelectedTabs(); + for (ScMarkData::MarkedTabsType::const_iterator iterator = rSelectedTabs.begin(); + iterator != rSelectedTabs.end() && !bTabWithPivotTable; ++iterator ) + { + const SCTAB nSelTab = *iterator; + const size_t nCount = pDPs->GetCount(); + for (size_t i = 0; i < nCount; ++i) + { + const ScDPObject& rDPObj = (*pDPs)[i]; + const ScSheetSourceDesc* pSheetSourceDesc = rDPObj.GetSheetDesc(); + if (pSheetSourceDesc->GetSourceRange().aStart.Tab() == nSelTab) + bTabWithPivotTable = true; + } + } + } + } + + if (bTabWithPivotTable) + { + // Hard warning as there is potential of data loss on deletion + bDoIt = ( RET_YES == + ScopedVclPtrInstance<QueryBox>( GetDialogParent(), + WinBits( WB_YES_NO | WB_DEF_NO ), + ScGlobal::GetRscString(STR_QUERY_PIVOTTABLE_DELTAB))->Execute() ); + } + else + { + // no parameter given, ask for confirmation + bDoIt = ( RET_YES == + ScopedVclPtrInstance<QueryBox>( GetDialogParent(), + WinBits( WB_YES_NO | WB_DEF_YES ), + ScGlobal::GetRscString(STR_QUERY_DELTAB))->Execute() ); + } } if (bDoIt) |