Search in sources :

Example 1 with HSLFSimpleShape

use of org.apache.poi.hslf.usermodel.HSLFSimpleShape 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;
}
Also used : HSLFTextShape(org.apache.poi.hslf.usermodel.HSLFTextShape) HSLFSimpleShape(org.apache.poi.hslf.usermodel.HSLFSimpleShape) CString(org.apache.poi.hslf.record.CString)

Example 2 with HSLFSimpleShape

use of org.apache.poi.hslf.usermodel.HSLFSimpleShape in project poi by apache.

the class TestShapes method lineWidth.

@Test
public void lineWidth() {
    HSLFSimpleShape sh = new HSLFAutoShape(ShapeType.RT_TRIANGLE);
    AbstractEscherOptRecord opt = sh.getEscherOptRecord();
    EscherSimpleProperty prop = HSLFSimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
    assertNull(prop);
    assertEquals(HSLFSimpleShape.DEFAULT_LINE_WIDTH, sh.getLineWidth(), 0);
    sh.setLineWidth(1.0);
    prop = HSLFSimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
    assertNotNull(prop);
    assertEquals(1.0, sh.getLineWidth(), 0);
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) HSLFAutoShape(org.apache.poi.hslf.usermodel.HSLFAutoShape) HSLFSimpleShape(org.apache.poi.hslf.usermodel.HSLFSimpleShape) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord) Test(org.junit.Test)

Example 3 with HSLFSimpleShape

use of org.apache.poi.hslf.usermodel.HSLFSimpleShape in project poi by apache.

the class Hyperlinks method main.

public static void main(String[] args) throws Exception {
    for (int i = 0; i < args.length; i++) {
        FileInputStream is = new FileInputStream(args[i]);
        HSLFSlideShow ppt = new HSLFSlideShow(is);
        is.close();
        for (HSLFSlide slide : ppt.getSlides()) {
            System.out.println("\nslide " + slide.getSlideNumber());
            // read hyperlinks from the slide's text runs
            System.out.println("- reading hyperlinks from the text runs");
            for (List<HSLFTextParagraph> paras : slide.getTextParagraphs()) {
                for (HSLFTextParagraph para : paras) {
                    for (HSLFTextRun run : para) {
                        HSLFHyperlink link = run.getHyperlink();
                        if (link != null) {
                            System.out.println(toStr(link, run.getRawText()));
                        }
                    }
                }
            }
            // in PowerPoint you can assign a hyperlink to a shape without text,
            // for example to a Line object. The code below demonstrates how to
            // read such hyperlinks
            System.out.println("- reading hyperlinks from the slide's shapes");
            for (HSLFShape sh : slide.getShapes()) {
                if (sh instanceof HSLFSimpleShape) {
                    HSLFHyperlink link = ((HSLFSimpleShape) sh).getHyperlink();
                    if (link != null) {
                        System.out.println(toStr(link, null));
                    }
                }
            }
        }
        ppt.close();
    }
}
Also used : HSLFTextRun(org.apache.poi.hslf.usermodel.HSLFTextRun) HSLFShape(org.apache.poi.hslf.usermodel.HSLFShape) HSLFTextParagraph(org.apache.poi.hslf.usermodel.HSLFTextParagraph) HSLFHyperlink(org.apache.poi.hslf.usermodel.HSLFHyperlink) HSLFSimpleShape(org.apache.poi.hslf.usermodel.HSLFSimpleShape) HSLFSlideShow(org.apache.poi.hslf.usermodel.HSLFSlideShow) HSLFSlide(org.apache.poi.hslf.usermodel.HSLFSlide) FileInputStream(java.io.FileInputStream)

Example 4 with HSLFSimpleShape

use of org.apache.poi.hslf.usermodel.HSLFSimpleShape in project poi by apache.

the class HeadersFooters method isVisible.

private boolean isVisible(int flag, Placeholder placeholderId) {
    boolean visible;
    if (_ppt2007) {
        HSLFSimpleShape ss = _sheet.getPlaceholder(placeholderId);
        visible = ss instanceof HSLFTextShape && ((HSLFTextShape) ss).getText() != null;
    } else {
        visible = _container.getHeadersFootersAtom().getFlag(flag);
    }
    return visible;
}
Also used : HSLFTextShape(org.apache.poi.hslf.usermodel.HSLFTextShape) HSLFSimpleShape(org.apache.poi.hslf.usermodel.HSLFSimpleShape)

Aggregations

HSLFSimpleShape (org.apache.poi.hslf.usermodel.HSLFSimpleShape)4 HSLFTextShape (org.apache.poi.hslf.usermodel.HSLFTextShape)2 FileInputStream (java.io.FileInputStream)1 AbstractEscherOptRecord (org.apache.poi.ddf.AbstractEscherOptRecord)1 EscherSimpleProperty (org.apache.poi.ddf.EscherSimpleProperty)1 CString (org.apache.poi.hslf.record.CString)1 HSLFAutoShape (org.apache.poi.hslf.usermodel.HSLFAutoShape)1 HSLFHyperlink (org.apache.poi.hslf.usermodel.HSLFHyperlink)1 HSLFShape (org.apache.poi.hslf.usermodel.HSLFShape)1 HSLFSlide (org.apache.poi.hslf.usermodel.HSLFSlide)1 HSLFSlideShow (org.apache.poi.hslf.usermodel.HSLFSlideShow)1 HSLFTextParagraph (org.apache.poi.hslf.usermodel.HSLFTextParagraph)1 HSLFTextRun (org.apache.poi.hslf.usermodel.HSLFTextRun)1 Test (org.junit.Test)1