fixed bug 51481 - fixed autofilters in HSSF to avoid warnings in Excel 2007

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1148700 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2011-07-20 11:04:31 +00:00
parent 44521220e5
commit 03fe1959f2
3 changed files with 21 additions and 0 deletions

View 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>

View 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);

View 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 );
}
}