summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2023-11-16 19:28:21 +0000
committerMichael Meeks <michael.meeks@collabora.com>2023-11-20 14:37:01 +0100
commit13eb599d8b0f81e4024f4aa2a6dd8b074f80a9df (patch)
tree60f48f5412c59fe14da3efd6637429548bfb22d9
parenta57f2ec591e6081ae32d6e4efb75768321494912 (diff)
lok: async calc merge-cells popup dialog.
Change-Id: I6f7d1e8de4ac36f546706f7702157cc7e49c80b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159581 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--sc/source/ui/inc/viewfunc.hxx3
-rw-r--r--sc/source/ui/undo/undoblk3.cxx3
-rw-r--r--sc/source/ui/view/cellsh3.cxx8
-rw-r--r--sc/source/ui/view/viewfun2.cxx96
4 files changed, 60 insertions, 50 deletions
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 45b053f3d33d..52e2aedd9d22 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -236,7 +236,8 @@ public:
bool TestMergeCells();
bool TestRemoveMerge();
- bool MergeCells( bool bApi, bool& rDoContents, bool bCenter );
+ void MergeCells( bool bApi, bool bDoContents, bool bCenter,
+ const sal_uInt16 nSlot );
bool RemoveMerge();
SC_DLLPUBLIC void
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index b7b615d6608f..bc967d96d47f 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -755,8 +755,7 @@ void ScUndoMerge::Repeat(SfxRepeatTarget& rTarget)
if (auto pViewTarget = dynamic_cast<ScTabViewTarget*>( &rTarget))
{
ScTabViewShell& rViewShell = *pViewTarget->GetViewShell();
- bool bCont = false;
- rViewShell.MergeCells( false, bCont, false );
+ rViewShell.MergeCells( false, false, false, 0 );
}
}
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index e052952ff664..e6c89b6a2b9c 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -943,13 +943,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
bMoveContents = static_cast<const SfxBoolItem*>(pItem)->GetValue();
}
- if (pTabViewShell->MergeCells( bApi, bMoveContents, bCenter ))
- {
- if (!bApi && bMoveContents) // "yes" clicked in dialog
- rReq.AppendItem( SfxBoolItem( nSlot, bMoveContents ) );
- rBindings.Invalidate( nSlot );
- rReq.Done();
- }
+ pTabViewShell->MergeCells( bApi, bMoveContents, bCenter, nSlot );
}
else
{
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index c2a7bfac2797..42c3ba2a62cd 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -20,6 +20,7 @@
#include <scitems.hxx>
#include <sfx2/app.hxx>
+#include <sfx2/request.hxx>
#include <editeng/borderline.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/fontitem.hxx>
@@ -1179,7 +1180,8 @@ bool ScViewFunc::TestMergeCells() // pre-test (for menu)
return false;
}
-bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bCenter )
+void ScViewFunc::MergeCells( bool bApi, bool bDoContents, bool bCenter,
+ const sal_uInt16 nSlot )
{
// Editable- and Being-Nested- test must be at the beginning (in DocFunc too),
// so that the Contents-QueryBox won't appear
@@ -1187,7 +1189,7 @@ bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bCenter )
if (!aTester.IsEditable())
{
ErrorMessage(aTester.GetMessageId());
- return false;
+ return;
}
ScMarkData& rMark = GetViewData().GetMarkData();
@@ -1195,7 +1197,7 @@ bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bCenter )
if (!rMark.IsMarked())
{
ErrorMessage(STR_NOMULTISELECT);
- return false;
+ return;
}
ScDocShell* pDocSh = GetViewData().GetDocShell();
@@ -1211,14 +1213,14 @@ bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bCenter )
if ( nStartCol == nEndCol && nStartRow == nEndRow )
{
// nothing to do
- return true;
+ return;
}
if ( rDoc.HasAttrib( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
HasAttrFlags::Merged | HasAttrFlags::Overlapped ) )
{ // "Don't nest merging !"
ErrorMessage(STR_MSSG_MERGECELLS_0);
- return false;
+ return;
}
// Check for the contents of all selected tables.
@@ -1241,7 +1243,7 @@ bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bCenter )
{
// this range contains only one data cell.
if (nStartCol != aState.mnCol1 || nStartRow != aState.mnRow1)
- rDoContents = true; // move the value to the top-left.
+ bDoContents = true; // move the value to the top-left.
break;
}
default:
@@ -1249,61 +1251,75 @@ bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bCenter )
}
}
- bool bOk = true;
bool bEmptyMergedCells = officecfg::Office::Calc::Compatibility::MergeCells::EmptyMergedCells::get();
+ auto doMerge = [this, pDocSh, aMergeOption, bApi, nStartCol, nStartRow, aMarkRange]
+ (bool bNowDoContents, bool bNowEmptyMergedCells)
+ {
+ if (pDocSh->GetDocFunc().MergeCells(aMergeOption, bNowDoContents, true/*bRecord*/,
+ bApi, bNowEmptyMergedCells))
+ {
+ SetCursor( nStartCol, nStartRow );
+ // DoneBlockMode( sal_False);
+ Unmark();
+
+ pDocSh->UpdateOle(GetViewData());
+ UpdateInputLine();
+
+ OUString aStartAddress = aMarkRange.aStart.GetColRowString();
+ OUString aEndAddress = aMarkRange.aEnd.GetColRowString();
+
+ collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}, "MERGE_CELLS");
+ }
+ };
+
if (bAskDialog)
{
bool bShowDialog = officecfg::Office::Calc::Compatibility::MergeCells::ShowDialog::get();
if (!bApi && bShowDialog)
{
- ScMergeCellsDialog aBox(GetViewData().GetDialogParent());
- sal_uInt16 nRetVal = aBox.run();
+ auto pBox = std::make_shared<ScMergeCellsDialog>(GetViewData().GetDialogParent());
- if ( nRetVal == RET_OK )
- {
- switch (aBox.GetMergeCellsOption())
+ SfxViewShell* pViewShell = GetViewData().GetViewShell();
+
+ weld::DialogController::runAsync(pBox, [=](sal_Int32 nRetVal) {
+ if (nRetVal == RET_OK)
{
+ bool bRealDoContents = bDoContents;
+ bool bRealEmptyMergedCells = bEmptyMergedCells;
+ switch (pBox->GetMergeCellsOption())
+ {
case MoveContentHiddenCells:
- rDoContents = true;
+ bRealDoContents = true;
break;
case KeepContentHiddenCells:
- bEmptyMergedCells = false;
+ bRealEmptyMergedCells = false;
break;
case EmptyContentHiddenCells:
- bEmptyMergedCells = true;
+ bRealEmptyMergedCells = true;
break;
default:
assert(!"Unknown option for merge cells.");
break;
- }
- }
- else if ( nRetVal == RET_CANCEL )
- bOk = false;
- }
- }
-
- if (bOk)
- {
- bOk = pDocSh->GetDocFunc().MergeCells( aMergeOption, rDoContents, true/*bRecord*/, bApi, bEmptyMergedCells );
-
- if (bOk)
- {
- SetCursor( nStartCol, nStartRow );
- //DoneBlockMode( sal_False);
- Unmark();
-
- pDocSh->UpdateOle(GetViewData());
- UpdateInputLine();
+ }
- OUString aStartAddress = aMarkRange.aStart.GetColRowString();
- OUString aEndAddress = aMarkRange.aEnd.GetColRowString();
+ doMerge(bRealDoContents, bRealEmptyMergedCells);
- collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}, "MERGE_CELLS");
+ if (nSlot != 0)
+ {
+ SfxRequest aReq(pViewShell->GetViewFrame(), nSlot);
+ if (!bApi && bRealDoContents)
+ aReq.AppendItem(SfxBoolItem(nSlot, bDoContents));
+ SfxBindings& rBindings = pViewShell->GetViewFrame().GetBindings();
+ rBindings.Invalidate(nSlot);
+ aReq.Done();
+ }
+ }
+ // else cancelled
+ });
}
- }
-
- return bOk;
+ } else
+ doMerge(bDoContents, bEmptyMergedCells);
}
bool ScViewFunc::TestRemoveMerge()