]> source.dussan.org Git - poi.git/commitdiff
fixed bug 51481 - fixed autofilters in HSSF to avoid warnings in Excel 2007
authorYegor Kozlov <yegor@apache.org>
Wed, 20 Jul 2011 11:04:31 +0000 (11:04 +0000)
committerYegor Kozlov <yegor@apache.org>
Wed, 20 Jul 2011 11:04:31 +0000 (11:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1148700 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/hssf/model/ComboboxShape.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java

index 967461af680c398ec927db4b5158caa666a32075..2ca1abd0c9c5e554d608bec0e71007ddf9dcba00 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta4" date="2011-??-??">
+           <action dev="poi-developers" type="fix">51481 - Fixed autofilters in HSSF to avoid warnings in Excel 2007</action>
            <action dev="poi-developers" type="fix">51533 - Avoid exception when changing name of a sheet containing shared formulas</action>
            <action dev="poi-developers" type="add">Support for appending images to existing drawings in HSSF</action>
            <action dev="poi-developers" type="fix">Added initial support for bookmarks in HWFP</action>
index 7032687f786a591317f8589a5e0fe95ebd9f260f..674fc46f0f9feb0b85162417d679164ea9009a4e 100644 (file)
@@ -56,11 +56,14 @@ public class ComboboxShape
         c.setAutofill(true);
         c.setAutoline(false);
 
+        FtCblsSubRecord f = new FtCblsSubRecord();
+
         LbsDataSubRecord l = LbsDataSubRecord.newAutoFilterInstance();
 
         EndSubRecord e = new EndSubRecord();
 
         obj.addSubRecord(c);
+        obj.addSubRecord(f);
         obj.addSubRecord(l);
         obj.addSubRecord(e);
 
index 85a4cb3b0acfabd44c704a87c86cab8cc03c9f57..1abf1026ed7d274a1701ca566cb6f51e75deafe2 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.poi.hssf.usermodel;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.util.List;
 
 import junit.framework.AssertionFailedError;
 
@@ -917,5 +918,21 @@ public final class TestHSSFSheet extends BaseTestSheet {
         assertNotNull(afilter );
         assertEquals(2, afilter.getNumEntries()); //filter covers two columns
 
+        HSSFPatriarch dr = sh.getDrawingPatriarch();
+        assertNotNull(dr);
+        HSSFSimpleShape comboBoxShape = (HSSFSimpleShape)dr.getChildren().get(0);
+        assertEquals(comboBoxShape.getShapeType(),  HSSFSimpleShape.OBJECT_TYPE_COMBO_BOX);
+
+        assertNull( ish.findFirstRecordBySid(ObjRecord.sid) ); // ObjRecord will appear after serializetion
+
+        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
+        sh = wb.getSheetAt(0);
+        ish = sh.getSheet();
+        ObjRecord objRecord = (ObjRecord)ish.findFirstRecordBySid(ObjRecord.sid);
+        List<SubRecord> subRecords = objRecord.getSubRecords();
+        assertEquals(3, subRecords.size());
+        assertTrue(subRecords.get(0) instanceof CommonObjectDataSubRecord );
+        assertTrue(subRecords.get(1) instanceof FtCblsSubRecord ); // must be present, see Bug 51481
+        assertTrue(subRecords.get(2) instanceof LbsDataSubRecord );
     }
 }