diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-11-30 05:55:55 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-11-30 05:55:55 +0100 |
commit | f8f0f56f77beb61c5651adfce0dffb8e943c1472 (patch) | |
tree | 354ddad07bc13c75529fad7d1abc4ce40b185163 | |
parent | 2f9e09a6efedbdfe811bc1d2aba687d653af4efe (diff) |
Make Pivot table db & external source dialogs asyncfeature/eszka
Change-Id: Iff1a49a9fa04b55ece1aa30259ab57d105883eda
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.hxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 199 |
3 files changed, 126 insertions, 89 deletions
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 11d9b5aa743a..5e36cd557a59 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -2852,124 +2852,149 @@ void ScCellShell::ExecuteDataPilotDialog() pTypeDlg->StartExecuteAsync([this, pTypeDlg, pTabViewShell, pScMod, pFact, pDoc, &rMark, &aDestPos](int nResult) { - 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 nResult) { + if ( nResult == 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 nResult) { + if ( nResult == 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(); }); } } |