[bug-66215] try to improve logic for overlapping tables

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903471 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-08-17 01:15:12 +00:00
parent 9a616913b9
commit 624b907c5d
1 changed files with 8 additions and 2 deletions

View File

@ -3044,7 +3044,10 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx
public void shiftRows(int startRow, int endRow, final int n, boolean copyRowHeight, boolean resetOriginalRowHeight) {
List<XSSFTable> overlappingTables = new ArrayList<>();
for (XSSFTable table : getTables()) {
if (table.getStartRowIndex() <= endRow || table.getEndRowIndex() >= startRow) {
if ((table.getStartRowIndex() < startRow && table.getEndRowIndex() < startRow)
|| (table.getStartRowIndex() > endRow && table.getEndRowIndex() > endRow)) {
// not overlapping
} else {
overlappingTables.add(table);
}
}
@ -3082,7 +3085,10 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx
public void shiftColumns(int startColumn, int endColumn, final int n) {
List<XSSFTable> overlappingTables = new ArrayList<>();
for (XSSFTable table : getTables()) {
if (table.getStartColIndex() <= endColumn || table.getEndRowIndex() >= startColumn) {
if ((table.getStartColIndex() < startColumn && table.getEndColIndex() < startColumn)
|| (table.getStartColIndex() > endColumn && table.getEndColIndex() > endColumn)) {
// not overlapping
} else {
overlappingTables.add(table);
}
}