use of org.apache.poi.hslf.usermodel.HSLFTextShape in project poi by apache.
the class HeadersFooters method getPlaceholderText.
private String getPlaceholderText(Placeholder ph, CString cs) {
String text;
if (_ppt2007) {
HSLFSimpleShape ss = _sheet.getPlaceholder(ph);
text = (ss instanceof HSLFTextShape) ? ((HSLFTextShape) ss).getText() : null;
// default text in master placeholders is not visible
if ("*".equals(text)) {
text = null;
}
} else {
text = (cs == null) ? null : cs.getText();
}
return text;
}
use of org.apache.poi.hslf.usermodel.HSLFTextShape in project tika by apache.
the class HSLFExtractor method extractMaster.
private void extractMaster(XHTMLContentHandler xhtml, HSLFMasterSheet master) throws SAXException {
if (master == null) {
return;
}
List<HSLFShape> shapes = master.getShapes();
if (shapes == null || shapes.isEmpty()) {
return;
}
xhtml.startElement("div", "class", "slide-master-content");
for (HSLFShape shape : shapes) {
if (shape != null && !HSLFMasterSheet.isPlaceholder(shape)) {
if (shape instanceof HSLFTextShape) {
HSLFTextShape tsh = (HSLFTextShape) shape;
String text = tsh.getText();
if (text != null) {
xhtml.element("p", text);
}
}
}
}
xhtml.endElement("div");
}
use of org.apache.poi.hslf.usermodel.HSLFTextShape in project poi by apache.
the class TestXSLFTextShape method metroBlob.
@Test
public void metroBlob() throws IOException {
assumeFalse(xslfOnly);
File f = POIDataSamples.getSlideShowInstance().getFile("bug52297.ppt");
SlideShow<?, ?> ppt = SlideShowFactory.create(f);
HSLFTextShape sh = (HSLFTextShape) ppt.getSlides().get(1).getShapes().get(3);
XSLFAutoShape xsh = (XSLFAutoShape) sh.getMetroShape();
String textExp = " ___ ___ ___ ________ __ _______ ___ ___________ __________ __ _____ ___ ___ ___ _______ ____ ______ ___________ _____________ ___ _______ ______ ____ ______ __ ___________ __________ ___ _________ _____ ________ __________ ___ _______ __________ ";
String textAct = xsh.getText();
ppt.close();
assertEquals(textExp, textAct);
}
use of org.apache.poi.hslf.usermodel.HSLFTextShape in project poi by apache.
the class TestShapes method lineColor.
@Test
public void lineColor() throws IOException {
HSLFSlideShow ss = new HSLFSlideShow(_slTests.openResourceAsStream("51731.ppt"));
List<HSLFShape> shape = ss.getSlides().get(0).getShapes();
assertEquals(4, shape.size());
HSLFTextShape sh1 = (HSLFTextShape) shape.get(0);
assertEquals("Hello Apache POI", sh1.getText());
assertNull(sh1.getLineColor());
HSLFTextShape sh2 = (HSLFTextShape) shape.get(1);
assertEquals("Why are you showing this border?", sh2.getText());
assertNull(sh2.getLineColor());
HSLFTextShape sh3 = (HSLFTextShape) shape.get(2);
assertEquals("Text in a black border", sh3.getText());
assertEquals(Color.black, sh3.getLineColor());
assertEquals(0.75, sh3.getLineWidth(), 0);
HSLFTextShape sh4 = (HSLFTextShape) shape.get(3);
assertEquals("Border width is 5 pt", sh4.getText());
assertEquals(Color.black, sh4.getLineColor());
assertEquals(5.0, sh4.getLineWidth(), 0);
ss.close();
}
use of org.apache.poi.hslf.usermodel.HSLFTextShape in project poi by apache.
the class TestShapes method textBoxSet.
private void textBoxSet(String filename) throws IOException {
HSLFSlideShow ss = new HSLFSlideShow(_slTests.openResourceAsStream(filename));
for (HSLFSlide sld : ss.getSlides()) {
ArrayList<String> lst1 = new ArrayList<String>();
for (List<HSLFTextParagraph> txt : sld.getTextParagraphs()) {
for (HSLFTextParagraph p : txt) {
for (HSLFTextRun r : p) {
lst1.add(r.getRawText());
}
}
}
ArrayList<String> lst2 = new ArrayList<String>();
for (HSLFShape sh : sld.getShapes()) {
if (sh instanceof HSLFTextShape) {
HSLFTextShape tbox = (HSLFTextShape) sh;
for (HSLFTextParagraph p : tbox.getTextParagraphs()) {
for (HSLFTextRun r : p) {
lst2.add(r.getRawText());
}
}
}
}
assertTrue(lst1.containsAll(lst2));
assertTrue(lst2.containsAll(lst1));
}
ss.close();
}
Aggregations