summaryrefslogtreecommitdiffstats
path: root/src/examples
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2011-08-11 08:38:19 +0000
committerYegor Kozlov <yegor@apache.org>2011-08-11 08:38:19 +0000
commitccad96e6d9e296958d03d90d44e70888f45ba8b9 (patch)
treebdb50d2be1e034bbbe951d8f6bd8e434ec773029 /src/examples
parenteb89ca36858a3aa86bf4a7db2a9c19081dbc69d9 (diff)
downloadpoi-ccad96e6d9e296958d03d90d44e70888f45ba8b9.tar.gz
poi-ccad96e6d9e296958d03d90d44e70888f45ba8b9.zip
initial support for XSLF usermodel API
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1156539 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/src/org/apache/poi/xslf/usermodel/SlidesAndShapes.java86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/SlidesAndShapes.java b/src/examples/src/org/apache/poi/xslf/usermodel/SlidesAndShapes.java
new file mode 100644
index 0000000000..cb700c6133
--- /dev/null
+++ b/src/examples/src/org/apache/poi/xslf/usermodel/SlidesAndShapes.java
@@ -0,0 +1,86 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.xslf.usermodel;
+
+import java.awt.*;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.GeneralPath;
+import java.io.FileOutputStream;
+
+/**
+ * Simple demo that creates a pptx slide show using the XSLF API
+ *
+ * @author Yegor Kozlov
+ */
+public class SlidesAndShapes {
+
+ public static void main(String[] args) throws Exception {
+ XMLSlideShow ppt = new XMLSlideShow();
+ ppt.setPageSize(new Dimension(792, 612));
+
+ XSLFSlide slide1 = ppt.createSlide();
+ XSLFTextBox textBox = slide1.createTextBox();
+ XSLFTextRun r1 = textBox.addNewTextParagraph().addNewTextRun();
+ r1.setBold(true);
+ r1.setItalic(true);
+ r1.setFontColor(Color.yellow);
+ r1.setFontFamily("Arial");
+ r1.setFontSize(24);
+ r1.setText("Apache");
+ XSLFTextRun r2 = textBox.addNewTextParagraph().addNewTextRun();
+ r2.setStrikethrough(true);
+ r2.setUnderline(true);
+ r2.setText("POI\u2122");
+ XSLFTextRun r3 = textBox.addNewTextParagraph().addNewTextRun();
+ r3.setFontFamily("Wingdings");
+ r3.setText(" Version 3.8");
+
+ textBox.setAnchor(new Rectangle(50, 50, 200, 100));
+ textBox.setLineColor(Color.black);
+ textBox.setFillColor(Color.orange);
+
+ XSLFAutoShape shape2 = slide1.createAutoShape();
+
+ shape2.setAnchor(new Rectangle(100, 100, 200, 200));
+
+ XSLFFreeformShape shape3 = slide1.createFreeform();
+ Rectangle rect = new Rectangle(150, 150, 300, 300);
+ GeneralPath path = new GeneralPath(rect);
+ path.append(new Ellipse2D.Double(200, 200, 100, 50), false);
+ shape3.setPath(path);
+ shape3.setAnchor(path.getBounds2D());
+ shape3.setLineColor(Color.black);
+ shape3.setFillColor(Color.lightGray);
+
+ XSLFSlide slide2 = ppt.createSlide();
+ XSLFGroupShape group = slide2.createGroup();
+
+ group.setAnchor(new Rectangle(0, 0, 792, 612));
+ group.setInteriorAnchor(new Rectangle(-10, -10, 20, 20));
+
+ XSLFAutoShape shape4 = group.createAutoShape();
+ shape4.setAnchor(new Rectangle(0, 0, 5, 5));
+ shape4.setLineWidth(5);
+ shape4.setLineColor(Color.black);
+
+
+ FileOutputStream out = new FileOutputStream("xslf-demo.pptx");
+ ppt.write(out);
+ out.close();
+ }
+
+}