wizards/source/sfdocuments/SF_Calc.xba | 35 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
New commits: commit c7ac513a8217179c5fae774363e8b0b1f41cea5c Author: Jean-Pierre Ledure <j...@ledure.be> AuthorDate: Mon Jan 16 16:25:22 2023 +0100 Commit: Jean-Pierre Ledure <j...@ledure.be> CommitDate: Tue Jan 17 16:17:45 2023 +0000 ScriptForge - (SF_Calc) fix CompactUp/CompactLeft methods When - WholeRow/WholeColumn = False - no row or column matches the FilterFormula the cells below or at the right were erroneously shifted down or right. Future behaviour: - when nothing to compact, the initial range is left unchanged the return value = the initial range - when all rows/columns are impacted, the initial range is cleared the return value = zero-length string - otherwise the initial range is compacted the return value is the compacted range In either case, the surrounding cells are unchanged. Change-Id: I27288878dcadeb4ded297b7bb1e6897947ed5e56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145622 Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <j...@ledure.be> diff --git a/wizards/source/sfdocuments/SF_Calc.xba b/wizards/source/sfdocuments/SF_Calc.xba index 806f30bd7cad..391321f361d8 100644 --- a/wizards/source/sfdocuments/SF_Calc.xba +++ b/wizards/source/sfdocuments/SF_Calc.xba @@ -673,16 +673,17 @@ Try: Next i ' Compute the final range position - If lCountDeleted < .Width Then sCompact = Offset(Range, 0, 0, 0, .Width - lCountDeleted) - - ' Push to the right the cells that migrated leftwards irrelevantly - If Not WholeColumn Then - If Len(sCompact) > 0 Then + If lCountDeleted > 0 Then + sCompact = Offset(Range, 0, 0, 0, .Width - lCountDeleted) + ' Push to the right the cells that migrated leftwards irrelevantly + If Not WholeColumn Then sShiftRange = Offset(sCompact, 0, .Width - lCountDeleted, , lCountDeleted) - Else - sShiftRange = .RangeName + ShiftRight(sShiftRange, WholeColumn := False) End If - ShiftRight(sShiftRange, WholeColumn := False) + ' Conventionally, if all columns are deleted, the returned range is the zero-length string + If .Width = lCountDeleted Then sCompact = "" + Else ' Initial range is left unchanged + sCompact = .RangeName End If End With @@ -724,7 +725,6 @@ Public Function CompactUp(Optional ByVal Range As Variant _ ''' ' The rows having a "X" in column G are completely suppressed Dim sCompact As String ' Return value -Dim oCompact As Object ' Return value as an _Address type Dim lCountDeleted As Long ' Count the deleted rows Dim vCompactRanges As Variant ' Array of ranges to be compacted based on the formula Dim oSourceAddress As Object ' Alias of Range as _Address @@ -768,16 +768,17 @@ Try: Next i ' Compute the final range position - If lCountDeleted < .Height Then sCompact = Offset(Range, 0, 0, .Height - lCountDeleted, 0) - - ' Push downwards the cells that migrated upwards irrelevantly - If Not WholeRow Then - If Len(sCompact) > 0 Then + If lCountDeleted > 0 Then + sCompact = Offset(Range, 0, 0, .Height - lCountDeleted, 0) + ' Push downwards the cells that migrated upwards irrelevantly + If Not WholeRow Then sShiftRange = Offset(sCompact, .Height - lCountDeleted, 0, lCountDeleted) - Else - sShiftRange = .RangeName + ShiftDown(sShiftRange, WholeRow := False) End If - ShiftDown(sShiftRange, WholeRow := False) + ' Conventionally, if all rows are deleted, the returned range is the zero-length string + If .Height = lCountDeleted Then sCompact = "" + Else ' Initial range is left unchanged + sCompact = .RangeName End If End With