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