use of org.apache.poi.hslf.usermodel.HSLFSlideShow in project poi by apache.
the class TestShapes method graphics.
@Test
public void graphics() throws IOException {
HSLFSlide slide = ppt.createSlide();
HSLFLine line = new HSLFLine();
java.awt.Rectangle lineAnchor = new java.awt.Rectangle(100, 200, 50, 60);
line.setAnchor(lineAnchor);
line.setLineWidth(3);
line.setLineDash(LineDash.DASH);
line.setLineColor(Color.red);
slide.addShape(line);
HSLFAutoShape ellipse = new HSLFAutoShape(ShapeType.ELLIPSE);
Rectangle2D ellipseAnchor = new Rectangle2D.Double(320, 154, 55, 111);
ellipse.setAnchor(ellipseAnchor);
ellipse.setLineWidth(2);
ellipse.setLineDash(LineDash.SOLID);
ellipse.setLineColor(Color.green);
ellipse.setFillColor(Color.lightGray);
slide.addShape(ellipse);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ppt.write(out);
out.close();
//read ppt from byte array
HSLFSlideShow ppt2 = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
assertEquals(1, ppt2.getSlides().size());
slide = ppt2.getSlides().get(0);
List<HSLFShape> shape = slide.getShapes();
assertEquals(2, shape.size());
//group shape
assertTrue(shape.get(0) instanceof HSLFLine);
//group shape
assertEquals(lineAnchor, shape.get(0).getAnchor());
//group shape
assertTrue(shape.get(1) instanceof HSLFAutoShape);
//group shape
assertEquals(ellipseAnchor, shape.get(1).getAnchor());
ppt2.close();
}
use of org.apache.poi.hslf.usermodel.HSLFSlideShow in project poi by apache.
the class TestExtractor method testExtractFromOwnEmbeded.
/**
* A powerpoint file with embeded powerpoint files
*/
@Test
public void testExtractFromOwnEmbeded() throws IOException {
PowerPointExtractor ppe = openExtractor("ppt_with_embeded.ppt");
List<OLEShape> shapes = ppe.getOLEShapes();
assertEquals("Expected 6 ole shapes", 6, shapes.size());
int num_ppt = 0, num_doc = 0, num_xls = 0;
for (OLEShape ole : shapes) {
String name = ole.getInstanceName();
InputStream data = ole.getObjectData().getData();
if ("Worksheet".equals(name)) {
HSSFWorkbook wb = new HSSFWorkbook(data);
num_xls++;
wb.close();
} else if ("Document".equals(name)) {
HWPFDocument doc = new HWPFDocument(data);
num_doc++;
doc.close();
} else if ("Presentation".equals(name)) {
num_ppt++;
HSLFSlideShow ppt = new HSLFSlideShow(data);
ppt.close();
}
data.close();
}
assertEquals("Expected 2 embedded Word Documents", 2, num_doc);
assertEquals("Expected 2 embedded Excel Spreadsheets", 2, num_xls);
assertEquals("Expected 2 embedded PowerPoint Presentations", 2, num_ppt);
ppe.close();
}
use of org.apache.poi.hslf.usermodel.HSLFSlideShow in project poi by apache.
the class TestBackground method getFillPictureRefCount.
private int getFillPictureRefCount(HSLFShape shape, HSLFFill fill) {
AbstractEscherOptRecord opt = shape.getEscherOptRecord();
EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
if (p != null) {
int idx = p.getPropertyValue();
HSLFSheet sheet = shape.getSheet();
HSLFSlideShow ppt = sheet.getSlideShow();
Document doc = ppt.getDocumentRecord();
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
List<EscherRecord> lst = bstore.getChildRecords();
return ((EscherBSERecord) lst.get(idx - 1)).getRef();
}
return 0;
}
use of org.apache.poi.hslf.usermodel.HSLFSlideShow in project poi by apache.
the class TestBackground method defaults.
/**
* Default background for slide, shape and slide master.
*/
@Test
public void defaults() throws IOException {
HSLFSlideShow ppt = new HSLFSlideShow();
assertEquals(HSLFFill.FILL_SOLID, ppt.getSlideMasters().get(0).getBackground().getFill().getFillType());
HSLFSlide slide = ppt.createSlide();
assertTrue(slide.getFollowMasterBackground());
assertEquals(HSLFFill.FILL_SOLID, slide.getBackground().getFill().getFillType());
HSLFShape shape = new HSLFAutoShape(ShapeType.RECT);
assertEquals(HSLFFill.FILL_SOLID, shape.getFill().getFillType());
ppt.close();
}
use of org.apache.poi.hslf.usermodel.HSLFSlideShow in project poi by apache.
the class TestHeadersFooters method testCreateNotesFooters.
@Test
public void testCreateNotesFooters() throws IOException {
HSLFSlideShow ppt1 = new HSLFSlideShow();
HeadersFooters hdd = ppt1.getNotesHeadersFooters();
hdd.setFootersText("My notes footer");
hdd.setHeaderText("My notes header");
hdd.setSlideNumberVisible(true);
HSLFSlideShow ppt2 = HSLFTestDataSamples.writeOutAndReadBack(ppt1);
HeadersFooters hdd2 = ppt2.getNotesHeadersFooters();
assertTrue(hdd2.isSlideNumberVisible());
assertTrue(hdd2.isFooterVisible());
assertEquals("My notes footer", hdd2.getFooterText());
assertTrue(hdd2.isHeaderVisible());
assertEquals("My notes header", hdd2.getHeaderText());
ppt2.close();
ppt1.close();
}
Aggregations