sc/source/ui/view/tabview2.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
New commits: commit ee6d3d10ae7962d7eb6562e65abe9e1524a04e99 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Tue Jul 18 15:09:18 2023 -0400 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Fri Aug 11 19:18:02 2023 +0200 tdf#155799: sc: fix formula reference "key up" When the formula reference mode is active and it process the keyboard event UP, it should decrease -1 according the merge attribute row, col span. Signed-off-by: Henry Castro <hcas...@collabora.com> Change-Id: I278bcd9d52caeb09e4a47336af8c8e9b522397c9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154999 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155628 diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index d9fa2cb3f3d5..6c7cdadd4d48 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -197,6 +197,8 @@ void moveRefByCell(SCCOL& rNewX, SCROW& rNewY, SCCOL nMovX, SCROW nMovY, SCTAB nRefTab, const ScDocument& rDoc) { + SCCOL nOldX = rNewX; + SCROW nOldY = rNewY; bool bSelectLocked = true; bool bSelectUnlocked = true; const ScTableProtection* pTabProtection = rDoc.GetTabProtection(nRefTab); @@ -223,6 +225,15 @@ void moveRefByCell(SCCOL& rNewX, SCROW& rNewY, } if (isCellQualified(&rDoc, nTempX, rNewY, nRefTab, bSelectLocked, bSelectUnlocked)) rNewX = nTempX; + + if (nMovX < 0 && rNewX > 0) + { + const ScMergeAttr* pMergeAttr = rDoc.GetAttr(rNewX, rNewY, nRefTab, ATTR_MERGE); + if (pMergeAttr && pMergeAttr->IsMerged() && + nOldX >= rNewX && + nOldX <= rNewX + pMergeAttr->GetRowMerge() - 1) + rNewX = rNewX - 1; + } } if (nMovY) @@ -239,6 +250,15 @@ void moveRefByCell(SCCOL& rNewX, SCROW& rNewY, } if (isCellQualified(&rDoc, rNewX, nTempY, nRefTab, bSelectLocked, bSelectUnlocked)) rNewY = nTempY; + + if (nMovY < 0 && rNewY > 0) + { + const ScMergeAttr* pMergeAttr = rDoc.GetAttr(rNewX, rNewY, nRefTab, ATTR_MERGE); + if (pMergeAttr && pMergeAttr->IsMerged() && + nOldY >= rNewY && + nOldY <= rNewY + pMergeAttr->GetRowMerge() - 1) + rNewY = rNewY - 1; + } } rDoc.SkipOverlapped(rNewX, rNewY, nRefTab);