Search in sources :

Example 1 with Placeholder

use of org.apache.poi.sl.usermodel.Placeholder in project poi by apache.

the class HSLFTextParagraph method isHeaderOrFooter.

/**
     * {@inheritDoc}
     * 
     * @see RoundTripHFPlaceholder12
     */
@Override
public boolean isHeaderOrFooter() {
    HSLFTextShape s = getParentShape();
    if (s == null) {
        return false;
    }
    Placeholder ph = s.getPlaceholder();
    if (ph == null) {
        return false;
    }
    switch(ph) {
        case DATETIME:
        case SLIDE_NUMBER:
        case FOOTER:
        case HEADER:
            return true;
        default:
            return false;
    }
}
Also used : Placeholder(org.apache.poi.sl.usermodel.Placeholder)

Example 2 with Placeholder

use of org.apache.poi.sl.usermodel.Placeholder in project poi by apache.

the class TestBugs method bug58159.

@Test
public void bug58159() throws IOException {
    HSLFSlideShow ppt = open("bug58159_headers-and-footers.ppt");
    HeadersFooters hf = ppt.getSlideHeadersFooters();
    assertNull(hf.getHeaderText());
    assertEquals("Slide footer", hf.getFooterText());
    hf = ppt.getNotesHeadersFooters();
    assertEquals("Notes header", hf.getHeaderText());
    assertEquals("Notes footer", hf.getFooterText());
    HSLFSlide sl = ppt.getSlides().get(0);
    hf = sl.getHeadersFooters();
    assertNull(hf.getHeaderText());
    assertEquals("Slide footer", hf.getFooterText());
    for (HSLFShape shape : sl.getShapes()) {
        if (shape instanceof HSLFTextShape) {
            HSLFTextShape ts = (HSLFTextShape) shape;
            Placeholder ph = ts.getPlaceholder();
            if (Placeholder.FOOTER == ph) {
                assertEquals("Slide footer", ts.getText());
            }
        }
    }
    ppt.close();
}
Also used : HeadersFooters(org.apache.poi.hslf.model.HeadersFooters) Placeholder(org.apache.poi.sl.usermodel.Placeholder) Test(org.junit.Test)

Example 3 with Placeholder

use of org.apache.poi.sl.usermodel.Placeholder in project poi by apache.

the class HSLFTextRun method getFieldType.

@Override
public FieldType getFieldType() {
    HSLFTextShape ts = getTextParagraph().getParentShape();
    Placeholder ph = ts.getPlaceholder();
    if (ph != null) {
        switch(ph) {
            case SLIDE_NUMBER:
                return FieldType.SLIDE_NUMBER;
            case DATETIME:
                return FieldType.DATE_TIME;
            default:
                break;
        }
    }
    if (ts.getSheet() instanceof MasterSheet) {
        TextShape<?, ? extends TextParagraph<?, ?, ? extends TextRun>> ms = ts.getMetroShape();
        if (ms == null || ms.getTextParagraphs().isEmpty()) {
            return null;
        }
        List<? extends TextRun> trList = ms.getTextParagraphs().get(0).getTextRuns();
        if (trList.isEmpty()) {
            return null;
        }
        return trList.get(0).getFieldType();
    }
    return null;
}
Also used : Placeholder(org.apache.poi.sl.usermodel.Placeholder) MasterSheet(org.apache.poi.sl.usermodel.MasterSheet)

Example 4 with Placeholder

use of org.apache.poi.sl.usermodel.Placeholder in project poi by apache.

the class HSLFTextShape method setTextPlaceholder.

@Override
public void setTextPlaceholder(TextPlaceholder placeholder) {
    // TOOD: check for correct placeholder handling - see org.apache.poi.hslf.model.Placeholder
    Placeholder ph = null;
    int runType;
    switch(placeholder) {
        default:
        case BODY:
            runType = TextHeaderAtom.BODY_TYPE;
            ph = Placeholder.BODY;
            break;
        case TITLE:
            runType = TextHeaderAtom.TITLE_TYPE;
            ph = Placeholder.TITLE;
            break;
        case CENTER_BODY:
            runType = TextHeaderAtom.CENTRE_BODY_TYPE;
            ph = Placeholder.BODY;
            break;
        case CENTER_TITLE:
            runType = TextHeaderAtom.CENTER_TITLE_TYPE;
            ph = Placeholder.TITLE;
            break;
        case HALF_BODY:
            runType = TextHeaderAtom.HALF_BODY_TYPE;
            ph = Placeholder.BODY;
            break;
        case QUARTER_BODY:
            runType = TextHeaderAtom.QUARTER_BODY_TYPE;
            ph = Placeholder.BODY;
            break;
        case NOTES:
            runType = TextHeaderAtom.NOTES_TYPE;
            break;
        case OTHER:
            runType = TextHeaderAtom.OTHER_TYPE;
            break;
    }
    setRunType(runType);
    if (ph != null) {
        setPlaceholder(ph);
    }
}
Also used : Placeholder(org.apache.poi.sl.usermodel.Placeholder)

Example 5 with Placeholder

use of org.apache.poi.sl.usermodel.Placeholder in project poi by apache.

the class XSLFSlideLayout method copyLayout.

/**
     * Copy placeholders from this layout to the destination slide
     *
     * @param slide destination slide
     */
public void copyLayout(XSLFSlide slide) {
    for (XSLFShape sh : getShapes()) {
        if (sh instanceof XSLFTextShape) {
            XSLFTextShape tsh = (XSLFTextShape) sh;
            Placeholder ph = tsh.getTextType();
            if (ph == null)
                continue;
            switch(ph) {
                // these are special and not copied by default
                case DATETIME:
                case SLIDE_NUMBER:
                case FOOTER:
                    break;
                default:
                    slide.getSpTree().addNewSp().set(tsh.getXmlObject().copy());
            }
        }
    }
}
Also used : CTPlaceholder(org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder) Placeholder(org.apache.poi.sl.usermodel.Placeholder)

Aggregations

Placeholder (org.apache.poi.sl.usermodel.Placeholder)6 QName (javax.xml.namespace.QName)1 Hyperlink (org.apache.poi.common.usermodel.Hyperlink)1 HeadersFooters (org.apache.poi.hslf.model.HeadersFooters)1 MasterSheet (org.apache.poi.sl.usermodel.MasterSheet)1 XmlObject (org.apache.xmlbeans.XmlObject)1 Test (org.junit.Test)1 CTPicture (org.openxmlformats.schemas.presentationml.x2006.main.CTPicture)1 CTPlaceholder (org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder)1 AttributesImpl (org.xml.sax.helpers.AttributesImpl)1