fixed bug 51675, added test case for bug 52272

git-svn-id: https://svn.apache.org/repos/asf/poi/branches/gsoc2012@1366700 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Evgeniy Berlog 2012-07-28 16:01:24 +00:00
parent 61cb6a93c5
commit c445756d08
3 changed files with 31 additions and 1 deletions

View File

@ -284,9 +284,9 @@ public final class PageSettingsBlock extends RecordAggregate {
pls.visitContainedRecords(rv);
}
visitIfPresent(_printSetup, rv);
visitIfPresent(_bitmap, rv);
visitIfPresent(_printSize, rv);
visitIfPresent(_headerFooter, rv);
visitIfPresent(_bitmap, rv);
}
private static void visitIfPresent(Record r, RecordVisitor rv) {
if (r != null) {

View File

@ -24,9 +24,12 @@ import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.extractor.ExcelExtractor;
import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
import org.apache.poi.hssf.record.aggregates.PageSettingsBlock;
import org.apache.poi.hssf.record.aggregates.RecordAggregate;
import org.apache.poi.hssf.record.common.UnicodeString;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
@ -2238,4 +2241,31 @@ if(1==2) {
// make sure we are still readable
writeOutAndReadBack(workbook);
}
public void test51675(){
final List<Short> list = new ArrayList<Short>();
HSSFWorkbook workbook = openSample("51675.xls");
HSSFSheet sh = workbook.getSheetAt(0);
InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
PageSettingsBlock psb = (PageSettingsBlock) ish.getRecords().get(13);
psb.visitContainedRecords(new RecordAggregate.RecordVisitor() {
public void visitRecord(Record r) {
list.add(r.getSid());
}
});
assertTrue(list.get(list.size()-1).intValue() == UnknownRecord.BITMAP_00E9);
assertTrue(list.get(list.size()-2).intValue() == UnknownRecord.HEADER_FOOTER_089C);
}
public void test52272(){
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sh = wb.createSheet();
HSSFPatriarch p = sh.createDrawingPatriarch();
HSSFSimpleShape s = p.createSimpleShape(new HSSFClientAnchor());
s.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
HSSFSheet sh2 = wb.cloneSheet(0);
assertNotNull(sh2.getDrawingPatriarch());
}
}

Binary file not shown.