sc/source/ui/view/tabview2.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
New commits: commit 10e80ef6d6eba3a2e5996c8eaee4f5090868072d Author: Henry Castro <hcas...@collabora.com> AuthorDate: Tue Jul 18 15:09:18 2023 -0400 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Aug 8 14:37:49 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> diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index 480574ec22af..308e734f95a0 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -198,6 +198,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); @@ -224,6 +226,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) @@ -240,6 +251,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);