Refine search
@Override public String getTitle(){ XSLFTextShape txt = getTextShapeByType(Placeholder.TITLE); return txt == null ? null : txt.getText(); }
CTTextBody otherTB = otherTS.getTextBody(false); CTTextBody thisTB = getTextBody(true); if (otherTB == null) { return; boolean srcWordWrap = otherTS.getWordWrap(); if (srcWordWrap != getWordWrap()) { setWordWrap(srcWordWrap); double leftInset = otherTS.getLeftInset(); if (leftInset != getLeftInset()) { setLeftInset(leftInset); double rightInset = otherTS.getRightInset(); if (rightInset != getRightInset()) { setRightInset(rightInset); double topInset = otherTS.getTopInset(); if (topInset != getTopInset()) { setTopInset(topInset); double bottomInset = otherTS.getBottomInset(); if (bottomInset != getBottomInset()) { setBottomInset(bottomInset); VerticalAlignment vAlign = otherTS.getVerticalAlignment(); if (vAlign != getVerticalAlignment()) { setVerticalAlignment(vAlign);
/** * Copy placeholders from this layout to the destination slide * * @param slide destination slide */ @SuppressWarnings("WeakerAccess") 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()); } } } }
@Override public Insets2D getInsets() { return new Insets2D(getTopInset(), getLeftInset(), getBottomInset(), getRightInset()); }
@Override public Rectangle2D resizeToFitText(Graphics2D graphics) { Rectangle2D anchor = getAnchor(); if (anchor.getWidth() == 0.) { throw new POIXMLException("Anchor of the shape was not set."); } double height = getTextHeight(graphics); height += 1; // add a pixel to compensate rounding errors Insets2D insets = getInsets(); anchor.setRect(anchor.getX(), anchor.getY(), anchor.getWidth(), height + insets.top + insets.bottom); setAnchor(anchor); return anchor; }
firstPara = !newParagraph; para = _paragraphs.get(_paragraphs.size() - 1); CTTextParagraph ctp = para.getXmlObject(); otherPPr = ctp.getPPr(); List<XSLFTextRun> runs = para.getTextRuns(); if (!runs.isEmpty()) { XSLFTextRun r0 = runs.get(runs.size() - 1); if (!firstPara) { if (para != null) { CTTextParagraph ctp = para.getXmlObject(); CTTextCharacterProperties unexpectedRPr = ctp.getEndParaRPr(); if (unexpectedRPr != null && unexpectedRPr != otherRPr) { para = addNewTextParagraph(); if (otherPPr != null) { para.getXmlObject().setPPr(otherPPr);
Placeholder ph = txt.getTextType(); if (skipPlaceholders && ph != null) { continue; for (XSLFTextParagraph p : txt.getTextParagraphs()) { xhtml.startElement("p"); if (! config.getIncludeHeadersAndFooters() && p.isHeaderOrFooter()) { continue; for (XSLFTextRun run : p.getTextRuns()) {
private void fetchCharacterProperty(final CharacterPropertyFetcher<?> visitor){ XSLFTextShape shape = _p.getParentShape(); CTTextCharacterProperties rPr = getRPr(false); if (rPr != null && visitor.fetch(rPr)) { return; } if (shape.fetchShapeProperty(visitor)) { return; } if (_p.fetchThemeProperty(visitor)) { return; } _p.fetchMasterProperty(visitor); }
double leftInset = _shape.getLeftInset(); double rightInset = _shape.getRightInset(); double leftMargin = getLeftMargin(); double indent = getIndent(); if(!_shape.getWordWrap()) { width = _shape.getSheet().getSlideShow().getPageSize().getWidth() - anchor.getX(); } else { width = anchor.getWidth() - leftInset - rightInset - leftMargin; if(firstLine) { if(isBullet()){ if(indent > 0) width -= indent; } else {
XSLFTextShape[] ph1 = slide1.getPlaceholders(); XSLFTextShape titlePlaceholder1 = ph1[0]; titlePlaceholder1.setText("This is a title"); XSLFTextShape subtitlePlaceholder1 = ph1[1]; subtitlePlaceholder1.setText("this is a subtitle"); XSLFTextShape[] ph2 = slide2.getPlaceholders(); XSLFTextShape titlePlaceholder2 = ph2[0]; titlePlaceholder2.setText("This is a title"); XSLFTextShape bodyPlaceholder = ph2[1]; bodyPlaceholder.clearText(); XSLFTextParagraph p1 = bodyPlaceholder.addNewTextParagraph(); p1.setIndentLevel(0); p1.addNewTextRun().setText("Level1 text"); XSLFTextParagraph p2 = bodyPlaceholder.addNewTextParagraph(); p2.setIndentLevel(1); p2.addNewTextRun().setText("Level2 text"); XSLFTextParagraph p3 = bodyPlaceholder.addNewTextParagraph(); p3.setIndentLevel(2); p3.addNewTextRun().setText("Level3 text");
@Override public void drawContent(Graphics2D graphics) { breakText(graphics); RenderableShape rShape = new RenderableShape(this); Rectangle2D anchor = rShape.getAnchor(graphics); double x = anchor.getX() + getLeftInset(); double y = anchor.getY(); // first dry-run to calculate the total height of the text double textHeight = getTextHeight(); switch (getVerticalAlignment()){ case TOP: y += getTopInset(); break; case BOTTOM: y += anchor.getHeight() - textHeight - getBottomInset(); break; default: case MIDDLE: double delta = anchor.getHeight() - textHeight - getTopInset() - getBottomInset(); y += getTopInset() + delta/2; break; } drawParagraphs(graphics, x, y); }
public void setText(String text){ clearText(); addNewTextParagraph().addNewTextRun().setText(text); }
public double draw(Graphics2D graphics, double x, double y){ double leftInset = _shape.getLeftInset(); double rightInset = _shape.getRightInset(); RenderableShape rShape = new RenderableShape(_shape); Rectangle2D anchor = rShape.getAnchor(graphics); double penY = y; double leftMargin = getLeftMargin(); boolean firstLine = true; double indent = getIndent(); double spacing = getLineSpacing(); for(TextFragment line : _lines){ double penX = x + leftMargin;
private boolean fetchParagraphProperty(ParagraphPropertyFetcher visitor){ boolean ok = false; if(_p.isSetPPr()) ok = visitor.fetch(_p.getPPr()); if(!ok) { XSLFTextShape shape = getParentShape(); ok = shape.fetchShapeProperty(visitor); if(!ok){ CTPlaceholder ph = shape.getCTPlaceholder(); if(ph == null){ // if it is a plain text box then take defaults from presentation.xml XMLSlideShow ppt = getParentShape().getSheet().getSlideShow(); CTTextParagraphProperties themeProps = ppt.getDefaultParagraphStyle(getLevel()); if(themeProps != null) ok = visitor.fetch(themeProps); } if(!ok){ // defaults for placeholders are defined in the slide master CTTextParagraphProperties defaultProps = getDefaultMasterStyle(); if(defaultProps != null) ok = visitor.fetch(defaultProps); } } } return ok; }
if (sh instanceof XSLFTextShape) { XSLFTextShape txt = (XSLFTextShape) sh; Placeholder ph = txt.getTextType(); if (skipPlaceholders && ph != null) { continue; for (XSLFTextParagraph p : txt.getTextParagraphs()) { xhtml.startElement("p"); for (XSLFTextRun run : p.getTextRuns()) {
XSLFTextShape[] phs = slide[i].getPlaceholders(); for (XSLFTextShape ts : phs) { java.util.List<XSLFTextParagraph> tpl = ts.getTextParagraphs(); for(XSLFTextParagraph tp: tpl) { java.util.List<XSLFTextRun> trs = tp.getTextRuns(); for(XSLFTextRun tr: trs) { logger.info(tr.getFontFamily()); tr.setFontFamily("SimSun"); } } }
@Override public TextPlaceholder getTextPlaceholder() { Placeholder ph = getTextType(); if (ph == null) { return TextPlaceholder.BODY; } switch (ph) { case BODY: return TextPlaceholder.BODY; case TITLE: return TextPlaceholder.TITLE; case CENTERED_TITLE: return TextPlaceholder.CENTER_TITLE; default: case CONTENT: return TextPlaceholder.OTHER; } }
@Override public boolean isHorizontalCentered() { PropertyFetcher<Boolean> fetcher = new TextBodyPropertyFetcher<Boolean>() { @Override public boolean fetch(CTTextBodyProperties props) { if (props.isSetAnchorCtr()) { setValue(props.getAnchorCtr()); return true; } return false; } }; fetchShapeProperty(fetcher); return fetcher.getValue() == null ? false : fetcher.getValue(); }
/** * Adjust the size of the shape so it encompasses the text inside it. * * @return a <code>Rectangle2D</code> that is the bounds of this shape. */ public Rectangle2D resizeToFitText(){ Rectangle2D anchor = getAnchor(); if(anchor.getWidth() == 0.) throw new POIXMLException( "Anchor of the shape was not set."); double height = getTextHeight(); height += 1; // add a pixel to compensate rounding errors anchor.setRect(anchor.getX(), anchor.getY(), anchor.getWidth(), height); setAnchor(anchor); return anchor; }
try { FileInputStream fis = new FileInputStream("C:\\sample\\sample.pptx"); XMLSlideShow pptxshow = new XMLSlideShow(fis); XSLFSlide[] slide2 = pptxshow.getSlides(); for (int i = 0; i < slide2.length; i++) { System.out.println(i); try { XSLFNotes mynotes = slide2[i].getNotes(); for (XSLFShape shape : mynotes) { if (shape instanceof XSLFTextShape) { XSLFTextShape txShape = (XSLFTextShape) shape; for (XSLFTextParagraph xslfParagraph : txShape.getTextParagraphs()) { System.out.println(xslfParagraph.getText()); } } } } catch (Exception e) { } } } catch (IOException e) { }