Search in sources :

Example 1 with MasterSheet

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

the class HSLFTextParagraph method setPropVal.

/**
     * Returns the named TextProp, either by fetching it (if it exists) or
     * adding it (if it didn't)
     *
     * @param props the TextPropCollection to fetch from / add into
     * @param name the name of the TextProp to fetch/add
     * @param val the value, null if unset
     */
protected void setPropVal(TextPropCollection props, TextPropCollection masterProps, String name, Integer val) {
    TextPropCollection pc = props;
    if (getSheet() instanceof MasterSheet && masterProps != null) {
        pc = masterProps;
    }
    if (val == null) {
        pc.removeByName(name);
        return;
    }
    // Fetch / Add the TextProp
    TextProp tp = pc.addWithName(name);
    tp.setValue(val);
}
Also used : BitMaskTextProp(org.apache.poi.hslf.model.textproperties.BitMaskTextProp) TextProp(org.apache.poi.hslf.model.textproperties.TextProp) ParagraphFlagsTextProp(org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp) MasterSheet(org.apache.poi.sl.usermodel.MasterSheet) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection)

Example 2 with MasterSheet

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

the class HSLFSimpleShape method getPlaceholder.

@Override
public Placeholder getPlaceholder() {
    List<? extends Record> clRecords = getClientRecords();
    if (clRecords == null) {
        return null;
    }
    int phSource;
    HSLFSheet sheet = getSheet();
    if (sheet instanceof HSLFSlideMaster) {
        phSource = 1;
    } else if (sheet instanceof HSLFNotes) {
        phSource = 2;
    } else if (sheet instanceof MasterSheet) {
        // notes master aren't yet supported ...
        phSource = 3;
    } else {
        phSource = 0;
    }
    for (Record r : clRecords) {
        int phId;
        if (r instanceof OEPlaceholderAtom) {
            phId = ((OEPlaceholderAtom) r).getPlaceholderId();
        } else if (r instanceof RoundTripHFPlaceholder12) {
            //special case for files saved in Office 2007
            phId = ((RoundTripHFPlaceholder12) r).getPlaceholderId();
        } else {
            continue;
        }
        switch(phSource) {
            case 0:
                return Placeholder.lookupNativeSlide(phId);
            default:
            case 1:
                return Placeholder.lookupNativeSlideMaster(phId);
            case 2:
                return Placeholder.lookupNativeNotes(phId);
            case 3:
                return Placeholder.lookupNativeNotesMaster(phId);
        }
    }
    return null;
}
Also used : RoundTripHFPlaceholder12(org.apache.poi.hslf.record.RoundTripHFPlaceholder12) MasterSheet(org.apache.poi.sl.usermodel.MasterSheet) EscherChildAnchorRecord(org.apache.poi.ddf.EscherChildAnchorRecord) Record(org.apache.poi.hslf.record.Record) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) EscherClientAnchorRecord(org.apache.poi.ddf.EscherClientAnchorRecord) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord) HSLFEscherClientDataRecord(org.apache.poi.hslf.record.HSLFEscherClientDataRecord) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) OEPlaceholderAtom(org.apache.poi.hslf.record.OEPlaceholderAtom)

Example 3 with MasterSheet

use of org.apache.poi.sl.usermodel.MasterSheet 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)

Aggregations

MasterSheet (org.apache.poi.sl.usermodel.MasterSheet)3 AbstractEscherOptRecord (org.apache.poi.ddf.AbstractEscherOptRecord)1 EscherChildAnchorRecord (org.apache.poi.ddf.EscherChildAnchorRecord)1 EscherClientAnchorRecord (org.apache.poi.ddf.EscherClientAnchorRecord)1 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)1 EscherOptRecord (org.apache.poi.ddf.EscherOptRecord)1 EscherRecord (org.apache.poi.ddf.EscherRecord)1 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)1 BitMaskTextProp (org.apache.poi.hslf.model.textproperties.BitMaskTextProp)1 ParagraphFlagsTextProp (org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp)1 TextProp (org.apache.poi.hslf.model.textproperties.TextProp)1 TextPropCollection (org.apache.poi.hslf.model.textproperties.TextPropCollection)1 HSLFEscherClientDataRecord (org.apache.poi.hslf.record.HSLFEscherClientDataRecord)1 OEPlaceholderAtom (org.apache.poi.hslf.record.OEPlaceholderAtom)1 Record (org.apache.poi.hslf.record.Record)1 RoundTripHFPlaceholder12 (org.apache.poi.hslf.record.RoundTripHFPlaceholder12)1 DrawPaint (org.apache.poi.sl.draw.DrawPaint)1 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)1 Placeholder (org.apache.poi.sl.usermodel.Placeholder)1