]> source.dussan.org Git - poi.git/commitdiff
bug 56454: keep XSSFRowShifter#shiftMerged in sync with HSSFSheet: when shifting...
authorJaven O'Neal <onealj@apache.org>
Mon, 20 Jun 2016 02:02:08 +0000 (02:02 +0000)
committerJaven O'Neal <onealj@apache.org>
Mon, 20 Jun 2016 02:02:08 +0000 (02:02 +0000)
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
src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java

index 36dcaa0f205d02acbf58737e32c442ab712a5808..a87312b5469e3b020681c87cc8a392415271e2fd 100644 (file)
@@ -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<CellRangeAddress> shiftedRegions = new ArrayList<CellRangeAddress>();
index a1436cc64363617958f24a3a57cf2b38772e5371..923af2a63fe9d9dd71b4d973bd3286d184252f93 100644 (file)
@@ -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<CellRangeAddress> shiftMerged(int startRow, int endRow, int n) {
         List<CellRangeAddress> shiftedRegions = new ArrayList<CellRangeAddress>();
@@ -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