]> source.dussan.org Git - poi.git/commitdiff
avoid corruption of XSSFWorkbook after removing all merged cells from sheet, see...
authorYegor Kozlov <yegor@apache.org>
Sat, 11 Sep 2010 13:48:00 +0000 (13:48 +0000)
committerYegor Kozlov <yegor@apache.org>
Sat, 11 Sep 2010 13:48:00 +0000 (13:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@996148 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java

index a837169ed3a8c3a5be578a5215210e956af4d105..0e77fa1bd850a7929cf02dfd1aa4de922e6277e3 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.7-beta3" date="2010-??-??">
+           <action dev="poi-developers" type="fix">49895 - avoid corruption of XSSFWorkbook after removing all merged cells from sheet</action>
            <action dev="poi-developers" type="fix">49907 - fixed inconsistent behaviour between HSSF and XSSF when creating consecutive names</action>
            <action dev="poi-developers" type="add">Add getMimeType() method to HWPF Picture, alongside existing file extension</action>
            <action dev="poi-developers" type="add">Add code for reading Ole10Native data</action>
index d33bea8f90f9bfbc9cc32fbef4594a62b3e3b90a..ce870cfcf6697aea7f35e05725f055e6b29674a1 100644 (file)
@@ -1350,7 +1350,11 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
                 mergeCellsArray[i - 1] = ctMergeCells.getMergeCellArray(i);
             }
         }
-        ctMergeCells.setMergeCellArray(mergeCellsArray);
+        if(mergeCellsArray.length > 0){
+            ctMergeCells.setMergeCellArray(mergeCellsArray);
+        } else{
+            worksheet.unsetMergeCells();
+        }
     }
 
     /**
index 7eec1794ab9226a8bb4f099c10c8c96e19e07e30..f38d773e6a2729fc7b6b1ef815cd4231d5a5006b 100644 (file)
@@ -253,6 +253,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
         sheet.removeMergedRegion(1);
         sheet.removeMergedRegion(0);
         assertEquals(0, sheet.getNumMergedRegions());
+        assertNull(" CTMergeCells should be deleted after removing the last merged " +
+                "region on the sheet.", sheet.getCTWorksheet().getMergeCells());
     }
 
     public void testSetDefaultColumnStyle() {