public void testDgRecordNumShapes() throws IOException { HSSFWorkbook wb = new HSSFWorkbook(); try { HSSFSheet sheet = wb.createSheet(); HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); EscherAggregate aggregate = HSSFTestHelper.getEscherAggregate(patriarch); EscherDgRecord dgRecord = (EscherDgRecord) aggregate.getEscherRecord(0).getChild(0); assertEquals(dgRecord.getNumShapes(), 1); } finally { wb.close(); } }
public void testBug45312() throws Exception { HSSFWorkbook wb = new HSSFWorkbook(); try { HSSFSheet sheet = wb.createSheet(); HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.setAnchor((short) 1, 1, 0, 0, (short) 1, 1, 512, 100); HSSFSimpleShape shape1 = patriarch.createSimpleShape(a1); shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE); } { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.setAnchor((short) 1, 1, 512, 0, (short) 1, 1, 1024, 100); HSSFSimpleShape shape1 = patriarch.createSimpleShape(a1); shape1.setFlipVertical(true); shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE); } { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.setAnchor((short) 2, 2, 0, 0, (short) 2, 2, 512, 100); HSSFSimpleShape shape1 = patriarch.createSimpleShape(a1); shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE); } { HSSFClientAnchor a1 = new HSSFClientAnchor(); a1.setAnchor((short) 2, 2, 0, 100, (short) 2, 2, 512, 200); HSSFSimpleShape shape1 = patriarch.createSimpleShape(a1); shape1.setFlipHorizontal(true); shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE); } /*OutputStream stream = new FileOutputStream("/tmp/45312.xls"); try { wb.write(stream); } finally { stream.close(); }*/ checkWorkbookBack(wb); } finally { wb.close(); } }
public void testOpt() throws Exception { HSSFWorkbook wb = new HSSFWorkbook(); try { // create a sheet with a text box HSSFSheet sheet = wb.createSheet(); HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); HSSFTextbox textbox = patriarch.createTextbox(new HSSFClientAnchor()); EscherOptRecord opt1 = HSSFTestHelper.getOptRecord(textbox); EscherOptRecord opt2 = HSSFTestHelper.getEscherContainer(textbox).getChildById(EscherOptRecord.RECORD_ID); assertSame(opt1, opt2); } finally { wb.close(); } }
public void testShapeContainerImplementsIterable() throws IOException { HSSFWorkbook wb = new HSSFWorkbook(); try { HSSFSheet sheet = wb.createSheet(); HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); patriarch.createSimpleShape(new HSSFClientAnchor()); patriarch.createSimpleShape(new HSSFClientAnchor()); int i = 2; for (HSSFShape shape : patriarch) { i--; } assertEquals(i, 0); } finally { wb.close(); } }
public void testCorrectOrderInOptRecord() throws IOException { HSSFWorkbook wb = new HSSFWorkbook(); try { HSSFSheet sheet = wb.createSheet(); HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); HSSFTextbox textbox = patriarch.createTextbox(new HSSFClientAnchor()); EscherOptRecord opt = HSSFTestHelper.getOptRecord(textbox); String opt1Str = opt.toXml(); textbox.setFillColor(textbox.getFillColor()); EscherContainerRecord container = HSSFTestHelper.getEscherContainer(textbox); EscherOptRecord optRecord = container.getChildById(EscherOptRecord.RECORD_ID); assertEquals(opt1Str, optRecord.toXml()); textbox.setLineStyle(textbox.getLineStyle()); assertEquals(opt1Str, optRecord.toXml()); textbox.setLineWidth(textbox.getLineWidth()); assertEquals(opt1Str, optRecord.toXml()); textbox.setLineStyleColor(textbox.getLineStyleColor()); assertEquals(opt1Str, optRecord.toXml()); } finally { wb.close(); } }