sc/source/ui/attrdlg/scdlgfact.cxx | 10 + sc/source/ui/attrdlg/scdlgfact.hxx | 6 - sc/source/ui/view/cellsh1.cxx | 200 ++++++++++++++++++++----------------- 3 files changed, 126 insertions(+), 90 deletions(-)
New commits: commit a5b021561545bdda65c8233e541c2090a0243f74 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Mon Nov 30 05:55:55 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Tue Dec 1 18:54:01 2020 +0100 Make Pivot table db & external source dialogs async Change-Id: Iff1a49a9fa04b55ece1aa30259ab57d105883eda Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106996 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index cb9d07c008ad..b5629728d356 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -105,6 +105,11 @@ short AbstractScDataPilotDatabaseDlg_Impl::Execute() return m_xDlg->run(); } +bool AbstractScDataPilotDatabaseDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + short AbstractScDataPilotSourceTypeDlg_Impl::Execute() { return m_xDlg->run(); @@ -120,6 +125,11 @@ short AbstractScDataPilotServiceDlg_Impl::Execute() return m_xDlg->run(); } +bool AbstractScDataPilotServiceDlg_Impl::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) +{ + return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + short AbstractScDeleteCellDlg_Impl::Execute() { return m_xDlg->run(); diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index 582d189ef4c0..91f6040b7842 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -165,13 +165,14 @@ public: class AbstractScDataPilotDatabaseDlg_Impl :public AbstractScDataPilotDatabaseDlg { - std::unique_ptr<ScDataPilotDatabaseDlg> m_xDlg; + std::shared_ptr<ScDataPilotDatabaseDlg> m_xDlg; public: explicit AbstractScDataPilotDatabaseDlg_Impl(std::unique_ptr<ScDataPilotDatabaseDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &) override; virtual void GetValues( ScImportSourceDesc& rDesc ) override; // screenshotting @@ -202,13 +203,14 @@ public: class AbstractScDataPilotServiceDlg_Impl : public AbstractScDataPilotServiceDlg { - std::unique_ptr<ScDataPilotServiceDlg> m_xDlg; + std::shared_ptr<ScDataPilotServiceDlg> m_xDlg; public: explicit AbstractScDataPilotServiceDlg_Impl(std::unique_ptr<ScDataPilotServiceDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &) override; virtual OUString GetServiceName() const override; virtual OUString GetParSource() const override; virtual OUString GetParName() const override; diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index f5d8a0ab17ea..26ef479f914f 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2852,124 +2852,148 @@ void ScCellShell::ExecuteDataPilotDialog() pTypeDlg->StartExecuteAsync([this, pTypeDlg, pTabViewShell, pScMod, pFact, pDoc, &rMark, aDestPos](int nResult) mutable { - const char* pSrcErrorId = nullptr; - std::unique_ptr<ScDPObject> pNewDPObject; - if (nResult == RET_OK ) { if ( pTypeDlg->IsExternal() ) { std::vector<OUString> aSources = ScDPObject::GetRegisteredSources(); - ScopedVclPtr<AbstractScDataPilotServiceDlg> pServDlg( + VclPtr<AbstractScDataPilotServiceDlg> pServDlg( pFact->CreateScDataPilotServiceDlg( pTabViewShell->GetFrameWeld(), aSources)); - if ( pServDlg->Execute() == RET_OK ) - { - ScDPServiceDesc aServDesc( - pServDlg->GetServiceName(), - pServDlg->GetParSource(), - pServDlg->GetParName(), - pServDlg->GetParUser(), - pServDlg->GetParPass() ); - pNewDPObject.reset(new ScDPObject(pDoc)); - pNewDPObject->SetServiceData( aServDesc ); - } + pServDlg->StartExecuteAsync([pServDlg, pScMod, pTabViewShell, + aDestPos, pDoc](int nResult2) mutable { + if ( nResult2 == RET_OK ) + { + ScDPServiceDesc aServDesc( + pServDlg->GetServiceName(), + pServDlg->GetParSource(), + pServDlg->GetParName(), + pServDlg->GetParUser(), + pServDlg->GetParPass() ); + std::unique_ptr<ScDPObject> pNewDPObject(new ScDPObject(pDoc)); + pNewDPObject->SetServiceData( aServDesc ); + + if ( pNewDPObject ) + pNewDPObject->SetOutRange( aDestPos ); + + RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject); + } + + pServDlg->disposeOnce(); + }); } else if ( pTypeDlg->IsDatabase() ) { assert(pFact && "ScAbstractFactory create fail!"); - ScopedVclPtr<AbstractScDataPilotDatabaseDlg> pDataDlg( + VclPtr<AbstractScDataPilotDatabaseDlg> pDataDlg( pFact->CreateScDataPilotDatabaseDlg(pTabViewShell->GetFrameWeld())); assert(pDataDlg && "Dialog create fail!"); - if ( pDataDlg->Execute() == RET_OK ) - { - ScImportSourceDesc aImpDesc(pDoc); - pDataDlg->GetValues( aImpDesc ); - pNewDPObject.reset(new ScDPObject(pDoc)); - pNewDPObject->SetImportDesc( aImpDesc ); - } + + pDataDlg->StartExecuteAsync([pDataDlg, pScMod, pTabViewShell, + aDestPos, pDoc](int nResult2) mutable { + if ( nResult2 == RET_OK ) + { + ScImportSourceDesc aImpDesc(pDoc); + pDataDlg->GetValues( aImpDesc ); + std::unique_ptr<ScDPObject> pNewDPObject(new ScDPObject(pDoc)); + pNewDPObject->SetImportDesc( aImpDesc ); + + if ( pNewDPObject ) + pNewDPObject->SetOutRange( aDestPos ); + + RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject); + } + + pDataDlg->disposeOnce(); + }); } - else if (pTypeDlg->IsNamedRange()) + else { - OUString aName = pTypeDlg->GetSelectedNamedRange(); - ScSheetSourceDesc aShtDesc(pDoc); - aShtDesc.SetRangeName(aName); - pSrcErrorId = aShtDesc.CheckSourceRange(); - if (!pSrcErrorId) + std::unique_ptr<ScDPObject> pNewDPObject; + const char* pSrcErrorId = nullptr; + + if (pTypeDlg->IsNamedRange()) { - pNewDPObject.reset(new ScDPObject(pDoc)); - pNewDPObject->SetSheetDesc(aShtDesc); + OUString aName = pTypeDlg->GetSelectedNamedRange(); + ScSheetSourceDesc aShtDesc(pDoc); + aShtDesc.SetRangeName(aName); + pSrcErrorId = aShtDesc.CheckSourceRange(); + if (!pSrcErrorId) + { + pNewDPObject.reset(new ScDPObject(pDoc)); + pNewDPObject->SetSheetDesc(aShtDesc); + } } - } - else // selection - { - //! use database ranges (select before type dialog?) - ScRange aRange; - ScMarkType eType = GetViewData()->GetSimpleArea(aRange); - if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE ) + else // selection { - // 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(); - if (pDoc->ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow)) + //! use database ranges (select before type dialog?) + ScRange aRange; + ScMarkType eType = GetViewData()->GetSimpleArea(aRange); + if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE ) { - aRange.aStart.SetCol(nStartCol); - aRange.aStart.SetRow(nStartRow); - aRange.aEnd.SetCol(nEndCol); - aRange.aEnd.SetRow(nEndRow); - rMark.SetMarkArea(aRange); - pTabViewShell->MarkRange(aRange); - } + // 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(); + if (pDoc->ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow)) + { + aRange.aStart.SetCol(nStartCol); + aRange.aStart.SetRow(nStartRow); + aRange.aEnd.SetCol(nEndCol); + aRange.aEnd.SetRow(nEndRow); + rMark.SetMarkArea(aRange); + 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(), - VclMessageType::Question, VclButtonsType::YesNo, - ScResId(STR_DATAPILOT_SUBTOTAL))); - xQueryBox->set_default_response(RET_YES); - if (xQueryBox->run() == RET_NO) - bOK = false; - } - if (bOK) - { - ScSheetSourceDesc aShtDesc(pDoc); - aShtDesc.SetSourceRange(aRange); - pSrcErrorId = aShtDesc.CheckSourceRange(); - if (!pSrcErrorId) + bool bOK = true; + if ( pDoc->HasSubTotalCells( aRange ) ) { - pNewDPObject.reset(new ScDPObject(pDoc)); - pNewDPObject->SetSheetDesc( aShtDesc ); + // confirm selection if it contains SubTotal cells + std::unique_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; } + 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() ); + // output below source data + if ( aRange.aEnd.Row()+2 <= pDoc->MaxRow() - 4 ) + aDestPos = ScAddress( aRange.aStart.Col(), + aRange.aEnd.Row()+2, + aRange.aStart.Tab() ); + } } } - } - } - 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 (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 ); + if ( pNewDPObject ) + pNewDPObject->SetOutRange( aDestPos ); - pTypeDlg->disposeOnce(); + RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject); + } + } - RunPivotLayoutDialog(pScMod, pTabViewShell, pNewDPObject); + pTypeDlg->disposeOnce(); }); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits