[Libreoffice-commits] core.git: sc/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Oct 15 07:59:10 UTC 2019
sc/source/ui/inc/namedlg.hxx | 1 -
sc/source/ui/inc/namemgrtable.hxx | 17 +++++++++++++++++
sc/source/ui/namedlg/namedlg.cxx | 10 ++++++----
sc/source/ui/namedlg/namemgrtable.cxx | 13 +++++++++++--
4 files changed, 34 insertions(+), 7 deletions(-)
New commits:
commit 09cd127981c18ab847aab736980455efbbe4df54
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Oct 14 19:40:47 2019 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Oct 15 09:57:50 2019 +0200
Resolves: tdf#128137 cursor jumping during edit, etc.
The mbNeedUpdate hackery to block changes caused by the
user was subverted by the async handling of the treeview selection.
a) add a call to wait and process outstanding async events within
the protected block
b) move the needupdate down to the range manager to block updates during
this block in CheckForFormulaString too
c) when updating the visible rows, also update the selected rows even if they
are not visible.
Change-Id: I4c67d6cd2780f55d5eab5f856f6fda21703b4977
Reviewed-on: https://gerrit.libreoffice.org/80794
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
index ed3e576b5e37..6442eae743a2 100644
--- a/sc/source/ui/inc/namedlg.hxx
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -43,7 +43,6 @@ private:
ScDocument* mpDoc;
const ScAddress maCursorPos;
- bool mbNeedUpdate;
bool mbDataChanged;
//ugly hack to call DefineNames from ManageNames
bool mbCloseWithoutUndo;
diff --git a/sc/source/ui/inc/namemgrtable.hxx b/sc/source/ui/inc/namemgrtable.hxx
index 3ee3925254cc..9b6ce575440d 100644
--- a/sc/source/ui/inc/namemgrtable.hxx
+++ b/sc/source/ui/inc/namemgrtable.hxx
@@ -45,6 +45,8 @@ private:
int m_nId;
+ bool mbNeedUpdate;
+
void GetLine(ScRangeNameLine& aLine, const weld::TreeIter& rEntry);
void Init();
const ScRangeData* findRangeData(const ScRangeNameLine& rLine);
@@ -70,6 +72,21 @@ public:
void GetCurrentLine(ScRangeNameLine& rLine);
bool IsMultiSelection() const;
std::vector<ScRangeNameLine> GetSelectedEntries();
+
+ void BlockUpdate()
+ {
+ mbNeedUpdate = false;
+ }
+
+ bool UpdatesBlocked() const
+ {
+ return !mbNeedUpdate;
+ }
+
+ void UnblockUpdate()
+ {
+ mbNeedUpdate = true;
+ }
};
#endif
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index de92dedaa9be..cdb9e5b18077 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -33,6 +33,7 @@
#include <tokenarray.hxx>
#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
#include <formula/errorcodes.hxx>
#include <unotools/charclass.hxx>
@@ -55,7 +56,6 @@ ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParen
, mpViewData(ptrViewData)
, mpDoc(ptrViewData->GetDocument())
, maCursorPos(aCursorPos)
- , mbNeedUpdate(true)
, mbDataChanged(false)
, mbCloseWithoutUndo(false)
@@ -379,7 +379,7 @@ void ScNameDlg::NameModified()
sal_uInt16 nIndex = (aNewScope != aOldScope ? 0 : pData->GetIndex());
pOldRangeName->erase(*pData);
- mbNeedUpdate = false;
+ m_xRangeManagerTable->BlockUpdate();
m_xRangeManagerTable->DeleteSelectedEntries();
ScRangeData::Type nType = ScRangeData::Type::Name;
if ( m_xBtnRowHeader->get_active() ) nType |= ScRangeData::Type::RowHeader;
@@ -395,7 +395,9 @@ void ScNameDlg::NameModified()
aLine.aExpression = aExpr;
aLine.aScope = aNewScope;
m_xRangeManagerTable->addEntry(aLine, true);
- mbNeedUpdate = true;
+ // tdf#128137 process pending async row change events while UpdatesBlocked in place
+ Application::Reschedule(true);
+ m_xRangeManagerTable->UnblockUpdate();
mbDataChanged = true;
}
}
@@ -403,7 +405,7 @@ void ScNameDlg::NameModified()
void ScNameDlg::SelectionChanged()
{
//don't update if we have just modified due to user input
- if (!mbNeedUpdate)
+ if (m_xRangeManagerTable->UpdatesBlocked())
{
return;
}
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index a8702d362b5a..45d2cb49ac13 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -60,6 +60,7 @@ ScRangeManagerTable::ScRangeManagerTable(std::unique_ptr<weld::TreeView> xTreeVi
, m_RangeMap(rRangeMap)
, maPos( rPos )
, m_nId(0)
+ , mbNeedUpdate(true)
{
auto nColWidth = m_xTreeView->get_size_request().Width() / 7;
std::vector<int> aWidths;
@@ -91,7 +92,10 @@ const ScRangeData* ScRangeManagerTable::findRangeData(const ScRangeNameLine& rLi
void ScRangeManagerTable::CheckForFormulaString()
{
- m_xTreeView->visible_foreach([this](weld::TreeIter& rEntry){
+ if (UpdatesBlocked())
+ return;
+
+ auto lambda = [this](weld::TreeIter& rEntry){
OUString sId(m_xTreeView->get_id(rEntry));
std::map<OUString, bool>::const_iterator itr = maCalculatedFormulaEntries.find(sId);
if (itr == maCalculatedFormulaEntries.end() || !itr->second)
@@ -105,7 +109,12 @@ void ScRangeManagerTable::CheckForFormulaString()
maCalculatedFormulaEntries.insert( std::pair<OUString, bool>(sId, true) );
}
return false;
- });
+ };
+
+ // ensure all visible entries are up to date
+ m_xTreeView->visible_foreach(lambda);
+ // and ensure all selected entries are up to date
+ m_xTreeView->selected_foreach(lambda);
}
IMPL_LINK_NOARG(ScRangeManagerTable, SizeAllocHdl, const Size&, void)
More information about the Libreoffice-commits
mailing list