sc/source/ui/view/tabview2.cxx | 116 +++++++++++++++++++++++++---------------- 1 file changed, 72 insertions(+), 44 deletions(-)
New commits: commit a58b3984c1ad05d77eaefd424da12d9b833f76b8 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 16:44:24 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/+/154599 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index 019bc460cb25..4faa5d89d569 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); commit 6ca51786b90270c86e854f85728f77d0ef5cffa6 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Mon Jul 17 09:41:55 2023 -0400 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Aug 8 16:44:15 2023 +0200 tdf#155799: sc: abstraction "moveRefByCell" Signed-off-by: Henry Castro <hcas...@collabora.com> Change-Id: Ib00e3cddcd4a5dc4ef3d74d3939cdf278f2cb44d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154598 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx index f80f0b309c15..019bc460cb25 100644 --- a/sc/source/ui/view/tabview2.cxx +++ b/sc/source/ui/view/tabview2.cxx @@ -194,6 +194,57 @@ bool checkBoundary(const ScDocument* pDoc, SCCOL& rCol, SCROW& rRow) return bGood; } +void moveRefByCell(SCCOL& rNewX, SCROW& rNewY, + SCCOL nMovX, SCROW nMovY, SCTAB nRefTab, + const ScDocument& rDoc) +{ + bool bSelectLocked = true; + bool bSelectUnlocked = true; + const ScTableProtection* pTabProtection = rDoc.GetTabProtection(nRefTab); + if (pTabProtection && pTabProtection->isProtected()) + { + bSelectLocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); + bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS); + } + + moveCursorByProtRule(rNewX, rNewY, nMovX, nMovY, nRefTab, &rDoc); + checkBoundary(&rDoc, rNewX, rNewY); + + if (nMovX) + { + SCCOL nTempX = rNewX; + while (rDoc.IsHorOverlapped(nTempX, rNewY, nRefTab)) + { + if (nMovX > 0) + ++nTempX; + else + --nTempX; + if (!checkBoundary(&rDoc, nTempX, rNewY)) + break; + } + if (isCellQualified(&rDoc, nTempX, rNewY, nRefTab, bSelectLocked, bSelectUnlocked)) + rNewX = nTempX; + } + + if (nMovY) + { + SCROW nTempY = rNewY; + while (rDoc.IsVerOverlapped(rNewX, nTempY, nRefTab)) + { + if (nMovY > 0) + ++nTempY; + else + --nTempY; + if (!checkBoundary(&rDoc, rNewX, nTempY)) + break; + } + if (isCellQualified(&rDoc, rNewX, nTempY, nRefTab, bSelectLocked, bSelectUnlocked)) + rNewY = nTempY; + } + + rDoc.SkipOverlapped(rNewX, rNewY, nRefTab); +} + void moveCursorByMergedCell(SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY, SCCOL nStartX, SCROW nStartY, SCTAB nTab, const ScDocument* pDoc) { @@ -993,51 +1044,8 @@ void ScTabView::ExpandBlock(SCCOL nMovX, SCROW nMovY, ScFollowMode eMode) SCROW nNewY = aViewData.GetRefEndY(); SCTAB nRefTab = aViewData.GetRefEndZ(); - bool bSelectLocked = true; - bool bSelectUnlocked = true; - const ScTableProtection* pTabProtection = rDoc.GetTabProtection(nRefTab); - if (pTabProtection && pTabProtection->isProtected()) - { - bSelectLocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); - bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS); - } - - moveCursorByProtRule(nNewX, nNewY, nMovX, nMovY, nRefTab, &rDoc); - checkBoundary(&rDoc, nNewX, nNewY); - - if (nMovX) - { - SCCOL nTempX = nNewX; - while (rDoc.IsHorOverlapped(nTempX, nNewY, nRefTab)) - { - if (nMovX > 0) - ++nTempX; - else - --nTempX; - if (!checkBoundary(&rDoc, nTempX, nNewY)) - break; - } - if (isCellQualified(&rDoc, nTempX, nNewY, nRefTab, bSelectLocked, bSelectUnlocked)) - nNewX = nTempX; - } - - if (nMovY) - { - SCROW nTempY = nNewY; - while (rDoc.IsVerOverlapped(nNewX, nTempY, nRefTab)) - { - if (nMovY > 0) - ++nTempY; - else - --nTempY; - if (!checkBoundary(&rDoc, nNewX, nTempY)) - break; - } - if (isCellQualified(&rDoc, nNewX, nTempY, nRefTab, bSelectLocked, bSelectUnlocked)) - nNewY = nTempY; - } + moveRefByCell(nNewX, nNewY, nMovX, nMovY, nRefTab, rDoc); - rDoc.SkipOverlapped(nNewX, nNewY, nRefTab); UpdateRef(nNewX, nNewY, nRefTab); SCCOL nTargetCol = nNewX; SCROW nTargetRow = nNewY;