aboutsummaryrefslogtreecommitdiffstats
path: root/poi
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2024-07-02 13:10:29 +0000
committerPJ Fanning <fanningpj@apache.org>2024-07-02 13:10:29 +0000
commite1c61686827acd674e09a484a84a597c47dee10b (patch)
tree3f47ec661970b42eef5e20e10f79c1c202344467 /poi
parent3d1375deee56ea921c35e86bcb8fe3e511fb80aa (diff)
downloadpoi-e1c61686827acd674e09a484a84a597c47dee10b.tar.gz
poi-e1c61686827acd674e09a484a84a597c47dee10b.zip
[bug-69154] add speculative row shifter fix
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918841 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r--poi/src/main/java/org/apache/poi/ss/usermodel/helpers/RowShifter.java10
-rw-r--r--poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java2
2 files changed, 6 insertions, 6 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/helpers/RowShifter.java b/poi/src/main/java/org/apache/poi/ss/usermodel/helpers/RowShifter.java
index 2c4b3fa507..2ef2921e07 100644
--- a/poi/src/main/java/org/apache/poi/ss/usermodel/helpers/RowShifter.java
+++ b/poi/src/main/java/org/apache/poi/ss/usermodel/helpers/RowShifter.java
@@ -102,16 +102,16 @@ public abstract class RowShifter extends BaseRowColShifter {
// build a range of the rows that are overwritten, i.e. the target-area, but without
// rows that are moved along
final CellRangeAddress overwrite;
- if(n > 0) {
+ if (n > 0) {
// area is moved down => overwritten area is [endRow + n - movedRows, endRow + n]
final int firstRow = Math.max(endRow + 1, endRow + n - movedRows);
final int lastRow = endRow + n;
- overwrite = new CellRangeAddress(firstRow, lastRow, 0, 0);
+ overwrite = new CellRangeAddress(firstRow, lastRow, merged.getFirstColumn(), merged.getLastColumn());
} else {
// area is moved up => overwritten area is [startRow + n, startRow + n + movedRows]
final int firstRow = startRow + n;
final int lastRow = Math.min(startRow - 1, startRow + n + movedRows);
- overwrite = new CellRangeAddress(firstRow, lastRow, 0, 0);
+ overwrite = new CellRangeAddress(firstRow, lastRow, merged.getFirstColumn(), merged.getLastColumn());
}
// if the merged-region and the overwritten area intersect, we need to remove it
@@ -126,10 +126,10 @@ public abstract class RowShifter extends BaseRowColShifter {
* @param step length of the shifting step
*/
public static void validateShiftParameters(int firstShiftColumnIndex, int lastShiftColumnIndex, int step) {
- if(step < 0) {
+ if (step < 0) {
throw new IllegalArgumentException("Shifting step may not be negative, but had " + step);
}
- if(firstShiftColumnIndex > lastShiftColumnIndex) {
+ if (firstShiftColumnIndex > lastShiftColumnIndex) {
throw new IllegalArgumentException(String.format(LocaleUtil.getUserLocale(),
"Incorrect shifting range : %d-%d", firstShiftColumnIndex, lastShiftColumnIndex));
}
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 b6c6330a31..af82e26c98 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
@@ -42,7 +42,7 @@ import org.junit.jupiter.api.Test;
*/
public abstract class BaseTestSheetShiftRows {
- private final ITestDataProvider _testDataProvider;
+ protected final ITestDataProvider _testDataProvider;
protected BaseTestSheetShiftRows(ITestDataProvider testDataProvider) {
_testDataProvider = testDataProvider;