summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-01-05 14:54:52 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2021-04-19 15:00:02 +0200
commitb940edac3b91a76ce6c1a98fb76cd6ad4b1d95ee (patch)
treef0e5c69a33f17c973ff30a30039dd52f0b3328b9 /sc
parent13a93fd97b01adf5ab6a774cd354c51402dc96ff (diff)
pivot table: make partial sum message box async
Change-Id: I63011526d60f332ee56edebf5bf48b30ad6b2a94 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108807 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114211 Tested-by: Jenkins
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/view/cellsh1.cxx101
1 files changed, 65 insertions, 36 deletions
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 84e6422d3511..c9e7a0a57978 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2901,6 +2901,50 @@ void RunPivotLayoutDialog(ScModule* pScMod,
}
}
+void SetupRangeForPivotTableDialog(const ScRange& rRange,
+ ScAddress& rDestPos,
+ ScDocument* pDoc,
+ const char* pSrcErrorId,
+ std::unique_ptr<ScDPObject>& pNewDPObject)
+{
+ ScSheetSourceDesc aShtDesc(pDoc);
+ aShtDesc.SetSourceRange(rRange);
+ pSrcErrorId = aShtDesc.CheckSourceRange();
+ if (!pSrcErrorId)
+ {
+ pNewDPObject.reset(new ScDPObject(pDoc));
+ pNewDPObject->SetSheetDesc( aShtDesc );
+ }
+
+ // output below source data
+ if ( rRange.aEnd.Row()+2 <= pDoc->MaxRow() - 4 )
+ rDestPos = ScAddress( rRange.aStart.Col(),
+ rRange.aEnd.Row()+2,
+ rRange.aStart.Tab() );
+}
+
+void ErrorOrRunPivotLayoutDialog(const char* pSrcErrorId,
+ ScAddress& rDestPos,
+ ScModule* pScMod,
+ ScTabViewShell* pTabViewShell,
+ std::unique_ptr<ScDPObject>& pNewDPObject)
+{
+ if (pSrcErrorId)
+ {
+ // Error occurred during data creation. Launch an error and bail out.
+ std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
+ VclMessageType::Info, VclButtonsType::Ok,
+ ScResId(pSrcErrorId)));
+ xInfoBox->run();
+ return;
+ }
+
+ if ( pNewDPObject )
+ pNewDPObject->SetOutRange( rDestPos );
+
+ RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject);
+}
+
}
void ScCellShell::ExecuteDataPilotDialog()
@@ -3015,11 +3059,11 @@ void ScCellShell::ExecuteDataPilotDialog()
}
else
{
- std::unique_ptr<ScDPObject> pNewDPObject;
const char* pSrcErrorId = nullptr;
if (pTypeDlg->IsNamedRange())
{
+ std::unique_ptr<ScDPObject> pNewDPObject;
OUString aName = pTypeDlg->GetSelectedNamedRange();
ScSheetSourceDesc aShtDesc(&rDoc);
aShtDesc.SetRangeName(aName);
@@ -3029,6 +3073,8 @@ void ScCellShell::ExecuteDataPilotDialog()
pNewDPObject.reset(new ScDPObject(&rDoc));
pNewDPObject->SetSheetDesc(aShtDesc);
}
+
+ ErrorOrRunPivotLayoutDialog(pSrcErrorId, aDestPos, pScMod, pTabViewShell, pNewDPObject);
}
else // selection
{
@@ -3037,6 +3083,8 @@ void ScCellShell::ExecuteDataPilotDialog()
ScMarkType eType = GetViewData()->GetSimpleArea(aRange);
if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE )
{
+ ScDocument* pDoc = &rDoc;
+
// Shrink the range to the data area.
SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col();
SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row();
@@ -3050,51 +3098,32 @@ void ScCellShell::ExecuteDataPilotDialog()
pTabViewShell->MarkRange(aRange);
}
- bool bOK = true;
if ( rDoc.HasSubTotalCells( aRange ) )
{
// confirm selection if it contains SubTotal cells
- std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
+ std::shared_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
VclMessageType::Question, VclButtonsType::YesNo,
ScResId(STR_DATAPILOT_SUBTOTAL)));
xQueryBox->set_default_response(RET_YES);
- if (xQueryBox->run() == RET_NO)
- bOK = false;
+ xQueryBox->runAsync(xQueryBox, [aRange, pDoc, pTypeDlg, aDestPos,
+ pScMod, pTabViewShell, pSrcErrorId] (int nResult2) mutable {
+ if (nResult2 == RET_NO)
+ return;
+
+ std::unique_ptr<ScDPObject> pNewDPObject;
+ SetupRangeForPivotTableDialog(aRange, aDestPos, pDoc, pSrcErrorId, pNewDPObject);
+ ErrorOrRunPivotLayoutDialog(pSrcErrorId, aDestPos, pScMod, pTabViewShell, pNewDPObject);
+ });
+
+ pTypeDlg->disposeOnce();
+ return;
}
- if (bOK)
- {
- ScSheetSourceDesc aShtDesc(&rDoc);
- aShtDesc.SetSourceRange(aRange);
- pSrcErrorId = aShtDesc.CheckSourceRange();
- if (!pSrcErrorId)
- {
- pNewDPObject.reset(new ScDPObject(&rDoc));
- pNewDPObject->SetSheetDesc( aShtDesc );
- }
- // output below source data
- if ( aRange.aEnd.Row()+2 <= rDoc.MaxRow() - 4 )
- aDestPos = ScAddress( aRange.aStart.Col(),
- aRange.aEnd.Row()+2,
- aRange.aStart.Tab() );
- }
+ std::unique_ptr<ScDPObject> pNewDPObject;
+ SetupRangeForPivotTableDialog(aRange, aDestPos, pDoc, pSrcErrorId, pNewDPObject);
+ ErrorOrRunPivotLayoutDialog(pSrcErrorId, aDestPos, pScMod, pTabViewShell, pNewDPObject);
}
}
-
- if (pSrcErrorId)
- {
- // Error occurred during data creation. Launch an error and bail out.
- std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
- VclMessageType::Info, VclButtonsType::Ok,
- ScResId(pSrcErrorId)));
- xInfoBox->run();
- return;
- }
-
- if ( pNewDPObject )
- pNewDPObject->SetOutRange( aDestPos );
-
- RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject);
}
}