sc/inc/globstr.hrc | 4 ++- sc/source/ui/src/globstr.src | 4 +++ sc/source/ui/view/tabvwshf.cxx | 47 +++++++++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 7 deletions(-)
New commits: commit 65d10c4dedbf72f87888e14984393c222a5b31f9 Author: Abhilash Singh <abhilash300si...@gmail.com> Date: Sun Dec 11 12:31:32 2016 +0530 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 <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc index e06d921..68d48d9 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 357c377..b11808f 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 a62c76e..d5b8c90 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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits