Example usage for org.apache.poi.xslf.usermodel XSLFSlide getSlideLayout

List of usage examples for org.apache.poi.xslf.usermodel XSLFSlide getSlideLayout

Introduction

In this page you can find the example usage for org.apache.poi.xslf.usermodel XSLFSlide getSlideLayout.

Prototype

@Override
    public XSLFSlideLayout getSlideLayout() 

Source Link

Usage

From source file:com.opensearchserver.extractor.parser.Pptx.java

License:Apache License

/**
 * Declined from XSLFPowerPointExtractor.java
 * /*  w  ww.  j a va  2s .co  m*/
 * @param pptSlideShow
 */
private void extractSides(XMLSlideShow slideshow) {

    XSLFSlide[] slides = (XSLFSlide[]) slideshow.getSlides();
    XSLFCommentAuthors commentAuthors = slideshow.getCommentAuthors();

    for (XSLFSlide slide : slides) {

        // One document per slide
        ParserDocument result = getNewParserDocument();

        XSLFNotes notes = slide.getNotes();
        XSLFComments comments = slide.getComments();
        XSLFSlideLayout layout = slide.getSlideLayout();
        XSLFSlideMaster master = layout.getSlideMaster();

        // TODO Do the slide's name
        // (Stored in docProps/app.xml)

        // Do the slide's text
        result.add(SLIDES, extractText(slide.getCommonSlideData(), false));
        result.add(LANG_DETECTION, languageDetection(SLIDES, 10000));

        // If requested, get text from the master and it's layout
        if (layout != null) {
            result.add(MASTER, extractText(layout.getCommonSlideData(), true));
        }
        if (master != null) {
            result.add(MASTER, extractText(master.getCommonSlideData(), true));
        }

        // If the slide has comments, do those too
        if (comments != null) {
            for (CTComment comment : comments.getCTCommentsList().getCmList()) {
                StringBuilder sbComment = new StringBuilder();
                // Do the author if we can
                if (commentAuthors != null) {
                    CTCommentAuthor author = commentAuthors.getAuthorById(comment.getAuthorId());
                    if (author != null) {
                        sbComment.append(author.getName());
                        sbComment.append(": ");
                    }
                }

                // Then the comment text, with a new line afterwards
                sbComment.append(comment.getText());
                sbComment.append("\n");
                if (sbComment.length() > 0)
                    result.add(COMMENTS, sbComment.toString());
            }
        }

        // Do the notes if requested
        if (notes != null) {
            result.add(NOTES, extractText(notes.getCommonSlideData(), false));
        }
    }
}

From source file:com.qwazr.extractor.parser.Pptx.java

License:Apache License

/**
 * Declined from XSLFPowerPointExtractor.java
 *
 * @param slideshow//from w w w  . j av  a 2  s  . com
 */
private void extractSides(XMLSlideShow slideshow) {

    List<XSLFSlide> slides = slideshow.getSlides();
    XSLFCommentAuthors commentAuthors = slideshow.getCommentAuthors();

    for (XSLFSlide slide : slides) {

        // One document per slide
        ParserDocument result = getNewParserDocument();

        XSLFNotes notes = slide.getNotes();
        XSLFComments comments = slide.getComments();
        XSLFSlideLayout layout = slide.getSlideLayout();
        XSLFSlideMaster master = layout.getSlideMaster();

        // TODO Do the slide's name
        // (Stored in docProps/app.xml)

        // Do the slide's text
        result.add(SLIDES, extractText(slide.getCommonSlideData(), false));
        result.add(LANG_DETECTION, languageDetection(SLIDES, 10000));

        // If requested, get text from the master and it's layout
        if (layout != null) {
            result.add(MASTER, extractText(layout.getCommonSlideData(), true));
        }
        if (master != null) {
            result.add(MASTER, extractText(master.getCommonSlideData(), true));
        }

        // If the slide has comments, do those too
        if (comments != null) {
            for (CTComment comment : comments.getCTCommentsList().getCmList()) {
                StringBuilder sbComment = new StringBuilder();
                // Do the author if we can
                if (commentAuthors != null) {
                    CTCommentAuthor author = commentAuthors.getAuthorById(comment.getAuthorId());
                    if (author != null) {
                        sbComment.append(author.getName());
                        sbComment.append(": ");
                    }
                }

                // Then the comment text, with a new line afterwards
                sbComment.append(comment.getText());
                sbComment.append("\n");
                if (sbComment.length() > 0)
                    result.add(COMMENTS, sbComment.toString());
            }
        }

        // Do the notes if requested
        if (notes != null) {
            result.add(NOTES, extractText(notes.getCommonSlideData(), false));
        }
    }
}

From source file:com.qwazr.library.poi.PptxParser.java

License:Apache License

/**
 * Declined from XSLFPowerPointExtractor.java
 *
 * @param slideshow//from www  .  j  a va2 s  .  c  o  m
 * @param resultBuilder
 */
private void extractSides(final XMLSlideShow slideshow, final ParserResultBuilder resultBuilder) {

    final List<XSLFSlide> slides = slideshow.getSlides();
    final XSLFCommentAuthors commentAuthors = slideshow.getCommentAuthors();

    for (XSLFSlide slide : slides) {

        // One document per slide
        final ParserFieldsBuilder result = resultBuilder.newDocument();

        final XSLFNotes notes = slide.getNotes();
        final XSLFComments comments = slide.getComments();
        final XSLFSlideLayout layout = slide.getSlideLayout();
        final XSLFSlideMaster master = layout.getSlideMaster();

        // TODO Do the slide's name
        // (Stored in docProps/app.xml)

        // Do the slide's text
        final String slideText = extractText(slide.getCommonSlideData(), false);
        result.add(SLIDES, slideText);
        result.add(CONTENT, slideText);

        // If requested, get text from the master and it's layout
        if (layout != null) {
            final String text = extractText(layout.getCommonSlideData(), true);
            result.add(MASTER, text);
            result.add(CONTENT, text);
        }
        if (master != null) {
            final String text = extractText(master.getCommonSlideData(), true);
            result.add(MASTER, text);
            result.add(CONTENT, text);
        }

        // If the slide has comments, do those too
        if (comments != null) {
            for (CTComment comment : comments.getCTCommentsList().getCmList()) {
                final StringBuilder sbComment = new StringBuilder();
                // Do the author if we can
                if (commentAuthors != null) {
                    CTCommentAuthor author = commentAuthors.getAuthorById(comment.getAuthorId());
                    if (author != null) {
                        sbComment.append(author.getName());
                        sbComment.append(": ");
                    }
                }

                // Then the comment text, with a new line afterwards
                sbComment.append(comment.getText());
                sbComment.append("\n");
                if (sbComment.length() > 0) {
                    final String text = sbComment.toString();
                    result.add(COMMENTS, text);
                    result.add(CONTENT, text);
                }
            }
        }

        // Do the notes if requested
        if (notes != null) {
            final String text = extractText(notes.getCommonSlideData(), false);
            result.add(NOTES, text);
            result.add(CONTENT, text);
        }

        result.add(LANG_DETECTION, languageDetection(result, CONTENT, 10000));

    }
}

From source file:easyoffice.powerpoint.PPTMaker.java

private static XSLFSlide copySlide(XMLSlideShow ppt, XSLFSlide srcSlide) {
    /*//from   ww w.j  a  v a2  s .  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);
}