]> source.dussan.org Git - poi.git/commitdiff
fixed bug 51675, added test case for bug 52272
authorEvgeniy Berlog <berlog@apache.org>
Sat, 28 Jul 2012 16:01:24 +0000 (16:01 +0000)
committerEvgeniy Berlog <berlog@apache.org>
Sat, 28 Jul 2012 16:01:24 +0000 (16:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/gsoc2012@1366700 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/aggregates/PageSettingsBlock.java
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
test-data/spreadsheet/51675.xls [new file with mode: 0644]

index 676a8f983133560250c356cb8f01218a4ff6b6c1..5236e184b8912beb961a190f60e6c461d0788074 100644 (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) {
index 0864549f6ce2dbecf57729ad46b92c0a7e09f533..69f0e3425b9e498a46a52ce40c4666d2d1368c31 100644 (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());
+    }
 }
diff --git a/test-data/spreadsheet/51675.xls b/test-data/spreadsheet/51675.xls
new file mode 100644 (file)
index 0000000..78df32c
Binary files /dev/null and b/test-data/spreadsheet/51675.xls differ