You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2026/09/20 21:24:08 UTC
(poi) branch trunk updated: [bug-69154] add regression test for shiftRows with merged regions not in column 0 (#1340)
This is an automated email from the ASF dual-hosted git repository.
pjfanning pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git
The following commit(s) were added to refs/heads/trunk by this push:
new d77c9b5b02 [bug-69154] add regression test for shiftRows with merged regions not in column 0 (#1340)
d77c9b5b02 is described below
commit d77c9b5b02a19bb96bf9ce7e71edfbab34199dae
Author: PJ Fanning <pj...@users.noreply.github.com>
AuthorDate: Sun Sep 20 22:24:03 2026 +0100
[bug-69154] add regression test for shiftRows with merged regions not in column 0 (#1340)
r1918841 changed RowShifter.removalNeeded to compare the overwritten area
against the merged region's own columns instead of column 0, but the test
added alongside it (TestXSSFSheetShiftRows.testBug69154) calls shiftColumns.
Add the row-shift counterpart of the reported scenario to
BaseTestSheetShiftRows so both HSSF and XSSF cover it; without the r1918841
change it fails with "Cannot add merged region B3:C3 to sheet because it
overlaps with an existing merged region (B2:B3)".
Co-authored-by: Claude Opus 5 (1M context) <no...@anthropic.com>
---
.../poi/ss/usermodel/BaseTestSheetShiftRows.java | 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java
index af82e26c98..d3c33aedf7 100644
--- a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java
+++ b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java
@@ -635,6 +635,34 @@ public abstract class BaseTestSheetShiftRows {
}
}
+ @Test
+ void bug69154ShiftRowsWithMergedRegionsNotInColumnZero() throws IOException {
+ // row-shift counterpart of the column-shift scenario in bug 69154:
+ // the overwritten area must be compared against the merged region's own
+ // columns, not column 0, or the region below is shifted onto the one it replaces
+ try (Workbook wb = _testDataProvider.createWorkbook()) {
+ Sheet sheet = wb.createSheet("test");
+ populateSheetCells(sheet, 6);
+
+ CellRangeAddress B1_C1 = new CellRangeAddress(0, 0, 1, 2);
+ CellRangeAddress B2_B3 = new CellRangeAddress(1, 2, 1, 1);
+ CellRangeAddress B4_C4 = new CellRangeAddress(3, 3, 1, 2);
+
+ assertEquals(0, sheet.addMergedRegion(B1_C1));
+ assertEquals(1, sheet.addMergedRegion(B2_B3));
+ assertEquals(2, sheet.addMergedRegion(B4_C4));
+
+ // B1:C1 is untouched
+ // B2:B3 is partly overwritten and should be removed
+ // B4:C4 should be B3:C3
+ sheet.shiftRows(2, sheet.getLastRowNum(), -1);
+
+ assertEquals(2, sheet.getNumMergedRegions());
+ assertEquals(CellRangeAddress.valueOf("B1:C1"), sheet.getMergedRegion(0));
+ assertEquals(CellRangeAddress.valueOf("B3:C3"), sheet.getMergedRegion(1));
+ }
+ }
+
@Test
void shiftMergedRowsToMergedRowsOverlappingMergedRegion() throws IOException {
try (Workbook wb = _testDataProvider.createWorkbook()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org