Kaydet (Commit) 65d10c4d authored tarafından Abhilash Singh's avatar Abhilash Singh Kaydeden (comit) Eike Rathke

tdf#87111 Warn about data loss when deleting source data of pivot table

Change-Id: I59ab7551494622b8f1e68bfd9ef5e7ae19e65aee
Reviewed-on: https://gerrit.libreoffice.org/31852Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarEike Rathke <erack@redhat.com>
üst 81aef113
......@@ -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
......
......@@ -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: */
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment