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
This commit is contained in:
Javen O'Neal 2016-06-20 02:02:08 +00:00
parent 55cb9381de
commit 0ec8b3a88e
2 changed files with 4 additions and 1 deletions

View 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>();

View 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