List of usage examples for org.apache.poi.xslf.usermodel XSLFSlide getSlideNumber
@Override
public int getSlideNumber()
From source file:com.github.codeurjc.slidesconverter.PowerPointToHTML.java
License:Apache License
private void generateSlidesContent(XMLSlideShow pptx, HSLFSlideShow ppt) throws IOException { out.println("<h1>Slides</h1>"); for (int numSlide = 0; numSlide < pptx.getSlides().size(); numSlide++) { System.out.println("Processing slide " + numSlide); XSLFSlide slideX = pptx.getSlides().get(numSlide); HSLFSlide slide = ppt.getSlides().get(numSlide); Section section = getSection(numSlide); if (section != null && section.startSlide == numSlide) { if (section.level == 0) { out.println("<h2>" + escape(section.sectionNum + ". " + section.name) + "</h2>"); } else { out.println(/* w w w . j a v a 2s.c o m*/ "<h3>" + escape(section.sectionNum + "." + section.subsectionNum + ". " + section.name) + "</h3>"); } } generateSlideImage(slide); out.println("<h4>Slide (" + (numSlide + 1) + ")</h4>"); out.println("<img src=" + getImageFileName(slideX.getSlideNumber()) + "><br>"); for (XSLFShape shape : slideX.getShapes()) { if (shape instanceof XSLFTextShape) { XSLFTextShape tsh = (XSLFTextShape) shape; boolean first = true; boolean code = false; boolean subtitle = false; for (XSLFTextParagraph p : tsh) { String indent = ""; int indentLevel = p.getIndentLevel(); if (subtitle) { indentLevel++; } if (indentLevel > 0) { for (int j = 0; j < indentLevel; j++) { indent += "> "; } } StringBuilder sb = new StringBuilder(); for (XSLFTextRun r : p) { sb.append(r.getRawText()); } String text = sb.toString(); // Avoid section or subsection name to appear in slide // contents if ((section != null && (text.equals(section.name) || (section.parentSection != null && section.parentSection.name.equals(text)))) || text.trim().isEmpty()) { continue; } if (first) { code = p.getDefaultFontFamily().startsWith("Courier"); if (code) { out.println("<pre style='border:1px;border-style: solid;'>"); } } if (!code) { out.println("<p>"); } out(indent + text); if (!code) { out.println("</p>"); } first = false; if (p.getTextAlign() == TextAlign.CENTER) { subtitle = true; } } if (code) { out.println("</pre>"); } } else if (shape instanceof XSLFPictureShape) { XSLFPictureShape pShape = (XSLFPictureShape) shape; out.println("<p>Imagen: " + pShape.getShapeName() + "</p>"); } } out.println("<hr>"); } out.println("</body></html>"); }
From source file:com.github.codeurjc.slidesconverter.PowerPointToHTML.java
License:Apache License
private String calculateTitle(XSLFSlide slideX, HSLFSlide slide) { String title = slide.getTitle(); if (title != null) { return title; }/* w w w .j a va 2 s. c o m*/ title = slideX.getTitle(); if (title != null) { return title; } boolean titleSlide = ArrayUtils.contains(titleSlides, slideX.getSlideNumber()); for (XSLFShape shape : slideX.getShapes()) { if (shape instanceof XSLFTextShape) { XSLFTextShape tsh = (XSLFTextShape) shape; Rectangle2D figure = getRelativeFigure(tsh); if (titleSlide || figure.getY() < 0.1) { StringBuilder titleSB = new StringBuilder(); for (XSLFTextParagraph p : tsh) { for (XSLFTextRun r : p) { titleSB.append(r.getRawText()); } } title = titleSB.toString(); if (!title.trim().isEmpty()) { return title; } } } } return null; }
From source file:easyoffice.powerpoint.PPTMaker.java
private static XSLFSlide copySlide(XMLSlideShow ppt, XSLFSlide srcSlide) { /*/*from w ww . j a v a2s. c o m*/ Create new slide instance copy */ XSLFSlideLayout layout = srcSlide.getSlideLayout(); XSLFSlide newSlide = ppt.createSlide(layout); ppt.setSlideOrder(newSlide, srcSlide.getSlideNumber()); return newSlide.importContent(srcSlide); }