diff --git a/src/java/org/apache/poi/hssf/record/aggregates/PageSettingsBlock.java b/src/java/org/apache/poi/hssf/record/aggregates/PageSettingsBlock.java index 676a8f983..5236e184b 100644 --- a/src/java/org/apache/poi/hssf/record/aggregates/PageSettingsBlock.java +++ b/src/java/org/apache/poi/hssf/record/aggregates/PageSettingsBlock.java @@ -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) { diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 0864549f6..69f0e3425 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -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 list = new ArrayList(); + 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()); + } } diff --git a/test-data/spreadsheet/51675.xls b/test-data/spreadsheet/51675.xls new file mode 100644 index 000000000..78df32cb9 Binary files /dev/null and b/test-data/spreadsheet/51675.xls differ