sc/source/ui/view/cellsh1.cxx | 99 ++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 36 deletions(-)
New commits: commit 3286d9a70bda46da2685a23ff6f353fbb1e055f4 Author: Szymon Kłos <[email protected]> AuthorDate: Tue Jan 5 14:54:52 2021 +0100 Commit: Szymon Kłos <[email protected]> CommitDate: Wed Jan 6 11:50:55 2021 +0100 pivot table: make partial sum message box async Change-Id: I63011526d60f332ee56edebf5bf48b30ad6b2a94 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108807 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 26ef479f914f..eb81697a4dfd 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2797,6 +2797,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() @@ -2910,11 +2954,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(pDoc); aShtDesc.SetRangeName(aName); @@ -2924,6 +2968,8 @@ void ScCellShell::ExecuteDataPilotDialog() pNewDPObject.reset(new ScDPObject(pDoc)); pNewDPObject->SetSheetDesc(aShtDesc); } + + ErrorOrRunPivotLayoutDialog(pSrcErrorId, aDestPos, pScMod, pTabViewShell, pNewDPObject); } else // selection { @@ -2945,51 +2991,32 @@ void ScCellShell::ExecuteDataPilotDialog() pTabViewShell->MarkRange(aRange); } - bool bOK = true; if ( pDoc->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(pDoc); - aShtDesc.SetSourceRange(aRange); - pSrcErrorId = aShtDesc.CheckSourceRange(); - if (!pSrcErrorId) - { - pNewDPObject.reset(new ScDPObject(pDoc)); - pNewDPObject->SetSheetDesc( aShtDesc ); - } - // output below source data - if ( aRange.aEnd.Row()+2 <= pDoc->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); } } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
