summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2023-01-16 16:25:22 +0100
committerJean-Pierre Ledure <jp@ledure.be>2023-01-17 16:17:45 +0000
commitc7ac513a8217179c5fae774363e8b0b1f41cea5c (patch)
tree1b7ec939d50fcc107adfdd1fb327e74631488a9b /wizards
parentea70cf3ca06a5b101d51ca1f4d4a106747a884ae (diff)
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 <jp@ledure.be>
Diffstat (limited to 'wizards')
-rw-r--r--wizards/source/sfdocuments/SF_Calc.xba35
1 files changed, 18 insertions, 17 deletions
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
&apos; Compute the final range position
- If lCountDeleted &lt; .Width Then sCompact = Offset(Range, 0, 0, 0, .Width - lCountDeleted)
-
- &apos; Push to the right the cells that migrated leftwards irrelevantly
- If Not WholeColumn Then
- If Len(sCompact) &gt; 0 Then
+ If lCountDeleted &gt; 0 Then
+ sCompact = Offset(Range, 0, 0, 0, .Width - lCountDeleted)
+ &apos; 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)
+ &apos; Conventionally, if all columns are deleted, the returned range is the zero-length string
+ If .Width = lCountDeleted Then sCompact = &quot;&quot;
+ Else &apos; Initial range is left unchanged
+ sCompact = .RangeName
End If
End With
@@ -724,7 +725,6 @@ Public Function CompactUp(Optional ByVal Range As Variant _
&apos;&apos;&apos; &apos; The rows having a &quot;X&quot; in column G are completely suppressed
Dim sCompact As String &apos; Return value
-Dim oCompact As Object &apos; Return value as an _Address type
Dim lCountDeleted As Long &apos; Count the deleted rows
Dim vCompactRanges As Variant &apos; Array of ranges to be compacted based on the formula
Dim oSourceAddress As Object &apos; Alias of Range as _Address
@@ -768,16 +768,17 @@ Try:
Next i
&apos; Compute the final range position
- If lCountDeleted &lt; .Height Then sCompact = Offset(Range, 0, 0, .Height - lCountDeleted, 0)
-
- &apos; Push downwards the cells that migrated upwards irrelevantly
- If Not WholeRow Then
- If Len(sCompact) &gt; 0 Then
+ If lCountDeleted &gt; 0 Then
+ sCompact = Offset(Range, 0, 0, .Height - lCountDeleted, 0)
+ &apos; 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)
+ &apos; Conventionally, if all rows are deleted, the returned range is the zero-length string
+ If .Height = lCountDeleted Then sCompact = &quot;&quot;
+ Else &apos; Initial range is left unchanged
+ sCompact = .RangeName
End If
End With