tdf#137899 sc: accept any unfinished editing before adding sheet
There might be a more general place where this belongs,
to cover other similar kinds of situations.
However, putting it here is very targetted,
and shouldn't get me into unanticipated trouble.
Any changes made in the "top view" need to be accepted before
they are committed. In this case, the user switched gears
and added a new sheet while in the process of editing.
So what should happen here? Should we commit the change
before changing task? Perhaps. Certainly it should
NOT show up on the new sheet - but that is what was happening.
Accepting the change when the user gets side-tracked is the norm
in cases like print-preview, switching to another soffice app,
or simply clicking on a different cell or switching tabs.
So auto-accepting in this situation is consistent behaviour.
Change-Id: I4f3f0103ad4fcc1aa8a0c6118383b63ace07ff5e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126501
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Reviewed-by: Eike Rathke <erack@redhat.com>
diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
index a95df55..a15b1c2 100644
--- a/sc/source/ui/view/tabcont.cxx
+++ b/sc/source/ui/view/tabcont.cxx
@@ -234,6 +234,11 @@ void ScTabControl::AddTabClick()
ScModule* pScMod = SC_MOD();
if (!rDoc.IsDocEditable() || pScMod->IsTableLocked())
return;
// auto-accept any in-process input - which would otherwise end up on the new sheet
if (!pScMod->IsFormulaMode())
pScMod->InputEnterHandler();
OUString aName;
rDoc.CreateValidTabName(aName);
SCTAB nTabCount = rDoc.GetTableCount();