diff options
author | Yegor Kozlov <yegor@apache.org> | 2009-11-21 15:30:54 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2009-11-21 15:30:54 +0000 |
commit | 437182aa72b8b3f97a44357f93679be998e83878 (patch) | |
tree | 4689e00928cffdec9f586d2cd3b670ce76bf7de4 /src/scratchpad | |
parent | 0b5d1a372a56fd72f45c80112dcd3a1cf47d51d9 (diff) | |
download | poi-437182aa72b8b3f97a44357f93679be998e83878.tar.gz poi-437182aa72b8b3f97a44357f93679be998e83878.zip |
included poi-ooxml-schemas and poi-examples in the release cycle, also misc improvements in build.xml: merged scratchpad and main examples, improved cross-module classpath dependencies, removed obsolete targets
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@882927 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad')
14 files changed, 0 insertions, 1723 deletions
diff --git a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java b/src/scratchpad/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java deleted file mode 100644 index 91621339b4..0000000000 --- a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java +++ /dev/null @@ -1,516 +0,0 @@ -/* ==================================================================== - 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.hslf.examples; - -import org.apache.poi.hslf.usermodel.*; -import org.apache.poi.hslf.model.*; -import org.apache.poi.hslf.record.TextHeaderAtom; - -import java.io.IOException; -import java.io.FileOutputStream; -import java.io.File; -import java.awt.*; - -/** - * Presentation for Fast Feather Track on ApacheconEU 2008 - * - * @author Yegor Kozlov - */ -public final class ApacheconEU08 { - - public static void main(String[] args) throws IOException { - SlideShow ppt = new SlideShow(); - ppt.setPageSize(new Dimension(720, 540)); - - slide1(ppt); - slide2(ppt); - slide3(ppt); - slide4(ppt); - slide5(ppt); - slide6(ppt); - slide7(ppt); - slide8(ppt); - slide9(ppt); - slide10(ppt); - slide11(ppt); - slide12(ppt); - - FileOutputStream out = new FileOutputStream("apachecon_eu_08.ppt"); - ppt.write(out); - out.close(); - - } - - public static void slide1(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); - - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); - tr1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE); - tr1.setText("POI-HSLF"); - box1.setAnchor(new Rectangle(54, 78, 612, 115)); - slide.addShape(box1); - - TextBox box2 = new TextBox(); - TextRun tr2 = box2.getTextRun(); - tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE); - tr2.setText("Java API To Access Microsoft PowerPoint Format Files"); - box2.setAnchor(new Rectangle(108, 204, 504, 138)); - slide.addShape(box2); - - TextBox box3 = new TextBox(); - TextRun tr3 = box3.getTextRun(); - tr3.getRichTextRuns()[0].setFontSize(32); - box3.setHorizontalAlignment(TextBox.AlignCenter); - tr3.setText( - "Yegor Kozlov\r" + - "yegor - apache - org"); - box3.setAnchor(new Rectangle(206, 348, 310, 84)); - slide.addShape(box3); - } - - public static void slide2(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); - - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); - tr1.setRunType(TextHeaderAtom.TITLE_TYPE); - tr1.setText("What is HSLF?"); - box1.setAnchor(new Rectangle(36, 21, 648, 90)); - slide.addShape(box1); - - TextBox box2 = new TextBox(); - TextRun tr2 = box2.getTextRun(); - tr2.setRunType(TextHeaderAtom.BODY_TYPE); - tr2.setText("HorribleSLideshowFormat is the POI Project's pure Java implementation " + - "of the Powerpoint binary file format. \r" + - "POI sub-project since 2005\r" + - "Started by Nick Birch, Yegor Kozlov joined soon after"); - box2.setAnchor(new Rectangle(36, 126, 648, 356)); - slide.addShape(box2); - - - } - - public static void slide3(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); - - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); - tr1.setRunType(TextHeaderAtom.TITLE_TYPE); - tr1.setText("HSLF in a Nutshell"); - box1.setAnchor(new Rectangle(36, 15, 648, 65)); - slide.addShape(box1); - - TextBox box2 = new TextBox(); - TextRun tr2 = box2.getTextRun(); - tr2.setRunType(TextHeaderAtom.BODY_TYPE); - tr2.setText( - "HSLF provides a way to read, create and modify MS PowerPoint presentations\r" + - "Pure Java API - you don't need PowerPoint to read and write *.ppt files\r" + - "Comprehensive support of PowerPoint objects"); - tr2.getRichTextRuns()[0].setFontSize(28); - box2.setAnchor(new Rectangle(36, 80, 648, 200)); - slide.addShape(box2); - - TextBox box3 = new TextBox(); - TextRun tr3 = box3.getTextRun(); - tr3.setRunType(TextHeaderAtom.BODY_TYPE); - tr3.setText( - "Rich text\r" + - "Tables\r" + - "Shapes\r" + - "Pictures\r" + - "Master slides"); - tr3.getRichTextRuns()[0].setFontSize(24); - tr3.getRichTextRuns()[0].setIndentLevel(1); - box3.setAnchor(new Rectangle(36, 265, 648, 150)); - slide.addShape(box3); - - TextBox box4 = new TextBox(); - TextRun tr4 = box4.getTextRun(); - tr4.setRunType(TextHeaderAtom.BODY_TYPE); - tr4.setText("Access to low level data structures"); - box4.setAnchor(new Rectangle(36, 430, 648, 50)); - slide.addShape(box4); - } - - public static void slide4(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); - - String[][] txt1 = { - {"Note"}, - {"This presentation was created programmatically using POI HSLF"} - }; - Table table1 = new Table(2, 1); - for (int i = 0; i < txt1.length; i++) { - for (int j = 0; j < txt1[i].length; j++) { - TableCell cell = table1.getCell(i, j); - cell.setText(txt1[i][j]); - cell.getTextRun().getRichTextRuns()[0].setFontSize(10); - RichTextRun rt = cell.getTextRun().getRichTextRuns()[0]; - rt.setFontName("Arial"); - rt.setBold(true); - if(i == 0){ - rt.setFontSize(32); - rt.setFontColor(Color.white); - cell.getFill().setForegroundColor(new Color(0, 153, 204)); - } else { - rt.setFontSize(28); - cell.getFill().setForegroundColor(new Color(235, 239, 241)); - } - cell.setVerticalAlignment(TextBox.AnchorMiddle); - } - } - - Line border1 = table1.createBorder(); - border1.setLineColor(Color.black); - border1.setLineWidth(1.0); - table1.setAllBorders(border1); - - Line border2 = table1.createBorder(); - border2.setLineColor(Color.black); - border2.setLineWidth(2.0); - table1.setOutsideBorders(border2); - - table1.setColumnWidth(0, 510); - table1.setRowHeight(0, 60); - table1.setRowHeight(1, 100); - slide.addShape(table1); - - table1.moveTo(100, 100); - - TextBox box1 = new TextBox(); - box1.setHorizontalAlignment(TextBox.AlignCenter); - TextRun tr1 = box1.getTextRun(); - tr1.setText("The source code is available at\r" + - "http://people.apache.org/~yegor/apachecon_eu08/"); - RichTextRun rt = tr1.getRichTextRuns()[0]; - rt.setFontSize(24); - box1.setAnchor(new Rectangle(80, 356, 553, 65)); - slide.addShape(box1); - - } - - public static void slide5(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); - - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); - tr1.setRunType(TextHeaderAtom.TITLE_TYPE); - tr1.setText("HSLF in Action - 1\rData Extraction"); - box1.setAnchor(new Rectangle(36, 21, 648, 100)); - slide.addShape(box1); - - TextBox box2 = new TextBox(); - TextRun tr2 = box2.getTextRun(); - tr2.setRunType(TextHeaderAtom.BODY_TYPE); - tr2.setText( - "Text from slides and notes\r" + - "Images\r" + - "Shapes and their properties (type, position in the slide, color, font, etc.)"); - box2.setAnchor(new Rectangle(36, 150, 648, 300)); - slide.addShape(box2); - - - } - - public static void slide6(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); - - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); - tr1.setRunType(TextHeaderAtom.TITLE_TYPE); - tr1.setText("HSLF in Action - 2"); - box1.setAnchor(new Rectangle(36, 20, 648, 90)); - slide.addShape(box1); - - TextBox box2 = new TextBox(); - TextRun tr2 = box2.getTextRun(); - tr2.getRichTextRuns()[0].setFontSize(18); - tr2.setText("Creating a simple presentation from scratch"); - box2.setAnchor(new Rectangle(170, 100, 364, 30)); - slide.addShape(box2); - - TextBox box3 = new TextBox(); - TextRun tr3 = box3.getTextRun(); - RichTextRun rt3 = tr3.getRichTextRuns()[0]; - rt3.setFontName("Courier New"); - rt3.setFontSize(8); - tr3.setText( - " SlideShow ppt = new SlideShow();\r" + - " Slide slide = ppt.createSlide();\r" + - "\r" + - " TextBox box2 = new TextBox();\r" + - " box2.setHorizontalAlignment(TextBox.AlignCenter);\r" + - " box2.setVerticalAlignment(TextBox.AnchorMiddle);\r" + - " box2.getTextRun().setText(\"Java Code\");\r" + - " box2.getFill().setForegroundColor(new Color(187, 224, 227));\r" + - " box2.setLineColor(Color.black);\r" + - " box2.setLineWidth(0.75);\r" + - " box2.setAnchor(new Rectangle(66, 243, 170, 170));\r" + - " slide.addShape(box2);\r" + - "\r" + - " TextBox box3 = new TextBox();\r" + - " box3.setHorizontalAlignment(TextBox.AlignCenter);\r" + - " box3.setVerticalAlignment(TextBox.AnchorMiddle);\r" + - " box3.getTextRun().setText(\"*.ppt file\");\r" + - " box3.setLineWidth(0.75);\r" + - " box3.setLineColor(Color.black);\r" + - " box3.getFill().setForegroundColor(new Color(187, 224, 227));\r" + - " box3.setAnchor(new Rectangle(473, 243, 170, 170));\r" + - " slide.addShape(box3);\r" + - "\r" + - " AutoShape box4 = new AutoShape(ShapeTypes.Arrow);\r" + - " box4.getFill().setForegroundColor(new Color(187, 224, 227));\r" + - " box4.setLineWidth(0.75);\r" + - " box4.setLineColor(Color.black);\r" + - " box4.setAnchor(new Rectangle(253, 288, 198, 85));\r" + - " slide.addShape(box4);\r" + - "\r" + - " FileOutputStream out = new FileOutputStream(\"hslf-demo.ppt\");\r" + - " ppt.write(out);\r" + - " out.close();"); - box3.setAnchor(new Rectangle(30, 150, 618, 411)); - slide.addShape(box3); - } - - public static void slide7(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); - - TextBox box2 = new TextBox(); - box2.setHorizontalAlignment(TextBox.AlignCenter); - box2.setVerticalAlignment(TextBox.AnchorMiddle); - box2.getTextRun().setText("Java Code"); - box2.getFill().setForegroundColor(new Color(187, 224, 227)); - box2.setLineColor(Color.black); - box2.setLineWidth(0.75); - box2.setAnchor(new Rectangle(66, 243, 170, 170)); - slide.addShape(box2); - - TextBox box3 = new TextBox(); - box3.setHorizontalAlignment(TextBox.AlignCenter); - box3.setVerticalAlignment(TextBox.AnchorMiddle); - box3.getTextRun().setText("*.ppt file"); - box3.setLineWidth(0.75); - box3.setLineColor(Color.black); - box3.getFill().setForegroundColor(new Color(187, 224, 227)); - box3.setAnchor(new Rectangle(473, 243, 170, 170)); - slide.addShape(box3); - - AutoShape box4 = new AutoShape(ShapeTypes.Arrow); - box4.getFill().setForegroundColor(new Color(187, 224, 227)); - box4.setLineWidth(0.75); - box4.setLineColor(Color.black); - box4.setAnchor(new Rectangle(253, 288, 198, 85)); - slide.addShape(box4); - } - - public static void slide8(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); - - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); - tr1.setRunType(TextHeaderAtom.TITLE_TYPE); - tr1.setText("Wait, there is more!"); - box1.setAnchor(new Rectangle(36, 21, 648, 90)); - slide.addShape(box1); - - TextBox box2 = new TextBox(); - TextRun tr2 = box2.getTextRun(); - tr2.setRunType(TextHeaderAtom.BODY_TYPE); - tr2.setText( - "Rich text\r" + - "Tables\r" + - "Pictures (JPEG, PNG, BMP, WMF, PICT)\r" + - "Comprehensive formatting features"); - box2.setAnchor(new Rectangle(36, 126, 648, 356)); - slide.addShape(box2); - } - - public static void slide9(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); - - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); - tr1.setRunType(TextHeaderAtom.TITLE_TYPE); - tr1.setText("HSLF in Action - 3"); - box1.setAnchor(new Rectangle(36, 20, 648, 50)); - slide.addShape(box1); - - TextBox box2 = new TextBox(); - TextRun tr2 = box2.getTextRun(); - tr2.getRichTextRuns()[0].setFontSize(18); - tr2.setText("PPGraphics2D: PowerPoint Graphics2D driver"); - box2.setAnchor(new Rectangle(178, 70, 387, 30)); - slide.addShape(box2); - - TextBox box3 = new TextBox(); - TextRun tr3 = box3.getTextRun(); - RichTextRun rt3 = tr3.getRichTextRuns()[0]; - rt3.setFontName("Courier New"); - rt3.setFontSize(8); - tr3.setText( - " //bar chart data. The first value is the bar color, the second is the width\r" + - " Object[] def = new Object[]{\r" + - " Color.yellow, new Integer(100),\r" + - " Color.green, new Integer(150),\r" + - " Color.gray, new Integer(75),\r" + - " Color.red, new Integer(200),\r" + - " };\r" + - "\r" + - " SlideShow ppt = new SlideShow();\r" + - " Slide slide = ppt.createSlide();\r" + - "\r" + - " ShapeGroup group = new ShapeGroup();\r" + - " //define position of the drawing in the slide\r" + - " Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);\r" + - " group.setAnchor(bounds);\r" + - " slide.addShape(group);\r" + - " Graphics2D graphics = new PPGraphics2D(group);\r" + - "\r" + - " //draw a simple bar graph\r" + - " int x = bounds.x + 50, y = bounds.y + 50;\r" + - " graphics.setFont(new Font(\"Arial\", Font.BOLD, 10));\r" + - " for (int i = 0, idx = 1; i < def.length; i+=2, idx++) {\r" + - " graphics.setColor(Color.black);\r" + - " int width = ((Integer)def[i+1]).intValue();\r" + - " graphics.drawString(\"Q\" + idx, x-20, y+20);\r" + - " graphics.drawString(width + \"%\", x + width + 10, y + 20);\r" + - " graphics.setColor((Color)def[i]);\r" + - " graphics.fill(new Rectangle(x, y, width, 30));\r" + - " y += 40;\r" + - " }\r" + - " graphics.setColor(Color.black);\r" + - " graphics.setFont(new Font(\"Arial\", Font.BOLD, 14));\r" + - " graphics.draw(bounds);\r" + - " graphics.drawString(\"Performance\", x + 70, y + 40);\r" + - "\r" + - " FileOutputStream out = new FileOutputStream(\"hslf-demo.ppt\");\r" + - " ppt.write(out);\r" + - " out.close();"); - box3.setAnchor(new Rectangle(96, 110, 499, 378)); - slide.addShape(box3); - } - - public static void slide10(SlideShow ppt) throws IOException { - //bar chart data. The first value is the bar color, the second is the width - Object[] def = new Object[]{ - Color.yellow, new Integer(100), - Color.green, new Integer(150), - Color.gray, new Integer(75), - Color.red, new Integer(200), - }; - - Slide slide = ppt.createSlide(); - - ShapeGroup group = new ShapeGroup(); - //define position of the drawing in the slide - Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300); - group.setAnchor(bounds); - slide.addShape(group); - Graphics2D graphics = new PPGraphics2D(group); - - //draw a simple bar graph - int x = bounds.x + 50, y = bounds.y + 50; - graphics.setFont(new Font("Arial", Font.BOLD, 10)); - for (int i = 0, idx = 1; i < def.length; i+=2, idx++) { - graphics.setColor(Color.black); - int width = ((Integer)def[i+1]).intValue(); - graphics.drawString("Q" + idx, x-20, y+20); - graphics.drawString(width + "%", x + width + 10, y + 20); - graphics.setColor((Color)def[i]); - graphics.fill(new Rectangle(x, y, width, 30)); - y += 40; - } - graphics.setColor(Color.black); - graphics.setFont(new Font("Arial", Font.BOLD, 14)); - graphics.draw(bounds); - graphics.drawString("Performance", x + 70, y + 40); - - } - - public static void slide11(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); - - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); - tr1.setRunType(TextHeaderAtom.TITLE_TYPE); - tr1.setText("HSLF Development Plans"); - box1.setAnchor(new Rectangle(36, 21, 648, 90)); - slide.addShape(box1); - - TextBox box2 = new TextBox(); - TextRun tr2 = box2.getTextRun(); - tr2.setRunType(TextHeaderAtom.BODY_TYPE); - tr2.getRichTextRuns()[0].setFontSize(32); - tr2.setText( - "Support for more PowerPoint functionality\r" + - "Rendering slides into java.awt.Graphics2D"); - box2.setAnchor(new Rectangle(36, 126, 648, 100)); - slide.addShape(box2); - - TextBox box3 = new TextBox(); - TextRun tr3 = box3.getTextRun(); - tr3.setRunType(TextHeaderAtom.BODY_TYPE); - tr3.getRichTextRuns()[0].setIndentLevel(1); - tr3.setText( - "A way to export slides into images or other formats"); - box3.setAnchor(new Rectangle(36, 220, 648, 70)); - slide.addShape(box3); - - TextBox box4 = new TextBox(); - TextRun tr4 = box4.getTextRun(); - tr4.setRunType(TextHeaderAtom.BODY_TYPE); - tr4.getRichTextRuns()[0].setFontSize(32); - tr4.setText( - "Integration with Apache FOP - Formatting Objects Processor"); - box4.setAnchor(new Rectangle(36, 290, 648, 90)); - slide.addShape(box4); - - TextBox box5 = new TextBox(); - TextRun tr5 = box5.getTextRun(); - tr5.setRunType(TextHeaderAtom.BODY_TYPE); - tr5.getRichTextRuns()[0].setIndentLevel(1); - tr5.setText( - "Transformation of XSL-FO into PPT\r" + - "PPT2PDF transcoder"); - box5.setAnchor(new Rectangle(36, 380, 648, 100)); - slide.addShape(box5); - } - - public static void slide12(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); - - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); - tr1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE); - tr1.setText("Questions?"); - box1.setAnchor(new Rectangle(54, 167, 612, 115)); - slide.addShape(box1); - - TextBox box2 = new TextBox(); - TextRun tr2 = box2.getTextRun(); - tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE); - tr2.setText( - "http://poi.apache.org/hslf/\r" + - "http://people.apache.org/~yegor"); - box2.setAnchor(new Rectangle(108, 306, 504, 138)); - slide.addShape(box2); - } -} diff --git a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/BulletsDemo.java b/src/scratchpad/examples/src/org/apache/poi/hslf/examples/BulletsDemo.java deleted file mode 100644 index 3a97b61aa0..0000000000 --- a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/BulletsDemo.java +++ /dev/null @@ -1,62 +0,0 @@ -/* ==================================================================== - 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.hslf.examples; - -import org.apache.poi.hslf.usermodel.SlideShow; -import org.apache.poi.hslf.usermodel.RichTextRun; -import org.apache.poi.hslf.model.Slide; -import org.apache.poi.hslf.model.TextBox; - -import java.io.FileOutputStream; - -/** - * How to create a single-level bulleted list - * and change some of the bullet attributes - * - * @author Yegor Kozlov - */ -public final class BulletsDemo { - - public static void main(String[] args) throws Exception { - - SlideShow ppt = new SlideShow(); - - Slide slide = ppt.createSlide(); - - TextBox shape = new TextBox(); - RichTextRun rt = shape.getTextRun().getRichTextRuns()[0]; - shape.setText( - "January\r" + - "February\r" + - "March\r" + - "April"); - rt.setFontSize(42); - rt.setBullet(true); - rt.setBulletOffset(0); //bullet offset - rt.setTextOffset(50); //text offset (should be greater than bullet offset) - rt.setBulletChar('\u263A'); //bullet character - slide.addShape(shape); - - shape.setAnchor(new java.awt.Rectangle(50, 50, 500, 300)); //position of the text box in the slide - slide.addShape(shape); - - FileOutputStream out = new FileOutputStream("bullets.ppt"); - ppt.write(out); - out.close(); - } -} diff --git a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/CreateHyperlink.java b/src/scratchpad/examples/src/org/apache/poi/hslf/examples/CreateHyperlink.java deleted file mode 100644 index c20a2f186f..0000000000 --- a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/CreateHyperlink.java +++ /dev/null @@ -1,60 +0,0 @@ -/* ==================================================================== - 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.hslf.examples; - -import org.apache.poi.hslf.usermodel.SlideShow; -import org.apache.poi.hslf.usermodel.RichTextRun; -import org.apache.poi.hslf.model.*; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.awt.*; - -/** - * Demonstrates how to create hyperlinks in PowerPoint presentations - * - * @author Yegor Kozlov - */ -public final class CreateHyperlink { - - public static void main(String[] args) throws Exception { - SlideShow ppt = new SlideShow(); - - Slide slide = ppt.createSlide(); - - TextBox shape = new TextBox(); - shape.setText("Apache POI"); - Rectangle anchor = new Rectangle(100, 100, 200, 50); - shape.setAnchor(anchor); - - String text = shape.getText(); - Hyperlink link = new Hyperlink(); - link.setAddress("http://www.apache.org"); - link.setTitle(shape.getText()); - int linkId = ppt.addHyperlink(link); - - shape.setHyperlink(linkId, 0, text.length()); - - slide.addShape(shape); - - FileOutputStream out = new FileOutputStream("hyperlink.ppt"); - ppt.write(out); - out.close(); - - } -} diff --git a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/DataExtraction.java b/src/scratchpad/examples/src/org/apache/poi/hslf/examples/DataExtraction.java deleted file mode 100644 index a278e894b6..0000000000 --- a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/DataExtraction.java +++ /dev/null @@ -1,148 +0,0 @@ -/* ==================================================================== - 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.hslf.examples; - -import org.apache.poi.hslf.usermodel.*; -import org.apache.poi.hslf.model.*; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.hwpf.HWPFDocument; -import org.apache.poi.hwpf.usermodel.Range; -import org.apache.poi.hwpf.usermodel.Paragraph; - -import java.io.*; - -/** - * Demonstrates how you can extract misc embedded data from a ppt file - * - * @author Yegor Kozlov - */ -public final class DataExtraction { - - public static void main(String args[]) throws Exception { - - if (args.length == 0) { - usage(); - return; - } - - FileInputStream is = new FileInputStream(args[0]); - SlideShow ppt = new SlideShow(is); - is.close(); - - //extract all sound files embedded in this presentation - SoundData[] sound = ppt.getSoundData(); - for (int i = 0; i < sound.length; i++) { - String type = sound[i].getSoundType(); //*.wav - String name = sound[i].getSoundName(); //typically file name - byte[] data = sound[i].getData(); //raw bytes - - //save the sound on disk - FileOutputStream out = new FileOutputStream(name + type); - out.write(data); - out.close(); - } - - //extract embedded OLE documents - Slide[] slide = ppt.getSlides(); - for (int i = 0; i < slide.length; i++) { - Shape[] shape = slide[i].getShapes(); - for (int j = 0; j < shape.length; j++) { - if (shape[j] instanceof OLEShape) { - OLEShape ole = (OLEShape) shape[j]; - ObjectData data = ole.getObjectData(); - String name = ole.getInstanceName(); - if ("Worksheet".equals(name)) { - - //read xls - HSSFWorkbook wb = new HSSFWorkbook(data.getData()); - - } else if ("Document".equals(name)) { - HWPFDocument doc = new HWPFDocument(data.getData()); - //read the word document - Range r = doc.getRange(); - for(int k = 0; k < r.numParagraphs(); k++) { - Paragraph p = r.getParagraph(k); - System.out.println(p.text()); - } - - //save on disk - FileOutputStream out = new FileOutputStream(name + "-("+(j)+").doc"); - doc.write(out); - out.close(); - } else { - FileOutputStream out = new FileOutputStream(ole.getProgID() + "-"+(j+1)+".dat"); - InputStream dis = data.getData(); - byte[] chunk = new byte[2048]; - int count; - while ((count = dis.read(chunk)) >= 0) { - out.write(chunk,0,count); - } - is.close(); - out.close(); - } - } - - } - } - - //Pictures - for (int i = 0; i < slide.length; i++) { - Shape[] shape = slide[i].getShapes(); - for (int j = 0; j < shape.length; j++) { - if (shape[j] instanceof Picture) { - Picture p = (Picture) shape[j]; - PictureData data = p.getPictureData(); - String name = p.getPictureName(); - int type = data.getType(); - String ext; - switch (type) { - case Picture.JPEG: - ext = ".jpg"; - break; - case Picture.PNG: - ext = ".png"; - break; - case Picture.WMF: - ext = ".wmf"; - break; - case Picture.EMF: - ext = ".emf"; - break; - case Picture.PICT: - ext = ".pict"; - break; - case Picture.DIB: - ext = ".dib"; - break; - default: - continue; - } - FileOutputStream out = new FileOutputStream("pict-" + j + ext); - out.write(data.getData()); - out.close(); - } - - } - } - - } - - private static void usage(){ - System.out.println("Usage: DataExtraction ppt"); - } -} diff --git a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java b/src/scratchpad/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java deleted file mode 100644 index b3d85640e0..0000000000 --- a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java +++ /dev/null @@ -1,80 +0,0 @@ -/* ==================================================================== - 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.hslf.examples; - -import org.apache.poi.hslf.usermodel.SlideShow; -import org.apache.poi.hslf.model.*; - -import java.awt.*; -import java.io.FileOutputStream; -import java.io.FileInputStream; - -/** - * Demonstrates how to draw into a slide using the HSLF Graphics2D driver. - * - * @author Yegor Kozlov - */ -public final class Graphics2DDemo { - - /** - * A simple bar chart demo - */ - public static void main(String[] args) throws Exception { - SlideShow ppt = new SlideShow(); - - //bar chart data. The first value is the bar color, the second is the width - Object[] def = new Object[]{ - Color.yellow, new Integer(40), - Color.green, new Integer(60), - Color.gray, new Integer(30), - Color.red, new Integer(80), - }; - - Slide slide = ppt.createSlide(); - - ShapeGroup group = new ShapeGroup(); - //define position of the drawing in the slide - Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300); - group.setAnchor(bounds); - group.setCoordinates(new java.awt.Rectangle(0, 0, 100, 100)); - slide.addShape(group); - Graphics2D graphics = new PPGraphics2D(group); - - //draw a simple bar graph - int x = 10, y = 10; - graphics.setFont(new Font("Arial", Font.BOLD, 10)); - for (int i = 0, idx = 1; i < def.length; i+=2, idx++) { - graphics.setColor(Color.black); - int width = ((Integer)def[i+1]).intValue(); - graphics.drawString("Q" + idx, x-5, y+10); - graphics.drawString(width + "%", x + width+3, y + 10); - graphics.setColor((Color)def[i]); - graphics.fill(new Rectangle(x, y, width, 10)); - y += 15; - } - graphics.setColor(Color.black); - graphics.setFont(new Font("Arial", Font.BOLD, 14)); - graphics.draw(group.getCoordinates()); - graphics.drawString("Performance", x + 30, y + 10); - - FileOutputStream out = new FileOutputStream("hslf-graphics.ppt"); - ppt.write(out); - out.close(); - } - -} diff --git a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/HeadersFootersDemo.java b/src/scratchpad/examples/src/org/apache/poi/hslf/examples/HeadersFootersDemo.java deleted file mode 100644 index 3ebcecc90f..0000000000 --- a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/HeadersFootersDemo.java +++ /dev/null @@ -1,51 +0,0 @@ -/* ==================================================================== - 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.hslf.examples; - -import org.apache.poi.hslf.usermodel.SlideShow; -import org.apache.poi.hslf.model.HeadersFooters; -import org.apache.poi.hslf.model.Slide; - -import java.io.FileOutputStream; - -/** - * Demonstrates how to set headers / footers - * - * @author Yegor Kozlov - */ -public class HeadersFootersDemo { - public static void main(String[] args) throws Exception { - SlideShow ppt = new SlideShow(); - - HeadersFooters slideHeaders = ppt.getSlideHeadersFooters(); - slideHeaders.setFootersText("Created by POI-HSLF"); - slideHeaders.setSlideNumberVisible(true); - slideHeaders.setDateTimeText("custom date time"); - - HeadersFooters notesHeaders = ppt.getNotesHeadersFooters(); - notesHeaders.setFootersText("My notes footers"); - notesHeaders.setHeaderText("My notes header"); - - Slide slide = ppt.createSlide(); - - FileOutputStream out = new FileOutputStream("headers_footers.ppt"); - ppt.write(out); - out.close(); - - } - -} diff --git a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/Hyperlinks.java b/src/scratchpad/examples/src/org/apache/poi/hslf/examples/Hyperlinks.java deleted file mode 100644 index 968426c513..0000000000 --- a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/Hyperlinks.java +++ /dev/null @@ -1,81 +0,0 @@ -/* ==================================================================== - 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.hslf.examples; - -import org.apache.poi.hslf.usermodel.SlideShow; -import org.apache.poi.hslf.model.Slide; -import org.apache.poi.hslf.model.TextRun; -import org.apache.poi.hslf.model.Hyperlink; -import org.apache.poi.hslf.model.Shape; - -import java.io.FileInputStream; - -/** - * Demonstrates how to read hyperlinks from a presentation - * - * @author Yegor Kozlov - */ -public final class Hyperlinks { - - public static void main(String[] args) throws Exception { - for (int i = 0; i < args.length; i++) { - FileInputStream is = new FileInputStream(args[i]); - SlideShow ppt = new SlideShow(is); - is.close(); - - Slide[] slide = ppt.getSlides(); - for (int j = 0; j < slide.length; j++) { - System.out.println("slide " + slide[j].getSlideNumber()); - - //read hyperlinks from the slide's text runs - System.out.println("reading hyperlinks from the text runs"); - TextRun[] txt = slide[j].getTextRuns(); - for (int k = 0; k < txt.length; k++) { - String text = txt[k].getText(); - Hyperlink[] links = txt[k].getHyperlinks(); - if(links != null) for (int l = 0; l < links.length; l++) { - Hyperlink link = links[l]; - String title = link.getTitle(); - String address = link.getAddress(); - System.out.println(" " + title); - System.out.println(" " + address); - String substring = text.substring(link.getStartIndex(), link.getEndIndex()-1);//in ppt end index is inclusive - System.out.println(" " + substring); - } - } - - //in PowerPoint you can assign a hyperlink to a shape without text, - //for example to a Line object. The code below demonstrates how to - //read such hyperlinks - System.out.println(" reading hyperlinks from the slide's shapes"); - Shape[] sh = slide[j].getShapes(); - for (int k = 0; k < sh.length; k++) { - Hyperlink link = sh[k].getHyperlink(); - if(link != null) { - String title = link.getTitle(); - String address = link.getAddress(); - System.out.println(" " + title); - System.out.println(" " + address); - } - } - } - - } - - } -} diff --git a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/PPT2PNG.java b/src/scratchpad/examples/src/org/apache/poi/hslf/examples/PPT2PNG.java deleted file mode 100644 index 2371f0fbf6..0000000000 --- a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/PPT2PNG.java +++ /dev/null @@ -1,107 +0,0 @@ -/* ==================================================================== - 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.hslf.examples; - -import org.apache.poi.hslf.usermodel.*; -import org.apache.poi.hslf.model.*; -import org.apache.poi.hslf.record.TextHeaderAtom; - -import javax.imageio.ImageIO; -import java.io.IOException; -import java.io.FileOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; - -/** - * Demonstrates how you can use HSLF to convert each slide into a PNG image - * - * @author Yegor Kozlov - */ -public final class PPT2PNG { - - public static void main(String args[]) throws Exception { - - if (args.length == 0) { - usage(); - return; - } - - int slidenum = -1; - float scale = 1; - String file = null; - - for (int i = 0; i < args.length; i++) { - if (args[i].startsWith("-")) { - if ("-scale".equals(args[i])){ - scale = Float.parseFloat(args[++i]); - } else if ("-slide".equals(args[i])) { - slidenum = Integer.parseInt(args[++i]); - } - } else { - file = args[i]; - } - } - if(file == null){ - usage(); - return; - } - - FileInputStream is = new FileInputStream(file); - SlideShow ppt = new SlideShow(is); - is.close(); - - Dimension pgsize = ppt.getPageSize(); - int width = (int)(pgsize.width*scale); - int height = (int)(pgsize.height*scale); - - Slide[] 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 "+slide[i].getSlideNumber() + (title == null ? "" : ": " + title)); - - BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - Graphics2D graphics = img.createGraphics(); - graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); - graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); - - graphics.setPaint(Color.white); - graphics.fill(new Rectangle2D.Float(0, 0, width, height)); - - graphics.scale((double)width/pgsize.width, (double)height/pgsize.height); - - slide[i].draw(graphics); - - String fname = file.replaceAll("\\.ppt", "-" + (i+1) + ".png"); - FileOutputStream out = new FileOutputStream(fname); - ImageIO.write(img, "png", out); - out.close(); - } - } - - private static void usage(){ - System.out.println("Usage: PPT2PNG [-scale <scale> -slide <num>] ppt"); - } -} diff --git a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/SoundFinder.java b/src/scratchpad/examples/src/org/apache/poi/hslf/examples/SoundFinder.java deleted file mode 100644 index b31019db94..0000000000 --- a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/SoundFinder.java +++ /dev/null @@ -1,80 +0,0 @@ -/* ==================================================================== - 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.hslf.examples; -import org.apache.poi.ddf.*; -import org.apache.poi.hslf.model.*; -import org.apache.poi.hslf.record.InteractiveInfo; -import org.apache.poi.hslf.record.InteractiveInfoAtom; -import org.apache.poi.hslf.record.Record; -import org.apache.poi.hslf.usermodel.*; -import java.io.FileInputStream; -import java.util.Iterator; -import java.util.List; - -/** - * For each slide iterate over shapes and found associated sound data. - * - * @author Yegor Kozlov - */ -public class SoundFinder { - public static void main(String[] args) throws Exception { - SlideShow ppt = new SlideShow(new FileInputStream(args[0])); - SoundData[] sounds = ppt.getSoundData(); - - Slide[] slide = ppt.getSlides(); - for (int i = 0; i < slide.length; i++) { - Shape[] shape = slide[i].getShapes(); - for (int j = 0; j < shape.length; j++) { - int soundRef = getSoundReference(shape[j]); - if(soundRef != -1) { - System.out.println("Slide["+i+"], shape["+j+"], soundRef: "+soundRef); - System.out.println(" " + sounds[soundRef].getSoundName()); - System.out.println(" " + sounds[soundRef].getSoundType()); - } - } - } - } - - /** - * Check if a given shape is associated with a sound. - * @return 0-based reference to a sound in the sound collection - * or -1 if the shape is not associated with a sound - */ - protected static int getSoundReference(Shape shape){ - int soundRef = -1; - //dive into the shape container and search for InteractiveInfoAtom - EscherContainerRecord spContainer = shape.getSpContainer(); - List spchild = spContainer.getChildRecords(); - for (Iterator it = spchild.iterator(); it.hasNext();) { - EscherRecord obj = (EscherRecord) it.next(); - if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) { - byte[] data = obj.serialize(); - Record[] records = Record.findChildRecords(data, 8, -data.length - 8); - for (int j = 0; j < records.length; j++) { - if (records[j] instanceof InteractiveInfo) { - InteractiveInfoAtom info = ((InteractiveInfo)records[j]).getInteractiveInfoAtom(); - if (info.getAction() == InteractiveInfoAtom.ACTION_MEDIA) { - soundRef = info.getSoundRef(); - } - } - } - } - } - return soundRef; - } -} diff --git a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/TableDemo.java b/src/scratchpad/examples/src/org/apache/poi/hslf/examples/TableDemo.java deleted file mode 100644 index 44935c05ac..0000000000 --- a/src/scratchpad/examples/src/org/apache/poi/hslf/examples/TableDemo.java +++ /dev/null @@ -1,127 +0,0 @@ -/* ==================================================================== - 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.hslf.examples; - -import org.apache.poi.hslf.usermodel.SlideShow; -import org.apache.poi.hslf.usermodel.RichTextRun; -import org.apache.poi.hslf.model.*; - -import java.awt.*; -import java.io.FileOutputStream; - -/** - * Demonstrates how to create tables - * - * @author Yegor Kozlov - */ -public final class TableDemo { - - public static void main(String[] args) throws Exception { - - //test data for the first taable - String[][] txt1 = { - {"INPUT FILE", "NUMBER OF RECORDS"}, - {"Item File", "11,559"}, - {"Vendor File", "502"}, - {"Purchase History File - # of PO\u2019s\r(12/01/04 - 05/31/06)", "12,852"}, - {"Purchase History File - # of PO Lines\r(12/01/04 - 05/31/06)", "53,523" }, - {"Total PO History Spend", "$10,172,038"} - }; - - SlideShow ppt = new SlideShow(); - - Slide slide = ppt.createSlide(); - - //six rows, two columns - Table table1 = new Table(6, 2); - for (int i = 0; i < txt1.length; i++) { - for (int j = 0; j < txt1[i].length; j++) { - TableCell cell = table1.getCell(i, j); - cell.setText(txt1[i][j]); - RichTextRun rt = cell.getTextRun().getRichTextRuns()[0]; - rt.setFontName("Arial"); - rt.setFontSize(10); - if(i == 0){ - cell.getFill().setForegroundColor(new Color(227, 227, 227)); - } else { - rt.setBold(true); - } - cell.setVerticalAlignment(TextBox.AnchorMiddle); - cell.setHorizontalAlignment(TextBox.AlignCenter); - } - } - - Line border1 = table1.createBorder(); - border1.setLineColor(Color.black); - border1.setLineWidth(1.0); - table1.setAllBorders(border1); - - table1.setColumnWidth(0, 300); - table1.setColumnWidth(1, 150); - - slide.addShape(table1); - int pgWidth = ppt.getPageSize().width; - table1.moveTo((pgWidth - table1.getAnchor().width)/2, 100); - - //test data for the second taable - String[][] txt2 = { - {"Data Source"}, - {"CAS Internal Metrics - Item Master Summary\r" + - "CAS Internal Metrics - Vendor Summary\r" + - "CAS Internal Metrics - PO History Summary"} - }; - - //two rows, one column - Table table2 = new Table(2, 1); - for (int i = 0; i < txt2.length; i++) { - for (int j = 0; j < txt2[i].length; j++) { - TableCell cell = table2.getCell(i, j); - cell.setText(txt2[i][j]); - RichTextRun rt = cell.getTextRun().getRichTextRuns()[0]; - rt.setFontSize(10); - rt.setFontName("Arial"); - if(i == 0){ - cell.getFill().setForegroundColor(new Color(0, 51, 102)); - rt.setFontColor(Color.white); - rt.setBold(true); - rt.setFontSize(14); - cell.setHorizontalAlignment(TextBox.AlignCenter); - } else { - rt.setBullet(true); - rt.setFontSize(12); - cell.setHorizontalAlignment(TextBox.AlignLeft); - } - cell.setVerticalAlignment(TextBox.AnchorMiddle); - } - } - table2.setColumnWidth(0, 300); - table2.setRowHeight(0, 30); - table2.setRowHeight(1, 70); - - Line border2 = table2.createBorder(); - table2.setOutsideBorders(border2); - - slide.addShape(table2); - table2.moveTo(200, 400); - - FileOutputStream out = new FileOutputStream("hslf-table.ppt"); - ppt.write(out); - out.close(); - - } -} diff --git a/src/scratchpad/examples/src/org/apache/poi/hsmf/examples/Msg2txt.java b/src/scratchpad/examples/src/org/apache/poi/hsmf/examples/Msg2txt.java deleted file mode 100644 index 546334bdaf..0000000000 --- a/src/scratchpad/examples/src/org/apache/poi/hsmf/examples/Msg2txt.java +++ /dev/null @@ -1,185 +0,0 @@ -/* ==================================================================== - 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.hsmf.examples; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.util.Iterator; -import java.util.Map; - -import org.apache.poi.hsmf.MAPIMessage; -import org.apache.poi.hsmf.exceptions.ChunkNotFoundException; - -/** - * Reads one or several Outlook MSG files and for each of them creates - * a text file from available chunks and a directory that contains - * attachments. - * - * @author Bruno Girin - * - */ -public class Msg2txt { - - /** - * The stem used to create file names for the text file and the directory - * that contains the attachments. - */ - private String fileNameStem; - - /** - * The Outlook MSG file being processed. - */ - private MAPIMessage msg; - - public Msg2txt(String fileName) throws IOException { - fileNameStem = fileName; - if(fileNameStem.endsWith(".msg") || fileNameStem.endsWith(".MSG")) { - fileNameStem = fileNameStem.substring(0, fileNameStem.length() - 4); - } - msg = new MAPIMessage(fileName); - } - - /** - * Processes the message. - * - * @throws IOException if an exception occurs while writing the message out - */ - public void processMessage() throws IOException { - String txtFileName = fileNameStem + ".txt"; - String attDirName = fileNameStem + "-att"; - PrintWriter txtOut = null; - try { - txtOut = new PrintWriter(txtFileName); - try { - String displayFrom = msg.getDisplayFrom(); - txtOut.println("From: "+displayFrom); - } catch (ChunkNotFoundException e) { - // ignore - } - try { - String displayTo = msg.getDisplayTo(); - txtOut.println("To: "+displayTo); - } catch (ChunkNotFoundException e) { - // ignore - } - try { - String displayCC = msg.getDisplayCC(); - txtOut.println("CC: "+displayCC); - } catch (ChunkNotFoundException e) { - // ignore - } - try { - String displayBCC = msg.getDisplayBCC(); - txtOut.println("BCC: "+displayBCC); - } catch (ChunkNotFoundException e) { - // ignore - } - try { - String subject = msg.getSubject(); - txtOut.println("Subject: "+subject); - } catch (ChunkNotFoundException e) { - // ignore - } - try { - String body = msg.getTextBody(); - txtOut.println(body); - } catch (ChunkNotFoundException e) { - System.err.println("No message body"); - } - Map attachmentMap = msg.getAttachmentFiles(); - if(attachmentMap.size() > 0) { - File d = new File(attDirName); - if(d.mkdir()) { - for( - Iterator ii = attachmentMap.entrySet().iterator(); - ii.hasNext(); - ) { - Map.Entry entry = (Map.Entry)ii.next(); - processAttachment(d, entry.getKey().toString(), - (ByteArrayInputStream)entry.getValue()); - } - } else { - System.err.println("Can't create directory "+attDirName); - } - } - } finally { - if(txtOut != null) { - txtOut.close(); - } - } - } - - /** - * Processes a single attachment: reads it from the Outlook MSG file and - * writes it to disk as an individual file. - * - * @param dir the directory in which to write the attachment file - * @param fileName the name of the attachment file - * @param fileIn the input stream that contains the attachment's data - * @throws IOException when any of the file operations fails - */ - public void processAttachment(File dir, String fileName, - ByteArrayInputStream fileIn) throws IOException { - File f = new File(dir, fileName); - OutputStream fileOut = null; - try { - fileOut = new FileOutputStream(f); - byte[] buffer = new byte[2048]; - int bNum = fileIn.read(buffer); - while(bNum > 0) { - fileOut.write(buffer); - bNum = fileIn.read(buffer); - } - } finally { - try { - if(fileIn != null) { - fileIn.close(); - } - } finally { - if(fileOut != null) { - fileOut.close(); - } - } - } - } - - /** - * Processes the list of arguments as a list of names of Outlook MSG files. - * - * @param args the list of MSG files to process - */ - public static void main(String[] args) { - if(args.length <= 0) { - System.err.println("No files names provided"); - } else { - for(int i = 0; i < args.length; i++) { - try { - Msg2txt processor = new Msg2txt(args[i]); - processor.processMessage(); - } catch (IOException e) { - System.err.println("Could not process "+args[i]+": "+e); - } - } - } - } - -} diff --git a/src/scratchpad/examples/src/org/apache/poi/hwpf/Word2Forrest.java b/src/scratchpad/examples/src/org/apache/poi/hwpf/Word2Forrest.java deleted file mode 100644 index 82d3a8a230..0000000000 --- a/src/scratchpad/examples/src/org/apache/poi/hwpf/Word2Forrest.java +++ /dev/null @@ -1,225 +0,0 @@ -/* ==================================================================== - 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.hwpf; - -import org.apache.poi.hwpf.HWPFDocument; -import org.apache.poi.hwpf.usermodel.*; -import org.apache.poi.hwpf.model.*; - -import java.io.*; - -public final class Word2Forrest -{ - Writer _out; - HWPFDocument _doc; - - public Word2Forrest(HWPFDocument doc, OutputStream stream) - throws IOException, UnsupportedEncodingException - { - OutputStreamWriter out = new OutputStreamWriter (stream, "UTF-8"); - _out = out; - _doc = doc; - - init (); - openDocument (); - openBody (); - - Range r = doc.getRange (); - StyleSheet styleSheet = doc.getStyleSheet (); - - int sectionLevel = 0; - int lenParagraph = r.numParagraphs (); - boolean inCode = false; - for (int x = 0; x < lenParagraph; x++) - { - Paragraph p = r.getParagraph (x); - String text = p.text (); - if (text.trim ().length () == 0) - { - continue; - } - StyleDescription paragraphStyle = styleSheet.getStyleDescription (p. - getStyleIndex ()); - String styleName = paragraphStyle.getName(); - if (styleName.startsWith ("Heading")) - { - if (inCode) - { - closeSource(); - inCode = false; - } - - int headerLevel = Integer.parseInt (styleName.substring (8)); - if (headerLevel > sectionLevel) - { - openSection (); - } - else - { - for (int y = 0; y < (sectionLevel - headerLevel) + 1; y++) - { - closeSection (); - } - openSection (); - } - sectionLevel = headerLevel; - openTitle (); - writePlainText (text); - closeTitle (); - } - else - { - int cruns = p.numCharacterRuns (); - CharacterRun run = p.getCharacterRun (0); - String fontName = run.getFontName(); - if (fontName.startsWith ("Courier")) - { - if (!inCode) - { - openSource (); - inCode = true; - } - writePlainText (p.text()); - } - else - { - if (inCode) - { - inCode = false; - closeSource(); - } - openParagraph(); - writePlainText(p.text()); - closeParagraph(); - } - } - } - for (int x = 0; x < sectionLevel; x++) - { - closeSection(); - } - closeBody(); - closeDocument(); - _out.flush(); - - } - - public void init () - throws IOException - { - _out.write ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); - _out.write ("<!DOCTYPE document PUBLIC \"-//APACHE//DTD Documentation V1.1//EN\" \"./dtd/document-v11.dtd\">\r\n"); - } - - public void openDocument () - throws IOException - { - _out.write ("<document>\r\n"); - } - public void closeDocument () - throws IOException - { - _out.write ("</document>\r\n"); - } - - - public void openBody () - throws IOException - { - _out.write ("<body>\r\n"); - } - - public void closeBody () - throws IOException - { - _out.write ("</body>\r\n"); - } - - - public void openSection () - throws IOException - { - _out.write ("<section>"); - - } - - public void closeSection () - throws IOException - { - _out.write ("</section>"); - - } - - public void openTitle () - throws IOException - { - _out.write ("<title>"); - } - - public void closeTitle () - throws IOException - { - _out.write ("</title>"); - } - - public void writePlainText (String text) - throws IOException - { - _out.write (text); - } - - public void openParagraph () - throws IOException - { - _out.write ("<p>"); - } - - public void closeParagraph () - throws IOException - { - _out.write ("</p>"); - } - - public void openSource () - throws IOException - { - _out.write ("<source><![CDATA["); - } - public void closeSource () - throws IOException - { - _out.write ("]]></source>"); - } - - - public static void main(String[] args) - { - try - { - OutputStream out = new FileOutputStream("c:\\test.xml"); - - new Word2Forrest(new HWPFDocument(new FileInputStream(args[0])), out); - out.close(); - } - catch (Throwable t) - { - t.printStackTrace(); - } - - } -} diff --git a/src/scratchpad/src/Manifest.mf b/src/scratchpad/src/Manifest.mf deleted file mode 100644 index 348f1bdd38..0000000000 --- a/src/scratchpad/src/Manifest.mf +++ /dev/null @@ -1 +0,0 @@ -Manifest-Version: 1.0
\ No newline at end of file diff --git a/src/scratchpad/src/org/apache/poi/hslf/data/empty.ppt b/src/scratchpad/src/org/apache/poi/hslf/data/empty.ppt Binary files differdeleted file mode 100644 index 20d2398e39..0000000000 --- a/src/scratchpad/src/org/apache/poi/hslf/data/empty.ppt +++ /dev/null |