From 624b907c5d6f1f16528c3b327b2bc3b6a413f4b0 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 17 Aug 2022 01:15:12 +0000 Subject: [PATCH] [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 --- .../java/org/apache/poi/xssf/usermodel/XSSFSheet.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 0dee5466ae..3fdd8c1b9a 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -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 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 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); } } -- 2.39.5