From: Javen O'Neal Date: Mon, 20 Jun 2016 02:02:08 +0000 (+0000) Subject: bug 56454: keep XSSFRowShifter#shiftMerged in sync with HSSFSheet: when shifting... X-Git-Tag: REL_3_15_BETA2~36 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=46b3d8eaeea557d4c623474a1dc6177ad47aa2e3;p=poi.git bug 56454: keep XSSFRowShifter#shiftMerged in sync with HSSFSheet: when shifting rows, shift merged regions (even when the merged region does not include column 0) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1749248 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 36dcaa0f20..a87312b546 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -1484,6 +1484,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { * @param startRow the start-index of the rows to shift, zero-based * @param endRow the end-index of the rows to shift, zero-based * @param n how far to shift, negative to shift up + * This should be kept in sync with {@link org.apache.poi.xssf.usermodel.helpers.XSSFRowShifter#shiftMerged(int, int, int)} */ private void shiftMerged(int startRow, int endRow, int n) { List shiftedRegions = new ArrayList(); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java index a1436cc643..923af2a63f 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java @@ -69,6 +69,8 @@ public final class XSSFRowShifter { * @param endRow the row to end shifting * @param n the number of rows to shift * @return an array of affected cell regions + * + * This should be kept in sync with {@link org.apache.poi.hssf.usermodel.HSSFSheet#shiftMerged(int, int, int)} */ public List shiftMerged(int startRow, int endRow, int n) { List shiftedRegions = new ArrayList(); @@ -87,7 +89,7 @@ public final class XSSFRowShifter { } //only shift if the region outside the shifted rows is not merged too - if (!containsCell(merged, startRow - 1, 0) && !containsCell(merged, endRow + 1, 0)) { + if (!merged.containsRow(startRow - 1) && !merged.containsRow(endRow + 1)) { merged.setFirstRow(merged.getFirstRow() + n); merged.setLastRow(merged.getLastRow() + n); //have to remove/add it back