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

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

本文整理了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

/**
 * Return notes slide for the specified slide or create new if it does not exist yet.
 */
public XSLFNotes getNotesSlide(XSLFSlide slide) {
  XSLFNotes notesSlide = slide.getNotes();
  if (notesSlide == null) {
    notesSlide = createNotesSlide(slide);
  }
  return notesSlide;
}

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

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

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

/**
 *
 * @return the information about background appearance of this slide
 */
@Override
public XSLFBackground getBackground() {
  CTBackground bg = _slide.getCSld().getBg();
  if(bg != null) {
    return new XSLFBackground(bg, this);
  } else {
    return getMasterSheet().getBackground();
  }
}

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

/**
 * @return the comment authors part or {@code null} if there weren't any comments
 * @since POI 4.0.0
 */
@SuppressWarnings("WeakerAccess")
public XSLFCommentAuthors getCommentAuthorsPart() {
  if(_commentAuthors == null) {
    // first scan the slide relations
    for (POIXMLDocumentPart p : getRelations()) {
      if (p instanceof XSLFCommentAuthors) {
        _commentAuthors = (XSLFCommentAuthors)p;
        return _commentAuthors;
      }
    }
    // then scan the presentation relations
    for (POIXMLDocumentPart p : getSlideShow().getRelations()) {
      if (p instanceof XSLFCommentAuthors) {
        _commentAuthors = (XSLFCommentAuthors)p;
        return _commentAuthors;
      }
    }
  }
  return null;
}

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

public XSLFSlide removeSlide(int index) {
  XSLFSlide slide = _slides.remove(index);
  removeRelation(slide);
  _presentation.getSldIdLst().removeSldId(index);
  for (POIXMLDocumentPart p : slide.getRelations()) {
    if (p instanceof XSLFChart) {
      XSLFChart chart = (XSLFChart) p;
      slide.removeChartRelation(chart);
      _charts.remove(chart);
    } else if (p instanceof XSLFSlideLayout) {
      XSLFSlideLayout layout = (XSLFSlideLayout) p;
      slide.removeLayoutRelation(layout);
    }
  }
  return slide;
}

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

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

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

List<XSLFSlide> slides = slideShow.getSlides();
for (XSLFSlide slide : slides) {
  String slideDesc;
  if (slide.getPackagePart() != null && slide.getPackagePart().getPartName() != null) {
    slideDesc = getJustFileName(slide.getPackagePart().getPartName().toString());
    slideDesc += "_";
  } else {
  extractContent(slide.getShapes(), false, xhtml, slideDesc);
  xhtml.endElement("div");
    XSLFSlideLayout slideLayout = slide.getMasterSheet();
    extractContent(slideLayout.getShapes(), true, xhtml, null);
    xhtml.endElement("div");
    XSLFNotes slideNotes = slide.getNotes();
    if (slideNotes != null) {
      xhtml.startElement("div", "class", "slide-notes");
  List<XSLFComment> comments = slide.getComments();
  if (comments != null) {
    StringBuilder authorStringBuilder = new StringBuilder();
      RELATION_DIAGRAM_DATA,
      "diagram-data",
      slide.getPackagePart(),
      metadata,
      new OOXMLWordAndPowerPointTextHandler(

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

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

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

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

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

@Override
  public List<Page> parse(InputStream fs, List<String> filterPatterns) throws Exception {
    List<Page> pages = new ArrayList<>();
    XMLSlideShow ppt = new XMLSlideShow(fs);
    ppt.getSlides().forEach(slide -> {
      Page page = new Page(slide.getSlideNumber());
      for (XSLFShape shape : slide.getShapes()) {
        if (shape instanceof XSLFTextShape) {
          page.getParagraphs().add(((XSLFTextShape) shape).getText());
        }
      }
      pages.add(page);
    });

    return pages;
  }
}

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

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

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

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

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

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

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

/**
 * Extracts data from PPT/PPTX from using poi.
 *
 * @param path
 * @return
 * @throws DataflowException
 */
public static String extractPPTFile(Path path) throws DataflowException {
  try (FileInputStream inputStream = new FileInputStream(path.toString());
      XMLSlideShow ppt = new XMLSlideShow(inputStream)) {
    StringBuffer res = new StringBuffer();
    for (XSLFSlide slide : ppt.getSlides()) {
      List<XSLFShape> shapes = slide.getShapes();
      for (XSLFShape shape : shapes) {
        if (shape instanceof XSLFTextShape) {
          XSLFTextShape textShape = (XSLFTextShape) shape;
          String text = textShape.getText();
          res.append(text);
        }
      }
    }
    return res.toString();
  } catch (IOException e) {
    throw new DataflowException(e);
  }
}

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

XSLFSlide[] slides = ppt.getSlides();
XSLFSlide slide1 =slides[0];
XSLFShape shapes[]= slide1.getShapes();
for(int i=0;i<shapes.length;i++){
  System.out.println(shapes[i].getShapeName());
   int idx = ppt.addPicture(pictureData,
       XSLFPictureData.PICTURE_TYPE_PNG);
 XSLFPictureShape picture = slide1.createPicture(idx);
 slide1.removeShape(pic);
 ppt.write(fos);
 fos.close();

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

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

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

/**
 * @return the comments part or {@code null} if there weren't any comments
 * @since POI 4.0.0
 */
@SuppressWarnings("WeakerAccess")
public XSLFComments getCommentsPart() {
  if(_comments == null) {
    for (POIXMLDocumentPart p : getRelations()) {
      if (p instanceof XSLFComments) {
        _comments = (XSLFComments)p;
        break;
      }
    }
  }
  return _comments;
}

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

/**
 * Create a blank notes slide.
 */
private XSLFNotes createNotesSlide(XSLFSlide slide) {
  if (_notesMaster == null) {
    createNotesMaster();
  }
  int slideIndex = XSLFRelation.SLIDE.getFileNameIndex(slide);
  XSLFRelation relationType = XSLFRelation.NOTES;
  slideIndex = findNextAvailableFileNameIndex(relationType, slideIndex);
  // add notes slide to presentation
  XSLFNotes notesSlide = (XSLFNotes) createRelationship
      (relationType, XSLFFactory.getInstance(), slideIndex);
  // link slide and notes slide with each other
  slide.addRelation(null, relationType, notesSlide);
  notesSlide.addRelation(null, XSLFRelation.NOTES_MASTER, _notesMaster);
  notesSlide.addRelation(null, XSLFRelation.SLIDE, slide);
  notesSlide.importContent(_notesMaster);
  return notesSlide;
}

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

/**
 * Create a slide and initialize it from the specified layout.
 *
 * @param layout
 * @return created slide
 */
public XSLFSlide createSlide(XSLFSlideLayout layout) {
  int slideNumber = 256, cnt = 1;
  CTSlideIdList slideList;
  if (!_presentation.isSetSldIdLst()) slideList = _presentation.addNewSldIdLst();
  else {
    slideList = _presentation.getSldIdLst();
    for(CTSlideIdListEntry slideId : slideList.getSldIdList()){
      slideNumber = (int)Math.max(slideId.getId() + 1, slideNumber);
      cnt++;
    }
  }
  XSLFSlide slide = (XSLFSlide)createRelationship(
      XSLFRelation.SLIDE, XSLFFactory.getInstance(), cnt);
  CTSlideIdListEntry slideId = slideList.addNewSldId();
  slideId.setId(slideNumber);
  slideId.setId2(slide.getPackageRelationship().getId());
  layout.copyLayout(slide);
  slide.addRelation(layout.getPackageRelationship().getId(), layout);
  PackagePartName ppName = layout.getPackagePart().getPartName();
  slide.getPackagePart().addRelationship(ppName, TargetMode.INTERNAL,
      layout.getPackageRelationship().getRelationshipType());
  _slides.add(slide);
  return slide;
}

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

@Override
public XSLFSlideLayout getMasterSheet(){
  return getSlideLayout();
}

相关文章