summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorcodewithvk <vivek.javiya@collabora.com>2023-12-10 23:30:47 +0530
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-01-10 10:49:23 +0100
commit4b33e878a446b0bcdb1d5f882a05a256967eea54 (patch)
tree719ee78d18a017f25a31edd3790bf2eb65e4971a /sc/source/ui
parente80842b37ed8b3e76dce68719ac0dfbeaefd567c (diff)
Make format condition, chart delete and pivot table error async
todo: Make executeDlg_ObjectProperties_withoutUndoGuard dialogs to async. Signed-off-by: codewithvk <vivek.javiya@collabora.com> Change-Id: I9927c1008d34370b9394aaf653afb575f69f2d45 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160557 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161703 Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/view/cellsh1.cxx151
1 files changed, 86 insertions, 65 deletions
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 35e4eec23ebc..4907b6b50c05 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -170,6 +170,49 @@ void SetTabNoAndCursor( const ScViewData& rViewData, std::u16string_view rCellId
}
}
+void HandleConditionalFormat(sal_uInt32 nIndex, bool bCondFormatDlg, bool bContainsCondFormat,
+ const sal_uInt16 nSlot, SfxViewShell* pTabViewShell)
+{
+ condformat::dialog::ScCondFormatDialogType eType = condformat::dialog::NONE;
+ switch (nSlot)
+ {
+ case SID_OPENDLG_CONDFRMT:
+ case SID_OPENDLG_CURRENTCONDFRMT:
+ eType = condformat::dialog::CONDITION;
+ break;
+ case SID_OPENDLG_COLORSCALE:
+ eType = condformat::dialog::COLORSCALE;
+ break;
+ case SID_OPENDLG_DATABAR:
+ eType = condformat::dialog::DATABAR;
+ break;
+ case SID_OPENDLG_ICONSET:
+ eType = condformat::dialog::ICONSET;
+ break;
+ case SID_OPENDLG_CONDDATE:
+ eType = condformat::dialog::DATE;
+ break;
+ default:
+ assert(false);
+ break;
+ }
+
+ if (bCondFormatDlg || !bContainsCondFormat)
+ {
+ // Put the xml string parameter to initialize the
+ // Conditional Format Dialog.
+ ScCondFormatDlgItem aDlgItem(nullptr, nIndex, false); // Change here
+ aDlgItem.SetDialogType(eType);
+ pTabViewShell->GetPool().DirectPutItemInPool(aDlgItem);
+
+ sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId();
+ SfxViewFrame& rViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = rViewFrm.GetChildWindow(nId);
+
+ SC_MOD()->SetRefDialog(nId, pWnd == nullptr);
+ }
+}
+
void InsertCells(ScTabViewShell* pTabViewShell, SfxRequest &rReq, InsCellCmd eCmd)
{
if (eCmd!=INS_NONE)
@@ -2156,7 +2199,6 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
}
// try to find an existing conditional format
- const ScConditionalFormat* pCondFormat = nullptr;
const ScPatternAttr* pPattern = rDoc.GetPattern(aPos.Col(), aPos.Row(), aPos.Tab());
ScConditionalFormatList* pList = rDoc.GetCondFormList(aPos.Tab());
const ScCondFormatIndexes& rCondFormats = pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
@@ -2168,7 +2210,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
for (const auto& rCondFormat : rCondFormats)
{
// check if at least one existing conditional format has the same range
- pCondFormat = pList->GetFormat(rCondFormat);
+ const ScConditionalFormat* pCondFormat = pList->GetFormat(rCondFormat);
if(!pCondFormat)
continue;
@@ -2345,78 +2387,57 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
// or should create a new overlapping conditional format
if(bContainsCondFormat && !bCondFormatDlg && bContainsExistingCondFormat)
{
- 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_EDIT_EXISTING_COND_FORMATS), pTabViewShell));
xQueryBox->set_default_response(RET_YES);
- bool bEditExisting = xQueryBox->run() == RET_YES;
- if (bEditExisting)
- {
- // differentiate between ranges where one conditional format is defined
- // and several formats are defined
- // if we have only one => open the cond format dlg to edit it
- // otherwise open the manage cond format dlg
- if (rCondFormats.size() == 1)
+ xQueryBox->runAsync(xQueryBox, [this, nIndex, nSlot, aPos, pTabViewShell] (int nResult) {
+ sal_uInt32 nNewIndex = nIndex;
+ bool bNewCondFormatDlg = false;
+
+ // use fresh data
+ ScDocument& rInnerDoc = GetViewData().GetDocument();
+ const ScPatternAttr* pInnerPattern = rInnerDoc.GetPattern(aPos.Col(), aPos.Row(), aPos.Tab());
+ ScConditionalFormatList* pInnerList = rInnerDoc.GetCondFormList(aPos.Tab());
+ const ScCondFormatIndexes& rInnerCondFormats = pInnerPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
+ bool bInnerContainsCondFormat = !rInnerCondFormats.empty();
+
+ bool bEditExisting = nResult == RET_YES;
+ if (bEditExisting)
{
- pCondFormat = pList->GetFormat(rCondFormats[0]);
- assert(pCondFormat);
- nIndex = pCondFormat->GetKey();
- bCondFormatDlg = true;
+ // differentiate between ranges where one conditional format is defined
+ // and several formats are defined
+ // if we have only one => open the cond format dlg to edit it
+ // otherwise open the manage cond format dlg
+ if (rInnerCondFormats.size() == 1)
+ {
+ const ScConditionalFormat* pCondFormat = pInnerList->GetFormat(rInnerCondFormats[0]);
+ assert(pCondFormat);
+ nNewIndex = pCondFormat->GetKey();
+ bNewCondFormatDlg = true;
+ }
+ else
+ {
+ // Queue message to open Conditional Format Manager Dialog.
+ GetViewData().GetDispatcher().Execute(
+ SID_OPENDLG_CONDFRMT_MANAGER, SfxCallMode::ASYNCHRON);
+ return;
+ }
}
else
{
- // Queue message to open Conditional Format Manager Dialog.
- GetViewData().GetDispatcher().Execute( SID_OPENDLG_CONDFRMT_MANAGER, SfxCallMode::ASYNCHRON );
- break;
+ // define an overlapping conditional format
+ assert(pInnerList->GetFormat(rInnerCondFormats[0]));
+ bNewCondFormatDlg = true;
}
- }
- else
- {
- // define an overlapping conditional format
- pCondFormat = pList->GetFormat(rCondFormats[0]);
- assert(pCondFormat);
- bCondFormatDlg = true;
- }
- }
- condformat::dialog::ScCondFormatDialogType eType = condformat::dialog::NONE;
- switch(nSlot)
- {
- case SID_OPENDLG_CONDFRMT:
- case SID_OPENDLG_CURRENTCONDFRMT:
- eType = condformat::dialog::CONDITION;
- break;
- case SID_OPENDLG_COLORSCALE:
- eType = condformat::dialog::COLORSCALE;
- break;
- case SID_OPENDLG_DATABAR:
- eType = condformat::dialog::DATABAR;
- break;
- case SID_OPENDLG_ICONSET:
- eType = condformat::dialog::ICONSET;
- break;
- case SID_OPENDLG_CONDDATE:
- eType = condformat::dialog::DATE;
- break;
- default:
- assert(false);
- break;
+ HandleConditionalFormat(nNewIndex, bNewCondFormatDlg, bInnerContainsCondFormat,
+ nSlot, pTabViewShell);
+ });
}
-
-
- if(bCondFormatDlg || !bContainsCondFormat)
+ else
{
- // Put the xml string parameter to initialize the
- // Conditional Format Dialog.
- ScCondFormatDlgItem aDlgItem(nullptr, nIndex, false);
- aDlgItem.SetDialogType(eType);
- pTabViewShell->GetPool().DirectPutItemInPool(aDlgItem);
-
- sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId();
- SfxViewFrame& rViewFrm = pTabViewShell->GetViewFrame();
- SfxChildWindow* pWnd = rViewFrm.GetChildWindow( nId );
-
- pScMod->SetRefDialog( nId, pWnd == nullptr );
+ HandleConditionalFormat(nIndex, bCondFormatDlg, bContainsCondFormat, nSlot, pTabViewShell);
}
}
break;
@@ -3275,10 +3296,10 @@ void ErrorOrRunPivotLayoutDialog(TranslateId pSrcErrorId,
if (pSrcErrorId)
{
// Error occurred during data creation. Launch an error and bail out.
- std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
+ std::shared_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(),
VclMessageType::Info, VclButtonsType::Ok,
ScResId(pSrcErrorId)));
- xInfoBox->run();
+ xInfoBox->runAsync(xInfoBox, [] (int) {});
return;
}