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


Java XSLFSlide类代码示例

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


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

示例1: parse

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的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

示例2: parse

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的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

示例3: parse

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的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

示例4: extractContent

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的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

示例5: main

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的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

示例6: main

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的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

示例7: main

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的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

示例8: actionPerformed

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    SlidesTopComponent currentTopComponent = OfficeTopComponent.getSelectedComponent(SlidesTopComponent.class);
    if (currentTopComponent != null) {
        String title = NbBundle.getMessage(getClass(), "CTL_BackgroundColorAction");
        Color chosenColor = JColorChooser.showDialog(WindowManager.getDefault().getMainWindow(), title, Color.WHITE);
        if (chosenColor != null) {
            int currentSlide = currentTopComponent.getSelectedSlide();
            XSLFSlide slide = currentTopComponent.getPresentation().getSlides()[currentSlide];
            // This throws java.lang.IllegalStateException: CTShapeProperties was not found.
            slide.getBackground().setFillColor(chosenColor);

            // Also change the background of the panel
            JPanel mainComponent = (JPanel) currentTopComponent.getMainComponent();
            SlideComponent slidePanel = (SlideComponent) mainComponent.getComponent(currentSlide);
            slidePanel.setBackground(chosenColor);
        }
    }
}
 
开发者ID:foxerfly,项目名称:Joeffice,代码行数:20,代码来源:BackgroundColorAction.java

示例9: setSlideIndex

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的package包/类
public void setSlideIndex(int slideIndex) {
    if (slideIndex < 0 || slideIndex >= presentation.getSlides().length) {
        Toolkit.getDefaultToolkit().beep();
        return;
    }
    this.slideIndex = slideIndex;
    if (isVisible()) {
        DisplayMode display = getScreen().getDisplayMode();
        XSLFSlide slide = presentation.getSlides()[slideIndex];
        Dimension displaySize = new Dimension(display.getWidth(), display.getHeight());
        SlideComponent slidePanel = new SlideComponent(slide, null, displaySize);
        if (getContentPane().getComponentCount() > 0) {
            getContentPane().remove(0);
        }
        add(slidePanel);
        setSize(displaySize);
        revalidate();
    }
    SlidesTopComponent currentTopComponent = OfficeTopComponent.getSelectedComponent(SlidesTopComponent.class);
    if (currentTopComponent != null) {
        currentTopComponent.setSelectedSlide(slideIndex);
    }
}
 
开发者ID:foxerfly,项目名称:Joeffice,代码行数:24,代码来源:FullScreenFrame.java

示例10: main

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的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

示例11: calculateSubtitle

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的package包/类
private String calculateSubtitle(XSLFSlide slideX, HSLFSlide slide) {

		if (isContentSlide(slide.getSlideNumber())) {
			return null;
		}

		for (XSLFShape shape : slideX.getShapes()) {

			if (shape instanceof XSLFTextShape) {

				XSLFTextShape tsh = (XSLFTextShape) shape;

				Rectangle2D figure = getRelativeFigure(tsh);

				if (figure.getY() < 0.1) {
					continue;
				}

				for (XSLFTextParagraph p : tsh) {
					for (XSLFTextRun r : p) {
						return r.getRawText();
					}
				}

				return null;
			}
		}

		return null;
	}
 
开发者ID:codeurjc,项目名称:slides-converter,代码行数:31,代码来源:PowerPointToHTML.java

示例12: exportAsPowerPoint

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的package包/类
public static <T, U> void exportAsPowerPoint(VennFigureParameters<T> parameters, File file) throws IOException {
    XMLSlideShow slideShow = new XMLSlideShow();
    XSLFSlide slide = slideShow.createSlide();
    VennDrawSlides<T> vennDrawSlides = new VennDrawSlides<>(VennFigureCreator.createVennFigure(parameters), slide);
    vennDrawSlides.draw();
    try (OutputStream os = new FileOutputStream(file)) {
        slideShow.write(os);
    }
}
 
开发者ID:informationsea,项目名称:VennDraw,代码行数:10,代码来源:VennExporter.java

示例13: findCurrentSlide

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的package包/类
private static XSLFSlide findCurrentSlide(POIXMLDocumentPart containerDocument) {
	while(containerDocument != null) {
		if(containerDocument instanceof XSLFSlide) {
			return (XSLFSlide) containerDocument;
		}
		if(containerDocument instanceof XMLSlideShow) {
			return null;
		}

		containerDocument = containerDocument.getParent();
	}
	return null;
}
 
开发者ID:Coreoz,项目名称:PPT-Templates,代码行数:14,代码来源:PptTemplates.java

示例14: main

import org.apache.poi.xslf.usermodel.XSLFSlide; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InvalidFormatException {
        FileInputStream is = new FileInputStream("/Users/brandl/Dropbox/private/oc2/testdata/experimental design.pptx");

        XMLSlideShow ppt2 = new XMLSlideShow(OPCPackage.open("/Users/brandl/Dropbox/private/oc2/testdata/experimental design.pptx"));
        XSLFSlide slide1 = ppt2.getSlides().get(0);
//        slide1.get

        HSLFSlideShow ppt = new HSLFSlideShow(is);
//
        HSLFSlide slide2 = ppt.getSlides().get(1);


        is.close();

        Dimension pgsize = ppt.getPageSize();

        java.util.List<HSLFSlide> slides = ppt.getSlides();

        for (int i = 0; i < slides.size(); i++) {

            BufferedImage img = new BufferedImage(pgsize.width, pgsize.height,
                    BufferedImage.TYPE_INT_RGB);
            Graphics2D graphics = img.createGraphics();
            //clear the drawing area
            graphics.setPaint(Color.white);
            graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));

            //render
            slides.get(i).draw(graphics);

            //save the output
            FileOutputStream out = new FileOutputStream("slide-" + (i + 1) + ".png");
            javax.imageio.ImageIO.write(img, "png", out);
            out.close();
        }
    }
 
开发者ID:holgerbrandl,项目名称:opencards,代码行数:37,代码来源:ConvertPPTX2PNG.java

示例15: main

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

    // blank slide
    ppt.createSlide();

    // there can be multiple masters each referencing a number of layouts
    // for demonstration purposes we use the first (default) slide master
    XSLFSlideMaster defaultMaster = ppt.getSlideMasters()[0];

    // title slide
    XSLFSlideLayout titleLayout = defaultMaster.getLayout(SlideLayout.TITLE);
    // fill the placeholders
    XSLFSlide slide1 = ppt.createSlide(titleLayout);

    // title and content
    XSLFSlideLayout titleBodyLayout = defaultMaster.getLayout(SlideLayout.TITLE_AND_CONTENT);
    XSLFSlide slide2 = ppt.createSlide(titleBodyLayout);

    FileOutputStream out = new FileOutputStream(dataPath + "Apache_Layouts_Out.pptx");
	ppt.write(out);
	out.close();
	
	System.out.println("Layout slides created Successfuly.");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:29,代码来源:ApacheAddLayoutSlides.java


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