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);
}
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;
}
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;
}
Aggregations