org.apache.poi.xslf.usermodel.XSLFSlide类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(244)

本文整理了Java中org.apache.poi.xslf.usermodel.XSLFSlide类的一些代码示例,展示了XSLFSlide类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSLFSlide类的具体详情如下:
包路径:org.apache.poi.xslf.usermodel.XSLFSlide
类名称:XSLFSlide

XSLFSlide介绍

暂无

代码示例

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. /**
  2. * Return notes slide for the specified slide or create new if it does not exist yet.
  3. */
  4. public XSLFNotes getNotesSlide(XSLFSlide slide) {
  5. XSLFNotes notesSlide = slide.getNotes();
  6. if (notesSlide == null) {
  7. notesSlide = createNotesSlide(slide);
  8. }
  9. return notesSlide;
  10. }

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. cnt = findNextAvailableFileNameIndex(relationType, cnt);
  2. RelationPart rp = createRelationship
  3. (relationType, XSLFFactory.getInstance(), cnt, false);
  4. XSLFSlide slide = rp.getDocumentPart();
  5. slide.getPackagePart().clearRelationships();
  6. slide.addRelation(null, XSLFRelation.SLIDE_LAYOUT, layout);

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. /**
  2. *
  3. * @return the information about background appearance of this slide
  4. */
  5. @Override
  6. public XSLFBackground getBackground() {
  7. CTBackground bg = _slide.getCSld().getBg();
  8. if(bg != null) {
  9. return new XSLFBackground(bg, this);
  10. } else {
  11. return getMasterSheet().getBackground();
  12. }
  13. }

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. /**
  2. * @return the comment authors part or {@code null} if there weren't any comments
  3. * @since POI 4.0.0
  4. */
  5. @SuppressWarnings("WeakerAccess")
  6. public XSLFCommentAuthors getCommentAuthorsPart() {
  7. if(_commentAuthors == null) {
  8. // first scan the slide relations
  9. for (POIXMLDocumentPart p : getRelations()) {
  10. if (p instanceof XSLFCommentAuthors) {
  11. _commentAuthors = (XSLFCommentAuthors)p;
  12. return _commentAuthors;
  13. }
  14. }
  15. // then scan the presentation relations
  16. for (POIXMLDocumentPart p : getSlideShow().getRelations()) {
  17. if (p instanceof XSLFCommentAuthors) {
  18. _commentAuthors = (XSLFCommentAuthors)p;
  19. return _commentAuthors;
  20. }
  21. }
  22. }
  23. return null;
  24. }

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. public XSLFSlide removeSlide(int index) {
  2. XSLFSlide slide = _slides.remove(index);
  3. removeRelation(slide);
  4. _presentation.getSldIdLst().removeSldId(index);
  5. for (POIXMLDocumentPart p : slide.getRelations()) {
  6. if (p instanceof XSLFChart) {
  7. XSLFChart chart = (XSLFChart) p;
  8. slide.removeChartRelation(chart);
  9. _charts.remove(chart);
  10. } else if (p instanceof XSLFSlideLayout) {
  11. XSLFSlideLayout layout = (XSLFSlideLayout) p;
  12. slide.removeLayoutRelation(layout);
  13. }
  14. }
  15. return slide;
  16. }

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. @Override
  2. public String getSlideName() {
  3. final CTCommonSlideData cSld = getXmlObject().getCSld();
  4. return cSld.isSetName() ? cSld.getName() : "Slide"+getSlideNumber();
  5. }
  6. }

代码示例来源:origin: apache/tika

  1. List<XSLFSlide> slides = slideShow.getSlides();
  2. for (XSLFSlide slide : slides) {
  3. String slideDesc;
  4. if (slide.getPackagePart() != null && slide.getPackagePart().getPartName() != null) {
  5. slideDesc = getJustFileName(slide.getPackagePart().getPartName().toString());
  6. slideDesc += "_";
  7. } else {
  8. extractContent(slide.getShapes(), false, xhtml, slideDesc);
  9. xhtml.endElement("div");
  10. XSLFSlideLayout slideLayout = slide.getMasterSheet();
  11. extractContent(slideLayout.getShapes(), true, xhtml, null);
  12. xhtml.endElement("div");
  13. XSLFNotes slideNotes = slide.getNotes();
  14. if (slideNotes != null) {
  15. xhtml.startElement("div", "class", "slide-notes");
  16. List<XSLFComment> comments = slide.getComments();
  17. if (comments != null) {
  18. StringBuilder authorStringBuilder = new StringBuilder();
  19. RELATION_DIAGRAM_DATA,
  20. "diagram-data",
  21. slide.getPackagePart(),
  22. metadata,
  23. new OOXMLWordAndPowerPointTextHandler(

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. StringBuffer text = new StringBuffer();
  2. XSLFSlide[] slides = slideshow.getSlides();
  3. XSLFCommentAuthors commentAuthors = slideshow.getCommentAuthors();
  4. XSLFNotes notes = slide.getNotes();
  5. XSLFComments comments = slide.getComments();
  6. XSLFSlideLayout layout = slide.getSlideLayout();
  7. XSLFSlideMaster master = layout.getSlideMaster();
  8. extractText(slide.getCommonSlideData(), false, text);

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. XMLSlideShow ppt = new XMLSlideShow(OPCPackage.open(file));
  2. Dimension pgsize = ppt.getPageSize();
  3. int width = (int) (pgsize.width * scale);
  4. int height = (int) (pgsize.height * scale);
  5. XSLFSlide[] slide = ppt.getSlides();
  6. for (int i = 0; i < slide.length; i++) {
  7. if (slidenum != -1 && slidenum != (i + 1)) continue;
  8. String title = slide[i].getTitle();
  9. System.out.println("Rendering slide " + (i + 1) + (title == null ? "" : ": " + title));
  10. slide[i].draw(graphics);

代码示例来源:origin: graphaware/neo4j-nlp

  1. @Override
  2. public List<Page> parse(InputStream fs, List<String> filterPatterns) throws Exception {
  3. List<Page> pages = new ArrayList<>();
  4. XMLSlideShow ppt = new XMLSlideShow(fs);
  5. ppt.getSlides().forEach(slide -> {
  6. Page page = new Page(slide.getSlideNumber());
  7. for (XSLFShape shape : slide.getShapes()) {
  8. if (shape instanceof XSLFTextShape) {
  9. page.getParagraphs().add(((XSLFTextShape) shape).getText());
  10. }
  11. }
  12. pages.add(page);
  13. });
  14. return pages;
  15. }
  16. }

代码示例来源:origin: stackoverflow.com

  1. XMLSlideShow pptx = new XMLSlideShow();
  2. XSLFSlide slide = pptx.createSlide();
  3. XSLFTable table = slide.createTable();
  4. table.setAnchor(new Rectangle2D.Double(50, 50, 500, 20));
  5. PackagePart part = pptx.getPackage().createPart(partName, "image/gif");
  6. OutputStream partOs = part.getOutputStream();
  7. FileInputStream fis = new FileInputStream("src/test/resources/100px.gif");
  8. partOs.close();
  9. PackageRelationship prs = slide.getPackagePart().addRelationship(partName, TargetMode.INTERNAL, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image");

代码示例来源:origin: org.apache.poi/poi-examples

  1. try (XMLSlideShow pptx = new XMLSlideShow(argIS)) {
  2. XSLFSlide slide = pptx.getSlides().get(0);
  3. for (POIXMLDocumentPart part : slide.getRelations()) {
  4. if (part instanceof XSLFChart) {
  5. chart = (XSLFChart) part;
  6. pptx.write(out);

代码示例来源:origin: org.apache.poi/poi-examples

  1. try (XMLSlideShow ppt = new XMLSlideShow(fis)) {
  2. fis.close();
  3. for (XSLFSlide slide : ppt.getSlides()) {
  4. System.out.println("Title: " + slide.getTitle());
  5. for (XSLFShape shape : slide.getShapes()) {
  6. if (shape instanceof XSLFTextShape) {
  7. XSLFTextShape tsh = (XSLFTextShape) shape;

代码示例来源:origin: Texera/texera

  1. /**
  2. * Extracts data from PPT/PPTX from using poi.
  3. *
  4. * @param path
  5. * @return
  6. * @throws DataflowException
  7. */
  8. public static String extractPPTFile(Path path) throws DataflowException {
  9. try (FileInputStream inputStream = new FileInputStream(path.toString());
  10. XMLSlideShow ppt = new XMLSlideShow(inputStream)) {
  11. StringBuffer res = new StringBuffer();
  12. for (XSLFSlide slide : ppt.getSlides()) {
  13. List<XSLFShape> shapes = slide.getShapes();
  14. for (XSLFShape shape : shapes) {
  15. if (shape instanceof XSLFTextShape) {
  16. XSLFTextShape textShape = (XSLFTextShape) shape;
  17. String text = textShape.getText();
  18. res.append(text);
  19. }
  20. }
  21. }
  22. return res.toString();
  23. } catch (IOException e) {
  24. throw new DataflowException(e);
  25. }
  26. }

代码示例来源:origin: stackoverflow.com

  1. XSLFSlide[] slides = ppt.getSlides();
  2. XSLFSlide slide1 =slides[0];
  3. XSLFShape shapes[]= slide1.getShapes();
  4. for(int i=0;i<shapes.length;i++){
  5. System.out.println(shapes[i].getShapeName());
  6. int idx = ppt.addPicture(pictureData,
  7. XSLFPictureData.PICTURE_TYPE_PNG);
  8. XSLFPictureShape picture = slide1.createPicture(idx);
  9. slide1.removeShape(pic);
  10. ppt.write(fos);
  11. fos.close();

代码示例来源:origin: stackoverflow.com

  1. public static void main(String[] args) throws Exception {
  2. XMLSlideShow ss = new XMLSlideShow();
  3. Dimension pgsize = ss.getPageSize();
  4. XSLFSlide slide = ss.createSlide();
  5. XSLFTextBox tb = slide.createTextBox();
  6. tb.setShapeType(XSLFShapeType.HEART);
  7. int shapeSize = 150;
  8. graphics.setPaint(Color.white);
  9. graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
  10. slide.draw(graphics);

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. /**
  2. * @return the comments part or {@code null} if there weren't any comments
  3. * @since POI 4.0.0
  4. */
  5. @SuppressWarnings("WeakerAccess")
  6. public XSLFComments getCommentsPart() {
  7. if(_comments == null) {
  8. for (POIXMLDocumentPart p : getRelations()) {
  9. if (p instanceof XSLFComments) {
  10. _comments = (XSLFComments)p;
  11. break;
  12. }
  13. }
  14. }
  15. return _comments;
  16. }

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. /**
  2. * Create a blank notes slide.
  3. */
  4. private XSLFNotes createNotesSlide(XSLFSlide slide) {
  5. if (_notesMaster == null) {
  6. createNotesMaster();
  7. }
  8. int slideIndex = XSLFRelation.SLIDE.getFileNameIndex(slide);
  9. XSLFRelation relationType = XSLFRelation.NOTES;
  10. slideIndex = findNextAvailableFileNameIndex(relationType, slideIndex);
  11. // add notes slide to presentation
  12. XSLFNotes notesSlide = (XSLFNotes) createRelationship
  13. (relationType, XSLFFactory.getInstance(), slideIndex);
  14. // link slide and notes slide with each other
  15. slide.addRelation(null, relationType, notesSlide);
  16. notesSlide.addRelation(null, XSLFRelation.NOTES_MASTER, _notesMaster);
  17. notesSlide.addRelation(null, XSLFRelation.SLIDE, slide);
  18. notesSlide.importContent(_notesMaster);
  19. return notesSlide;
  20. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. /**
  2. * Create a slide and initialize it from the specified layout.
  3. *
  4. * @param layout
  5. * @return created slide
  6. */
  7. public XSLFSlide createSlide(XSLFSlideLayout layout) {
  8. int slideNumber = 256, cnt = 1;
  9. CTSlideIdList slideList;
  10. if (!_presentation.isSetSldIdLst()) slideList = _presentation.addNewSldIdLst();
  11. else {
  12. slideList = _presentation.getSldIdLst();
  13. for(CTSlideIdListEntry slideId : slideList.getSldIdList()){
  14. slideNumber = (int)Math.max(slideId.getId() + 1, slideNumber);
  15. cnt++;
  16. }
  17. }
  18. XSLFSlide slide = (XSLFSlide)createRelationship(
  19. XSLFRelation.SLIDE, XSLFFactory.getInstance(), cnt);
  20. CTSlideIdListEntry slideId = slideList.addNewSldId();
  21. slideId.setId(slideNumber);
  22. slideId.setId2(slide.getPackageRelationship().getId());
  23. layout.copyLayout(slide);
  24. slide.addRelation(layout.getPackageRelationship().getId(), layout);
  25. PackagePartName ppName = layout.getPackagePart().getPartName();
  26. slide.getPackagePart().addRelationship(ppName, TargetMode.INTERNAL,
  27. layout.getPackageRelationship().getRelationshipType());
  28. _slides.add(slide);
  29. return slide;
  30. }

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. @Override
  2. public XSLFSlideLayout getMasterSheet(){
  3. return getSlideLayout();
  4. }

相关文章