From fa17a12b5ba1e7e2a9dc53412a7934779a68c44d Mon Sep 17 00:00:00 2001 From: Danny Mui Date: Fri, 27 Jun 2003 23:13:29 +0000 Subject: [PATCH] Fixing future bug when we support continue records for more than xxxx merged regions. Fetch the last merged record as the merged pointer if the current one is killed. git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353167 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/hssf/model/Sheet.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/java/org/apache/poi/hssf/model/Sheet.java b/src/java/org/apache/poi/hssf/model/Sheet.java index 1c87da87ba..c481665424 100644 --- a/src/java/org/apache/poi/hssf/model/Sheet.java +++ b/src/java/org/apache/poi/hssf/model/Sheet.java @@ -469,12 +469,20 @@ public class Sheet implements Model numMergedRegions--; if (rec.getNumAreas() == 0) { + mergedRecords.remove(pos); + if (merged == rec) { + //pull up the LAST record for operations when we finally + //support continue records for mergedRegions + if (mergedRecords.size() > 0) { + merged = (MergeCellsRecord) mergedRecords.get(mergedRecords.size() - 1); + } else { + merged = null; + } + } - if (merged == rec) - merged = (MergeCellsRecord) mergedRecords.get(mergedRecords.size() - 1); int removePos = ((Integer) mergedLocs.get(pos)).intValue(); records.remove(removePos); - mergedRecords.remove(pos); + mergedLocs.remove(pos); //if we're not tracking merged records, kill the pointer to reset the state