diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 967461af68..2ca1abd0c9 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 51481 - Fixed autofilters in HSSF to avoid warnings in Excel 2007 51533 - Avoid exception when changing name of a sheet containing shared formulas Support for appending images to existing drawings in HSSF Added initial support for bookmarks in HWFP diff --git a/src/java/org/apache/poi/hssf/model/ComboboxShape.java b/src/java/org/apache/poi/hssf/model/ComboboxShape.java index 7032687f78..674fc46f0f 100644 --- a/src/java/org/apache/poi/hssf/model/ComboboxShape.java +++ b/src/java/org/apache/poi/hssf/model/ComboboxShape.java @@ -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); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index 85a4cb3b0a..1abf1026ed 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -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 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 ); } }