From: Dominik Stadler Date: Sun, 22 Mar 2015 21:45:56 +0000 (+0000) Subject: Add test from bug 49423 to verify that the problem was fixed in the meantime X-Git-Tag: REL_3_12_FINAL~65 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=642ba728728b1936931979a891916c9c534de2f3;p=poi.git Add test from bug 49423 to verify that the problem was fixed in the meantime git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1668481 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java index 2fabba9def..efe4f01ecb 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java @@ -28,6 +28,7 @@ import static org.apache.poi.POITestCase.assertContains; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; @@ -1106,4 +1107,36 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { private void expectName(HSSFWorkbook wb, String name, String expect) { assertEquals(expect, wb.getName(name).getRefersToFormula()); } + + @Test + public void test49423() throws Exception + { + HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("49423.xls"); + + boolean found = false; + int numSheets = workbook.getNumberOfSheets(); + for (int i = 0; i < numSheets; i++) { + HSSFSheet sheet = workbook.getSheetAt(i); + List shapes = sheet.getDrawingPatriarch().getChildren(); + for(HSSFShape shape : shapes){ + HSSFAnchor anchor = shape.getAnchor(); + + if(anchor instanceof HSSFClientAnchor){ + // absolute coordinates + HSSFClientAnchor clientAnchor = (HSSFClientAnchor)anchor; + assertNotNull(clientAnchor); + //System.out.println(clientAnchor.getRow1() + "," + clientAnchor.getRow2()); + found = true; + } else if (anchor instanceof HSSFChildAnchor){ + // shape is grouped and the anchor is expressed in the coordinate system of the group + HSSFChildAnchor childAnchor = (HSSFChildAnchor)anchor; + assertNotNull(childAnchor); + //System.out.println(childAnchor.getDy1() + "," + childAnchor.getDy2()); + found = true; + } + } + } + + assertTrue("Should find some images via Client or Child anchors, but did not find any at all", found); + } } diff --git a/test-data/spreadsheet/49423.xls b/test-data/spreadsheet/49423.xls new file mode 100644 index 0000000000..3d8524cba3 Binary files /dev/null and b/test-data/spreadsheet/49423.xls differ