当前位置: 首页>>代码示例>>Java>>正文


Java XMLSlideShow类代码示例

本文整理汇总了Java中org.apache.poi.xslf.usermodel.XMLSlideShow的典型用法代码示例。如果您正苦于以下问题:Java XMLSlideShow类的具体用法?Java XMLSlideShow怎么用?Java XMLSlideShow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XMLSlideShow类属于org.apache.poi.xslf.usermodel包,在下文中一共展示了XMLSlideShow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
@Override
public void write(JSONObject object, OutputStream outputStream) {
    if (validator.isEmpty(object) || !object.containsKey("slides"))
        return;

    XMLSlideShow xmlSlideShow = new XMLSlideShow();
    setSize(xmlSlideShow, object);
    slides(xmlSlideShow, object.getJSONArray("slides"));

    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.MILLISECOND, -1 * (calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)));
    String time = dateTime.toString(calendar.getTime(), "yyyy-MM-dd'T'HH:mm:ss'Z'");
    xmlSlideShow.getProperties().getCoreProperties().setCreated(time);
    xmlSlideShow.getProperties().getCoreProperties().setModified(time);

    try {
        xmlSlideShow.write(outputStream);
    } catch (IOException e) {
        logger.warn(e, "输出PPTx到输出流时发生异常!");
    }
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:22,代码来源:PptxImpl.java

示例2: read

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
@Override
public JSONObject read(InputStream inputStream, StreamWriter streamWriter) {
    JSONObject object = new JSONObject();
    try {
        XMLSlideShow xmlSlideShow = new XMLSlideShow(inputStream);
        JSONObject size = new JSONObject();
        size.put("width", xmlSlideShow.getPageSize().width);
        size.put("height", xmlSlideShow.getPageSize().height);
        object.put("size", size);

        JSONArray slides = new JSONArray();
        slides(slides, xmlSlideShow.getSlides(), streamWriter);
        object.put("slides", slides);
        xmlSlideShow.close();
        inputStream.close();
    } catch (IOException e) {
        logger.warn(e, "解析PPTx数据时发生异常!");
    }

    return object;
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:22,代码来源:PptxImpl.java

示例3: parse

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
@Override
public boolean parse(XMLSlideShow xmlSlideShow, XSLFSlide xslfSlide, JSONObject object) {
    XSLFTextBox xslfTextBox = xslfSlide.createTextBox();
    xslfTextBox.clearText();
    xslfTextBox.setAnchor(parserHelper.getRectangle(object));
    parserHelper.rotate(xslfTextBox, object);
    XSLFTextParagraph xslfTextParagraph = newParagraph(xslfTextBox, object);
    if (object.containsKey("texts")) {
        JSONArray texts = object.getJSONArray("texts");
        for (int i = 0, size = texts.size(); i < size; i++)
            xslfTextParagraph = add(xslfTextBox, xslfTextParagraph, object, texts.getJSONObject(i));
    } else if (object.containsKey(getType()))
        add(xslfTextBox, xslfTextParagraph, object, new JSONObject());

    return true;
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:17,代码来源:TextParserImpl.java

示例4: parse

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
@Override
public boolean parse(XMLSlideShow xmlSlideShow, XSLFSlide xslfSlide, JSONObject object) {
    String image = object.getString(getType());
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    Map<String, String> map = new HashMap<>();
    http.get(image, null, null, map, outputStream);
    if (map.isEmpty())
        return false;

    try {
        String contenType = map.get("Content-Type");
        XSLFPictureData xslfPictureData = xmlSlideShow.addPicture(parserHelper.getImage(object, contenType, outputStream),
                getPictureType(image, contenType));
        XSLFPictureShape xslfPictureShape = xslfSlide.createPicture(xslfPictureData);
        xslfPictureShape.setAnchor(parserHelper.getRectangle(object));
        parserHelper.rotate(xslfPictureShape, object);

        return true;
    } catch (IOException e) {
        logger.warn(e, "解析图片[{}]时发生异常!", object.toJSONString());

        return false;
    }
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:25,代码来源:ImageParserImpl.java

示例5: parse

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
@Override
public boolean parse(XMLSlideShow xmlSlideShow, XSLFSlide xslfSlide, JSONObject object) {
    try {
        XSLFPictureData xslfPictureData = xmlSlideShow.addPicture(parserHelper.getImage(object, "image/png",
                readSvg(object.getString("svg"))), PictureData.PictureType.PNG);
        XSLFPictureShape xslfPictureShape = xslfSlide.createPicture(xslfPictureData);
        xslfPictureShape.setAnchor(parserHelper.getRectangle(object));
        parserHelper.rotate(xslfPictureShape, object);

        return true;
    } catch (IOException | TranscoderException e) {
        logger.warn(e, "解析SVG图片[{}]时发生异常!", object.toJSONString());

        return false;
    }
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:17,代码来源:SvgParserImpl.java

示例6: createXMLSlideShowFileSimpleImages

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
/**
 * @작성자 : KYJ
 * @작성일 : 2017. 10. 18.
 * @param pptFile
 * @param images
 * @throws IOException
 * @Deprecated 처리되지않는 함수 존재.
 */
@Deprecated
public static void createXMLSlideShowFileSimpleImages(File pptFile, File... images) throws IOException {

	XMLSlideShow ppt = new XMLSlideShow();
	for (File image : images) {

		CreateXmlSlideImageHandler handler = new DefaultXmlSlideCreateImageHandler(ppt);
		handler.createImage(image);
	}

	try (FileOutputStream stream = new FileOutputStream(pptFile)) {
		ppt.write(stream);
	}

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:24,代码来源:PPTUtil.java

示例7: processShapesContainer

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
private static void processShapesContainer(ShapeContainer<XSLFShape, ?> shapeContainer, XMLSlideShow ppt, PptMapper mapper) {
	List<ImageToReplace> imagesToReplace = new ArrayList<>();
	List<XSLFShape> shapesToDelete = new ArrayList<>();

	for(XSLFShape shape : shapeContainer.getShapes()) {
		if(processShape(shape, imagesToReplace, ppt, mapper)) {
			shapesToDelete.add(shape);
		}
	}

	for(XSLFShape shapeToDelete : shapesToDelete) {
		shapeContainer.removeShape(shapeToDelete);
	}

	for(ImageToReplace imageToReplace : imagesToReplace) {
		replaceImage(ppt, shapeContainer, imageToReplace);
	}
}
 
开发者ID:Coreoz,项目名称:PPT-Templates,代码行数:19,代码来源:PptTemplates.java

示例8: readContent

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
@Override
public String readContent(final VFSLeaf leaf) throws IOException, DocumentException {
    BufferedInputStream bis = null;
    final StringBuilder buffy = new StringBuilder();
    try {
        bis = new BufferedInputStream(leaf.getInputStream());
        final POIXMLTextExtractor extractor = (POIXMLTextExtractor) ExtractorFactory.createExtractor(bis);
        final POIXMLDocument document = extractor.getDocument();

        if (document instanceof XSLFSlideShow) {
            final XSLFSlideShow slideShow = (XSLFSlideShow) document;
            final XMLSlideShow xmlSlideShow = new XMLSlideShow(slideShow);
            extractContent(buffy, xmlSlideShow);
        }

        return buffy.toString();
    } catch (final Exception e) {
        throw new DocumentException(e.getMessage());
    } finally {
        if (bis != null) {
            bis.close();
        }
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:25,代码来源:PowerPointOOXMLDocument.java

示例9: extractContent

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
private void extractContent(final StringBuilder buffy, final XMLSlideShow xmlSlideShow) throws IOException, XmlException {
    final XSLFSlide[] slides = xmlSlideShow.getSlides();
    for (final XSLFSlide slide : slides) {
        final CTSlide rawSlide = slide._getCTSlide();
        final CTSlideIdListEntry slideId = slide._getCTSlideId();

        final CTNotesSlide notes = xmlSlideShow._getXSLFSlideShow().getNotes(slideId);
        final CTCommentList comments = xmlSlideShow._getXSLFSlideShow().getSlideComments(slideId);

        extractShapeContent(buffy, rawSlide.getCSld().getSpTree());

        if (comments != null) {
            for (final CTComment comment : comments.getCmArray()) {
                buffy.append(comment.getText()).append(' ');
            }
        }

        if (notes != null) {
            extractShapeContent(buffy, notes.getCSld().getSpTree());
        }
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:23,代码来源:PowerPointOOXMLDocument.java

示例10: main

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithslides/moveslide/data/";
	
	XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(dataPath + "presentation.pptx"));

	//add slides
    ppt.createSlide();
    ppt.createSlide();
    ppt.createSlide();

    XSLFSlide[] slides = ppt.getSlides();
    ppt.setSlideOrder(slides[0], 4); 
    
    //save changes in a file
    FileOutputStream out = new FileOutputStream(dataPath + "Apache_ReOrdered_Slides_Out.pptx");
    ppt.write(out);
    out.close();
    
	System.out.println("Slides ReOrdered Successfuly.");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:22,代码来源:ApacheMoveSlides.java

示例11: main

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithpresentation/openandsave/data/";
	
	XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(dataPath + "presentation.pptx"));
	
	//append a new slide to the end
	XSLFSlide blankSlide = ppt.createSlide();
	
	//save changes in a file
	FileOutputStream out = new FileOutputStream(dataPath + "EditedPPT_Apache_Out.pptx");
	ppt.write(out);
	out.close();

	System.out.println("Presentation Edited and Saved.");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:17,代码来源:ApacheOpenandSave.java

示例12: main

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithtext/hyperlinks/data/";
	
	XMLSlideShow ppt = new XMLSlideShow();
	XSLFSlide slide = ppt.createSlide();
	   
	// assign a hyperlink to a text run
	XSLFTextBox shape = slide.createTextBox();
	XSLFTextRun r = shape.addNewTextParagraph().addNewTextRun();
	r.setText("Apache POI");
	XSLFHyperlink link = r.createHyperlink();
	link.setAddress("http://poi.apache.org");
    
    //save changes 
    FileOutputStream out = new FileOutputStream(dataPath + "Apache_Hyperlink_Out.ppt");
    ppt.write(out);
    out.close();
    
	System.out.println("Presentation with hyperlink Saved.");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:22,代码来源:ApacheHyperlink.java

示例13: actionPerformed

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    SlidesTopComponent currentTopComponent = OfficeTopComponent.getSelectedComponent(SlidesTopComponent.class);
    if (currentTopComponent != null) {
        XMLSlideShow presentation = currentTopComponent.getPresentation();
        int slideIndex = currentTopComponent.getSelectedSlide();
        presentation.removeSlide(slideIndex);
        removeSlideFromPanel(slideIndex, (JPanel) currentTopComponent.getMainComponent());
        currentTopComponent.getDataObject().setModified(true);
        if (slideIndex >= presentation.getSlides().length) {
            currentTopComponent.setSelectedSlide(slideIndex - 1);
        } else {
            currentTopComponent.setSelectedSlide(slideIndex);
        }
    }
}
 
开发者ID:foxerfly,项目名称:Joeffice,代码行数:17,代码来源:RemoveSlideAction.java

示例14: main

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    if (args.length == 0) {
        System.err.println("Please profile a file path to open");
        System.exit(-1);
    }

    JPanel mainPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5));
    XMLSlideShow presentation = new XMLSlideShow(new FileInputStream(args[0]));
    XSLFSlide[] slides = presentation.getSlides();
    for (XSLFSlide slide : slides) {
        XSLFShape[] shapes = slide.getShapes();
        for (XSLFShape shape : shapes) {

            BufferedImage img = new BufferedImage((int) shape.getAnchor().getWidth(), (int) shape.getAnchor().getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
            Graphics2D graphics = img.createGraphics();
            graphics.translate(-shape.getAnchor().getX(), -shape.getAnchor().getY());
            shape.draw(graphics);
            graphics.dispose();
            JLabel shapeLabel = new JLabel(new ImageIcon(img));
            shapeLabel.setBorder(BorderFactory.createLineBorder(Color.RED));

            mainPanel.add(shapeLabel);
        }
    }
    showDemo(new JScrollPane(mainPanel), "Shape not displayed");
}
 
开发者ID:foxerfly,项目名称:Joeffice,代码行数:27,代码来源:PptxShapeNotDrawn.java

示例15: setSize

import org.apache.poi.xslf.usermodel.XMLSlideShow; //导入依赖的package包/类
private void setSize(XMLSlideShow xmlSlideShow, JSONObject object) {
    if (!object.containsKey("size"))
        return;

    JSONObject size = object.getJSONObject("size");
    if (size.getIntValue("width") <= 0 || size.getIntValue("height") <= 0)
        return;

    xmlSlideShow.setPageSize(new Dimension(size.getIntValue("width"), size.getIntValue("height")));
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:11,代码来源:PptxImpl.java


注:本文中的org.apache.poi.xslf.usermodel.XMLSlideShow类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。