From 0ec8b3a88e2b37cf3a51ac9b767263db4740a007 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Mon, 20 Jun 2016 02:02:08 +0000 Subject: [PATCH] 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 --- src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java | 1 + .../org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 36dcaa0f2..a87312b54 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 a1436cc64..923af2a63 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