summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/cellsh1.cxx
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-11-30 05:55:55 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2021-01-07 08:41:17 +0100
commit41cfe181e3eb4502847fb56955635852e3928d92 (patch)
tree0d3ac2ef095b157d723f2c6a78178fb5630244ce /sc/source/ui/view/cellsh1.cxx
parent29e36c699c610be4fe6f8a2fe21ae3e4c8bdbd38 (diff)
Make Pivot table db & external source dialogs async
Change-Id: Iff1a49a9fa04b55ece1aa30259ab57d105883eda Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106996 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108798 Tested-by: Jenkins
Diffstat (limited to 'sc/source/ui/view/cellsh1.cxx')
-rw-r--r--sc/source/ui/view/cellsh1.cxx199
1 files changed, 112 insertions, 87 deletions
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 26efd68b55dd..f38184ac3b1b 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2917,124 +2917,149 @@ void ScCellShell::ExecuteDataPilotDialog()
pTypeDlg->StartExecuteAsync([this, pTypeDlg, pTabViewShell,
pScMod, pFact, &rDoc, &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(&rDoc));
- pNewDPObject->SetServiceData( aServDesc );
- }
+ pServDlg->StartExecuteAsync([pServDlg, pScMod, pTabViewShell,
+ aDestPos, &rDoc](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(&rDoc));
+ 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(&rDoc);
- pDataDlg->GetValues( aImpDesc );
- pNewDPObject.reset(new ScDPObject(&rDoc));
- pNewDPObject->SetImportDesc( aImpDesc );
- }
+
+ pDataDlg->StartExecuteAsync([pDataDlg, pScMod, pTabViewShell,
+ aDestPos, &rDoc](int nResult2) mutable {
+ if ( nResult2 == RET_OK )
+ {
+ ScImportSourceDesc aImpDesc(&rDoc);
+ pDataDlg->GetValues( aImpDesc );
+ std::unique_ptr<ScDPObject> pNewDPObject(new ScDPObject(&rDoc));
+ 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(&rDoc);
- aShtDesc.SetRangeName(aName);
- pSrcErrorId = aShtDesc.CheckSourceRange();
- if (!pSrcErrorId)
+ std::unique_ptr<ScDPObject> pNewDPObject;
+ const char* pSrcErrorId = nullptr;
+
+ if (pTypeDlg->IsNamedRange())
{
- pNewDPObject.reset(new ScDPObject(&rDoc));
- pNewDPObject->SetSheetDesc(aShtDesc);
+ OUString aName = pTypeDlg->GetSelectedNamedRange();
+ ScSheetSourceDesc aShtDesc(&rDoc);
+ aShtDesc.SetRangeName(aName);
+ pSrcErrorId = aShtDesc.CheckSourceRange();
+ if (!pSrcErrorId)
+ {
+ pNewDPObject.reset(new ScDPObject(&rDoc));
+ 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 (rDoc.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 (rDoc.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 ( rDoc.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(&rDoc);
- aShtDesc.SetSourceRange(aRange);
- pSrcErrorId = aShtDesc.CheckSourceRange();
- if (!pSrcErrorId)
+ bool bOK = true;
+ if ( rDoc.HasSubTotalCells( aRange ) )
{
- pNewDPObject.reset(new ScDPObject(&rDoc));
- 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(&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() );
+ // output below source data
+ if ( aRange.aEnd.Row()+2 <= rDoc.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();
});
}
}