diff --git a/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java b/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java index 7d013237ff..7a4b20c187 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java +++ b/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java @@ -34,7 +34,7 @@ import java.awt.*; public final class ApacheconEU08 { public static void main(String[] args) throws IOException { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); ppt.setPageSize(new Dimension(720, 540)); slide1(ppt); @@ -56,27 +56,27 @@ public final class ApacheconEU08 { } - public static void slide1(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); + public static void slide1(HSLFSlideShow ppt) throws IOException { + HSLFSlide slide = ppt.createSlide(); - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); + HSLFTextBox box1 = new HSLFTextBox(); + HSLFTextParagraph tr1 = box1.getTextParagraph(); 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(); + HSLFTextBox box2 = new HSLFTextBox(); + HSLFTextParagraph tr2 = box2.getTextParagraph(); 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(); + HSLFTextBox box3 = new HSLFTextBox(); + HSLFTextParagraph tr3 = box3.getTextParagraph(); tr3.getRichTextRuns()[0].setFontSize(32); - box3.setHorizontalAlignment(TextBox.AlignCenter); + box3.setHorizontalAlignment(HSLFTextBox.AlignCenter); tr3.setText( "Yegor Kozlov\r" + "yegor - apache - org"); @@ -84,18 +84,18 @@ public final class ApacheconEU08 { slide.addShape(box3); } - public static void slide2(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); + public static void slide2(HSLFSlideShow ppt) throws IOException { + HSLFSlide slide = ppt.createSlide(); - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); + HSLFTextBox box1 = new HSLFTextBox(); + HSLFTextParagraph tr1 = box1.getTextParagraph(); 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(); + HSLFTextBox box2 = new HSLFTextBox(); + HSLFTextParagraph tr2 = box2.getTextParagraph(); tr2.setRunType(TextHeaderAtom.BODY_TYPE); tr2.setText("HorribleSLideshowFormat is the POI Project's pure Java implementation " + "of the Powerpoint binary file format. \r" + @@ -107,18 +107,18 @@ public final class ApacheconEU08 { } - public static void slide3(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); + public static void slide3(HSLFSlideShow ppt) throws IOException { + HSLFSlide slide = ppt.createSlide(); - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); + HSLFTextBox box1 = new HSLFTextBox(); + HSLFTextParagraph tr1 = box1.getTextParagraph(); 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(); + HSLFTextBox box2 = new HSLFTextBox(); + HSLFTextParagraph tr2 = box2.getTextParagraph(); tr2.setRunType(TextHeaderAtom.BODY_TYPE); tr2.setText( "HSLF provides a way to read, create and modify MS PowerPoint presentations\r" + @@ -128,8 +128,8 @@ public final class ApacheconEU08 { box2.setAnchor(new Rectangle(36, 80, 648, 200)); slide.addShape(box2); - TextBox box3 = new TextBox(); - TextRun tr3 = box3.getTextRun(); + HSLFTextBox box3 = new HSLFTextBox(); + HSLFTextParagraph tr3 = box3.getTextParagraph(); tr3.setRunType(TextHeaderAtom.BODY_TYPE); tr3.setText( "Rich text\r" + @@ -142,16 +142,16 @@ public final class ApacheconEU08 { box3.setAnchor(new Rectangle(36, 265, 648, 150)); slide.addShape(box3); - TextBox box4 = new TextBox(); - TextRun tr4 = box4.getTextRun(); + HSLFTextBox box4 = new HSLFTextBox(); + HSLFTextParagraph tr4 = box4.getTextParagraph(); 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(); + public static void slide4(HSLFSlideShow ppt) throws IOException { + HSLFSlide slide = ppt.createSlide(); String[][] txt1 = { {"Note"}, @@ -162,8 +162,8 @@ public final class ApacheconEU08 { 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]; + cell.getTextParagraph().getRichTextRuns()[0].setFontSize(10); + HSLFTextRun rt = cell.getTextParagraph().getRichTextRuns()[0]; rt.setFontName("Arial"); rt.setBold(true); if(i == 0){ @@ -174,7 +174,7 @@ public final class ApacheconEU08 { rt.setFontSize(28); cell.getFill().setForegroundColor(new Color(235, 239, 241)); } - cell.setVerticalAlignment(TextBox.AnchorMiddle); + cell.setVerticalAlignment(HSLFTextBox.AnchorMiddle); } } @@ -195,30 +195,30 @@ public final class ApacheconEU08 { table1.moveTo(100, 100); - TextBox box1 = new TextBox(); - box1.setHorizontalAlignment(TextBox.AlignCenter); - TextRun tr1 = box1.getTextRun(); + HSLFTextBox box1 = new HSLFTextBox(); + box1.setHorizontalAlignment(HSLFTextBox.AlignCenter); + HSLFTextParagraph tr1 = box1.getTextParagraph(); tr1.setText("The source code is available at\r" + "http://people.apache.org/~yegor/apachecon_eu08/"); - RichTextRun rt = tr1.getRichTextRuns()[0]; + HSLFTextRun 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(); + public static void slide5(HSLFSlideShow ppt) throws IOException { + HSLFSlide slide = ppt.createSlide(); - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); + HSLFTextBox box1 = new HSLFTextBox(); + HSLFTextParagraph tr1 = box1.getTextParagraph(); 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(); + HSLFTextBox box2 = new HSLFTextBox(); + HSLFTextParagraph tr2 = box2.getTextParagraph(); tr2.setRunType(TextHeaderAtom.BODY_TYPE); tr2.setText( "Text from slides and notes\r" + @@ -230,26 +230,26 @@ public final class ApacheconEU08 { } - public static void slide6(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); + public static void slide6(HSLFSlideShow ppt) throws IOException { + HSLFSlide slide = ppt.createSlide(); - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); + HSLFTextBox box1 = new HSLFTextBox(); + HSLFTextParagraph tr1 = box1.getTextParagraph(); 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(); + HSLFTextBox box2 = new HSLFTextBox(); + HSLFTextParagraph tr2 = box2.getTextParagraph(); 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]; + HSLFTextBox box3 = new HSLFTextBox(); + HSLFTextParagraph tr3 = box3.getTextParagraph(); + HSLFTextRun rt3 = tr3.getRichTextRuns()[0]; rt3.setFontName("Courier New"); rt3.setFontSize(8); tr3.setText( @@ -290,30 +290,30 @@ public final class ApacheconEU08 { slide.addShape(box3); } - public static void slide7(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); + public static void slide7(HSLFSlideShow ppt) throws IOException { + HSLFSlide slide = ppt.createSlide(); - TextBox box2 = new TextBox(); - box2.setHorizontalAlignment(TextBox.AlignCenter); - box2.setVerticalAlignment(TextBox.AnchorMiddle); - box2.getTextRun().setText("Java Code"); + HSLFTextBox box2 = new HSLFTextBox(); + box2.setHorizontalAlignment(HSLFTextBox.AlignCenter); + box2.setVerticalAlignment(HSLFTextBox.AnchorMiddle); + box2.getTextParagraph().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"); + HSLFTextBox box3 = new HSLFTextBox(); + box3.setHorizontalAlignment(HSLFTextBox.AlignCenter); + box3.setVerticalAlignment(HSLFTextBox.AnchorMiddle); + box3.getTextParagraph().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(ShapeType.RIGHT_ARROW); + HSLFAutoShape box4 = new HSLFAutoShape(ShapeType.RIGHT_ARROW); box4.getFill().setForegroundColor(new Color(187, 224, 227)); box4.setLineWidth(0.75); box4.setLineColor(Color.black); @@ -321,18 +321,18 @@ public final class ApacheconEU08 { slide.addShape(box4); } - public static void slide8(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); + public static void slide8(HSLFSlideShow ppt) throws IOException { + HSLFSlide slide = ppt.createSlide(); - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); + HSLFTextBox box1 = new HSLFTextBox(); + HSLFTextParagraph tr1 = box1.getTextParagraph(); 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(); + HSLFTextBox box2 = new HSLFTextBox(); + HSLFTextParagraph tr2 = box2.getTextParagraph(); tr2.setRunType(TextHeaderAtom.BODY_TYPE); tr2.setText( "Rich text\r" + @@ -343,26 +343,26 @@ public final class ApacheconEU08 { slide.addShape(box2); } - public static void slide9(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); + public static void slide9(HSLFSlideShow ppt) throws IOException { + HSLFSlide slide = ppt.createSlide(); - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); + HSLFTextBox box1 = new HSLFTextBox(); + HSLFTextParagraph tr1 = box1.getTextParagraph(); 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(); + HSLFTextBox box2 = new HSLFTextBox(); + HSLFTextParagraph tr2 = box2.getTextParagraph(); 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]; + HSLFTextBox box3 = new HSLFTextBox(); + HSLFTextParagraph tr3 = box3.getTextParagraph(); + HSLFTextRun rt3 = tr3.getRichTextRuns()[0]; rt3.setFontName("Courier New"); rt3.setFontSize(8); tr3.setText( @@ -408,7 +408,7 @@ public final class ApacheconEU08 { slide.addShape(box3); } - public static void slide10(SlideShow ppt) throws IOException { + public static void slide10(HSLFSlideShow 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), @@ -417,7 +417,7 @@ public final class ApacheconEU08 { Color.red, new Integer(200), }; - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); HSLFGroupShape group = new HSLFGroupShape(); //define position of the drawing in the slide @@ -445,18 +445,18 @@ public final class ApacheconEU08 { } - public static void slide11(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); + public static void slide11(HSLFSlideShow ppt) throws IOException { + HSLFSlide slide = ppt.createSlide(); - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); + HSLFTextBox box1 = new HSLFTextBox(); + HSLFTextParagraph tr1 = box1.getTextParagraph(); 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(); + HSLFTextBox box2 = new HSLFTextBox(); + HSLFTextParagraph tr2 = box2.getTextParagraph(); tr2.setRunType(TextHeaderAtom.BODY_TYPE); tr2.getRichTextRuns()[0].setFontSize(32); tr2.setText( @@ -465,8 +465,8 @@ public final class ApacheconEU08 { box2.setAnchor(new Rectangle(36, 126, 648, 100)); slide.addShape(box2); - TextBox box3 = new TextBox(); - TextRun tr3 = box3.getTextRun(); + HSLFTextBox box3 = new HSLFTextBox(); + HSLFTextParagraph tr3 = box3.getTextParagraph(); tr3.setRunType(TextHeaderAtom.BODY_TYPE); tr3.getRichTextRuns()[0].setIndentLevel(1); tr3.setText( @@ -474,8 +474,8 @@ public final class ApacheconEU08 { box3.setAnchor(new Rectangle(36, 220, 648, 70)); slide.addShape(box3); - TextBox box4 = new TextBox(); - TextRun tr4 = box4.getTextRun(); + HSLFTextBox box4 = new HSLFTextBox(); + HSLFTextParagraph tr4 = box4.getTextParagraph(); tr4.setRunType(TextHeaderAtom.BODY_TYPE); tr4.getRichTextRuns()[0].setFontSize(32); tr4.setText( @@ -483,8 +483,8 @@ public final class ApacheconEU08 { box4.setAnchor(new Rectangle(36, 290, 648, 90)); slide.addShape(box4); - TextBox box5 = new TextBox(); - TextRun tr5 = box5.getTextRun(); + HSLFTextBox box5 = new HSLFTextBox(); + HSLFTextParagraph tr5 = box5.getTextParagraph(); tr5.setRunType(TextHeaderAtom.BODY_TYPE); tr5.getRichTextRuns()[0].setIndentLevel(1); tr5.setText( @@ -494,18 +494,18 @@ public final class ApacheconEU08 { slide.addShape(box5); } - public static void slide12(SlideShow ppt) throws IOException { - Slide slide = ppt.createSlide(); + public static void slide12(HSLFSlideShow ppt) throws IOException { + HSLFSlide slide = ppt.createSlide(); - TextBox box1 = new TextBox(); - TextRun tr1 = box1.getTextRun(); + HSLFTextBox box1 = new HSLFTextBox(); + HSLFTextParagraph tr1 = box1.getTextParagraph(); 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(); + HSLFTextBox box2 = new HSLFTextBox(); + HSLFTextParagraph tr2 = box2.getTextParagraph(); tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE); tr2.setText( "http://poi.apache.org/hslf/\r" + diff --git a/src/examples/src/org/apache/poi/hslf/examples/BulletsDemo.java b/src/examples/src/org/apache/poi/hslf/examples/BulletsDemo.java index 3a97b61aa0..ed6dd1231d 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/BulletsDemo.java +++ b/src/examples/src/org/apache/poi/hslf/examples/BulletsDemo.java @@ -17,10 +17,10 @@ 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 org.apache.poi.hslf.usermodel.HSLFSlideShow; +import org.apache.poi.hslf.usermodel.HSLFTextRun; +import org.apache.poi.hslf.model.HSLFSlide; +import org.apache.poi.hslf.model.HSLFTextBox; import java.io.FileOutputStream; @@ -34,12 +34,12 @@ public final class BulletsDemo { public static void main(String[] args) throws Exception { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); - TextBox shape = new TextBox(); - RichTextRun rt = shape.getTextRun().getRichTextRuns()[0]; + HSLFTextBox shape = new HSLFTextBox(); + HSLFTextRun rt = shape.getTextParagraph().getRichTextRuns()[0]; shape.setText( "January\r" + "February\r" + diff --git a/src/examples/src/org/apache/poi/hslf/examples/CreateHyperlink.java b/src/examples/src/org/apache/poi/hslf/examples/CreateHyperlink.java index 0aa8db32de..99c5d7d31f 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/CreateHyperlink.java +++ b/src/examples/src/org/apache/poi/hslf/examples/CreateHyperlink.java @@ -17,7 +17,7 @@ package org.apache.poi.hslf.examples; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.hslf.model.*; import java.io.FileOutputStream; @@ -31,14 +31,14 @@ import java.awt.*; public final class CreateHyperlink { public static void main(String[] args) throws Exception { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); - Slide slideA = ppt.createSlide(); - Slide slideB = ppt.createSlide(); - Slide slideC = ppt.createSlide(); + HSLFSlide slideA = ppt.createSlide(); + HSLFSlide slideB = ppt.createSlide(); + HSLFSlide slideC = ppt.createSlide(); // link to a URL - TextBox textBox1 = new TextBox(); + HSLFTextBox textBox1 = new HSLFTextBox(); textBox1.setText("Apache POI"); textBox1.setAnchor(new Rectangle(100, 100, 200, 50)); @@ -54,7 +54,7 @@ public final class CreateHyperlink { slideA.addShape(textBox1); // link to another slide - TextBox textBox2 = new TextBox(); + HSLFTextBox textBox2 = new HSLFTextBox(); textBox2.setText("Go to slide #3"); textBox2.setAnchor(new Rectangle(100, 300, 200, 50)); diff --git a/src/examples/src/org/apache/poi/hslf/examples/DataExtraction.java b/src/examples/src/org/apache/poi/hslf/examples/DataExtraction.java index e0f58741e1..d4028d7c67 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/DataExtraction.java +++ b/src/examples/src/org/apache/poi/hslf/examples/DataExtraction.java @@ -41,11 +41,11 @@ public final class DataExtraction { } FileInputStream is = new FileInputStream(args[0]); - SlideShow ppt = new SlideShow(is); + HSLFSlideShow ppt = new HSLFSlideShow(is); is.close(); //extract all sound files embedded in this presentation - SoundData[] sound = ppt.getSoundData(); + HSLFSoundData[] 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 @@ -58,13 +58,13 @@ public final class DataExtraction { } //extract embedded OLE documents - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { HSLFShape[] 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(); + HSLFObjectData data = ole.getObjectData(); String name = ole.getInstanceName(); if ("Worksheet".equals(name)) { @@ -104,29 +104,29 @@ public final class DataExtraction { for (int i = 0; i < slide.length; i++) { HSLFShape[] 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(); + if (shape[j] instanceof HSLFPictureShape) { + HSLFPictureShape p = (HSLFPictureShape) shape[j]; + HSLFPictureData data = p.getPictureData(); String name = p.getPictureName(); int type = data.getType(); String ext; switch (type) { - case Picture.JPEG: + case HSLFPictureShape.JPEG: ext = ".jpg"; break; - case Picture.PNG: + case HSLFPictureShape.PNG: ext = ".png"; break; - case Picture.WMF: + case HSLFPictureShape.WMF: ext = ".wmf"; break; - case Picture.EMF: + case HSLFPictureShape.EMF: ext = ".emf"; break; - case Picture.PICT: + case HSLFPictureShape.PICT: ext = ".pict"; break; - case Picture.DIB: + case HSLFPictureShape.DIB: ext = ".dib"; break; default: diff --git a/src/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java b/src/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java index a2f14ac41b..4e678ba64d 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java +++ b/src/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java @@ -17,7 +17,7 @@ package org.apache.poi.hslf.examples; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.hslf.model.*; import java.awt.*; @@ -34,7 +34,7 @@ public final class Graphics2DDemo { * A simple bar chart demo */ public static void main(String[] args) throws Exception { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); //bar chart data. The first value is the bar color, the second is the width Object[] def = new Object[]{ @@ -44,7 +44,7 @@ public final class Graphics2DDemo { Color.red, new Integer(80), }; - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); HSLFGroupShape group = new HSLFGroupShape(); //define position of the drawing in the slide diff --git a/src/examples/src/org/apache/poi/hslf/examples/HeadersFootersDemo.java b/src/examples/src/org/apache/poi/hslf/examples/HeadersFootersDemo.java index 3ebcecc90f..068d675347 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/HeadersFootersDemo.java +++ b/src/examples/src/org/apache/poi/hslf/examples/HeadersFootersDemo.java @@ -16,9 +16,9 @@ ==================================================================== */ package org.apache.poi.hslf.examples; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.hslf.model.HeadersFooters; -import org.apache.poi.hslf.model.Slide; +import org.apache.poi.hslf.model.HSLFSlide; import java.io.FileOutputStream; @@ -29,7 +29,7 @@ import java.io.FileOutputStream; */ public class HeadersFootersDemo { public static void main(String[] args) throws Exception { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); HeadersFooters slideHeaders = ppt.getSlideHeadersFooters(); slideHeaders.setFootersText("Created by POI-HSLF"); @@ -40,7 +40,7 @@ public class HeadersFootersDemo { notesHeaders.setFootersText("My notes footers"); notesHeaders.setHeaderText("My notes header"); - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); FileOutputStream out = new FileOutputStream("headers_footers.ppt"); ppt.write(out); diff --git a/src/examples/src/org/apache/poi/hslf/examples/Hyperlinks.java b/src/examples/src/org/apache/poi/hslf/examples/Hyperlinks.java index a90b6a1df0..89dcb636af 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/Hyperlinks.java +++ b/src/examples/src/org/apache/poi/hslf/examples/Hyperlinks.java @@ -17,9 +17,9 @@ 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.usermodel.HSLFSlideShow; +import org.apache.poi.hslf.model.HSLFSlide; +import org.apache.poi.hslf.model.HSLFTextParagraph; import org.apache.poi.hslf.model.Hyperlink; import org.apache.poi.hslf.model.HSLFShape; @@ -35,16 +35,16 @@ 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); + HSLFSlideShow ppt = new HSLFSlideShow(is); is.close(); - Slide[] slide = ppt.getSlides(); + HSLFSlide[] 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(); + HSLFTextParagraph[] txt = slide[j].getTextRuns(); for (int k = 0; k < txt.length; k++) { String text = txt[k].getText(); Hyperlink[] links = txt[k].getHyperlinks(); diff --git a/src/examples/src/org/apache/poi/hslf/examples/PPT2PNG.java b/src/examples/src/org/apache/poi/hslf/examples/PPT2PNG.java index 99037d3264..373f942844 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/PPT2PNG.java +++ b/src/examples/src/org/apache/poi/hslf/examples/PPT2PNG.java @@ -62,14 +62,14 @@ public final class PPT2PNG { } FileInputStream is = new FileInputStream(file); - SlideShow ppt = new SlideShow(is); + HSLFSlideShow ppt = new HSLFSlideShow(is); is.close(); Dimension pgsize = ppt.getPageSize(); int width = (int)(pgsize.width*scale); int height = (int)(pgsize.height*scale); - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { if (slidenum != -1 && slidenum != (i+1)) continue; diff --git a/src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java b/src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java index 571c86a425..765ba3ef49 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java +++ b/src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java @@ -32,10 +32,10 @@ import java.util.List; */ public class SoundFinder { public static void main(String[] args) throws Exception { - SlideShow ppt = new SlideShow(new FileInputStream(args[0])); - SoundData[] sounds = ppt.getSoundData(); + HSLFSlideShow ppt = new HSLFSlideShow(new FileInputStream(args[0])); + HSLFSoundData[] sounds = ppt.getSoundData(); - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { HSLFShape[] shape = slide[i].getShapes(); for (int j = 0; j < shape.length; j++) { diff --git a/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java b/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java index 44935c05ac..5dd1edea06 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java +++ b/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java @@ -17,8 +17,8 @@ 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.usermodel.HSLFSlideShow; +import org.apache.poi.hslf.usermodel.HSLFTextRun; import org.apache.poi.hslf.model.*; import java.awt.*; @@ -43,9 +43,9 @@ public final class TableDemo { {"Total PO History Spend", "$10,172,038"} }; - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); //six rows, two columns Table table1 = new Table(6, 2); @@ -53,7 +53,7 @@ public final class TableDemo { 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]; + HSLFTextRun rt = cell.getTextParagraph().getRichTextRuns()[0]; rt.setFontName("Arial"); rt.setFontSize(10); if(i == 0){ @@ -61,8 +61,8 @@ public final class TableDemo { } else { rt.setBold(true); } - cell.setVerticalAlignment(TextBox.AnchorMiddle); - cell.setHorizontalAlignment(TextBox.AlignCenter); + cell.setVerticalAlignment(HSLFTextBox.AnchorMiddle); + cell.setHorizontalAlignment(HSLFTextBox.AlignCenter); } } @@ -92,7 +92,7 @@ public final class TableDemo { 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]; + HSLFTextRun rt = cell.getTextParagraph().getRichTextRuns()[0]; rt.setFontSize(10); rt.setFontName("Arial"); if(i == 0){ @@ -100,13 +100,13 @@ public final class TableDemo { rt.setFontColor(Color.white); rt.setBold(true); rt.setFontSize(14); - cell.setHorizontalAlignment(TextBox.AlignCenter); + cell.setHorizontalAlignment(HSLFTextBox.AlignCenter); } else { rt.setBullet(true); rt.setFontSize(12); - cell.setHorizontalAlignment(TextBox.AlignLeft); + cell.setHorizontalAlignment(HSLFTextBox.AlignLeft); } - cell.setVerticalAlignment(TextBox.AnchorMiddle); + cell.setVerticalAlignment(HSLFTextBox.AnchorMiddle); } } table2.setColumnWidth(0, 300); diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/EmeddedObjects.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/EmeddedObjects.java index bb6f19d0a5..caf96a84c8 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/EmeddedObjects.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/EmeddedObjects.java @@ -21,8 +21,8 @@ import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.Entry; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.hwpf.HWPFDocument; -import org.apache.poi.hslf.HSLFSlideShow; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import java.io.FileInputStream; import java.util.Iterator; @@ -47,7 +47,7 @@ public class EmeddedObjects { //System.out.println(entry.getName() + ": " + embeddedWordDocument.getRange().text()); } else if (oleName.equals("Presentation")) { DirectoryNode dn = (DirectoryNode) obj.getDirectory(); - SlideShow embeddedPowerPointDocument = new SlideShow(new HSLFSlideShow(dn)); + HSLFSlideShow embeddedPowerPointDocument = new HSLFSlideShow(new HSLFSlideShowImpl(dn)); //System.out.println(entry.getName() + ": " + embeddedPowerPointDocument.getSlides().length); } else { if(obj.hasDirectoryEntry()){ diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java b/src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java index b7e08fc6f1..5437b5dea4 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java +++ b/src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java @@ -76,7 +76,6 @@ public final class DataExtraction { Dimension pageSize = ppt.getPageSize(); // size of the canvas in points for(XSLFSlide slide : ppt.getSlides()) { for(XSLFShape shape : slide){ - Rectangle2D anchor = shape.getAnchor(); // position on the canvas if(shape instanceof XSLFTextShape) { XSLFTextShape txShape = (XSLFTextShape)shape; System.out.println(txShape.getText()); diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial4.java b/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial4.java index 2e810e1d45..926bc0d4bf 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial4.java +++ b/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial4.java @@ -19,12 +19,12 @@ package org.apache.poi.xslf.usermodel; -import java.awt.*; +import java.awt.Color; import java.awt.geom.Rectangle2D; import java.io.FileOutputStream; import java.io.IOException; -import org.apache.poi.sl.usermodel.TextAlign; +import org.apache.poi.sl.usermodel.TextParagraph.TextAlign; /** * PPTX Tables diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/EmbeddedObjects.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/EmbeddedObjects.java index b50e959460..ea3a5b28e1 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/EmbeddedObjects.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/EmbeddedObjects.java @@ -20,7 +20,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.xwpf.usermodel.XWPFDocument; -import org.apache.poi.hslf.HSLFSlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.xslf.XSLFSlideShow; import org.apache.poi.hssf.usermodel.HSSFWorkbook; @@ -54,7 +54,7 @@ public class EmbeddedObjects { } // PowerPoint Document - binary file format else if (contentType.equals("application/vnd.ms-powerpoint")) { - HSLFSlideShow slideShow = new HSLFSlideShow(pPart.getInputStream()); + HSLFSlideShowImpl slideShow = new HSLFSlideShowImpl(pPart.getInputStream()); } // PowerPoint Document - OpenXML file format else if (contentType.equals("application/vnd.openxmlformats-officedocument.presentationml.presentation")) { diff --git a/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java index 51e54f6eb2..6b2ee5f09e 100644 --- a/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java @@ -22,14 +22,14 @@ import static org.junit.Assert.assertTrue; import java.io.FileInputStream; import java.io.InputStream; -import org.apache.poi.hslf.HSLFSlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.Record; import org.junit.Test; public class HSLFFileHandler extends POIFSFileHandler { @Override public void handleFile(InputStream stream) throws Exception { - HSLFSlideShow slide = new HSLFSlideShow(stream); + HSLFSlideShowImpl slide = new HSLFSlideShowImpl(stream); assertNotNull(slide.getCurrentUserAtom()); assertNotNull(slide.getEmbeddedObjects()); assertNotNull(slide.getUnderlyingBytes()); diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java index 57e96f8ee5..9a58a5128a 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java @@ -19,25 +19,19 @@ package org.apache.poi.xslf.usermodel; -import java.awt.Graphics2D; -import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.util.Iterator; import java.util.List; import java.util.regex.Pattern; -import org.apache.poi.openxml4j.opc.PackagePart; -import org.apache.poi.openxml4j.opc.PackageRelationship; -import org.apache.poi.openxml4j.opc.TargetMode; -import org.apache.poi.sl.usermodel.*; +import org.apache.poi.openxml4j.opc.*; +import org.apache.poi.sl.usermodel.PlaceableShape; +import org.apache.poi.sl.usermodel.ShapeGroup; import org.apache.poi.util.Beta; import org.apache.poi.util.Units; import org.apache.xmlbeans.XmlObject; import org.openxmlformats.schemas.drawingml.x2006.main.*; -import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector; -import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape; -import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual; -import org.openxmlformats.schemas.presentationml.x2006.main.CTShape; +import org.openxmlformats.schemas.presentationml.x2006.main.*; /** * Represents a group shape that consists of many shapes grouped together. @@ -45,7 +39,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTShape; * @author Yegor Kozlov */ @Beta -public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, PlaceableShape { +public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, ShapeGroup { private final List _shapes; private final CTGroupShapeProperties _grpSpPr; private XSLFDrawing _drawing; diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java index 62f9cc4ad6..a953e2013e 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java @@ -17,20 +17,19 @@ package org.apache.poi.xslf.usermodel; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.sl.usermodel.Notes; -import org.apache.poi.sl.usermodel.TextRun; import org.apache.poi.util.Beta; import org.apache.xmlbeans.XmlException; -import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData; -import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide; -import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument; +import org.openxmlformats.schemas.presentationml.x2006.main.*; @Beta -public final class XSLFNotes extends XSLFSheet implements Notes { +public final class XSLFNotes extends XSLFSheet implements Notes { private CTNotesSlide _notes; /** @@ -91,19 +90,15 @@ public final class XSLFNotes extends XSLFSheet implements Notes { return null; } - public TextRun getTextRun() { + @Override + public List getTextParagraphs() { + List tp = new ArrayList(); for (XSLFShape sh : super.getShapes()) { if (sh instanceof XSLFTextShape) { XSLFTextShape txt = (XSLFTextShape)sh; - for (XSLFTextParagraph p : txt.getTextParagraphs()) { - for (XSLFTextRun r : p.getTextRuns()) { - return r; - } - } + tp.addAll(txt.getTextParagraphs()); } } - return null; + return tp; } - - } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java index c5de537677..aeea5cc521 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java @@ -47,7 +47,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument; * @author Yegor Kozlov */ @Beta - public class XSLFNotesMaster extends XSLFSheet implements MasterSheet { + public class XSLFNotesMaster extends XSLFSheet implements MasterSheet { private CTNotesMaster _slide; private XSLFTheme _theme; @@ -94,7 +94,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument; } @Override - public MasterSheet getMasterSheet() { + public MasterSheet getMasterSheet() { return null; } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java index d0f75e0535..b815e00d42 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java @@ -19,7 +19,6 @@ package org.apache.poi.xslf.usermodel; -import java.awt.Graphics2D; import java.awt.Insets; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; @@ -32,27 +31,18 @@ import javax.xml.namespace.QName; import org.apache.poi.POIXMLException; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; +import org.apache.poi.sl.usermodel.PictureShape; import org.apache.poi.util.Beta; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlObject; -import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip; -import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties; -import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps; -import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension; -import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtensionList; -import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D; -import org.openxmlformats.schemas.drawingml.x2006.main.CTRelativeRect; -import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties; -import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType; -import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps; -import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture; -import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual; +import org.openxmlformats.schemas.drawingml.x2006.main.*; +import org.openxmlformats.schemas.presentationml.x2006.main.*; /** * Represents a picture shape */ @Beta -public class XSLFPictureShape extends XSLFSimpleShape { +public class XSLFPictureShape extends XSLFSimpleShape implements PictureShape { private XSLFPictureData _data; /*package*/ XSLFPictureShape(CTPicture shape, XSLFSheet sheet) { diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java index 9004a6be5f..0b0e4f0aad 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java @@ -88,7 +88,7 @@ public class XSLFShadow extends XSLFShape implements Shadow { */ public Color getFillColor() { SolidPaint ps = getFillStyle(); - if (ps == TRANSPARENT_PAINT) return null; + if (ps == PaintStyle.TRANSPARENT_PAINT) return null; Color col = DrawPaint.applyColorTransform(ps.getSolidColor()); return col; } @@ -97,7 +97,7 @@ public class XSLFShadow extends XSLFShape implements Shadow { public SolidPaint getFillStyle() { XSLFTheme theme = getSheet().getTheme(); CTOuterShadowEffect ct = (CTOuterShadowEffect)getXmlObject(); - if(ct == null) return TRANSPARENT_PAINT; + if(ct == null) return PaintStyle.TRANSPARENT_PAINT; CTSchemeColor phClr = ct.getSchemeClr(); final XSLFColor xc = new XSLFColor(ct, theme, phClr); diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java index 5634838302..0f2ba25834 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java @@ -19,7 +19,6 @@ package org.apache.poi.xslf.usermodel; -import java.awt.Color; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; @@ -28,7 +27,6 @@ import java.util.Comparator; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; -import org.apache.poi.sl.draw.DrawPaint; import org.apache.poi.sl.usermodel.*; import org.apache.poi.sl.usermodel.PaintStyle.GradientPaint; import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint; @@ -56,19 +54,6 @@ public abstract class XSLFShape implements Shape { private CTNonVisualDrawingProps _nvPr; private CTPlaceholder _ph; - protected static final SolidPaint TRANSPARENT_PAINT = new SolidPaint() { - public ColorStyle getSolidColor() { - return new ColorStyle(){ - public Color getColor() { return DrawPaint.NO_PAINT; } - public int getAlpha() { return -1; } - public int getLumOff() { return -1; } - public int getLumMod() { return -1; } - public int getShade() { return -1; } - public int getTint() { return -1; } - }; - } - }; - protected XSLFShape(XmlObject shape, XSLFSheet sheet) { _shape = shape; _sheet = sheet; @@ -146,7 +131,7 @@ public abstract class XSLFShape implements Shape { try { pr = shape.getSpPr(); if (((CTShapeProperties)pr).isSetNoFill()) { - setValue(TRANSPARENT_PAINT); + setValue(PaintStyle.TRANSPARENT_PAINT); return true; } } catch (IllegalStateException e) {} @@ -158,7 +143,7 @@ public abstract class XSLFShape implements Shape { pr = shape.getGrpSpPr(); } if (pr == null) { - setValue(TRANSPARENT_PAINT); + setValue(PaintStyle.TRANSPARENT_PAINT); return true; } @@ -190,7 +175,7 @@ public abstract class XSLFShape implements Shape { fillRef = getBgRef(); } if (fillRef == null) { - return TRANSPARENT_PAINT; + return PaintStyle.TRANSPARENT_PAINT; } // The idx attribute refers to the index of a fill style or @@ -213,21 +198,21 @@ public abstract class XSLFShape implements Shape { paint = selectPaint(fillProps, phClr, sheet.getPackagePart()); } - return paint == null ? TRANSPARENT_PAINT : paint; + return paint == null ? PaintStyle.TRANSPARENT_PAINT : paint; } protected CTBackgroundProperties getBgPr() { - String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:bgPr"; + String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:bgPr"; return selectProperty(CTBackgroundProperties.class, xquery); } protected CTStyleMatrixReference getBgRef() { - String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:bgRef"; + String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:bgRef"; return selectProperty(CTStyleMatrixReference.class, xquery); } protected CTGroupShapeProperties getGrpSpPr() { - String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:grpSpPr"; + String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:grpSpPr"; return selectProperty(CTGroupShapeProperties.class, xquery); } @@ -241,7 +226,7 @@ public abstract class XSLFShape implements Shape { protected CTShapeProperties getSpPr() { if (_spPr == null) { - String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:spPr"; + String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:spPr"; _spPr = selectProperty(CTShapeProperties.class, xquery); } if (_spPr == null) { @@ -252,7 +237,7 @@ public abstract class XSLFShape implements Shape { protected CTShapeStyle getSpStyle() { if (_spStyle == null) { - String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:style"; + String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:style"; _spStyle = selectProperty(CTShapeStyle.class, xquery); } return _spStyle; @@ -348,7 +333,7 @@ public abstract class XSLFShape implements Shape { paint = selectPaint(obj, phClr, pp); if(paint != null) break; } - return paint == null ? TRANSPARENT_PAINT : paint; + return paint == null ? PaintStyle.TRANSPARENT_PAINT : paint; } /** @@ -373,7 +358,7 @@ public abstract class XSLFShape implements Shape { */ protected PaintStyle selectPaint(XmlObject obj, final CTSchemeColor phClr, final PackagePart parentPart) { if (obj instanceof CTNoFillProperties) { - return TRANSPARENT_PAINT; + return PaintStyle.TRANSPARENT_PAINT; } else if (obj instanceof CTSolidColorFillProperties) { return selectPaint((CTSolidColorFillProperties)obj, phClr, parentPart); } else if (obj instanceof CTBlipFillProperties) { diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java index 163d8a65aa..38dea1b462 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java @@ -37,7 +37,7 @@ import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelations import org.openxmlformats.schemas.presentationml.x2006.main.*; @Beta -public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeContainer, Sheet { +public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeContainer, Sheet { private XSLFCommonSlideData _commonSlideData; private XSLFDrawing _drawing; private List _shapes; @@ -516,25 +516,26 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC * Import a package part into this sheet. */ PackagePart importPart(PackageRelationship srcRel, PackagePart srcPafrt) { - - OPCPackage pkg = getPackagePart().getPackage(); - if(!pkg.containPart(srcPafrt.getPartName())){ - PackageRelationship rel = getPackagePart().addRelationship( - srcPafrt.getPartName(), TargetMode.INTERNAL, srcRel.getRelationshipType()); - - PackagePart part = pkg.createPart(srcPafrt.getPartName(), srcPafrt.getContentType()); - OutputStream out = part.getOutputStream(); - try { - InputStream is = srcPafrt.getInputStream(); - IOUtils.copy(is, out); - out.close(); - } catch (IOException e){ - throw new POIXMLException(e); - } - return part; - } else { + PackagePart destPP = getPackagePart(); + PackagePartName srcPPName = srcPafrt.getPartName(); + + OPCPackage pkg = destPP.getPackage(); + if(pkg.containPart(srcPPName)){ // already exists - return pkg.getPart(srcPafrt.getPartName()); + return pkg.getPart(srcPPName); + } + + destPP.addRelationship(srcPPName, TargetMode.INTERNAL, srcRel.getRelationshipType()); + + PackagePart part = pkg.createPart(srcPPName, srcPafrt.getContentType()); + OutputStream out = part.getOutputStream(); + try { + InputStream is = srcPafrt.getInputStream(); + IOUtils.copy(is, out); + out.close(); + } catch (IOException e){ + throw new POIXMLException(e); } + return part; } } \ No newline at end of file diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java index ffe0fc823d..fb97180605 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java @@ -19,19 +19,21 @@ package org.apache.poi.xslf.usermodel; +import static org.apache.poi.sl.usermodel.PaintStyle.TRANSPARENT_PAINT; + import java.awt.Color; import java.awt.geom.Rectangle2D; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; -import org.apache.poi.sl.draw.DrawPaint; import org.apache.poi.sl.draw.geom.*; import org.apache.poi.sl.usermodel.*; import org.apache.poi.sl.usermodel.LineDecoration.DecorationShape; import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize; import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint; import org.apache.poi.sl.usermodel.StrokeStyle.LineCap; +import org.apache.poi.sl.usermodel.StrokeStyle.LineCompound; import org.apache.poi.sl.usermodel.StrokeStyle.LineDash; import org.apache.poi.util.Beta; import org.apache.poi.util.Units; @@ -208,8 +210,7 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape { PaintStyle ps = getLinePaint(); if (ps == null || ps == TRANSPARENT_PAINT) return null; if (ps instanceof SolidPaint) { - Color col = ((SolidPaint)ps).getSolidColor().getColor(); - return (col == DrawPaint.NO_PAINT) ? null : col; + return ((SolidPaint)ps).getSolidColor().getColor(); } return null; } @@ -273,7 +274,6 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape { } /** - * * @return line width in points. 0 means no line. */ public double getLineWidth() { @@ -310,6 +310,54 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape { return lineWidth; } + /** + * @return the line compound + */ + public LineCompound getLineCompound() { + PropertyFetcher fetcher = new PropertyFetcher() { + public boolean fetch(XSLFShape shape) { + CTShapeProperties spPr = shape.getSpPr(); + CTLineProperties ln = spPr.getLn(); + if (ln != null) { + STCompoundLine.Enum stCmpd = ln.getCmpd(); + if (stCmpd != null) { + setValue(stCmpd.intValue()); + return true; + } + } + return false; + } + }; + fetchShapeProperty(fetcher); + + Integer cmpd = fetcher.getValue(); + if (cmpd == null) { + CTLineProperties defaultLn = getDefaultLineProperties(); + if (defaultLn != null) { + STCompoundLine.Enum stCmpd = defaultLn.getCmpd(); + if (stCmpd != null) { + cmpd = stCmpd.intValue(); + } + } + } + + if (cmpd == null) return null; + + switch (cmpd) { + default: + case STCompoundLine.INT_SNG: + return LineCompound.SINGLE; + case STCompoundLine.INT_DBL: + return LineCompound.DOUBLE; + case STCompoundLine.INT_THICK_THIN: + return LineCompound.THICK_THIN; + case STCompoundLine.INT_THIN_THICK: + return LineCompound.THIN_THICK; + case STCompoundLine.INT_TRI: + return LineCompound.TRIPLE; + } + } + /** * * @param dash a preset line dashing scheme to stroke thr shape outline @@ -453,8 +501,7 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape { PaintStyle ps = getFillPaint(); if (ps == null || ps == TRANSPARENT_PAINT) return null; if (ps instanceof SolidPaint) { - Color col = ((SolidPaint)ps).getSolidColor().getColor(); - return (col == DrawPaint.NO_PAINT) ? null : col; + return ((SolidPaint)ps).getSolidColor().getColor(); } return null; } @@ -769,6 +816,10 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape { public double getLineWidth() { return XSLFSimpleShape.this.getLineWidth(); } + + public LineCompound getLineCompound() { + return XSLFSimpleShape.this.getLineCompound(); + } }; } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java index 795daa30b5..ee62ee9d79 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java @@ -29,7 +29,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.*; import org.openxmlformats.schemas.presentationml.x2006.main.*; @Beta -public final class XSLFSlide extends XSLFSheet implements Slide { +public final class XSLFSlide extends XSLFSheet implements Slide { private final CTSlide _slide; private XSLFSlideLayout _layout; private XSLFComments _comments; @@ -245,7 +245,7 @@ public final class XSLFSlide extends XSLFSheet implements Slide { throw new UnsupportedOperationException(); } - public void setNotes(Notes notes) { + public void setNotes(Notes notes) { // TODO Auto-generated method stub } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java index bd6c38ca46..65487bd45b 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java @@ -31,7 +31,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldLayoutDocument; import java.io.IOException; @Beta -public class XSLFSlideLayout extends XSLFSheet implements MasterSheet { +public class XSLFSlideLayout extends XSLFSheet implements MasterSheet { private CTSlideLayout _layout; private XSLFSlideMaster _master; diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java index 0b64306fd1..830a531a24 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java @@ -54,7 +54,7 @@ import java.util.Map; * @author Yegor Kozlov */ @Beta - public class XSLFSlideMaster extends XSLFSheet implements MasterSheet { + public class XSLFSlideMaster extends XSLFSheet implements MasterSheet { private CTSlideMaster _slide; private Map _layouts; private XSLFTheme _theme; @@ -83,7 +83,7 @@ import java.util.Map; } @Override - public MasterSheet getMasterSheet() { + public MasterSheet getMasterSheet() { return null; } diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java index e3dad561b6..5b7109059f 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java @@ -18,9 +18,10 @@ package org.apache.poi.xslf.usermodel; import junit.framework.TestCase; -import org.apache.poi.sl.usermodel.ShapeType; -import org.apache.poi.sl.usermodel.TextAlign; -import org.apache.poi.sl.usermodel.VerticalAlignment; +import org.apache.poi.sl.usermodel.*; +import org.apache.poi.sl.usermodel.TextParagraph.TextAlign; +import org.apache.poi.sl.usermodel.TextShape.TextAutofit; +import org.apache.poi.sl.usermodel.TextShape.TextDirection; import org.apache.poi.util.Units; import org.openxmlformats.schemas.drawingml.x2006.main.STTextStrikeType; import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType; diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java index ae7de8d5c0..0dc9c4d6f7 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java @@ -16,14 +16,17 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; +import java.awt.Color; +import java.awt.Rectangle; + import junit.framework.TestCase; -import org.apache.poi.sl.usermodel.ShapeType; +import org.apache.poi.sl.usermodel.LineDecoration.DecorationShape; +import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize; +import org.apache.poi.sl.usermodel.*; import org.openxmlformats.schemas.drawingml.x2006.main.*; import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector; -import java.awt.*; - /** * @author Yegor Kozlov */ @@ -40,70 +43,70 @@ public class TestXSLFConnectorShape extends TestCase { assertFalse(shape.getSpPr().getLn().isSetTailEnd()); // line decorations - assertEquals(LineDecoration.NONE, shape.getLineHeadDecoration()); - assertEquals(LineDecoration.NONE, shape.getLineTailDecoration()); + assertEquals(DecorationShape.NONE, shape.getLineHeadDecoration()); + assertEquals(DecorationShape.NONE, shape.getLineTailDecoration()); shape.setLineHeadDecoration(null); shape.setLineTailDecoration(null); - assertEquals(LineDecoration.NONE, shape.getLineHeadDecoration()); - assertEquals(LineDecoration.NONE, shape.getLineTailDecoration()); + assertEquals(DecorationShape.NONE, shape.getLineHeadDecoration()); + assertEquals(DecorationShape.NONE, shape.getLineTailDecoration()); assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetType()); assertFalse(shape.getSpPr().getLn().getTailEnd().isSetType()); - shape.setLineHeadDecoration(LineDecoration.ARROW); - shape.setLineTailDecoration(LineDecoration.DIAMOND); - assertEquals(LineDecoration.ARROW, shape.getLineHeadDecoration()); - assertEquals(LineDecoration.DIAMOND, shape.getLineTailDecoration()); + shape.setLineHeadDecoration(DecorationShape.ARROW); + shape.setLineTailDecoration(DecorationShape.DIAMOND); + assertEquals(DecorationShape.ARROW, shape.getLineHeadDecoration()); + assertEquals(DecorationShape.DIAMOND, shape.getLineTailDecoration()); assertEquals(STLineEndType.ARROW, shape.getSpPr().getLn().getHeadEnd().getType()); assertEquals(STLineEndType.DIAMOND, shape.getSpPr().getLn().getTailEnd().getType()); - shape.setLineHeadDecoration(LineDecoration.DIAMOND); - shape.setLineTailDecoration(LineDecoration.ARROW); - assertEquals(LineDecoration.DIAMOND, shape.getLineHeadDecoration()); - assertEquals(LineDecoration.ARROW, shape.getLineTailDecoration()); + shape.setLineHeadDecoration(DecorationShape.DIAMOND); + shape.setLineTailDecoration(DecorationShape.ARROW); + assertEquals(DecorationShape.DIAMOND, shape.getLineHeadDecoration()); + assertEquals(DecorationShape.ARROW, shape.getLineTailDecoration()); assertEquals(STLineEndType.DIAMOND, shape.getSpPr().getLn().getHeadEnd().getType()); assertEquals(STLineEndType.ARROW, shape.getSpPr().getLn().getTailEnd().getType()); // line end width - assertEquals(LineEndWidth.MEDIUM, shape.getLineHeadWidth()); - assertEquals(LineEndWidth.MEDIUM, shape.getLineTailWidth()); + assertEquals(DecorationSize.MEDIUM, shape.getLineHeadWidth()); + assertEquals(DecorationSize.MEDIUM, shape.getLineTailWidth()); shape.setLineHeadWidth(null); shape.setLineHeadWidth(null); - assertEquals(LineEndWidth.MEDIUM, shape.getLineHeadWidth()); - assertEquals(LineEndWidth.MEDIUM, shape.getLineTailWidth()); + assertEquals(DecorationSize.MEDIUM, shape.getLineHeadWidth()); + assertEquals(DecorationSize.MEDIUM, shape.getLineTailWidth()); assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetW()); assertFalse(shape.getSpPr().getLn().getTailEnd().isSetW()); - shape.setLineHeadWidth(LineEndWidth.LARGE); - shape.setLineTailWidth(LineEndWidth.MEDIUM); - assertEquals(LineEndWidth.LARGE, shape.getLineHeadWidth()); - assertEquals(LineEndWidth.MEDIUM, shape.getLineTailWidth()); + shape.setLineHeadWidth(DecorationSize.LARGE); + shape.setLineTailWidth(DecorationSize.MEDIUM); + assertEquals(DecorationSize.LARGE, shape.getLineHeadWidth()); + assertEquals(DecorationSize.MEDIUM, shape.getLineTailWidth()); assertEquals(STLineEndWidth.LG, shape.getSpPr().getLn().getHeadEnd().getW()); assertEquals(STLineEndWidth.MED, shape.getSpPr().getLn().getTailEnd().getW()); - shape.setLineHeadWidth(LineEndWidth.MEDIUM); - shape.setLineTailWidth(LineEndWidth.LARGE); - assertEquals(LineEndWidth.MEDIUM, shape.getLineHeadWidth()); - assertEquals(LineEndWidth.LARGE, shape.getLineTailWidth()); + shape.setLineHeadWidth(DecorationSize.MEDIUM); + shape.setLineTailWidth(DecorationSize.LARGE); + assertEquals(DecorationSize.MEDIUM, shape.getLineHeadWidth()); + assertEquals(DecorationSize.LARGE, shape.getLineTailWidth()); assertEquals(STLineEndWidth.MED, shape.getSpPr().getLn().getHeadEnd().getW()); assertEquals(STLineEndWidth.LG, shape.getSpPr().getLn().getTailEnd().getW()); // line end length - assertEquals(LineEndLength.MEDIUM, shape.getLineHeadLength()); - assertEquals(LineEndLength.MEDIUM, shape.getLineTailLength()); + assertEquals(DecorationSize.MEDIUM, shape.getLineHeadLength()); + assertEquals(DecorationSize.MEDIUM, shape.getLineTailLength()); shape.setLineHeadLength(null); shape.setLineTailLength(null); - assertEquals(LineEndLength.MEDIUM, shape.getLineHeadLength()); - assertEquals(LineEndLength.MEDIUM, shape.getLineTailLength()); + assertEquals(DecorationSize.MEDIUM, shape.getLineHeadLength()); + assertEquals(DecorationSize.MEDIUM, shape.getLineTailLength()); assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetLen()); assertFalse(shape.getSpPr().getLn().getTailEnd().isSetLen()); - shape.setLineHeadLength(LineEndLength.LARGE); - shape.setLineTailLength(LineEndLength.MEDIUM); - assertEquals(LineEndLength.LARGE, shape.getLineHeadLength()); - assertEquals(LineEndLength.MEDIUM, shape.getLineTailLength()); + shape.setLineHeadLength(DecorationSize.LARGE); + shape.setLineTailLength(DecorationSize.MEDIUM); + assertEquals(DecorationSize.LARGE, shape.getLineHeadLength()); + assertEquals(DecorationSize.MEDIUM, shape.getLineTailLength()); assertEquals(STLineEndLength.LG, shape.getSpPr().getLn().getHeadEnd().getLen()); assertEquals(STLineEndLength.MED, shape.getSpPr().getLn().getTailEnd().getLen()); - shape.setLineHeadLength(LineEndLength.MEDIUM); - shape.setLineTailLength(LineEndLength.LARGE); - assertEquals(LineEndLength.MEDIUM, shape.getLineHeadLength()); - assertEquals(LineEndLength.LARGE, shape.getLineTailLength()); + shape.setLineHeadLength(DecorationSize.MEDIUM); + shape.setLineTailLength(DecorationSize.LARGE); + assertEquals(DecorationSize.MEDIUM, shape.getLineHeadLength()); + assertEquals(DecorationSize.LARGE, shape.getLineTailLength()); assertEquals(STLineEndLength.MED, shape.getSpPr().getLn().getHeadEnd().getLen()); assertEquals(STLineEndLength.LG, shape.getSpPr().getLn().getTailEnd().getLen()); diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java index 2153ceb26f..b3a5fc211e 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java @@ -20,17 +20,11 @@ import java.awt.Color; import junit.framework.TestCase; -import org.apache.poi.sl.usermodel.LineCap; -import org.apache.poi.sl.usermodel.LineDash; +import org.apache.poi.sl.usermodel.StrokeStyle.LineCap; +import org.apache.poi.sl.usermodel.StrokeStyle.LineDash; import org.apache.poi.util.Units; import org.apache.poi.xslf.XSLFTestDataSamples; -import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleItem; -import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleList; -import org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect; -import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor; -import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix; -import org.openxmlformats.schemas.drawingml.x2006.main.STLineCap; -import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal; +import org.openxmlformats.schemas.drawingml.x2006.main.*; /** * @author Yegor Kozlov diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java index 505703bcaa..80a52fd2cc 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java @@ -20,6 +20,7 @@ import junit.framework.TestCase; import org.apache.poi.sl.usermodel.VerticalAlignment; import org.apache.poi.xslf.XSLFTestDataSamples; +import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell; import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame; import java.awt.Color; @@ -99,10 +100,11 @@ public class TestXSLFTable extends TestCase { XSLFTableCell cell0 = row0.addCell(); assertNotNull(cell0.getXmlObject()); // by default table cell has no borders - assertTrue(cell0.getXmlObject().getTcPr().getLnB().isSetNoFill()); - assertTrue(cell0.getXmlObject().getTcPr().getLnT().isSetNoFill()); - assertTrue(cell0.getXmlObject().getTcPr().getLnL().isSetNoFill()); - assertTrue(cell0.getXmlObject().getTcPr().getLnR().isSetNoFill()); + CTTableCell tc = (CTTableCell)cell0.getXmlObject(); + assertTrue(tc.getTcPr().getLnB().isSetNoFill()); + assertTrue(tc.getTcPr().getLnT().isSetNoFill()); + assertTrue(tc.getTcPr().getLnL().isSetNoFill()); + assertTrue(tc.getTcPr().getLnR().isSetNoFill()); assertSame(cell0, row0.getCells().get(0)); assertEquals(1, tbl.getNumberOfColumns()); diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java index 45bc30286e..fb906ed3a1 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java @@ -16,25 +16,46 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; -import junit.framework.TestCase; - -import org.apache.poi.sl.draw.TextFragment; -import org.apache.poi.sl.usermodel.TextAlign; -import org.apache.poi.util.POILogFactory; -import org.apache.poi.util.POILogger; -import org.apache.poi.xslf.XSLFTestDataSamples; +import static org.junit.Assert.*; import java.awt.*; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.util.List; +import org.apache.poi.sl.draw.DrawTextFragment; +import org.apache.poi.sl.draw.DrawTextParagraph; +import org.apache.poi.sl.usermodel.TextParagraph.TextAlign; +import org.apache.poi.util.POILogFactory; +import org.apache.poi.util.POILogger; +import org.apache.poi.xslf.XSLFTestDataSamples; +import org.junit.Test; + /** * @author Yegor Kozlov */ -public class TestXSLFTextParagraph extends TestCase { +public class TestXSLFTextParagraph { private static POILogger _logger = POILogFactory.getLogger(XSLFTextParagraph.class); + static class DrawTextParagraphProxy extends DrawTextParagraph { + DrawTextParagraphProxy(XSLFTextParagraph p) { + super(p); + } + + public void breakText(Graphics2D graphics) { + super.breakText(graphics); + } + + public double getWrappingWidth(boolean firstLine, Graphics2D graphics) { + return super.getWrappingWidth(firstLine, graphics); + } + + public List getLines() { + return lines; + } + } + + @Test public void testWrappingWidth() throws Exception { XMLSlideShow ppt = new XMLSlideShow(); XSLFSlide slide = ppt.createSlide(); @@ -49,45 +70,47 @@ public class TestXSLFTextParagraph extends TestCase { Rectangle2D anchor = new Rectangle(50, 50, 300, 200); sh.setAnchor(anchor); + + DrawTextParagraphProxy dtp = new DrawTextParagraphProxy(p); double leftInset = sh.getLeftInset(); double rightInset = sh.getRightInset(); - assertEquals(7.2, leftInset); - assertEquals(7.2, rightInset); + assertEquals(7.2, leftInset, 0); + assertEquals(7.2, rightInset, 0); double leftMargin = p.getLeftMargin(); - assertEquals(0.0, leftMargin); + assertEquals(0.0, leftMargin, 0); double indent = p.getIndent(); - assertEquals(0.0, indent); // default + assertEquals(0.0, indent, 0); // default double expectedWidth; // Case 1: bullet=false, leftMargin=0, indent=0. expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin; - assertEquals(285.6, expectedWidth); // 300 - 7.2 - 7.2 - 0 - assertEquals(expectedWidth, p.getWrappingWidth(true, null)); - assertEquals(expectedWidth, p.getWrappingWidth(false, null)); + assertEquals(285.6, expectedWidth, 0); // 300 - 7.2 - 7.2 - 0 + assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0); + assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0); p.setLeftMargin(36); // 0.5" leftMargin = p.getLeftMargin(); - assertEquals(36.0, leftMargin); + assertEquals(36.0, leftMargin, 0); expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin; assertEquals(249.6, expectedWidth, 1E-5); // 300 - 7.2 - 7.2 - 36 - assertEquals(expectedWidth, p.getWrappingWidth(true, null)); - assertEquals(expectedWidth, p.getWrappingWidth(false, null)); + assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0); + assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0); // increase insets, the wrapping width should get smaller sh.setLeftInset(10); sh.setRightInset(10); leftInset = sh.getLeftInset(); rightInset = sh.getRightInset(); - assertEquals(10.0, leftInset); - assertEquals(10.0, rightInset); + assertEquals(10.0, leftInset, 0); + assertEquals(10.0, rightInset, 0); expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin; - assertEquals(244.0, expectedWidth); // 300 - 10 - 10 - 36 - assertEquals(expectedWidth, p.getWrappingWidth(true, null)); - assertEquals(expectedWidth, p.getWrappingWidth(false, null)); + assertEquals(244.0, expectedWidth, 0); // 300 - 10 - 10 - 36 + assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0); + assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0); // set a positive indent of a 0.5 inch. This means "First Line" indentation: // |<--- indent -->|Here goes first line of the text @@ -95,34 +118,35 @@ public class TestXSLFTextParagraph extends TestCase { p.setIndent(36.0); // 0.5" indent = p.getIndent(); - assertEquals(36.0, indent); + assertEquals(36.0, indent, 0); expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin - indent; - assertEquals(208.0, expectedWidth); // 300 - 10 - 10 - 36 - 6.4 - assertEquals(expectedWidth, p.getWrappingWidth(true, null)); // first line is indented + assertEquals(208.0, expectedWidth, 0); // 300 - 10 - 10 - 36 - 6.4 + assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0); // first line is indented // other lines are not indented expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin; - assertEquals(244.0, expectedWidth); // 300 - 10 - 10 - 36 - assertEquals(expectedWidth, p.getWrappingWidth(false, null)); + assertEquals(244.0, expectedWidth, 0); // 300 - 10 - 10 - 36 + assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0); // set a negative indent of a 1 inch. This means "Hanging" indentation: // Here goes first line of the text // |<--- indent -->|Here go other lines (second and subsequent) p.setIndent(-72.0); // 1" indent = p.getIndent(); - assertEquals(-72.0, indent); + assertEquals(-72.0, indent, 0); expectedWidth = anchor.getWidth() - leftInset - rightInset; - assertEquals(280.0, expectedWidth); // 300 - 10 - 10 - assertEquals(expectedWidth, p.getWrappingWidth(true, null)); // first line is NOT indented + assertEquals(280.0, expectedWidth, 0); // 300 - 10 - 10 + assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0); // first line is NOT indented // other lines are indented by leftMargin (the value of indent is not used) expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin; - assertEquals(244.0, expectedWidth); // 300 - 10 - 10 - 36 - assertEquals(expectedWidth, p.getWrappingWidth(false, null)); + assertEquals(244.0, expectedWidth, 0); // 300 - 10 - 10 - 36 + assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0); } /** * test breaking test into lines. * This test requires that the Arial font is available and will run only on windows */ + @Test public void testBreakLines(){ String os = System.getProperty("os.name"); if(os == null || !os.contains("Windows")) { @@ -144,44 +168,52 @@ public class TestXSLFTextParagraph extends TestCase { "residing within the corresponding paragraph."); sh.setAnchor(new Rectangle(50, 50, 300, 200)); + DrawTextParagraphProxy dtp = new DrawTextParagraphProxy(p); BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics(); - List lines; - lines = p.breakText(graphics); + List lines; + dtp.breakText(graphics); + lines = dtp.getLines(); assertEquals(4, lines.size()); // descrease the shape width from 300 pt to 100 pt sh.setAnchor(new Rectangle(50, 50, 100, 200)); - lines = p.breakText(graphics); + dtp.breakText(graphics); + lines = dtp.getLines(); assertEquals(12, lines.size()); // descrease the shape width from 300 pt to 100 pt sh.setAnchor(new Rectangle(50, 50, 600, 200)); - lines = p.breakText(graphics); + dtp.breakText(graphics); + lines = dtp.getLines(); assertEquals(2, lines.size()); // set left and right margins to 200pt. This leaves 200pt for wrapping text sh.setLeftInset(200); sh.setRightInset(200); - lines = p.breakText(graphics); + dtp.breakText(graphics); + lines = dtp.getLines(); assertEquals(5, lines.size()); r.setText("Apache POI"); - lines = p.breakText(graphics); + dtp.breakText(graphics); + lines = dtp.getLines(); assertEquals(1, lines.size()); assertEquals("Apache POI", lines.get(0).getString()); r.setText("Apache\nPOI"); - lines = p.breakText(graphics); + dtp.breakText(graphics); + lines = dtp.getLines(); assertEquals(2, lines.size()); assertEquals("Apache", lines.get(0).getString()); assertEquals("POI", lines.get(1).getString()); // trailing newlines are ignored r.setText("Apache\nPOI\n"); - lines = p.breakText(graphics); + dtp.breakText(graphics); + lines = dtp.getLines(); assertEquals(2, lines.size()); assertEquals("Apache", lines.get(0).getString()); assertEquals("POI", lines.get(1).getString()); @@ -197,7 +229,8 @@ public class TestXSLFTextParagraph extends TestCase { r3.setFontFamily("serif"); // this should always be available r3.setFontSize(10); r3.setText("POI"); - lines = p2.breakText(graphics); + dtp.breakText(graphics); + lines = dtp.getLines(); assertEquals(2, lines.size()); assertEquals("Apache", lines.get(0).getString()); assertEquals("POI", lines.get(1).getString()); @@ -206,6 +239,7 @@ public class TestXSLFTextParagraph extends TestCase { } + @Test public void testThemeInheritance(){ XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("prProps.pptx"); XSLFShape[] shapes = ppt.getSlides()[0].getShapes(); @@ -220,6 +254,7 @@ public class TestXSLFTextParagraph extends TestCase { assertEquals(TextAlign.CENTER, sh3.getTextParagraphs().get(0).getTextAlign()); } + @Test public void testParagraphProperties(){ XMLSlideShow ppt = new XMLSlideShow(); XSLFSlide slide = ppt.createSlide(); @@ -242,25 +277,25 @@ public class TestXSLFTextParagraph extends TestCase { p.setBulletFontColor(Color.red); assertEquals(Color.red, p.getBulletFontColor()); - assertEquals(100.0, p.getBulletFontSize()); + assertEquals(100.0, p.getBulletFontSize(), 0); p.setBulletFontSize(200.); - assertEquals(200., p.getBulletFontSize()); + assertEquals(200., p.getBulletFontSize(), 0); p.setBulletFontSize(-20.); - assertEquals(-20.0, p.getBulletFontSize()); + assertEquals(-20.0, p.getBulletFontSize(), 0); - assertEquals(72.0, p.getDefaultTabSize()); + assertEquals(72.0, p.getDefaultTabSize(), 0); - assertEquals(0.0, p.getIndent()); + assertEquals(0.0, p.getIndent(), 0); p.setIndent(72.0); - assertEquals(72.0, p.getIndent()); + assertEquals(72.0, p.getIndent(), 0); p.setIndent(-1.0); // the value of -1.0 resets to the defaults - assertEquals(0.0, p.getIndent()); + assertEquals(0.0, p.getIndent(), 0); - assertEquals(0.0, p.getLeftMargin()); + assertEquals(0.0, p.getLeftMargin(), 0); p.setLeftMargin(72.0); - assertEquals(72.0, p.getLeftMargin()); + assertEquals(72.0, p.getLeftMargin(), 0); p.setLeftMargin(-1.0); // the value of -1.0 resets to the defaults - assertEquals(0.0, p.getLeftMargin()); + assertEquals(0.0, p.getLeftMargin(), 0); assertEquals(0, p.getLevel()); p.setLevel(1); @@ -268,23 +303,23 @@ public class TestXSLFTextParagraph extends TestCase { p.setLevel(2); assertEquals(2, p.getLevel()); - assertEquals(100., p.getLineSpacing()); + assertEquals(100., p.getLineSpacing(), 0); p.setLineSpacing(200.); - assertEquals(200.0, p.getLineSpacing()); + assertEquals(200.0, p.getLineSpacing(), 0); p.setLineSpacing(-15.); - assertEquals(-15.0, p.getLineSpacing()); + assertEquals(-15.0, p.getLineSpacing(), 0); - assertEquals(0., p.getSpaceAfter()); + assertEquals(0., p.getSpaceAfter(), 0); p.setSpaceAfter(200.); - assertEquals(200.0, p.getSpaceAfter()); + assertEquals(200.0, p.getSpaceAfter(), 0); p.setSpaceAfter(-15.); - assertEquals(-15.0, p.getSpaceAfter()); + assertEquals(-15.0, p.getSpaceAfter(), 0); - assertEquals(0., p.getSpaceBefore()); + assertEquals(0., p.getSpaceBefore(), 0); p.setSpaceBefore(200.); - assertEquals(200.0, p.getSpaceBefore()); + assertEquals(200.0, p.getSpaceBefore(), 0); p.setSpaceBefore(-15.); - assertEquals(-15.0, p.getSpaceBefore()); + assertEquals(-15.0, p.getSpaceBefore(), 0); assertEquals(TextAlign.LEFT, p.getTextAlign()); p.setTextAlign(TextAlign.RIGHT); @@ -296,15 +331,16 @@ public class TestXSLFTextParagraph extends TestCase { p.setBulletAutoNumber(ListAutoNumber.ALPHA_LC_PARENT_BOTH, 1); double tabStop = p.getTabStop(0); - assertEquals(0.0, tabStop); + assertEquals(0.0, tabStop, 0); p.addTabStop(100.); - assertEquals(100., p.getTabStop(0)); + assertEquals(100., p.getTabStop(0), 0); - assertEquals(72.0, p.getDefaultTabSize()); + assertEquals(72.0, p.getDefaultTabSize(), 0); } + @Test public void testLineBreak(){ XMLSlideShow ppt = new XMLSlideShow(); XSLFSlide slide = ppt.createSlide(); @@ -316,12 +352,12 @@ public class TestXSLFTextParagraph extends TestCase { XSLFTextRun r2 = p.addLineBreak(); assertEquals("\n", r2.getText()); r2.setFontSize(10.0); - assertEquals(10.0, r2.getFontSize()); + assertEquals(10.0, r2.getFontSize(), 0); XSLFTextRun r3 = p.addNewTextRun(); r3.setText("World!"); r3.setFontSize(20.0); XSLFTextRun r4 = p.addLineBreak(); - assertEquals(20.0, r4.getFontSize()); + assertEquals(20.0, r4.getFontSize(), 0); assertEquals("Hello,\nWorld!\n",sh.getText()); diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java index f217c58278..f9232a1733 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java @@ -16,20 +16,17 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; +import java.awt.Color; + import junit.framework.TestCase; -import org.apache.poi.sl.usermodel.TextAlign; +import org.apache.poi.sl.usermodel.TextParagraph.TextAlign; import org.apache.poi.sl.usermodel.VerticalAlignment; import org.apache.poi.xslf.XSLFTestDataSamples; -import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties; -import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties; -import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties; -import org.openxmlformats.schemas.drawingml.x2006.main.STTextAlignType; +import org.openxmlformats.schemas.drawingml.x2006.main.*; import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder; import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType; -import java.awt.Color; - /** * @author Yegor Kozlov */ diff --git a/src/resources/scratchpad/org/apache/poi/sl/draw/presetShapeDefinitions.xml b/src/resources/scratchpad/org/apache/poi/sl/draw/geom/presetShapeDefinitions.xml similarity index 100% rename from src/resources/scratchpad/org/apache/poi/sl/draw/presetShapeDefinitions.xml rename to src/resources/scratchpad/org/apache/poi/sl/draw/geom/presetShapeDefinitions.xml diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java b/src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java index 9f59de4a86..4c9e9ceaf6 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/Bitmap.java @@ -17,7 +17,7 @@ package org.apache.poi.hslf.blip; -import org.apache.poi.hslf.usermodel.PictureData; +import org.apache.poi.hslf.usermodel.HSLFPictureData; import java.io.IOException; import java.io.ByteArrayOutputStream; @@ -28,7 +28,7 @@ import java.io.ByteArrayOutputStream; * * @author Yegor Kozlov */ -public abstract class Bitmap extends PictureData { +public abstract class Bitmap extends HSLFPictureData { public byte[] getData(){ byte[] rawdata = getRawData(); diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java b/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java index aae83bf6e1..6795601a6c 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/BitmapPainter.java @@ -17,8 +17,8 @@ package org.apache.poi.hslf.blip; -import org.apache.poi.hslf.usermodel.PictureData; -import org.apache.poi.hslf.model.Picture; +import org.apache.poi.hslf.usermodel.HSLFPictureData; +import org.apache.poi.hslf.model.HSLFPictureShape; import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogFactory; @@ -56,7 +56,7 @@ import java.io.ByteArrayInputStream; public final class BitmapPainter implements ImagePainter { protected POILogger logger = POILogFactory.getLogger(this.getClass()); - public void paint(Graphics2D graphics, PictureData pict, Picture parent) { + public void paint(Graphics2D graphics, HSLFPictureData pict, HSLFPictureShape parent) { BufferedImage img; try { img = ImageIO.read(new ByteArrayInputStream(pict.getData())); diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java b/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java index 21ea072ff7..401ac43476 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/DIB.java @@ -17,7 +17,7 @@ package org.apache.poi.hslf.blip; -import org.apache.poi.hslf.model.Picture; +import org.apache.poi.hslf.model.HSLFPictureShape; import org.apache.poi.util.LittleEndian; import java.io.IOException; @@ -35,10 +35,10 @@ public final class DIB extends Bitmap { /** * @return type of this picture - * @see org.apache.poi.hslf.model.Picture#DIB + * @see org.apache.poi.hslf.model.HSLFPictureShape#DIB */ public int getType(){ - return Picture.DIB; + return HSLFPictureShape.DIB; } /** @@ -89,4 +89,8 @@ public final class DIB extends Bitmap { System.arraycopy(data, HEADER_SIZE, dib, 0, dib.length); super.setData(dib); } + + public String getContentType() { + return "image/bmp"; + } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java b/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java index 7ad569aa8d..5fe55f1819 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/EMF.java @@ -17,7 +17,7 @@ package org.apache.poi.hslf.blip; -import org.apache.poi.hslf.model.Picture; +import org.apache.poi.hslf.model.HSLFPictureShape; import org.apache.poi.hslf.model.HSLFShape; import org.apache.poi.hslf.exceptions.HSLFException; @@ -80,7 +80,7 @@ public final class EMF extends Metafile { } public int getType(){ - return Picture.EMF; + return HSLFPictureShape.EMF; } /** @@ -91,4 +91,8 @@ public final class EMF extends Metafile { public int getSignature(){ return 0x3D40; } + + public String getContentType() { + return "image/x-emf"; + } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java b/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java index 2c35007048..0f1afecb98 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/ImagePainter.java @@ -17,8 +17,8 @@ package org.apache.poi.hslf.blip; -import org.apache.poi.hslf.model.Picture; -import org.apache.poi.hslf.usermodel.PictureData; +import org.apache.poi.hslf.model.HSLFPictureShape; +import org.apache.poi.hslf.usermodel.HSLFPictureData; import java.awt.*; @@ -68,5 +68,5 @@ public interface ImagePainter { * @param pict the data to paint * @param parent the shapes that owns the picture data */ - public void paint(Graphics2D graphics, PictureData pict, Picture parent); + public void paint(Graphics2D graphics, HSLFPictureData pict, HSLFPictureShape parent); } diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java b/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java index 65ade3ee38..567fc996ee 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/JPEG.java @@ -17,7 +17,7 @@ package org.apache.poi.hslf.blip; -import org.apache.poi.hslf.model.Picture; +import org.apache.poi.hslf.model.HSLFPictureShape; /** * Represents a JPEG picture data in a PPT file @@ -28,10 +28,10 @@ public final class JPEG extends Bitmap { /** * @return type of this picture - * @see org.apache.poi.hslf.model.Picture#JPEG + * @see org.apache.poi.hslf.model.HSLFPictureShape#JPEG */ public int getType(){ - return Picture.JPEG; + return HSLFPictureShape.JPEG; } /** @@ -42,4 +42,8 @@ public final class JPEG extends Bitmap { public int getSignature(){ return 0x46A0; } + + public String getContentType() { + return "image/jpeg"; + } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java b/src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java index c05d19acb0..535e206410 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/Metafile.java @@ -18,7 +18,7 @@ package org.apache.poi.hslf.blip; import org.apache.poi.util.LittleEndian; -import org.apache.poi.hslf.usermodel.PictureData; +import org.apache.poi.hslf.usermodel.HSLFPictureData; import java.awt.*; import java.io.*; @@ -30,7 +30,7 @@ import java.util.zip.DeflaterOutputStream; * * @author Yegor Kozlov */ -public abstract class Metafile extends PictureData { +public abstract class Metafile extends HSLFPictureData { /** * A structure which represents a 34-byte header preceeding the compressed metafile data diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java b/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java index 4b401518ee..9b2df64262 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/PICT.java @@ -23,7 +23,7 @@ import java.io.IOException; import java.util.zip.InflaterInputStream; import org.apache.poi.hslf.exceptions.HSLFException; -import org.apache.poi.hslf.model.Picture; +import org.apache.poi.hslf.model.HSLFPictureShape; import org.apache.poi.hslf.model.HSLFShape; /** @@ -102,10 +102,10 @@ public final class PICT extends Metafile { } /** - * @see org.apache.poi.hslf.model.Picture#PICT + * @see org.apache.poi.hslf.model.HSLFPictureShape#PICT */ public int getType(){ - return Picture.PICT; + return HSLFPictureShape.PICT; } /** @@ -117,4 +117,8 @@ public final class PICT extends Metafile { return 0x5430; } + public String getContentType() { + return "image/x-pict"; + } + } diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java b/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java index 12b98f1802..a1d9aa50a9 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/PNG.java @@ -17,14 +17,8 @@ package org.apache.poi.hslf.blip; +import org.apache.poi.hslf.model.HSLFPictureShape; import org.apache.poi.util.PngUtils; -import org.apache.poi.hslf.model.Picture; -import org.apache.poi.hslf.exceptions.HSLFException; - -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.IOException; /** * Represents a PNG picture data in a PPT file @@ -52,10 +46,10 @@ public final class PNG extends Bitmap { /** * @return type of this picture - * @see org.apache.poi.hslf.model.Picture#PNG + * @see org.apache.poi.hslf.model.HSLFPictureShape#PNG */ public int getType(){ - return Picture.PNG; + return HSLFPictureShape.PNG; } /** @@ -66,4 +60,8 @@ public final class PNG extends Bitmap { public int getSignature(){ return 0x6E00; } + + public String getContentType() { + return "image/png"; + } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java b/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java index 76f680eafd..3270b32596 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java +++ b/src/scratchpad/src/org/apache/poi/hslf/blip/WMF.java @@ -19,7 +19,7 @@ package org.apache.poi.hslf.blip; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.POILogger; -import org.apache.poi.hslf.model.Picture; +import org.apache.poi.hslf.model.HSLFPictureShape; import org.apache.poi.hslf.model.HSLFShape; import org.apache.poi.hslf.exceptions.HSLFException; @@ -95,7 +95,7 @@ public final class WMF extends Metafile { * We are of type Picture.WMF */ public int getType(){ - return Picture.WMF; + return HSLFPictureShape.WMF; } /** @@ -188,4 +188,9 @@ public final class WMF extends Metafile { } } + + public String getContentType() { + return "image/x-wmf"; + } + } diff --git a/src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java b/src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java index f46906f73c..e437f9504e 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java +++ b/src/scratchpad/src/org/apache/poi/hslf/dev/PPDrawingTextListing.java @@ -18,6 +18,7 @@ package org.apache.poi.hslf.dev; import org.apache.poi.hslf.*; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.*; @@ -33,7 +34,7 @@ public final class PPDrawingTextListing { System.exit(1); } - HSLFSlideShow ss = new HSLFSlideShow(args[0]); + HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]); // Find PPDrawings at any second level position Record[] records = ss.getRecords(); diff --git a/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java b/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java index 490e3e2055..d0ab5ec98f 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java +++ b/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTListing.java @@ -17,7 +17,7 @@ package org.apache.poi.hslf.dev; -import org.apache.poi.hslf.HSLFSlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.Document; import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.RecordTypes; @@ -35,7 +35,7 @@ public final class SLWTListing { System.exit(1); } - HSLFSlideShow ss = new HSLFSlideShow(args[0]); + HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]); // Find the documents, and then their SLWT Record[] records = ss.getRecords(); diff --git a/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java b/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java index 16858aa3db..fc9b224801 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java +++ b/src/scratchpad/src/org/apache/poi/hslf/dev/SLWTTextListing.java @@ -18,6 +18,7 @@ package org.apache.poi.hslf.dev; import org.apache.poi.hslf.*; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.*; /** @@ -32,7 +33,7 @@ public final class SLWTTextListing { System.exit(1); } - HSLFSlideShow ss = new HSLFSlideShow(args[0]); + HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]); // Find the documents, and then their SLWT Record[] records = ss.getRecords(); diff --git a/src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java b/src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java index 2dd32a4af0..2a69c17d81 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java +++ b/src/scratchpad/src/org/apache/poi/hslf/dev/SlideAndNotesAtomListing.java @@ -18,6 +18,7 @@ package org.apache.poi.hslf.dev; import org.apache.poi.hslf.*; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.*; @@ -34,7 +35,7 @@ public final class SlideAndNotesAtomListing { System.exit(1); } - HSLFSlideShow ss = new HSLFSlideShow(args[0]); + HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]); System.out.println(""); // Find either Slides or Notes diff --git a/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java b/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java index 010f424c33..b4f487ab8a 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java +++ b/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java @@ -20,7 +20,7 @@ package org.apache.poi.hslf.dev; import java.io.ByteArrayOutputStream; import java.util.Map; -import org.apache.poi.hslf.HSLFSlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.Document; import org.apache.poi.hslf.record.Notes; import org.apache.poi.hslf.record.NotesAtom; @@ -31,7 +31,7 @@ import org.apache.poi.hslf.record.Slide; import org.apache.poi.hslf.record.SlideAtom; import org.apache.poi.hslf.record.SlideListWithText; import org.apache.poi.hslf.record.SlidePersistAtom; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.util.LittleEndian; /** @@ -50,8 +50,8 @@ public final class SlideIdListing { // Create the slideshow object, for normal working with - HSLFSlideShow hss = new HSLFSlideShow(args[0]); - SlideShow ss = new SlideShow(hss); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(args[0]); + HSLFSlideShow ss = new HSLFSlideShow(hss); // Grab the base contents fileContents = hss.getUnderlyingBytes(); diff --git a/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowRecordDumper.java b/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowRecordDumper.java index f2e7b36dc2..77415ff2dc 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowRecordDumper.java +++ b/src/scratchpad/src/org/apache/poi/hslf/dev/SlideShowRecordDumper.java @@ -19,10 +19,9 @@ package org.apache.poi.hslf.dev; import java.io.ByteArrayOutputStream; import java.io.IOException; - import java.util.Iterator; -import org.apache.poi.hslf.HSLFSlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.Record; import org.apache.poi.util.HexDump; import org.apache.poi.ddf.DefaultEscherRecordFactory; @@ -44,7 +43,7 @@ import org.apache.poi.hslf.record.StyleTextPropAtom; public final class SlideShowRecordDumper { private boolean optVerbose; private boolean optEscher; - private HSLFSlideShow doc; + private HSLFSlideShowImpl doc; /** * right now this function takes one parameter: a ppt file, and outputs @@ -103,7 +102,7 @@ public final class SlideShowRecordDumper { { optVerbose = verbose; optEscher = escher; - doc = new HSLFSlideShow(fileName); + doc = new HSLFSlideShowImpl(fileName); } diff --git a/src/scratchpad/src/org/apache/poi/hslf/dev/TextStyleListing.java b/src/scratchpad/src/org/apache/poi/hslf/dev/TextStyleListing.java index a919f61cdd..d7fcbc6fd1 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/dev/TextStyleListing.java +++ b/src/scratchpad/src/org/apache/poi/hslf/dev/TextStyleListing.java @@ -18,6 +18,7 @@ package org.apache.poi.hslf.dev; import org.apache.poi.hslf.*; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.model.textproperties.BitMaskTextProp; import org.apache.poi.hslf.model.textproperties.TextProp; import org.apache.poi.hslf.model.textproperties.TextPropCollection; @@ -36,7 +37,7 @@ public final class TextStyleListing { System.exit(1); } - HSLFSlideShow ss = new HSLFSlideShow(args[0]); + HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]); // Find the documents, and then their SLWT Record[] records = ss.getRecords(); diff --git a/src/scratchpad/src/org/apache/poi/hslf/dev/UserEditAndPersistListing.java b/src/scratchpad/src/org/apache/poi/hslf/dev/UserEditAndPersistListing.java index 749cfa9484..c7c8057171 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/dev/UserEditAndPersistListing.java +++ b/src/scratchpad/src/org/apache/poi/hslf/dev/UserEditAndPersistListing.java @@ -20,7 +20,7 @@ package org.apache.poi.hslf.dev; import java.io.ByteArrayOutputStream; import java.util.Map; -import org.apache.poi.hslf.HSLFSlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.CurrentUserAtom; import org.apache.poi.hslf.record.PersistPtrHolder; import org.apache.poi.hslf.record.PositionDependentRecord; @@ -44,7 +44,7 @@ public final class UserEditAndPersistListing { // Create the slideshow object, for normal working with - HSLFSlideShow ss = new HSLFSlideShow(args[0]); + HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]); fileContents = ss.getUnderlyingBytes(); System.out.println(""); diff --git a/src/scratchpad/src/org/apache/poi/hslf/extractor/ImageExtractor.java b/src/scratchpad/src/org/apache/poi/hslf/extractor/ImageExtractor.java index 24d6d9096e..268eb3b2fb 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/extractor/ImageExtractor.java +++ b/src/scratchpad/src/org/apache/poi/hslf/extractor/ImageExtractor.java @@ -17,10 +17,10 @@ package org.apache.poi.hslf.extractor; -import org.apache.poi.hslf.usermodel.SlideShow; -import org.apache.poi.hslf.usermodel.PictureData; -import org.apache.poi.hslf.HSLFSlideShow; -import org.apache.poi.hslf.model.Picture; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; +import org.apache.poi.hslf.usermodel.HSLFPictureData; +import org.apache.poi.hslf.model.HSLFPictureShape; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import java.io.IOException; import java.io.FileOutputStream; @@ -37,12 +37,12 @@ public final class ImageExtractor { System.err.println("\tImageExtractor "); return; } - SlideShow ppt = new SlideShow(new HSLFSlideShow(args[0])); + HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl(args[0])); //extract all pictures contained in the presentation - PictureData[] pdata = ppt.getPictureData(); + HSLFPictureData[] pdata = ppt.getPictureData(); for (int i = 0; i < pdata.length; i++) { - PictureData pict = pdata[i]; + HSLFPictureData pict = pdata[i]; // picture data byte[] data = pict.getData(); @@ -50,22 +50,22 @@ public final class ImageExtractor { int type = pict.getType(); String ext; switch (type) { - case Picture.JPEG: + case HSLFPictureShape.JPEG: ext = ".jpg"; break; - case Picture.PNG: + case HSLFPictureShape.PNG: ext = ".png"; break; - case Picture.WMF: + case HSLFPictureShape.WMF: ext = ".wmf"; break; - case Picture.EMF: + case HSLFPictureShape.EMF: ext = ".emf"; break; - case Picture.PICT: + case HSLFPictureShape.PICT: ext = ".pict"; break; - case Picture.DIB: + case HSLFPictureShape.DIB: ext = ".dib"; break; default: diff --git a/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java b/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java index e870e5d0f8..621d2b6fcd 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java +++ b/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java @@ -25,9 +25,8 @@ import java.util.List; import java.util.ArrayList; import org.apache.poi.POIOLE2TextExtractor; -import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.model.*; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; @@ -39,9 +38,9 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; * @author Nick Burch */ public final class PowerPointExtractor extends POIOLE2TextExtractor { - private HSLFSlideShow _hslfshow; - private SlideShow _show; - private Slide[] _slides; + private HSLFSlideShowImpl _hslfshow; + private HSLFSlideShow _show; + private HSLFSlide[] _slides; private boolean _slidesByDefault = true; private boolean _notesByDefault = false; @@ -120,7 +119,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor { * @param dir the POIFS Directory containing the PowerPoint document */ public PowerPointExtractor(DirectoryNode dir) throws IOException { - this(new HSLFSlideShow(dir)); + this(new HSLFSlideShowImpl(dir)); } /** @@ -128,7 +127,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor { */ @Deprecated public PowerPointExtractor(DirectoryNode dir, POIFSFileSystem fs) throws IOException { - this(new HSLFSlideShow(dir, fs)); + this(new HSLFSlideShowImpl(dir, fs)); } /** @@ -136,10 +135,10 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor { * * @param ss the HSLFSlideShow to extract text from */ - public PowerPointExtractor(HSLFSlideShow ss) { + public PowerPointExtractor(HSLFSlideShowImpl ss) { super(ss); _hslfshow = ss; - _show = new SlideShow(_hslfshow); + _show = new HSLFSlideShow(_hslfshow); _slides = _show.getSlides(); } @@ -190,7 +189,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor { List list = new ArrayList(); for (int i = 0; i < _slides.length; i++) { - Slide slide = _slides[i]; + HSLFSlide slide = _slides[i]; HSLFShape[] shapes = slide.getShapes(); for (int j = 0; j < shapes.length; j++) { @@ -222,14 +221,14 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor { if (getMasterText) { for (SlideMaster master : _show.getSlidesMasters()) { for(HSLFShape sh : master.getShapes()){ - if(sh instanceof TextShape){ - if(MasterSheet.isPlaceholder(sh)) { + if(sh instanceof HSLFTextShape){ + if(HSLFMasterSheet.isPlaceholder(sh)) { // don't bother about boiler // plate text on master // sheets continue; } - TextShape tsh = (TextShape)sh; + HSLFTextShape tsh = (HSLFTextShape)sh; String text = tsh.getText(); if (text != null){ ret.append(text); @@ -243,7 +242,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor { } for (int i = 0; i < _slides.length; i++) { - Slide slide = _slides[i]; + HSLFSlide slide = _slides[i]; // Slide header, if set HeadersFooters hf = slide.getHeadersFooters(); @@ -286,7 +285,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor { HeadersFooters hf = _show.getNotesHeadersFooters(); for (int i = 0; i < _slides.length; i++) { - Notes notes = _slides[i].getNotesSheet(); + HSLFNotes notes = _slides[i].getNotesSheet(); if (notes == null) { continue; } @@ -331,13 +330,13 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor { ret.append('\n'); } } - private void textRunsToText(StringBuffer ret, TextRun[] runs) { + private void textRunsToText(StringBuffer ret, HSLFTextParagraph[] runs) { if (runs==null) { return; } for (int j = 0; j < runs.length; j++) { - TextRun run = runs[j]; + HSLFTextParagraph run = runs[j]; if (run != null) { String text = run.getText(); ret.append(text); diff --git a/src/scratchpad/src/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java b/src/scratchpad/src/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java index e449a555e8..9c92c5c591 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java +++ b/src/scratchpad/src/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java @@ -23,7 +23,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; -import org.apache.poi.hslf.model.TextRun; +import org.apache.poi.hslf.model.HSLFTextParagraph; import org.apache.poi.hslf.record.CString; import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.RecordTypes; @@ -175,17 +175,17 @@ public final class QuickButCruddyTextExtractor { // Otherwise, check the type to see if it's text long type = LittleEndian.getUShort(pptContents,startPos+2); - TextRun trun = null; + HSLFTextParagraph trun = null; // TextBytesAtom if(type == RecordTypes.TextBytesAtom.typeID) { TextBytesAtom tba = (TextBytesAtom)Record.createRecordForType(type, pptContents, startPos, len+8); - trun = new TextRun((TextHeaderAtom)null,tba,(StyleTextPropAtom)null); + trun = new HSLFTextParagraph((TextHeaderAtom)null,tba,(StyleTextPropAtom)null); } // TextCharsAtom if(type == RecordTypes.TextCharsAtom.typeID) { TextCharsAtom tca = (TextCharsAtom)Record.createRecordForType(type, pptContents, startPos, len+8); - trun = new TextRun((TextHeaderAtom)null,tca,(StyleTextPropAtom)null); + trun = new HSLFTextParagraph((TextHeaderAtom)null,tca,(StyleTextPropAtom)null); } // CString (doesn't go via a TextRun) diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java index f1c90130db..95f83a3834 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java @@ -45,7 +45,7 @@ import org.apache.poi.util.StringUtil; * TODO: finish * @author Yegor Kozlov */ -public final class ActiveXShape extends Picture { +public final class ActiveXShape extends HSLFPictureShape { public static final int DEFAULT_ACTIVEX_THUMBNAIL = -1; /** @@ -108,7 +108,7 @@ public final class ActiveXShape extends Picture { /** * Assign a control to this shape * - * @see org.apache.poi.hslf.usermodel.SlideShow#addMovie(String, int) + * @see org.apache.poi.hslf.usermodel.HSLFSlideShow#addMovie(String, int) * @param idx the index of the movie */ public void setActiveXIndex(int idx){ @@ -164,7 +164,7 @@ public final class ActiveXShape extends Picture { return ctrl; } - protected void afterInsert(Sheet sheet){ + protected void afterInsert(HSLFSheet sheet){ ExControl ctrl = getExControl(); ctrl.getExControlAtom().setSlideId(sheet._getSheetNumber()); diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Background.java b/src/scratchpad/src/org/apache/poi/hslf/model/Background.java deleted file mode 100644 index 1b172bdb8f..0000000000 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Background.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.model; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Rectangle; -import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; - -import javax.imageio.ImageIO; - -import org.apache.poi.ddf.EscherContainerRecord; -import org.apache.poi.hslf.blip.Bitmap; -import org.apache.poi.hslf.usermodel.PictureData; -import org.apache.poi.sl.usermodel.ShapeContainer; -import org.apache.poi.util.POILogger; - -/** - * Background shape - * - * @author Yegor Kozlov - */ -public final class Background extends HSLFShape { - - protected Background(EscherContainerRecord escherRecord, ShapeContainer parent) { - super(escherRecord, parent); - } - - protected EscherContainerRecord createSpContainer(boolean isChild) { - return null; - } - - public void draw(Graphics2D graphics) { - Fill f = getFill(); - Dimension pg = getSheet().getSlideShow().getPageSize(); - Rectangle anchor = new Rectangle(0, 0, pg.width, pg.height); - switch (f.getFillType()) { - case Fill.FILL_SOLID: - Color color = f.getForegroundColor(); - graphics.setPaint(color); - graphics.fill(anchor); - break; - case Fill.FILL_PICTURE: - PictureData data = f.getPictureData(); - if (data instanceof Bitmap) { - BufferedImage img = null; - try { - img = ImageIO.read(new ByteArrayInputStream(data.getData())); - } catch (Exception e) { - logger.log(POILogger.WARN, "ImageIO failed to create image. image.type: " + data.getType()); - return; - } - Image scaledImg = img.getScaledInstance(anchor.width, anchor.height, Image.SCALE_SMOOTH); - graphics.drawImage(scaledImg, anchor.x, anchor.y, null); - - } - break; - default: - logger.log(POILogger.WARN, "unsuported fill type: " + f.getFillType()); - break; - } - } -} diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFAutoShape.java similarity index 86% rename from src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFAutoShape.java index 0cadd7c0d9..1f74f2ceb5 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/AutoShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFAutoShape.java @@ -18,11 +18,13 @@ package org.apache.poi.hslf.model; import org.apache.poi.ddf.*; -import org.apache.poi.sl.usermodel.ShapeContainer; -import org.apache.poi.sl.usermodel.ShapeType; +import org.apache.poi.sl.draw.geom.CustomGeometry; +import org.apache.poi.sl.draw.geom.Guide; +import org.apache.poi.sl.usermodel.*; import org.apache.poi.util.POILogger; import java.awt.geom.Rectangle2D; +import java.util.Iterator; /** * Represents an AutoShape. @@ -33,18 +35,18 @@ import java.awt.geom.Rectangle2D; * * @author Yegor Kozlov */ -public class AutoShape extends TextShape { +public class HSLFAutoShape extends HSLFTextShape implements AutoShape { - protected AutoShape(EscherContainerRecord escherRecord, ShapeContainer parent){ + protected HSLFAutoShape(EscherContainerRecord escherRecord, ShapeContainer parent){ super(escherRecord, parent); } - public AutoShape(ShapeType type, ShapeContainer parent){ + public HSLFAutoShape(ShapeType type, ShapeContainer parent){ super(null, parent); _escherContainer = createSpContainer(type, parent instanceof HSLFGroupShape); } - public AutoShape(ShapeType type){ + public HSLFAutoShape(ShapeType type){ this(type, null); } @@ -66,10 +68,10 @@ public class AutoShape extends TextShape { return _escherContainer; } - protected void setDefaultTextProperties(TextRun _txtrun){ - setVerticalAlignment(TextBox.AnchorMiddle); - setHorizontalAlignment(TextBox.AlignCenter); - setWordWrap(TextBox.WrapNone); + protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){ + setVerticalAlignment(HSLFTextBox.AnchorMiddle); + setHorizontalAlignment(HSLFTextBox.AlignCenter); + setWordWrap(HSLFTextBox.WrapNone); } /** @@ -118,5 +120,4 @@ public class AutoShape extends TextShape { java.awt.Shape shape = outline.getOutline(this); return AutoShapes.transform(shape, anchor); } - } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/HSLFBackground.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFBackground.java new file mode 100644 index 0000000000..8d581f5f35 --- /dev/null +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFBackground.java @@ -0,0 +1,38 @@ +/* ==================================================================== + 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.model; + +import org.apache.poi.ddf.EscherContainerRecord; +import org.apache.poi.sl.usermodel.Background; +import org.apache.poi.sl.usermodel.ShapeContainer; + +/** + * Background shape + * + * @author Yegor Kozlov + */ +public final class HSLFBackground extends HSLFShape implements Background { + + protected HSLFBackground(EscherContainerRecord escherRecord, ShapeContainer parent) { + super(escherRecord, parent); + } + + protected EscherContainerRecord createSpContainer(boolean isChild) { + return null; + } +} diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFFill.java similarity index 75% rename from src/scratchpad/src/org/apache/poi/hslf/model/Fill.java rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFFill.java index a394cac474..14846e1ea0 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFFill.java @@ -18,17 +18,17 @@ package org.apache.poi.hslf.model; import java.awt.Color; +import java.io.ByteArrayInputStream; +import java.io.InputStream; import java.util.List; -import org.apache.poi.ddf.EscherBSERecord; -import org.apache.poi.ddf.EscherContainerRecord; -import org.apache.poi.ddf.EscherOptRecord; -import org.apache.poi.ddf.EscherProperties; -import org.apache.poi.ddf.EscherRecord; -import org.apache.poi.ddf.EscherSimpleProperty; +import org.apache.poi.ddf.*; import org.apache.poi.hslf.record.Document; -import org.apache.poi.hslf.usermodel.PictureData; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFPictureData; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; +import org.apache.poi.sl.usermodel.*; +import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint; +import org.apache.poi.sl.usermodel.PaintStyle.TexturePaint; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; @@ -37,7 +37,7 @@ import org.apache.poi.util.POILogger; * * @author Yegor Kozlov */ -public final class Fill { +public final class HSLFFill { // For logging protected POILogger logger = POILogFactory.getLogger(this.getClass()); @@ -106,10 +106,55 @@ public final class Fill { * * @param shape the shape this background applies to */ - public Fill(HSLFShape shape){ + public HSLFFill(HSLFShape shape){ this.shape = shape; } + + public FillStyle getFillStyle() { + return new FillStyle() { + public PaintStyle getPaint() { + switch (getFillType()) { + case FILL_SOLID: { + return new SolidPaint() { + public ColorStyle getSolidColor() { + return new ColorStyle() { + public Color getColor() { return getForegroundColor(); } + public int getAlpha() { return -1; } + public int getLumOff() { return -1; } + public int getLumMod() { return -1; } + public int getShade() { return -1; } + public int getTint() { return -1; } + }; + } + }; + } + case FILL_PICTURE: { + return new TexturePaint() { + final HSLFPictureData pd = getPictureData(); + + public InputStream getImageData() { + return new ByteArrayInputStream(pd.getData()); + } + + public String getContentType() { + return pd.getContentType(); + } + + public int getAlpha() { + return (int)(shape.getAlpha(EscherProperties.FILL__FILLOPACITY)*100000.0); + } + }; + } + default: + logger.log(POILogger.WARN, "unsuported fill type: " + getFillType()); + break; + } + return PaintStyle.TRANSPARENT_PAINT; + } + }; + } + /** * Returns fill type. * Must be one of the FILL_* constants defined in this class. @@ -124,7 +169,7 @@ public final class Fill { /** */ - protected void afterInsert(Sheet sh){ + protected void afterInsert(HSLFSheet sh){ EscherOptRecord opt = shape.getEscherOptRecord(); EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE); if(p != null) { @@ -135,12 +180,12 @@ public final class Fill { } protected EscherBSERecord getEscherBSERecord(int idx){ - Sheet sheet = shape.getSheet(); + HSLFSheet sheet = shape.getSheet(); if(sheet == null) { logger.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet"); return null; } - SlideShow ppt = sheet.getSlideShow(); + HSLFSlideShow ppt = sheet.getSlideShow(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); @@ -220,13 +265,13 @@ public final class Fill { /** * PictureData object used in a texture, pattern of picture fill. */ - public PictureData getPictureData(){ + public HSLFPictureData getPictureData(){ EscherOptRecord opt = shape.getEscherOptRecord(); EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE); if (p == null) return null; - SlideShow ppt = shape.getSheet().getSlideShow(); - PictureData[] pict = ppt.getPictureData(); + HSLFSlideShow ppt = shape.getSheet().getSlideShow(); + HSLFPictureData[] pict = ppt.getPictureData(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFFreeformShape.java similarity index 97% rename from src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFFreeformShape.java index 6bf232af46..685e2dad2f 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFFreeformShape.java @@ -45,7 +45,7 @@ import org.apache.poi.util.POILogger; *

* @author Yegor Kozlov */ -public final class Freeform extends AutoShape { +public final class HSLFFreeformShape extends HSLFAutoShape { public static final byte[] SEGMENTINFO_MOVETO = new byte[]{0x00, 0x40}; public static final byte[] SEGMENTINFO_LINETO = new byte[]{0x00, (byte)0xAC}; @@ -62,7 +62,7 @@ public final class Freeform extends AutoShape { * @param escherRecord EscherSpContainer container which holds information about this shape * @param parent the parent of the shape */ - protected Freeform(EscherContainerRecord escherRecord, ShapeContainer parent){ + protected HSLFFreeformShape(EscherContainerRecord escherRecord, ShapeContainer parent){ super(escherRecord, parent); } @@ -73,7 +73,7 @@ public final class Freeform extends AutoShape { * @param parent the parent of this Shape. For example, if this text box is a cell * in a table then the parent is Table. */ - public Freeform(ShapeContainer parent){ + public HSLFFreeformShape(ShapeContainer parent){ super((EscherContainerRecord)null, parent); _escherContainer = createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof HSLFGroupShape); } @@ -82,7 +82,7 @@ public final class Freeform extends AutoShape { * Create a new Freeform. This constructor is used when a new shape is created. * */ - public Freeform(){ + public HSLFFreeformShape(){ this(null); } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/HSLFGroupShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFGroupShape.java index 336f11743a..64d4de28b4 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/HSLFGroupShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFGroupShape.java @@ -177,7 +177,7 @@ public class HSLFGroupShape extends HSLFShape implements ShapeContainer { + public HSLFMasterSheet(SheetContainer container, int sheetNo){ super(container, sheetNo); } @@ -47,9 +49,9 @@ public abstract class MasterSheet extends Sheet { * @return true if the shape is a placeholder */ public static boolean isPlaceholder(HSLFShape shape){ - if(!(shape instanceof TextShape)) return false; + if(!(shape instanceof HSLFTextShape)) return false; - TextShape tx = (TextShape)shape; + HSLFTextShape tx = (HSLFTextShape)shape; return tx.getPlaceholderAtom() != null; } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Notes.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFNotes.java similarity index 50% rename from src/scratchpad/src/org/apache/poi/hslf/model/Notes.java rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFNotes.java index cdb05030b4..2a7698d21c 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Notes.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFNotes.java @@ -17,6 +17,12 @@ package org.apache.poi.hslf.model; +import java.util.Arrays; +import java.util.List; + +import org.apache.poi.hslf.usermodel.HSLFSlideShow; +import org.apache.poi.sl.usermodel.Notes; + /** * This class represents a slide's notes in a PowerPoint Document. It * allows access to the text within, and the layout. For now, it only @@ -25,42 +31,45 @@ package org.apache.poi.hslf.model; * @author Nick Burch */ -public final class Notes extends Sheet -{ - private TextRun[] _runs; +public final class HSLFNotes extends HSLFSheet implements Notes { + private HSLFTextParagraph[] _runs; - /** - * Constructs a Notes Sheet from the given Notes record. - * Initialises TextRuns, to provide easier access to the text - * - * @param notes the Notes record to read from - */ - public Notes (org.apache.poi.hslf.record.Notes notes) { - super(notes, notes.getNotesAtom().getSlideID()); + /** + * Constructs a Notes Sheet from the given Notes record. + * Initialises TextRuns, to provide easier access to the text + * + * @param notes the Notes record to read from + */ + public HSLFNotes(org.apache.poi.hslf.record.Notes notes) { + super(notes, notes.getNotesAtom().getSlideID()); - // Now, build up TextRuns from pairs of TextHeaderAtom and - // one of TextBytesAtom or TextCharsAtom, found inside - // EscherTextboxWrapper's in the PPDrawing - _runs = findTextRuns(getPPDrawing()); + // Now, build up TextRuns from pairs of TextHeaderAtom and + // one of TextBytesAtom or TextCharsAtom, found inside + // EscherTextboxWrapper's in the PPDrawing + _runs = findTextRuns(getPPDrawing()); - // Set the sheet on each TextRun - for (int i = 0; i < _runs.length; i++) - _runs[i].setSheet(this); - } + // Set the sheet on each TextRun + for (HSLFTextParagraph tp : _runs) { + tp.supplySheet(this); + } + } + /** + * Returns an array of all the TextRuns found + */ + public HSLFTextParagraph[] getTextRuns() { + return _runs; + } - // Accesser methods follow - - /** - * Returns an array of all the TextRuns found - */ - public TextRun[] getTextRuns() { return _runs; } - + @Override + public List getTextParagraphs() { + return Arrays.asList(_runs); + } + /** * Return null - Notes Masters are not yet supported */ - public MasterSheet getMasterSheet() { + public HSLFMasterSheet getMasterSheet() { return null; } - } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFPictureShape.java similarity index 93% rename from src/scratchpad/src/org/apache/poi/hslf/model/Picture.java rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFPictureShape.java index 8c3b2b6399..e6b72a60fb 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFPictureShape.java @@ -37,8 +37,8 @@ import org.apache.poi.ddf.EscherSimpleProperty; import org.apache.poi.ddf.EscherSpRecord; import org.apache.poi.hslf.blip.Bitmap; import org.apache.poi.hslf.record.Document; -import org.apache.poi.hslf.usermodel.PictureData; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFPictureData; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.sl.usermodel.ShapeContainer; import org.apache.poi.sl.usermodel.ShapeType; import org.apache.poi.util.POILogger; @@ -51,7 +51,7 @@ import org.apache.poi.util.Units; * * @author Yegor Kozlov */ -public class Picture extends SimpleShape { +public class HSLFPictureShape extends HSLFSimpleShape { /** * Windows Enhanced Metafile (EMF) @@ -88,7 +88,7 @@ public class Picture extends SimpleShape { * * @param idx the index of the picture */ - public Picture(int idx){ + public HSLFPictureShape(int idx){ this(idx, null); } @@ -98,7 +98,7 @@ public class Picture extends SimpleShape { * @param idx the index of the picture * @param parent the parent shape */ - public Picture(int idx, ShapeContainer parent) { + public HSLFPictureShape(int idx, ShapeContainer parent) { super(null, parent); _escherContainer = createSpContainer(idx, parent instanceof HSLFGroupShape); } @@ -110,7 +110,7 @@ public class Picture extends SimpleShape { * this picture in the Slide * @param parent the parent shape of this picture */ - protected Picture(EscherContainerRecord escherRecord, ShapeContainer parent){ + protected HSLFPictureShape(EscherContainerRecord escherRecord, ShapeContainer parent){ super(escherRecord, parent); } @@ -156,7 +156,7 @@ public class Picture extends SimpleShape { * for other types sets the default size of 200x200 pixels. */ public void setDefaultSize(){ - PictureData pict = getPictureData(); + HSLFPictureData pict = getPictureData(); if (pict instanceof Bitmap){ BufferedImage img = null; try { @@ -183,9 +183,9 @@ public class Picture extends SimpleShape { * * @return the picture data for this picture. */ - public PictureData getPictureData(){ - SlideShow ppt = getSheet().getSlideShow(); - PictureData[] pict = ppt.getPictureData(); + public HSLFPictureData getPictureData(){ + HSLFSlideShow ppt = getSheet().getSlideShow(); + HSLFPictureData[] pict = ppt.getPictureData(); EscherBSERecord bse = getEscherBSERecord(); if (bse == null){ @@ -202,7 +202,7 @@ public class Picture extends SimpleShape { } protected EscherBSERecord getEscherBSERecord(){ - SlideShow ppt = getSheet().getSlideShow(); + HSLFSlideShow ppt = getSheet().getSlideShow(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); @@ -247,7 +247,7 @@ public class Picture extends SimpleShape { /** * By default set the orininal image size */ - protected void afterInsert(Sheet sh){ + protected void afterInsert(HSLFSheet sh){ super.afterInsert(sh); EscherBSERecord bse = getEscherBSERecord(); @@ -263,7 +263,7 @@ public class Picture extends SimpleShape { AffineTransform at = graphics.getTransform(); ShapePainter.paint(this, graphics); - PictureData data = getPictureData(); + HSLFPictureData data = getPictureData(); if(data != null) data.draw(graphics, this); graphics.setTransform(at); diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/HSLFShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFShape.java index c673cae2de..4e2229982e 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/HSLFShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFShape.java @@ -17,17 +17,15 @@ package org.apache.poi.hslf.model; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.util.Iterator; + import org.apache.poi.ddf.*; import org.apache.poi.hslf.record.ColorSchemeAtom; -import org.apache.poi.sl.usermodel.ShapeContainer; -import org.apache.poi.sl.usermodel.ShapeType; -import org.apache.poi.util.POILogger; -import org.apache.poi.util.POILogFactory; -import org.apache.poi.util.Units; - -import java.util.*; -import java.awt.*; -import java.awt.geom.Rectangle2D; +import org.apache.poi.sl.usermodel.*; +import org.apache.poi.util.*; /** *

@@ -45,7 +43,7 @@ import java.awt.geom.Rectangle2D; * * @author Yegor Kozlov */ -public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape { +public abstract class HSLFShape implements Shape { // For logging protected POILogger logger = POILogFactory.getLogger(this.getClass()); @@ -90,12 +88,12 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.ShapeSheet this shape belongs to */ - protected Sheet _sheet; + protected HSLFSheet _sheet; /** * Fill */ - protected Fill _fill; + protected HSLFFill _fill; /** * Create a Shape object. This constructor is used when an existing Shape is read from from a PowerPoint document. @@ -336,7 +334,7 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.ShapeSlideShow this shape belongs to */ - public Sheet getSheet(){ + public HSLFSheet getSheet(){ return _sheet; } @@ -354,7 +352,7 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape> 24) & 0xFF; int b = (val >> 16) & 0xFF; @@ -446,11 +449,16 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape { - private static POILogger logger = POILogFactory.getLogger(Sheet.class); +public abstract class HSLFSheet implements Sheet { + private static POILogger logger = POILogFactory.getLogger(HSLFSheet.class); /** * The SlideShow we belong to */ - private SlideShow _slideShow; + private HSLFSlideShow _slideShow; /** * Sheet background */ - private Background _background; + private HSLFBackground _background; /** * Record container that holds sheet data. @@ -80,7 +58,7 @@ public abstract class Sheet implements ShapeContainer { private int _sheetNo; - public Sheet(SheetContainer container, int sheetNo) { + public HSLFSheet(SheetContainer container, int sheetNo) { _container = container; _sheetNo = sheetNo; } @@ -88,7 +66,7 @@ public abstract class Sheet implements ShapeContainer { /** * Returns an array of all the TextRuns in the sheet. */ - public abstract TextRun[] getTextRuns(); + public abstract HSLFTextParagraph[] getTextRuns(); /** * Returns the (internal, RefID based) sheet number, as used @@ -116,7 +94,7 @@ public abstract class Sheet implements ShapeContainer { /** * Fetch the SlideShow we're attached to */ - public SlideShow getSlideShow() { + public HSLFSlideShow getSlideShow() { return _slideShow; } @@ -131,13 +109,12 @@ public abstract class Sheet implements ShapeContainer { * Set the SlideShow we're attached to. * Also passes it on to our child RichTextRuns */ - public void setSlideShow(SlideShow ss) { + public void setSlideShow(HSLFSlideShow ss) { _slideShow = ss; - TextRun[] trs = getTextRuns(); - if (trs != null) { - for (int i = 0; i < trs.length; i++) { - trs[i].supplySlideShow(_slideShow); - } + HSLFTextParagraph[] trs = getTextRuns(); + if (trs == null) return; + for (HSLFTextParagraph tp : trs) { + tp.supplySheet(this); } } @@ -145,8 +122,8 @@ public abstract class Sheet implements ShapeContainer { /** * For a given PPDrawing, grab all the TextRuns */ - public static TextRun[] findTextRuns(PPDrawing ppdrawing) { - final List runsV = new ArrayList(); + public static HSLFTextParagraph[] findTextRuns(PPDrawing ppdrawing) { + final List runsV = new ArrayList(); final EscherTextboxWrapper[] wrappers = ppdrawing.getTextboxWrappers(); for (int i = 0; i < wrappers.length; i++) { int s1 = runsV.size(); @@ -156,11 +133,11 @@ public abstract class Sheet implements ShapeContainer { findTextRuns(wrappers[i], runsV); int s2 = runsV.size(); if (s2 != s1){ - TextRun t = runsV.get(runsV.size()-1); + HSLFTextParagraph t = runsV.get(runsV.size()-1); t.setShapeId(wrappers[i].getShapeId()); } } - return runsV.toArray(new TextRun[runsV.size()]); + return runsV.toArray(new HSLFTextParagraph[runsV.size()]); } /** * Scans through the supplied record array, looking for @@ -170,7 +147,7 @@ public abstract class Sheet implements ShapeContainer { * @param records the records to build from * @param found vector to add any found to */ - protected static void findTextRuns(final Record[] records, final List found) { + protected static void findTextParagraphs(final Record[] records, final List found) { findTextRuns(records, found, null); } /** @@ -181,7 +158,7 @@ public abstract class Sheet implements ShapeContainer { * @param wrapper an EscherTextboxWrapper * @param found vector to add any found to */ - protected static void findTextRuns(final EscherTextboxWrapper wrapper, final List found) { + protected static void findTextRuns(final EscherTextboxWrapper wrapper, final List found) { findTextRuns(wrapper.getChildRecords(), found, wrapper.getStyleTextProp9Atom()); } /** @@ -193,12 +170,12 @@ public abstract class Sheet implements ShapeContainer { * @param found vector to add any found to * @param styleTextProp9Atom a StyleTextProp9Atom with numbered lists info */ - protected static void findTextRuns(final Record[] records, final List found, final StyleTextProp9Atom styleTextProp9Atom) { + protected static void findTextRuns(final Record[] records, final List found, final StyleTextProp9Atom styleTextProp9Atom) { for (int i = 0, slwtIndex=0; i < (records.length - 1); i++) { if (records[i] instanceof TextHeaderAtom) { TextHeaderAtom tha = (TextHeaderAtom) records[i]; StyleTextPropAtom stpa = null; - TextRun trun = null; + HSLFTextParagraph trun = null; Record next = null; Record subs = null; @@ -231,10 +208,10 @@ public abstract class Sheet implements ShapeContainer { // Now, check if the next record is one to record if (next instanceof TextCharsAtom) { TextCharsAtom tca = (TextCharsAtom)next; - trun = new TextRun(tha, tca, stpa); + trun = new HSLFTextParagraph(tha, tca, stpa); } else if (next instanceof TextBytesAtom) { TextBytesAtom tba = (TextBytesAtom)next; - trun = new TextRun(tha, tba, stpa); + trun = new HSLFTextParagraph(tha, tba, stpa); } else if (next instanceof StyleTextPropAtom) { stpa = (StyleTextPropAtom)next; } else if (next instanceof TextHeaderAtom) { @@ -372,7 +349,7 @@ public abstract class Sheet implements ShapeContainer { /** * Return the master sheet . */ - public abstract MasterSheet getMasterSheet(); + public abstract HSLFMasterSheet getMasterSheet(); /** * Color scheme for this sheet. @@ -386,7 +363,7 @@ public abstract class Sheet implements ShapeContainer { * * @return the background shape for this sheet. */ - public Background getBackground() { + public HSLFBackground getBackground() { if (_background == null) { PPDrawing ppdrawing = getPPDrawing(); @@ -400,7 +377,7 @@ public abstract class Sheet implements ShapeContainer { break; } } - _background = new Background(spContainer, null); + _background = new HSLFBackground(spContainer, null); _background.setSheet(this); } return _background; @@ -416,7 +393,7 @@ public abstract class Sheet implements ShapeContainer { * * @param shape */ - protected void onAddTextShape(TextShape shape) { + protected void onAddTextShape(HSLFTextShape shape) { } @@ -426,12 +403,12 @@ public abstract class Sheet implements ShapeContainer { * @param type type of text, See {@link org.apache.poi.hslf.record.TextHeaderAtom} * @return TextShape or null */ - public TextShape getPlaceholderByTextType(int type){ + public HSLFTextShape getPlaceholderByTextType(int type){ HSLFShape[] shape = getShapes(); for (int i = 0; i < shape.length; i++) { - if(shape[i] instanceof TextShape){ - TextShape tx = (TextShape)shape[i]; - TextRun run = tx.getTextRun(); + if(shape[i] instanceof HSLFTextShape){ + HSLFTextShape tx = (HSLFTextShape)shape[i]; + HSLFTextParagraph run = tx.getTextParagraph(); if(run != null && run.getRunType() == type){ return tx; } @@ -446,11 +423,11 @@ public abstract class Sheet implements ShapeContainer { * @param type type of placeholder to search. See {@link org.apache.poi.hslf.record.OEPlaceholderAtom} * @return TextShape or null */ - public TextShape getPlaceholder(int type){ + public HSLFTextShape getPlaceholder(int type){ HSLFShape[] shape = getShapes(); for (int i = 0; i < shape.length; i++) { - if(shape[i] instanceof TextShape){ - TextShape tx = (TextShape)shape[i]; + if(shape[i] instanceof HSLFTextShape){ + HSLFTextShape tx = (HSLFTextShape)shape[i]; int placeholderId = 0; OEPlaceholderAtom oep = tx.getPlaceholderAtom(); if(oep != null) { @@ -540,4 +517,14 @@ public abstract class Sheet implements ShapeContainer { return shapeList; } + /** + * @return whether shapes on the master sheet should be shown. By default master graphics is turned off. + * Sheets that support the notion of master (slide, slideLayout) should override it and + * check this setting + */ + public boolean getFollowMasterGraphics() { + return false; + } + + } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSimpleShape.java similarity index 89% rename from src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFSimpleShape.java index bfe6a1d95a..71c3c34d77 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSimpleShape.java @@ -38,8 +38,10 @@ import org.apache.poi.hslf.exceptions.HSLFException; 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.sl.usermodel.ShapeContainer; +import org.apache.poi.sl.usermodel.*; +import org.apache.poi.sl.usermodel.StrokeStyle.*; import org.apache.poi.util.LittleEndian; +import org.apache.poi.util.Units; /** * An abstract simple (non-group) shape. @@ -47,7 +49,7 @@ import org.apache.poi.util.LittleEndian; * * @author Yegor Kozlov */ -public abstract class SimpleShape extends HSLFShape { +public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape { public final static double DEFAULT_LINE_WIDTH = 0.75; @@ -63,7 +65,7 @@ public abstract class SimpleShape extends HSLFShape { * @param escherRecord EscherSpContainer container which holds information about this shape * @param parent the parent of the shape */ - protected SimpleShape(EscherContainerRecord escherRecord, ShapeContainer parent){ + protected HSLFSimpleShape(EscherContainerRecord escherRecord, ShapeContainer parent){ super(escherRecord, parent); } @@ -112,7 +114,7 @@ public abstract class SimpleShape extends HSLFShape { public double getLineWidth(){ EscherOptRecord opt = getEscherOptRecord(); EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH); - double width = prop == null ? DEFAULT_LINE_WIDTH : (double)prop.getPropertyValue()/EMU_PER_POINT; + double width = (prop == null) ? DEFAULT_LINE_WIDTH : Units.toPoints(prop.getPropertyValue()); return width; } @@ -122,7 +124,7 @@ public abstract class SimpleShape extends HSLFShape { */ public void setLineWidth(double width){ EscherOptRecord opt = getEscherOptRecord(); - setEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH, (int)(width*EMU_PER_POINT)); + setEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH, Units.toEMU(width)); } /** @@ -155,36 +157,45 @@ public abstract class SimpleShape extends HSLFShape { } /** - * Gets line dashing. One of the PEN_* constants defined in this class. + * Gets line dashing. * * @return dashing of the line. */ - public int getLineDashing(){ + public LineDash getLineDashing(){ EscherOptRecord opt = getEscherOptRecord(); - EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING); - return prop == null ? Line.PEN_SOLID : prop.getPropertyValue(); + return (prop == null) ? LineDash.SOLID : LineDash.fromNativeId(prop.getPropertyValue()); } /** - * Sets line dashing. One of the PEN_* constants defined in this class. + * Sets line dashing. * * @param pen new style of the line. */ - public void setLineDashing(int pen){ + public void setLineDashing(LineDash pen){ EscherOptRecord opt = getEscherOptRecord(); - - setEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING, pen == Line.PEN_SOLID ? -1 : pen); + setEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING, pen == LineDash.SOLID ? -1 : pen.nativeId); } /** - * Sets line style. One of the constants defined in this class. + * Gets the line compound style * - * @param style new style of the line. + * @return the compound style of the line. */ - public void setLineStyle(int style){ + public LineCompound getLineCompound() { EscherOptRecord opt = getEscherOptRecord(); - setEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE, style == Line.LINE_SIMPLE ? -1 : style); + EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE); + return (prop == null) ? LineCompound.SINGLE : LineCompound.fromNativeId(prop.getPropertyValue()); + } + + /** + * Sets the line compound style + * + * @param style new compound style of the line. + */ + public void setLineCompound(LineCompound style){ + EscherOptRecord opt = getEscherOptRecord(); + setEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE, style == LineCompound.SINGLE ? -1 : style.nativeId); } /** @@ -192,10 +203,29 @@ public abstract class SimpleShape extends HSLFShape { * * @return style of the line. */ - public int getStrokeStyle(){ - EscherOptRecord opt = getEscherOptRecord(); - EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE); - return prop == null ? Line.LINE_SIMPLE : prop.getPropertyValue(); + public StrokeStyle getStrokeStyle(){ + return new StrokeStyle() { + public PaintStyle getPaint() { + return null; + } + + public LineCap getLineCap() { + return null; + } + + public LineDash getLineDash() { + return null; + } + + public LineCompound getLineCompound() { + return null; + } + + public double getLineWidth() { + return 0; + } + + }; } /** diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlide.java similarity index 88% rename from src/scratchpad/src/org/apache/poi/hslf/model/Slide.java rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlide.java index 1db3173e6a..7030ce73e1 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlide.java @@ -37,7 +37,9 @@ import org.apache.poi.hslf.record.SlideAtom; import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet; import org.apache.poi.hslf.record.StyleTextProp9Atom; import org.apache.poi.hslf.record.TextHeaderAtom; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.sl.usermodel.ShapeType; +import org.apache.poi.sl.usermodel.Slide; /** * This class represents a slide in a PowerPoint Document. It allows @@ -48,11 +50,11 @@ import org.apache.poi.sl.usermodel.ShapeType; * @author Yegor Kozlov */ -public final class Slide extends Sheet { +public final class HSLFSlide extends HSLFSheet implements Slide { private int _slideNo; private SlideAtomsSet _atomSet; - private TextRun[] _runs; - private Notes _notes; // usermodel needs to set this + private HSLFTextParagraph[] _runs; + private HSLFNotes _notes; // usermodel needs to set this /** * Constructs a Slide from the Slide record, and the SlideAtomsSet @@ -63,7 +65,7 @@ public final class Slide extends Sheet { * @param notes the Notes sheet attached to us * @param atomSet the SlideAtomsSet to get the text from */ - public Slide(org.apache.poi.hslf.record.Slide slide, Notes notes, SlideAtomsSet atomSet, int slideIdentifier, int slideNumber) { + public HSLFSlide(org.apache.poi.hslf.record.Slide slide, HSLFNotes notes, SlideAtomsSet atomSet, int slideIdentifier, int slideNumber) { super(slide, slideIdentifier); _notes = notes; @@ -71,31 +73,31 @@ public final class Slide extends Sheet { _slideNo = slideNumber; // Grab the TextRuns from the PPDrawing - TextRun[] _otherRuns = findTextRuns(getPPDrawing()); + HSLFTextParagraph[] _otherRuns = findTextRuns(getPPDrawing()); // For the text coming in from the SlideAtomsSet: // Build up TextRuns from pairs of TextHeaderAtom and // one of TextBytesAtom or TextCharsAtom - final List textRuns = new LinkedList(); + final List textParagraphs = new LinkedList(); if(_atomSet != null) { - findTextRuns(_atomSet.getSlideRecords(),textRuns); + findTextParagraphs(_atomSet.getSlideRecords(),textParagraphs); } else { // No text on the slide, must just be pictures } // Build an array, more useful than a vector - _runs = new TextRun[textRuns.size()+_otherRuns.length]; + _runs = new HSLFTextParagraph[textParagraphs.size()+_otherRuns.length]; // Grab text from SlideListWithTexts entries int i=0; - for(i=0; iTextBox object that represents the slide's title. */ - public TextBox addTitle() { + public HSLFTextBox addTitle() { Placeholder pl = new Placeholder(); pl.setShapeType(ShapeType.RECT); - pl.getTextRun().setRunType(TextHeaderAtom.TITLE_TYPE); + pl.getTextParagraph().setRunType(TextHeaderAtom.TITLE_TYPE); pl.setText("Click to edit title"); pl.setAnchor(new java.awt.Rectangle(54, 48, 612, 90)); addShape(pl); @@ -203,7 +205,7 @@ public final class Slide extends Sheet { * @return title of this slide */ public String getTitle(){ - TextRun[] txt = getTextRuns(); + HSLFTextParagraph[] txt = getTextRuns(); for (int i = 0; i < txt.length; i++) { int type = txt[i].getRunType(); if (type == TextHeaderAtom.CENTER_TITLE_TYPE || @@ -220,7 +222,7 @@ public final class Slide extends Sheet { /** * Returns an array of all the TextRuns found */ - public TextRun[] getTextRuns() { return _runs; } + public HSLFTextParagraph[] getTextRuns() { return _runs; } /** * Returns the (public facing) page number of this slide @@ -237,7 +239,7 @@ public final class Slide extends Sheet { /** * Returns the Notes Sheet for this slide, or null if there isn't one */ - public Notes getNotesSheet() { return _notes; } + public HSLFNotes getNotesSheet() { return _notes; } /** * @return set of records inside SlideListWithtext container @@ -251,11 +253,11 @@ public final class Slide extends Sheet { * * @return the master sheet associated with this slide. */ - public MasterSheet getMasterSheet(){ + public HSLFMasterSheet getMasterSheet(){ SlideMaster[] master = getSlideShow().getSlidesMasters(); SlideAtom sa = getSlideRecord().getSlideAtom(); int masterId = sa.getMasterID(); - MasterSheet sheet = null; + HSLFMasterSheet sheet = null; for (int i = 0; i < master.length; i++) { if (masterId == master[i]._getSheetNumber()) { sheet = master[i]; @@ -277,7 +279,7 @@ public final class Slide extends Sheet { /** * Change Master of this slide. */ - public void setMasterSheet(MasterSheet master){ + public void setMasterSheet(HSLFMasterSheet master){ SlideAtom sa = getSlideRecord().getSlideAtom(); int sheetNo = master._getSheetNumber(); sa.setMasterID(sheetNo); @@ -352,7 +354,7 @@ public final class Slide extends Sheet { /** * Background for this slide. */ - public Background getBackground() { + public HSLFBackground getBackground() { if(getFollowMasterBackground()) { return getMasterSheet().getBackground(); } @@ -423,14 +425,14 @@ public final class Slide extends Sheet { } public void draw(Graphics2D graphics){ - MasterSheet master = getMasterSheet(); - Background bg = getBackground(); + HSLFMasterSheet master = getMasterSheet(); + HSLFBackground bg = getBackground(); if(bg != null)bg.draw(graphics); if(getFollowMasterObjects()){ HSLFShape[] sh = master.getShapes(); for (int i = 0; i < sh.length; i++) { - if(MasterSheet.isPlaceholder(sh[i])) continue; + if(HSLFMasterSheet.isPlaceholder(sh[i])) continue; sh[i].draw(graphics); } @@ -469,12 +471,12 @@ public final class Slide extends Sheet { return new HeadersFooters(hdd, this, newRecord, ppt2007); } - protected void onAddTextShape(TextShape shape) { - TextRun run = shape.getTextRun(); + protected void onAddTextShape(HSLFTextShape shape) { + HSLFTextParagraph run = shape.getTextParagraph(); - if(_runs == null) _runs = new TextRun[]{run}; + if(_runs == null) _runs = new HSLFTextParagraph[]{run}; else { - TextRun[] tmp = new TextRun[_runs.length + 1]; + HSLFTextParagraph[] tmp = new HSLFTextParagraph[_runs.length + 1]; System.arraycopy(_runs, 0, tmp, 0, _runs.length); tmp[tmp.length-1] = run; _runs = tmp; diff --git a/src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowEncrypted.java similarity index 98% rename from src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowEncrypted.java index 07a01aa244..803aeacaf3 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/EncryptedSlideShow.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowEncrypted.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hslf; +package org.apache.poi.hslf.model; import java.io.OutputStream; import java.security.GeneralSecurityException; @@ -49,7 +49,7 @@ import org.apache.poi.util.LittleEndian; * This class provides helper functions for encrypted PowerPoint documents. */ @Internal -public class EncryptedSlideShow { +public class HSLFSlideShowEncrypted { DocumentEncryptionAtom dea; CryptoAPIEncryptor enc = null; CryptoAPIDecryptor dec = null; @@ -58,11 +58,11 @@ public class EncryptedSlideShow { private static final BitField fieldRecInst = new BitField(0xFFF0); - protected EncryptedSlideShow(DocumentEncryptionAtom dea) { + protected HSLFSlideShowEncrypted(DocumentEncryptionAtom dea) { this.dea = dea; } - protected EncryptedSlideShow(byte[] docstream, NavigableMap recordMap) { + protected HSLFSlideShowEncrypted(byte[] docstream, NavigableMap recordMap) { // check for DocumentEncryptionAtom, which would be at the last offset // need to ignore already set UserEdit and PersistAtoms UserEditAtom userEditAtomWithEncryption = null; @@ -362,7 +362,7 @@ public class EncryptedSlideShow { /** * remove duplicated UserEditAtoms and merge PersistPtrHolder. * Before this method is called, make sure that the offsets are correct, - * i.e. call {@link HSLFSlideShow#updateAndWriteDependantRecords(OutputStream, Map)} + * i.e. call {@link HSLFSlideShowImpl#updateAndWriteDependantRecords(OutputStream, Map)} */ protected static Record[] normalizeRecords(Record records[]) { // http://msdn.microsoft.com/en-us/library/office/gg615594(v=office.14).aspx diff --git a/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowImpl.java similarity index 93% rename from src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowImpl.java index 55c3f6f876..48e52da65c 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFSlideShowImpl.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hslf; +package org.apache.poi.hslf.model; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -45,8 +45,8 @@ import org.apache.poi.hslf.record.PositionDependentRecord; import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.RecordTypes; import org.apache.poi.hslf.record.UserEditAtom; -import org.apache.poi.hslf.usermodel.ObjectData; -import org.apache.poi.hslf.usermodel.PictureData; +import org.apache.poi.hslf.usermodel.HSLFObjectData; +import org.apache.poi.hslf.usermodel.HSLFPictureData; import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptor; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentEntry; @@ -64,7 +64,7 @@ import org.apache.poi.util.POILogger; * * @author Nick Burch */ -public final class HSLFSlideShow extends POIDocument { +public final class HSLFSlideShowImpl extends POIDocument { public static final int UNSET_OFFSET = -1; // For logging @@ -80,10 +80,10 @@ public final class HSLFSlideShow extends POIDocument { private Record[] _records; // Raw Pictures contained in the pictures stream - private List _pictures; + private List _pictures; // Embedded objects stored in storage records in the document stream, lazily populated. - private ObjectData[] _objects; + private HSLFObjectData[] _objects; /** * Returns the underlying POIFSFileSystem for the document @@ -108,7 +108,7 @@ public final class HSLFSlideShow extends POIDocument { * @param fileName The name of the file to read. * @throws IOException if there is a problem while parsing the document. */ - public HSLFSlideShow(String fileName) throws IOException + public HSLFSlideShowImpl(String fileName) throws IOException { this(new FileInputStream(fileName)); } @@ -120,7 +120,7 @@ public final class HSLFSlideShow extends POIDocument { * @param inputStream the source of the data * @throws IOException if there is a problem while parsing the document. */ - public HSLFSlideShow(InputStream inputStream) throws IOException { + public HSLFSlideShowImpl(InputStream inputStream) throws IOException { //do Ole stuff this(new POIFSFileSystem(inputStream)); } @@ -132,7 +132,7 @@ public final class HSLFSlideShow extends POIDocument { * @param filesystem the POIFS FileSystem to read from * @throws IOException if there is a problem while parsing the document. */ - public HSLFSlideShow(POIFSFileSystem filesystem) throws IOException + public HSLFSlideShowImpl(POIFSFileSystem filesystem) throws IOException { this(filesystem.getRoot()); } @@ -144,7 +144,7 @@ public final class HSLFSlideShow extends POIDocument { * @param filesystem the POIFS FileSystem to read from * @throws IOException if there is a problem while parsing the document. */ - public HSLFSlideShow(NPOIFSFileSystem filesystem) throws IOException + public HSLFSlideShowImpl(NPOIFSFileSystem filesystem) throws IOException { this(filesystem.getRoot()); } @@ -160,7 +160,7 @@ public final class HSLFSlideShow extends POIDocument { * @throws IOException if there is a problem while parsing the document. */ @Deprecated - public HSLFSlideShow(DirectoryNode dir, POIFSFileSystem filesystem) throws IOException + public HSLFSlideShowImpl(DirectoryNode dir, POIFSFileSystem filesystem) throws IOException { this(dir); } @@ -173,7 +173,7 @@ public final class HSLFSlideShow extends POIDocument { * @param dir the POIFS directory to read from * @throws IOException if there is a problem while parsing the document. */ - public HSLFSlideShow(DirectoryNode dir) throws IOException { + public HSLFSlideShowImpl(DirectoryNode dir) throws IOException { super(handleDualStorage(dir)); // First up, grab the "Current User" stream @@ -202,13 +202,13 @@ public final class HSLFSlideShow extends POIDocument { /** * Constructs a new, empty, Powerpoint document. */ - public static final HSLFSlideShow create() { - InputStream is = HSLFSlideShow.class.getResourceAsStream("data/empty.ppt"); + public static final HSLFSlideShowImpl create() { + InputStream is = HSLFSlideShowImpl.class.getResourceAsStream("data/empty.ppt"); if (is == null) { throw new RuntimeException("Missing resource 'empty.ppt'"); } try { - return new HSLFSlideShow(is); + return new HSLFSlideShowImpl(is); } catch (IOException e) { throw new RuntimeException(e); } @@ -279,7 +279,7 @@ public final class HSLFSlideShow extends POIDocument { NavigableMap records = new TreeMap(); // offset -> record Map persistIds = new HashMap(); // offset -> persistId initRecordOffsets(docstream, usrOffset, records, persistIds); - EncryptedSlideShow decryptData = new EncryptedSlideShow(docstream, records); + HSLFSlideShowEncrypted decryptData = new HSLFSlideShowEncrypted(docstream, records); for (Map.Entry entry : records.entrySet()) { Integer offset = entry.getKey(); @@ -373,12 +373,12 @@ public final class HSLFSlideShow extends POIDocument { */ @SuppressWarnings("unused") private void readPictures() throws IOException { - _pictures = new ArrayList(); + _pictures = new ArrayList(); // if the presentation doesn't contain pictures - will use a null set instead if (!directory.hasEntry("Pictures")) return; - EncryptedSlideShow decryptData = new EncryptedSlideShow(getDocumentEncryptionAtom()); + HSLFSlideShowEncrypted decryptData = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom()); DocumentEntry entry = (DocumentEntry)directory.getEntry("Pictures"); byte[] pictstream = new byte[entry.getSize()]; @@ -423,7 +423,7 @@ public final class HSLFSlideShow extends POIDocument { } else { // Build the PictureData object from the data try { - PictureData pict = PictureData.create(type - 0xF018); + HSLFPictureData pict = HSLFPictureData.create(type - 0xF018); // Copy the data, ready to pass to PictureData byte[] imgdata = new byte[imgsize]; @@ -451,7 +451,7 @@ public final class HSLFSlideShow extends POIDocument { } catch (IOException e) { throw new CorruptPowerPointFileException(e); } - _records = EncryptedSlideShow.normalizeRecords(_records); + _records = HSLFSlideShowEncrypted.normalizeRecords(_records); } @@ -517,7 +517,7 @@ public final class HSLFSlideShow extends POIDocument { persistIds.put(oldToNewPositions.get(entry.getValue()), entry.getKey()); } - EncryptedSlideShow encData = new EncryptedSlideShow(getDocumentEncryptionAtom()); + HSLFSlideShowEncrypted encData = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom()); for (Record record : _records) { assert(record instanceof PositionDependentRecord); @@ -580,7 +580,7 @@ public final class HSLFSlideShow extends POIDocument { getDocumentSummaryInformation(); // set new encryption settings - EncryptedSlideShow encryptedSS = new EncryptedSlideShow(getDocumentEncryptionAtom()); + HSLFSlideShowEncrypted encryptedSS = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom()); _records = encryptedSS.updateEncryptionRecord(_records); // Get a new Filesystem to write into @@ -615,7 +615,7 @@ public final class HSLFSlideShow extends POIDocument { if (_pictures.size() > 0) { BufAccessBAOS pict = new BufAccessBAOS(); - for (PictureData p : _pictures) { + for (HSLFPictureData p : _pictures) { int offset = pict.size(); p.write(pict); encryptedSS.encryptPicture(pict.getBuf(), offset); @@ -704,7 +704,7 @@ public final class HSLFSlideShow extends POIDocument { * * @return offset of this picture in the Pictures stream */ - public int addPicture(PictureData img) { + public int addPicture(HSLFPictureData img) { // Process any existing pictures if we haven't yet if(_pictures == null) { try { @@ -717,7 +717,7 @@ public final class HSLFSlideShow extends POIDocument { // Add the new picture in int offset = 0; if(_pictures.size() > 0) { - PictureData prev = _pictures.get(_pictures.size() - 1); + HSLFPictureData prev = _pictures.get(_pictures.size() - 1); offset = prev.getOffset() + prev.getRawData().length + 8; } img.setOffset(offset); @@ -750,7 +750,7 @@ public final class HSLFSlideShow extends POIDocument { * @return array with the read pictures or null if the * presentation doesn't contain pictures. */ - public PictureData[] getPictures() { + public HSLFPictureData[] getPictures() { if(_pictures == null) { try { readPictures(); @@ -759,7 +759,7 @@ public final class HSLFSlideShow extends POIDocument { } } - return _pictures.toArray(new PictureData[_pictures.size()]); + return _pictures.toArray(new HSLFPictureData[_pictures.size()]); } /** @@ -767,15 +767,15 @@ public final class HSLFSlideShow extends POIDocument { * * @return the embedded objects. */ - public ObjectData[] getEmbeddedObjects() { + public HSLFObjectData[] getEmbeddedObjects() { if (_objects == null) { - List objects = new ArrayList(); + List objects = new ArrayList(); for (Record r : _records) { if (r instanceof ExOleObjStg) { - objects.add(new ObjectData((ExOleObjStg)r)); + objects.add(new HSLFObjectData((ExOleObjStg)r)); } } - _objects = objects.toArray(new ObjectData[objects.size()]); + _objects = objects.toArray(new HSLFObjectData[objects.size()]); } return _objects; } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextBox.java similarity index 89% rename from src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextBox.java index dc5ac94104..25ea585c95 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextBox.java @@ -30,7 +30,7 @@ import org.apache.poi.sl.usermodel.ShapeType; * * @author Yegor Kozlov */ -public class TextBox extends TextShape { +public class HSLFTextBox extends HSLFTextShape { /** * Create a TextBox object and initialize it from the supplied Record container. @@ -38,7 +38,7 @@ public class TextBox extends TextShape { * @param escherRecord EscherSpContainer container which holds information about this shape * @param parent the parent of the shape */ - protected TextBox(EscherContainerRecord escherRecord, ShapeContainer parent){ + protected HSLFTextBox(EscherContainerRecord escherRecord, ShapeContainer parent){ super(escherRecord, parent); } @@ -49,7 +49,7 @@ public class TextBox extends TextShape { * @param parent the parent of this Shape. For example, if this text box is a cell * in a table then the parent is Table. */ - public TextBox(ShapeContainer parent){ + public HSLFTextBox(ShapeContainer parent){ super(parent); } @@ -57,7 +57,7 @@ public class TextBox extends TextShape { * Create a new TextBox. This constructor is used when a new shape is created. * */ - public TextBox(){ + public HSLFTextBox(){ this(null); } @@ -84,8 +84,8 @@ public class TextBox extends TextShape { return _escherContainer; } - protected void setDefaultTextProperties(TextRun _txtrun){ - setVerticalAlignment(TextBox.AnchorTop); + protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){ + setVerticalAlignment(HSLFTextBox.AnchorTop); setEscherProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20002); } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextParagraph.java similarity index 90% rename from src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextParagraph.java index 755482f183..b23c997dbe 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextParagraph.java @@ -1,746 +1,744 @@ -/* ==================================================================== - 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.model; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import org.apache.poi.hslf.model.textproperties.TextPropCollection; -import org.apache.poi.hslf.record.PPDrawing; -import org.apache.poi.hslf.record.Record; -import org.apache.poi.hslf.record.RecordContainer; -import org.apache.poi.hslf.record.SlideListWithText; -import org.apache.poi.hslf.record.StyleTextProp9Atom; -import org.apache.poi.hslf.record.StyleTextPropAtom; -import org.apache.poi.hslf.record.TextBytesAtom; -import org.apache.poi.hslf.record.TextCharsAtom; -import org.apache.poi.hslf.record.TextHeaderAtom; -import org.apache.poi.hslf.record.TextRulerAtom; -import org.apache.poi.hslf.record.TextSpecInfoAtom; -import org.apache.poi.hslf.usermodel.RichTextRun; -import org.apache.poi.hslf.usermodel.SlideShow; -import org.apache.poi.util.StringUtil; - -/** - * This class represents a run of text in a powerpoint document. That - * run could be text on a sheet, or text in a note. - * It is only a very basic class for now - * - * @author Nick Burch - */ - -public final class TextRun -{ - // Note: These fields are protected to help with unit testing - // Other classes shouldn't really go playing with them! - protected TextHeaderAtom _headerAtom; - protected TextBytesAtom _byteAtom; - protected TextCharsAtom _charAtom; - protected StyleTextPropAtom _styleAtom; - protected TextRulerAtom _ruler; - protected boolean _isUnicode; - protected RichTextRun[] _rtRuns; - private SlideShow slideShow; - private Sheet _sheet; - private int shapeId; - private int slwtIndex = -1; //position in the owning SlideListWithText - /** - * all text run records that follow TextHeaderAtom. - * (there can be misc InteractiveInfo, TxInteractiveInfo and other records) - */ - protected Record[] _records; - // private StyleTextPropAtom styleTextPropAtom; - private StyleTextProp9Atom styleTextProp9Atom; - - /** - * Constructs a Text Run from a Unicode text block - * - * @param tha the TextHeaderAtom that defines what's what - * @param tca the TextCharsAtom containing the text - * @param sta the StyleTextPropAtom which defines the character stylings - */ - public TextRun(TextHeaderAtom tha, TextCharsAtom tca, StyleTextPropAtom sta) { - this(tha,null,tca,sta); - } - - /** - * Constructs a Text Run from a Ascii text block - * - * @param tha the TextHeaderAtom that defines what's what - * @param tba the TextBytesAtom containing the text - * @param sta the StyleTextPropAtom which defines the character stylings - */ - public TextRun(TextHeaderAtom tha, TextBytesAtom tba, StyleTextPropAtom sta) { - this(tha,tba,null,sta); - } - - /** - * Internal constructor and initializer - */ - private TextRun(TextHeaderAtom tha, TextBytesAtom tba, TextCharsAtom tca, StyleTextPropAtom sta) { - _headerAtom = tha; - _styleAtom = sta; - if(tba != null) { - _byteAtom = tba; - _isUnicode = false; - } else { - _charAtom = tca; - _isUnicode = true; - } - String runRawText = getText(); - - // Figure out the rich text runs - LinkedList pStyles = new LinkedList(); - LinkedList cStyles = new LinkedList(); - if(_styleAtom != null) { - // Get the style atom to grok itself - _styleAtom.setParentTextSize(runRawText.length()); - pStyles = _styleAtom.getParagraphStyles(); - cStyles = _styleAtom.getCharacterStyles(); - } - buildRichTextRuns(pStyles, cStyles, runRawText); - } - - public void buildRichTextRuns(LinkedList pStyles, LinkedList cStyles, String runRawText){ - - // Handle case of no current style, with a default - if(pStyles.size() == 0 || cStyles.size() == 0) { - _rtRuns = new RichTextRun[1]; - _rtRuns[0] = new RichTextRun(this, 0, runRawText.length()); - } else { - // Build up Rich Text Runs, one for each - // character/paragraph style pair - List rtrs = new ArrayList(); - - int pos = 0; - - int curP = 0; - int curC = 0; - int pLenRemain = -1; - int cLenRemain = -1; - - // Build one for each run with the same style - while(pos <= runRawText.length() && curP < pStyles.size() && curC < cStyles.size()) { - // Get the Props to use - TextPropCollection pProps = pStyles.get(curP); - TextPropCollection cProps = cStyles.get(curC); - - int pLen = pProps.getCharactersCovered(); - int cLen = cProps.getCharactersCovered(); - - // Handle new pass - boolean freshSet = false; - if(pLenRemain == -1 && cLenRemain == -1) { freshSet = true; } - if(pLenRemain == -1) { pLenRemain = pLen; } - if(cLenRemain == -1) { cLenRemain = cLen; } - - // So we know how to build the eventual run - int runLen = -1; - boolean pShared = false; - boolean cShared = false; - - // Same size, new styles - neither shared - if(pLen == cLen && freshSet) { - runLen = cLen; - pShared = false; - cShared = false; - curP++; - curC++; - pLenRemain = -1; - cLenRemain = -1; - } else { - // Some sharing - - // See if we are already in a shared block - if(pLenRemain < pLen) { - // Existing shared p block - pShared = true; - - // Do we end with the c block, or either side of it? - if(pLenRemain == cLenRemain) { - // We end at the same time - cShared = false; - runLen = pLenRemain; - curP++; - curC++; - pLenRemain = -1; - cLenRemain = -1; - } else if(pLenRemain < cLenRemain) { - // We end before the c block - cShared = true; - runLen = pLenRemain; - curP++; - cLenRemain -= pLenRemain; - pLenRemain = -1; - } else { - // We end after the c block - cShared = false; - runLen = cLenRemain; - curC++; - pLenRemain -= cLenRemain; - cLenRemain = -1; - } - } else if(cLenRemain < cLen) { - // Existing shared c block - cShared = true; - - // Do we end with the p block, or either side of it? - if(pLenRemain == cLenRemain) { - // We end at the same time - pShared = false; - runLen = cLenRemain; - curP++; - curC++; - pLenRemain = -1; - cLenRemain = -1; - } else if(cLenRemain < pLenRemain) { - // We end before the p block - pShared = true; - runLen = cLenRemain; - curC++; - pLenRemain -= cLenRemain; - cLenRemain = -1; - } else { - // We end after the p block - pShared = false; - runLen = pLenRemain; - curP++; - cLenRemain -= pLenRemain; - pLenRemain = -1; - } - } else { - // Start of a shared block - if(pLenRemain < cLenRemain) { - // Shared c block - pShared = false; - cShared = true; - runLen = pLenRemain; - curP++; - cLenRemain -= pLenRemain; - pLenRemain = -1; - } else { - // Shared p block - pShared = true; - cShared = false; - runLen = cLenRemain; - curC++; - pLenRemain -= cLenRemain; - cLenRemain = -1; - } - } - } - - // Wind on - int prevPos = pos; - pos += runLen; - // Adjust for end-of-run extra 1 length - if(pos > runRawText.length()) { - runLen--; - } - - // Save - RichTextRun rtr = new RichTextRun(this, prevPos, runLen, pProps, cProps, pShared, cShared); - rtrs.add(rtr); - } - - // Build the array - _rtRuns = rtrs.toArray(new RichTextRun[rtrs.size()]); - } - - } - - // Update methods follow - - /** - * Adds the supplied text onto the end of the TextRun, - * creating a new RichTextRun (returned) for it to - * sit in. - * In many cases, before calling this, you'll want to add - * a newline onto the end of your last RichTextRun - */ - public RichTextRun appendText(String s) { - // We will need a StyleTextProp atom - ensureStyleAtomPresent(); - - // First up, append the text to the - // underlying text atom - int oldSize = getRawText().length(); - storeText( - getRawText() + s - ); - - // If either of the previous styles overran - // the text by one, we need to shuffle that - // extra character onto the new ones - int pOverRun = _styleAtom.getParagraphTextLengthCovered() - oldSize; - int cOverRun = _styleAtom.getCharacterTextLengthCovered() - oldSize; - if(pOverRun > 0) { - TextPropCollection tpc = _styleAtom.getParagraphStyles().getLast(); - tpc.updateTextSize( - tpc.getCharactersCovered() - pOverRun - ); - } - if(cOverRun > 0) { - TextPropCollection tpc = _styleAtom.getCharacterStyles().getLast(); - tpc.updateTextSize( - tpc.getCharactersCovered() - cOverRun - ); - } - - // Next, add the styles for its paragraph and characters - TextPropCollection newPTP = - _styleAtom.addParagraphTextPropCollection(s.length()+pOverRun); - TextPropCollection newCTP = - _styleAtom.addCharacterTextPropCollection(s.length()+cOverRun); - - // Now, create the new RichTextRun - RichTextRun nr = new RichTextRun( - this, oldSize, s.length(), - newPTP, newCTP, false, false - ); - - // Add the new RichTextRun onto our list - RichTextRun[] newRuns = new RichTextRun[_rtRuns.length+1]; - System.arraycopy(_rtRuns, 0, newRuns, 0, _rtRuns.length); - newRuns[newRuns.length-1] = nr; - _rtRuns = newRuns; - - // And return the new run to the caller - return nr; - } - - /** - * Saves the given string to the records. Doesn't - * touch the stylings. - */ - private void storeText(String s) { - // Store in the appropriate record - if(_isUnicode) { - // The atom can safely convert to unicode - _charAtom.setText(s); - } else { - // Will it fit in a 8 bit atom? - boolean hasMultibyte = StringUtil.hasMultibyte(s); - if(! hasMultibyte) { - // Fine to go into 8 bit atom - byte[] text = new byte[s.length()]; - StringUtil.putCompressedUnicode(s,text,0); - _byteAtom.setText(text); - } else { - // Need to swap a TextBytesAtom for a TextCharsAtom - - // Build the new TextCharsAtom - _charAtom = new TextCharsAtom(); - _charAtom.setText(s); - - // Use the TextHeaderAtom to do the swap on the parent - RecordContainer parent = _headerAtom.getParentRecord(); - Record[] cr = parent.getChildRecords(); - for(int i=0; i pStyles = _styleAtom.getParagraphStyles(); - while(pStyles.size() > 1) { pStyles.removeLast(); } - - if (!pStyles.isEmpty()) { - pStyles.getFirst().updateTextSize( s.length()+1 ); - } - - LinkedList cStyles = _styleAtom.getCharacterStyles(); - while(cStyles.size() > 1) { cStyles.removeLast(); } - - if (!cStyles.isEmpty()) { - cStyles.getFirst().updateTextSize( s.length()+1 ); - } - - _rtRuns[0].setText(s); - } else { - // Recreate rich text run with no styling - _rtRuns[0] = new RichTextRun(this,0,s.length()); - } - - } - - /** - * Changes the text. - * Converts '\r' into '\n' - */ - public void setText(String s) { - String text = normalize(s); - setRawText(text); - } - - /** - * Ensure a StyleTextPropAtom is present for this run, - * by adding if required. Normally for internal TextRun use. - */ - public void ensureStyleAtomPresent() { - if(_styleAtom != null) { - // All there - return; - } - - // Create a new one at the right size - _styleAtom = new StyleTextPropAtom(getRawText().length() + 1); - - // Use the TextHeader atom to get at the parent - RecordContainer runAtomsParent = _headerAtom.getParentRecord(); - - // Add the new StyleTextPropAtom after the TextCharsAtom / TextBytesAtom - Record addAfter = _byteAtom; - if(_byteAtom == null) { addAfter = _charAtom; } - runAtomsParent.addChildAfter(_styleAtom, addAfter); - - // Feed this to our sole rich text run - if(_rtRuns.length != 1) { - throw new IllegalStateException("Needed to add StyleTextPropAtom when had many rich text runs"); - } - // These are the only styles for now - _rtRuns[0].supplyTextProps( - _styleAtom.getParagraphStyles().get(0), - _styleAtom.getCharacterStyles().get(0), - false, - false - ); - } - - // Accesser methods follow - - /** - * Returns the text content of the run, which has been made safe - * for printing and other use. - */ - public String getText() { - String rawText = getRawText(); - - // PowerPoint seems to store files with \r as the line break - // The messes things up on everything but a Mac, so translate - // them to \n - String text = rawText.replace('\r','\n'); - - int type = _headerAtom == null ? 0 : _headerAtom.getTextType(); - if(type == TextHeaderAtom.TITLE_TYPE || type == TextHeaderAtom.CENTER_TITLE_TYPE){ - //0xB acts like cariage return in page titles and like blank in the others - text = text.replace((char) 0x0B, '\n'); - } else { - text = text.replace((char) 0x0B, ' '); - } - return text; - } - - /** - * Returns the raw text content of the run. This hasn't had any - * changes applied to it, and so is probably unlikely to print - * out nicely. - */ - public String getRawText() { - if(_isUnicode) { - return _charAtom.getText(); - } - return _byteAtom.getText(); - } - - /** - * Fetch the rich text runs (runs of text with the same styling) that - * are contained within this block of text - */ - public RichTextRun[] getRichTextRuns() { - return _rtRuns; - } - - /** - * Returns the type of the text, from the TextHeaderAtom. - * Possible values can be seen from TextHeaderAtom - * @see org.apache.poi.hslf.record.TextHeaderAtom - */ - public int getRunType() { - return _headerAtom.getTextType(); - } - - /** - * Changes the type of the text. Values should be taken - * from TextHeaderAtom. No checking is done to ensure you - * set this to a valid value! - * @see org.apache.poi.hslf.record.TextHeaderAtom - */ - public void setRunType(int type) { - _headerAtom.setTextType(type); - } - - /** - * Supply the SlideShow we belong to. - * Also passes it on to our child RichTextRuns - */ - public void supplySlideShow(SlideShow ss) { - slideShow = ss; - if(_rtRuns != null) { - for(int i=0; i<_rtRuns.length; i++) { - _rtRuns[i].supplySlideShow(slideShow); - } - } - } - - public void setSheet(Sheet sheet){ - this._sheet = sheet; - } - - public Sheet getSheet(){ - return this._sheet; - } - - /** - * @return Shape ID - */ - protected int getShapeId(){ - return shapeId; - } - - /** - * @param id Shape ID - */ - protected void setShapeId(int id){ - shapeId = id; - } - - /** - * @return 0-based index of the text run in the SLWT container - */ - protected int getIndex(){ - return slwtIndex; - } - - /** - * @param id 0-based index of the text run in the SLWT container - */ - protected void setIndex(int id){ - slwtIndex = id; - } - - /** - * Is this Text Run one from a {@link PPDrawing}, or is it - * one from the {@link SlideListWithText}? - */ - public boolean isDrawingBased() { - return (slwtIndex == -1); - } - - /** - * Returns the array of all hyperlinks in this text run - * - * @return the array of all hyperlinks in this text run - * or null if not found. - */ - public Hyperlink[] getHyperlinks(){ - return Hyperlink.find(this); - } - - /** - * Fetch RichTextRun at a given position - * - * @param pos 0-based index in the text - * @return RichTextRun or null if not found - */ - public RichTextRun getRichTextRunAt(int pos){ - for (int i = 0; i < _rtRuns.length; i++) { - int start = _rtRuns[i].getStartIndex(); - int end = _rtRuns[i].getEndIndex(); - if(pos >= start && pos < end) return _rtRuns[i]; - } - return null; - } - - public TextRulerAtom getTextRuler(){ - if(_ruler == null){ - if(_records != null) for (int i = 0; i < _records.length; i++) { - if(_records[i] instanceof TextRulerAtom) { - _ruler = (TextRulerAtom)_records[i]; - break; - } - } - - } - return _ruler; - - } - - public TextRulerAtom createTextRuler(){ - _ruler = getTextRuler(); - if(_ruler == null){ - _ruler = TextRulerAtom.getParagraphInstance(); - _headerAtom.getParentRecord().appendChildRecord(_ruler); - } - return _ruler; - } - - /** - * Returns a new string with line breaks converted into internal ppt representation - */ - public String normalize(String s){ - String ns = s.replaceAll("\\r?\\n", "\r"); - return ns; - } - - /** - * Returns records that make up this text run - * - * @return text run records - */ - public Record[] getRecords(){ - return _records; - } - /** Numbered List info */ - public void setStyleTextProp9Atom(final StyleTextProp9Atom styleTextProp9Atom) { - this.styleTextProp9Atom = styleTextProp9Atom; - } - /** Numbered List info */ - public StyleTextProp9Atom getStyleTextProp9Atom() { - return this.styleTextProp9Atom; - } - - /** Characters covered */ - public StyleTextPropAtom getStyleTextPropAtom() { - return this._styleAtom; - } - -} +/* ==================================================================== + 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.model; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import org.apache.poi.hslf.model.textproperties.TextPropCollection; +import org.apache.poi.hslf.record.PPDrawing; +import org.apache.poi.hslf.record.Record; +import org.apache.poi.hslf.record.RecordContainer; +import org.apache.poi.hslf.record.SlideListWithText; +import org.apache.poi.hslf.record.StyleTextProp9Atom; +import org.apache.poi.hslf.record.StyleTextPropAtom; +import org.apache.poi.hslf.record.TextBytesAtom; +import org.apache.poi.hslf.record.TextCharsAtom; +import org.apache.poi.hslf.record.TextHeaderAtom; +import org.apache.poi.hslf.record.TextRulerAtom; +import org.apache.poi.hslf.record.TextSpecInfoAtom; +import org.apache.poi.hslf.usermodel.HSLFTextRun; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; +import org.apache.poi.sl.usermodel.TextParagraph; +import org.apache.poi.util.StringUtil; + +/** + * This class represents a run of text in a powerpoint document. That + * run could be text on a sheet, or text in a note. + * It is only a very basic class for now + * + * @author Nick Burch + */ + +public final class HSLFTextParagraph implements TextParagraph +{ + // Note: These fields are protected to help with unit testing + // Other classes shouldn't really go playing with them! + protected TextHeaderAtom _headerAtom; + protected TextBytesAtom _byteAtom; + protected TextCharsAtom _charAtom; + protected StyleTextPropAtom _styleAtom; + protected TextRulerAtom _ruler; + protected boolean _isUnicode; + protected HSLFTextRun[] _rtRuns; + protected HSLFTextShape _parentShape; + // private SlideShow slideShow; + private HSLFSheet _sheet; + private int shapeId; + private int slwtIndex = -1; //position in the owning SlideListWithText + /** + * all text run records that follow TextHeaderAtom. + * (there can be misc InteractiveInfo, TxInteractiveInfo and other records) + */ + protected Record[] _records; + // private StyleTextPropAtom styleTextPropAtom; + private StyleTextProp9Atom styleTextProp9Atom; + + /** + * Constructs a Text Run from a Unicode text block + * + * @param tha the TextHeaderAtom that defines what's what + * @param tca the TextCharsAtom containing the text + * @param sta the StyleTextPropAtom which defines the character stylings + */ + public HSLFTextParagraph(TextHeaderAtom tha, TextCharsAtom tca, StyleTextPropAtom sta) { + this(tha,null,tca,sta); + } + + /** + * Constructs a Text Run from a Ascii text block + * + * @param tha the TextHeaderAtom that defines what's what + * @param tba the TextBytesAtom containing the text + * @param sta the StyleTextPropAtom which defines the character stylings + */ + public HSLFTextParagraph(TextHeaderAtom tha, TextBytesAtom tba, StyleTextPropAtom sta) { + this(tha,tba,null,sta); + } + + /** + * Internal constructor and initializer + */ + private HSLFTextParagraph(TextHeaderAtom tha, TextBytesAtom tba, TextCharsAtom tca, StyleTextPropAtom sta) { + _headerAtom = tha; + _styleAtom = sta; + if(tba != null) { + _byteAtom = tba; + _isUnicode = false; + } else { + _charAtom = tca; + _isUnicode = true; + } + String runRawText = getText(); + + // Figure out the rich text runs + LinkedList pStyles = new LinkedList(); + LinkedList cStyles = new LinkedList(); + if(_styleAtom != null) { + // Get the style atom to grok itself + _styleAtom.setParentTextSize(runRawText.length()); + pStyles = _styleAtom.getParagraphStyles(); + cStyles = _styleAtom.getCharacterStyles(); + } + buildRichTextRuns(pStyles, cStyles, runRawText); + } + + public void buildRichTextRuns(LinkedList pStyles, LinkedList cStyles, String runRawText){ + + // Handle case of no current style, with a default + if(pStyles.size() == 0 || cStyles.size() == 0) { + _rtRuns = new HSLFTextRun[1]; + _rtRuns[0] = new HSLFTextRun(this, 0, runRawText.length()); + } else { + // Build up Rich Text Runs, one for each + // character/paragraph style pair + List rtrs = new ArrayList(); + + int pos = 0; + + int curP = 0; + int curC = 0; + int pLenRemain = -1; + int cLenRemain = -1; + + // Build one for each run with the same style + while(pos <= runRawText.length() && curP < pStyles.size() && curC < cStyles.size()) { + // Get the Props to use + TextPropCollection pProps = pStyles.get(curP); + TextPropCollection cProps = cStyles.get(curC); + + int pLen = pProps.getCharactersCovered(); + int cLen = cProps.getCharactersCovered(); + + // Handle new pass + boolean freshSet = false; + if(pLenRemain == -1 && cLenRemain == -1) { freshSet = true; } + if(pLenRemain == -1) { pLenRemain = pLen; } + if(cLenRemain == -1) { cLenRemain = cLen; } + + // So we know how to build the eventual run + int runLen = -1; + boolean pShared = false; + boolean cShared = false; + + // Same size, new styles - neither shared + if(pLen == cLen && freshSet) { + runLen = cLen; + pShared = false; + cShared = false; + curP++; + curC++; + pLenRemain = -1; + cLenRemain = -1; + } else { + // Some sharing + + // See if we are already in a shared block + if(pLenRemain < pLen) { + // Existing shared p block + pShared = true; + + // Do we end with the c block, or either side of it? + if(pLenRemain == cLenRemain) { + // We end at the same time + cShared = false; + runLen = pLenRemain; + curP++; + curC++; + pLenRemain = -1; + cLenRemain = -1; + } else if(pLenRemain < cLenRemain) { + // We end before the c block + cShared = true; + runLen = pLenRemain; + curP++; + cLenRemain -= pLenRemain; + pLenRemain = -1; + } else { + // We end after the c block + cShared = false; + runLen = cLenRemain; + curC++; + pLenRemain -= cLenRemain; + cLenRemain = -1; + } + } else if(cLenRemain < cLen) { + // Existing shared c block + cShared = true; + + // Do we end with the p block, or either side of it? + if(pLenRemain == cLenRemain) { + // We end at the same time + pShared = false; + runLen = cLenRemain; + curP++; + curC++; + pLenRemain = -1; + cLenRemain = -1; + } else if(cLenRemain < pLenRemain) { + // We end before the p block + pShared = true; + runLen = cLenRemain; + curC++; + pLenRemain -= cLenRemain; + cLenRemain = -1; + } else { + // We end after the p block + pShared = false; + runLen = pLenRemain; + curP++; + cLenRemain -= pLenRemain; + pLenRemain = -1; + } + } else { + // Start of a shared block + if(pLenRemain < cLenRemain) { + // Shared c block + pShared = false; + cShared = true; + runLen = pLenRemain; + curP++; + cLenRemain -= pLenRemain; + pLenRemain = -1; + } else { + // Shared p block + pShared = true; + cShared = false; + runLen = cLenRemain; + curC++; + pLenRemain -= cLenRemain; + cLenRemain = -1; + } + } + } + + // Wind on + int prevPos = pos; + pos += runLen; + // Adjust for end-of-run extra 1 length + if(pos > runRawText.length()) { + runLen--; + } + + // Save + HSLFTextRun rtr = new HSLFTextRun(this, prevPos, runLen, pProps, cProps, pShared, cShared); + rtrs.add(rtr); + } + + // Build the array + _rtRuns = rtrs.toArray(new HSLFTextRun[rtrs.size()]); + } + + } + + // Update methods follow + + /** + * Adds the supplied text onto the end of the TextRun, + * creating a new RichTextRun (returned) for it to + * sit in. + * In many cases, before calling this, you'll want to add + * a newline onto the end of your last RichTextRun + */ + public HSLFTextRun appendText(String s) { + // We will need a StyleTextProp atom + ensureStyleAtomPresent(); + + // First up, append the text to the + // underlying text atom + int oldSize = getRawText().length(); + storeText( + getRawText() + s + ); + + // If either of the previous styles overran + // the text by one, we need to shuffle that + // extra character onto the new ones + int pOverRun = _styleAtom.getParagraphTextLengthCovered() - oldSize; + int cOverRun = _styleAtom.getCharacterTextLengthCovered() - oldSize; + if(pOverRun > 0) { + TextPropCollection tpc = _styleAtom.getParagraphStyles().getLast(); + tpc.updateTextSize( + tpc.getCharactersCovered() - pOverRun + ); + } + if(cOverRun > 0) { + TextPropCollection tpc = _styleAtom.getCharacterStyles().getLast(); + tpc.updateTextSize( + tpc.getCharactersCovered() - cOverRun + ); + } + + // Next, add the styles for its paragraph and characters + TextPropCollection newPTP = + _styleAtom.addParagraphTextPropCollection(s.length()+pOverRun); + TextPropCollection newCTP = + _styleAtom.addCharacterTextPropCollection(s.length()+cOverRun); + + // Now, create the new RichTextRun + HSLFTextRun nr = new HSLFTextRun( + this, oldSize, s.length(), + newPTP, newCTP, false, false + ); + + // Add the new RichTextRun onto our list + HSLFTextRun[] newRuns = new HSLFTextRun[_rtRuns.length+1]; + System.arraycopy(_rtRuns, 0, newRuns, 0, _rtRuns.length); + newRuns[newRuns.length-1] = nr; + _rtRuns = newRuns; + + // And return the new run to the caller + return nr; + } + + /** + * Saves the given string to the records. Doesn't + * touch the stylings. + */ + private void storeText(String s) { + // Store in the appropriate record + if(_isUnicode) { + // The atom can safely convert to unicode + _charAtom.setText(s); + } else { + // Will it fit in a 8 bit atom? + boolean hasMultibyte = StringUtil.hasMultibyte(s); + if(! hasMultibyte) { + // Fine to go into 8 bit atom + byte[] text = new byte[s.length()]; + StringUtil.putCompressedUnicode(s,text,0); + _byteAtom.setText(text); + } else { + // Need to swap a TextBytesAtom for a TextCharsAtom + + // Build the new TextCharsAtom + _charAtom = new TextCharsAtom(); + _charAtom.setText(s); + + // Use the TextHeaderAtom to do the swap on the parent + RecordContainer parent = _headerAtom.getParentRecord(); + Record[] cr = parent.getChildRecords(); + for(int i=0; i pStyles = _styleAtom.getParagraphStyles(); + while(pStyles.size() > 1) { pStyles.removeLast(); } + + if (!pStyles.isEmpty()) { + pStyles.getFirst().updateTextSize( s.length()+1 ); + } + + LinkedList cStyles = _styleAtom.getCharacterStyles(); + while(cStyles.size() > 1) { cStyles.removeLast(); } + + if (!cStyles.isEmpty()) { + cStyles.getFirst().updateTextSize( s.length()+1 ); + } + + _rtRuns[0].setText(s); + } else { + // Recreate rich text run with no styling + _rtRuns[0] = new HSLFTextRun(this,0,s.length()); + } + + } + + /** + * Changes the text. + * Converts '\r' into '\n' + */ + public void setText(String s) { + String text = normalize(s); + setRawText(text); + } + + /** + * Ensure a StyleTextPropAtom is present for this run, + * by adding if required. Normally for internal TextRun use. + */ + public void ensureStyleAtomPresent() { + if(_styleAtom != null) { + // All there + return; + } + + // Create a new one at the right size + _styleAtom = new StyleTextPropAtom(getRawText().length() + 1); + + // Use the TextHeader atom to get at the parent + RecordContainer runAtomsParent = _headerAtom.getParentRecord(); + + // Add the new StyleTextPropAtom after the TextCharsAtom / TextBytesAtom + Record addAfter = _byteAtom; + if(_byteAtom == null) { addAfter = _charAtom; } + runAtomsParent.addChildAfter(_styleAtom, addAfter); + + // Feed this to our sole rich text run + if(_rtRuns.length != 1) { + throw new IllegalStateException("Needed to add StyleTextPropAtom when had many rich text runs"); + } + // These are the only styles for now + _rtRuns[0].supplyTextProps( + _styleAtom.getParagraphStyles().get(0), + _styleAtom.getCharacterStyles().get(0), + false, + false + ); + } + + // Accesser methods follow + + /** + * Returns the text content of the run, which has been made safe + * for printing and other use. + */ + public String getText() { + String rawText = getRawText(); + + // PowerPoint seems to store files with \r as the line break + // The messes things up on everything but a Mac, so translate + // them to \n + String text = rawText.replace('\r','\n'); + + int type = _headerAtom == null ? 0 : _headerAtom.getTextType(); + if(type == TextHeaderAtom.TITLE_TYPE || type == TextHeaderAtom.CENTER_TITLE_TYPE){ + //0xB acts like cariage return in page titles and like blank in the others + text = text.replace((char) 0x0B, '\n'); + } else { + text = text.replace((char) 0x0B, ' '); + } + return text; + } + + /** + * Returns the raw text content of the run. This hasn't had any + * changes applied to it, and so is probably unlikely to print + * out nicely. + */ + public String getRawText() { + if(_isUnicode) { + return _charAtom.getText(); + } + return _byteAtom.getText(); + } + + /** + * Fetch the rich text runs (runs of text with the same styling) that + * are contained within this block of text + */ + public HSLFTextRun[] getRichTextRuns() { + return _rtRuns; + } + + /** + * Returns the type of the text, from the TextHeaderAtom. + * Possible values can be seen from TextHeaderAtom + * @see org.apache.poi.hslf.record.TextHeaderAtom + */ + public int getRunType() { + return _headerAtom.getTextType(); + } + + /** + * Changes the type of the text. Values should be taken + * from TextHeaderAtom. No checking is done to ensure you + * set this to a valid value! + * @see org.apache.poi.hslf.record.TextHeaderAtom + */ + public void setRunType(int type) { + _headerAtom.setTextType(type); + } + + /** + * Supply the Sheet we belong to, which might have an assigned SlideShow + * Also passes it on to our child RichTextRuns + */ + public void supplySheet(HSLFSheet sheet){ + this._sheet = sheet; + + if (_rtRuns == null) return; + for(HSLFTextRun rt : _rtRuns) { + rt.updateSheet(); + } + } + + public HSLFSheet getSheet(){ + return this._sheet; + } + + /** + * @return Shape ID + */ + protected int getShapeId(){ + return shapeId; + } + + /** + * @param id Shape ID + */ + protected void setShapeId(int id){ + shapeId = id; + } + + /** + * @return 0-based index of the text run in the SLWT container + */ + protected int getIndex(){ + return slwtIndex; + } + + /** + * @param id 0-based index of the text run in the SLWT container + */ + protected void setIndex(int id){ + slwtIndex = id; + } + + /** + * Is this Text Run one from a {@link PPDrawing}, or is it + * one from the {@link SlideListWithText}? + */ + public boolean isDrawingBased() { + return (slwtIndex == -1); + } + + /** + * Returns the array of all hyperlinks in this text run + * + * @return the array of all hyperlinks in this text run + * or null if not found. + */ + public Hyperlink[] getHyperlinks(){ + return Hyperlink.find(this); + } + + /** + * Fetch RichTextRun at a given position + * + * @param pos 0-based index in the text + * @return RichTextRun or null if not found + */ + public HSLFTextRun getRichTextRunAt(int pos){ + for (int i = 0; i < _rtRuns.length; i++) { + int start = _rtRuns[i].getStartIndex(); + int end = _rtRuns[i].getEndIndex(); + if(pos >= start && pos < end) return _rtRuns[i]; + } + return null; + } + + public TextRulerAtom getTextRuler(){ + if(_ruler == null){ + if(_records != null) for (int i = 0; i < _records.length; i++) { + if(_records[i] instanceof TextRulerAtom) { + _ruler = (TextRulerAtom)_records[i]; + break; + } + } + + } + return _ruler; + + } + + public TextRulerAtom createTextRuler(){ + _ruler = getTextRuler(); + if(_ruler == null){ + _ruler = TextRulerAtom.getParagraphInstance(); + _headerAtom.getParentRecord().appendChildRecord(_ruler); + } + return _ruler; + } + + /** + * Returns a new string with line breaks converted into internal ppt representation + */ + public String normalize(String s){ + String ns = s.replaceAll("\\r?\\n", "\r"); + return ns; + } + + /** + * Returns records that make up this text run + * + * @return text run records + */ + public Record[] getRecords(){ + return _records; + } + /** Numbered List info */ + public void setStyleTextProp9Atom(final StyleTextProp9Atom styleTextProp9Atom) { + this.styleTextProp9Atom = styleTextProp9Atom; + } + /** Numbered List info */ + public StyleTextProp9Atom getStyleTextProp9Atom() { + return this.styleTextProp9Atom; + } + + /** Characters covered */ + public StyleTextPropAtom getStyleTextPropAtom() { + return this._styleAtom; + } + +} diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextShape.java similarity index 90% rename from src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java rename to src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextShape.java index 3f47ae6a5b..17e8b81d21 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFTextShape.java @@ -47,7 +47,7 @@ import org.apache.poi.hslf.record.TextBytesAtom; import org.apache.poi.hslf.record.TextCharsAtom; import org.apache.poi.hslf.record.TextHeaderAtom; import org.apache.poi.hslf.record.TxInteractiveInfoAtom; -import org.apache.poi.hslf.usermodel.RichTextRun; +import org.apache.poi.hslf.usermodel.HSLFTextRun; import org.apache.poi.sl.usermodel.ShapeContainer; import org.apache.poi.util.POILogger; @@ -56,7 +56,7 @@ import org.apache.poi.util.POILogger; * * @author Yegor Kozlov */ -public abstract class TextShape extends SimpleShape { +public abstract class HSLFTextShape extends HSLFSimpleShape { /** * How to anchor the text @@ -92,7 +92,7 @@ public abstract class TextShape extends SimpleShape { /** * TextRun object which holds actual text and format data */ - protected TextRun _txtrun; + protected HSLFTextParagraph _txtrun; /** * Escher container which holds text attributes such as @@ -111,7 +111,7 @@ public abstract class TextShape extends SimpleShape { * @param escherRecord EscherSpContainer container which holds information about this shape * @param parent the parent of the shape */ - protected TextShape(EscherContainerRecord escherRecord, ShapeContainer parent){ + protected HSLFTextShape(EscherContainerRecord escherRecord, ShapeContainer parent){ super(escherRecord, parent); } @@ -122,7 +122,7 @@ public abstract class TextShape extends SimpleShape { * @param parent the parent of this Shape. For example, if this text box is a cell * in a table then the parent is Table. */ - public TextShape(ShapeContainer parent){ + public HSLFTextShape(ShapeContainer parent){ super(null, parent); _escherContainer = createSpContainer(parent instanceof HSLFGroupShape); } @@ -131,15 +131,15 @@ public abstract class TextShape extends SimpleShape { * Create a new TextBox. This constructor is used when a new shape is created. * */ - public TextShape(){ + public HSLFTextShape(){ this(null); } - public TextRun createTextRun(){ + public HSLFTextParagraph createTextRun(){ _txtbox = getEscherTextboxWrapper(); if(_txtbox == null) _txtbox = new EscherTextboxWrapper(); - _txtrun = getTextRun(); + _txtrun = getTextParagraph(); if(_txtrun == null){ TextHeaderAtom tha = new TextHeaderAtom(); tha.setParentRecord(_txtbox); @@ -151,7 +151,7 @@ public abstract class TextShape extends SimpleShape { StyleTextPropAtom sta = new StyleTextPropAtom(0); _txtbox.appendChildRecord(sta); - _txtrun = new TextRun(tha,tca,sta); + _txtrun = new HSLFTextParagraph(tha,tca,sta); _txtrun._records = new Record[]{tha, tca, sta}; _txtrun.setText(""); @@ -170,7 +170,7 @@ public abstract class TextShape extends SimpleShape { * AutoShape: align=center, valign=middle * */ - protected void setDefaultTextProperties(TextRun _txtrun){ + protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){ } @@ -180,7 +180,7 @@ public abstract class TextShape extends SimpleShape { * @return the text string for this textbox. */ public String getText(){ - TextRun tx = getTextRun(); + HSLFTextParagraph tx = getTextParagraph(); return tx == null ? null : tx.getText(); } @@ -190,7 +190,7 @@ public abstract class TextShape extends SimpleShape { * @param text the text string used by this object. */ public void setText(String text){ - TextRun tx = getTextRun(); + HSLFTextParagraph tx = getTextParagraph(); if(tx == null){ tx = createTextRun(); } @@ -204,7 +204,7 @@ public abstract class TextShape extends SimpleShape { * * @param sh the sheet we are adding to */ - protected void afterInsert(Sheet sh){ + protected void afterInsert(HSLFSheet sh){ super.afterInsert(sh); EscherTextboxWrapper _txtbox = getEscherTextboxWrapper(); @@ -241,7 +241,7 @@ public abstract class TextShape extends SimpleShape { String txt = getText(); if(txt == null || txt.length() == 0) return new Rectangle2D.Float(); - RichTextRun rt = getTextRun().getRichTextRuns()[0]; + HSLFTextRun rt = getTextParagraph().getRichTextRuns()[0]; int size = rt.getFontSize(); int style = 0; if (rt.isBold()) style |= Font.BOLD; @@ -284,26 +284,26 @@ public abstract class TextShape extends SimpleShape { public int getVerticalAlignment(){ EscherOptRecord opt = getEscherOptRecord(); EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__ANCHORTEXT); - int valign = TextShape.AnchorTop; + int valign = HSLFTextShape.AnchorTop; if (prop == null){ /** * If vertical alignment was not found in the shape properties then try to * fetch the master shape and search for the align property there. */ - int type = getTextRun().getRunType(); - MasterSheet master = getSheet().getMasterSheet(); + int type = getTextParagraph().getRunType(); + HSLFMasterSheet master = getSheet().getMasterSheet(); if(master != null){ - TextShape masterShape = master.getPlaceholderByTextType(type); + HSLFTextShape masterShape = master.getPlaceholderByTextType(type); if(masterShape != null) valign = masterShape.getVerticalAlignment(); } else { //not found in the master sheet. Use the hardcoded defaults. switch (type){ case TextHeaderAtom.TITLE_TYPE: case TextHeaderAtom.CENTER_TITLE_TYPE: - valign = TextShape.AnchorMiddle; + valign = HSLFTextShape.AnchorMiddle; break; default: - valign = TextShape.AnchorTop; + valign = HSLFTextShape.AnchorTop; break; } } @@ -330,7 +330,7 @@ public abstract class TextShape extends SimpleShape { * @param align - the type of horizontal alignment */ public void setHorizontalAlignment(int align){ - TextRun tx = getTextRun(); + HSLFTextParagraph tx = getTextParagraph(); if(tx != null) tx.getRichTextRuns()[0].setAlignment(align); } @@ -341,7 +341,7 @@ public abstract class TextShape extends SimpleShape { * @return align - the type of horizontal alignment */ public int getHorizontalAlignment(){ - TextRun tx = getTextRun(); + HSLFTextParagraph tx = getTextParagraph(); return tx == null ? -1 : tx.getRichTextRuns()[0].getAlignment(); } @@ -487,7 +487,7 @@ public abstract class TextShape extends SimpleShape { /** * @return the TextRun object for this text box */ - public TextRun getTextRun(){ + public HSLFTextParagraph getTextParagraph(){ if (null == this._txtrun) initTextRun(); if (null == this._txtrun && null != this._txtbox) { TextHeaderAtom tha = null; @@ -507,36 +507,31 @@ public abstract class TextShape extends SimpleShape { } } if (tba != null) { - this._txtrun = new TextRun(tha, tba, sta); + this._txtrun = new HSLFTextParagraph(tha, tba, sta); } else if (tca != null) { - this._txtrun = new TextRun(tha, tca, sta); + this._txtrun = new HSLFTextParagraph(tha, tca, sta); } } return _txtrun; } - public void setSheet(Sheet sheet) { + public void setSheet(HSLFSheet sheet) { _sheet = sheet; // Initialize _txtrun object. // (We can't do it in the constructor because the sheet // is not assigned then, it's only built once we have // all the records) - TextRun tx = getTextRun(); + HSLFTextParagraph tx = getTextParagraph(); if (tx != null) { // Supply the sheet to our child RichTextRuns - tx.setSheet(_sheet); - RichTextRun[] rt = tx.getRichTextRuns(); - for (int i = 0; i < rt.length; i++) { - rt[i].supplySlideShow(_sheet.getSlideShow()); - } + tx.supplySheet(_sheet); } - } protected void initTextRun(){ EscherTextboxWrapper txtbox = getEscherTextboxWrapper(); - Sheet sheet = getSheet(); + HSLFSheet sheet = getSheet(); if(sheet == null || txtbox == null) return; @@ -550,7 +545,7 @@ public abstract class TextShape extends SimpleShape { } } - TextRun[] runs = _sheet.getTextRuns(); + HSLFTextParagraph[] runs = _sheet.getTextRuns(); if (ota != null) { int idx = ota.getTextIndex(); for (int i = 0; i < runs.length; i++) { @@ -572,11 +567,14 @@ public abstract class TextShape extends SimpleShape { } } } + // ensure the same references child records of TextRun - if(_txtrun != null) for (int i = 0; i < child.length; i++) { - for (Record r : _txtrun.getRecords()) { - if (child[i].getRecordType() == r.getRecordType()) { - child[i] = r; + if(_txtrun != null) { + for (int i = 0; i < child.length; i++) { + for (Record r : _txtrun.getRecords()) { + if (child[i].getRecordType() == r.getRecordType()) { + child[i] = r; + } } } } @@ -605,7 +603,7 @@ public abstract class TextShape extends SimpleShape { * @param linkId id of the hyperlink, @see org.apache.poi.hslf.usermodel.SlideShow#addHyperlink(Hyperlink) * @param beginIndex the beginning index, inclusive. * @param endIndex the ending index, exclusive. - * @see org.apache.poi.hslf.usermodel.SlideShow#addHyperlink(Hyperlink) + * @see org.apache.poi.hslf.usermodel.HSLFSlideShow#addHyperlink(Hyperlink) */ public void setHyperlink(int linkId, int beginIndex, int endIndex){ //TODO validate beginIndex and endIndex and throw IllegalArgumentException diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java b/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java index 8bb441e4e4..bd3a6da399 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HeadersFooters.java @@ -18,7 +18,7 @@ package org.apache.poi.hslf.model; import org.apache.poi.hslf.record.*; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; /** * Header / Footer settings. @@ -31,19 +31,19 @@ public final class HeadersFooters { private HeadersFootersContainer _container; private boolean _newRecord; - private SlideShow _ppt; - private Sheet _sheet; + private HSLFSlideShow _ppt; + private HSLFSheet _sheet; private boolean _ppt2007; - public HeadersFooters(HeadersFootersContainer rec, SlideShow ppt, boolean newRecord, boolean isPpt2007){ + public HeadersFooters(HeadersFootersContainer rec, HSLFSlideShow ppt, boolean newRecord, boolean isPpt2007){ _container = rec; _newRecord = newRecord; _ppt = ppt; _ppt2007 = isPpt2007; } - public HeadersFooters(HeadersFootersContainer rec, Sheet sheet, boolean newRecord, boolean isPpt2007){ + public HeadersFooters(HeadersFootersContainer rec, HSLFSheet sheet, boolean newRecord, boolean isPpt2007){ _container = rec; _newRecord = newRecord; _sheet = sheet; @@ -240,8 +240,8 @@ public final class HeadersFooters { private boolean isVisible(int flag, int placeholderId){ boolean visible; if(_ppt2007){ - Sheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0]; - TextShape placeholder = master.getPlaceholder(placeholderId); + HSLFSheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0]; + HSLFTextShape placeholder = master.getPlaceholder(placeholderId); visible = placeholder != null && placeholder.getText() != null; } else { visible = _container.getHeadersFootersAtom().getFlag(flag); @@ -252,8 +252,8 @@ public final class HeadersFooters { private String getPlaceholderText(int placeholderId, CString cs){ String text = null; if(_ppt2007){ - Sheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0]; - TextShape placeholder = master.getPlaceholder(placeholderId); + HSLFSheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0]; + HSLFTextShape placeholder = master.getPlaceholder(placeholderId); if(placeholder != null) text = placeholder.getText(); //default text in master placeholders is not visible diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java b/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java index df207e6716..2e1f1ec586 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Hyperlink.java @@ -18,7 +18,7 @@ package org.apache.poi.hslf.model; import org.apache.poi.hslf.record.*; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.ddf.EscherContainerRecord; import org.apache.poi.ddf.EscherRecord; import org.apache.poi.ddf.EscherClientDataRecord; @@ -95,7 +95,7 @@ public final class Hyperlink { return address; } - public void setAddress(Slide slide) { + public void setAddress(HSLFSlide slide) { String href = slide._getSheetNumber() + ","+slide.getSlideNumber()+",Slide " + slide.getSlideNumber(); setAddress(href);; setTitle("Slide " + slide.getSlideNumber()); @@ -151,9 +151,9 @@ public final class Hyperlink { * @param run TextRun to lookup hyperlinks in * @return found hyperlinks or null if not found */ - protected static Hyperlink[] find(TextRun run){ + protected static Hyperlink[] find(HSLFTextParagraph run){ List lst = new ArrayList(); - SlideShow ppt = run.getSheet().getSlideShow(); + HSLFSlideShow ppt = run.getSheet().getSlideShow(); //document-level container which stores info about all links in a presentation ExObjList exobj = ppt.getDocumentRecord().getExObjList(); if (exobj == null) { @@ -178,7 +178,7 @@ public final class Hyperlink { */ protected static Hyperlink find(HSLFShape shape){ List lst = new ArrayList(); - SlideShow ppt = shape.getSheet().getSlideShow(); + HSLFSlideShow ppt = shape.getSheet().getSlideShow(); //document-level container which stores info about all links in a presentation ExObjList exobj = ppt.getDocumentRecord().getExObjList(); if (exobj == null) { diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Line.java b/src/scratchpad/src/org/apache/poi/hslf/model/Line.java index e811aeb6bf..b2e0b35884 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Line.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Line.java @@ -29,74 +29,7 @@ import java.awt.geom.Line2D; * * @author Yegor Kozlov */ -public final class Line extends SimpleShape { - /** - * Solid (continuous) pen - */ - public static final int PEN_SOLID = 1; - /** - * PS_DASH system dash style - */ - public static final int PEN_PS_DASH = 2; - /** - * PS_DOT system dash style - */ - public static final int PEN_DOT = 3; - /** - * PS_DASHDOT system dash style - */ - public static final int PEN_DASHDOT = 4; - /** - * PS_DASHDOTDOT system dash style - */ - public static final int PEN_DASHDOTDOT = 5; - /** - * square dot style - */ - public static final int PEN_DOTGEL = 6; - /** - * dash style - */ - public static final int PEN_DASH = 7; - /** - * long dash style - */ - public static final int PEN_LONGDASHGEL = 8; - /** - * dash short dash - */ - public static final int PEN_DASHDOTGEL = 9; - /** - * long dash short dash - */ - public static final int PEN_LONGDASHDOTGEL = 10; - /** - * long dash short dash short dash - */ - public static final int PEN_LONGDASHDOTDOTGEL = 11; - - /** - * Single line (of width lineWidth) - */ - public static final int LINE_SIMPLE = 0; - /** - * Double lines of equal width - */ - public static final int LINE_DOUBLE = 1; - /** - * Double lines, one thick, one thin - */ - public static final int LINE_THICKTHIN = 2; - /** - * Double lines, reverse order - */ - public static final int LINE_THINTHICK = 3; - /** - * Three lines, thin, thick, thin - */ - public static final int LINE_TRIPLE = 4; - - +public final class Line extends HSLFSimpleShape { protected Line(EscherContainerRecord escherRecord, ShapeContainer parent){ super(escherRecord, parent); } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java index 834dc870e4..e366fdbe92 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java @@ -24,7 +24,7 @@ import org.apache.poi.ddf.EscherContainerRecord; import org.apache.poi.ddf.EscherProperties; import org.apache.poi.hslf.exceptions.HSLFException; import org.apache.poi.hslf.record.*; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.sl.usermodel.ShapeContainer; /** @@ -32,7 +32,7 @@ import org.apache.poi.sl.usermodel.ShapeContainer; * * @author Yegor Kozlov */ -public final class MovieShape extends Picture { +public final class MovieShape extends HSLFPictureShape { public static final int DEFAULT_MOVIE_THUMBNAIL = -1; public static final int MOVIE_MPEG = 1; @@ -113,7 +113,7 @@ public final class MovieShape extends Picture { /** * Assign a movie to this shape * - * @see org.apache.poi.hslf.usermodel.SlideShow#addMovie(String, int) + * @see org.apache.poi.hslf.usermodel.HSLFSlideShow#addMovie(String, int) * @param idx the index of the movie */ public void setMovieIndex(int idx){ @@ -154,7 +154,7 @@ public final class MovieShape extends Picture { OEShapeAtom oe = getClientDataRecord(RecordTypes.OEShapeAtom.typeID); int idx = oe.getOptions(); - SlideShow ppt = getSheet().getSlideShow(); + HSLFSlideShow ppt = getSheet().getSlideShow(); ExObjList lst = (ExObjList)ppt.getDocumentRecord().findFirstOfType(RecordTypes.ExObjList.typeID); if(lst == null) return null; diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java index a1e9c94e08..49ed8c2073 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java @@ -18,8 +18,8 @@ package org.apache.poi.hslf.model; import org.apache.poi.ddf.*; -import org.apache.poi.hslf.usermodel.SlideShow; -import org.apache.poi.hslf.usermodel.ObjectData; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; +import org.apache.poi.hslf.usermodel.HSLFObjectData; import org.apache.poi.hslf.record.ExObjList; import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.ExEmbed; @@ -34,7 +34,7 @@ import org.apache.poi.util.POILogger; * * @author Yegor Kozlov */ -public final class OLEShape extends Picture { +public final class OLEShape extends HSLFPictureShape { protected ExEmbed _exEmbed; /** @@ -117,13 +117,13 @@ public final class OLEShape extends Picture { * * @return the unique identifier for the OLE object */ - public ObjectData getObjectData(){ - SlideShow ppt = getSheet().getSlideShow(); - ObjectData[] ole = ppt.getEmbeddedObjects(); + public HSLFObjectData getObjectData(){ + HSLFSlideShow ppt = getSheet().getSlideShow(); + HSLFObjectData[] ole = ppt.getEmbeddedObjects(); //persist reference ExEmbed exEmbed = getExEmbed(); - ObjectData data = null; + HSLFObjectData data = null; if(exEmbed != null) { int ref = exEmbed.getExOleObjAtom().getObjStgDataRef(); @@ -156,7 +156,7 @@ public final class OLEShape extends Picture { */ public ExEmbed getExEmbed(){ if(_exEmbed == null){ - SlideShow ppt = getSheet().getSlideShow(); + HSLFSlideShow ppt = getSheet().getSlideShow(); ExObjList lst = ppt.getDocumentRecord().getExObjList(); if(lst == null){ diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java b/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java index f775addac3..47500df2f6 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java @@ -28,7 +28,7 @@ import java.awt.image.renderable.RenderableImage; import java.awt.geom.*; import java.text.AttributedCharacterIterator; import java.util.Map; -import org.apache.poi.hslf.usermodel.RichTextRun; +import org.apache.poi.hslf.usermodel.HSLFTextRun; import org.apache.poi.hslf.exceptions.HSLFException; import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogFactory; @@ -214,7 +214,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable { */ public void draw(Shape shape){ GeneralPath path = new GeneralPath(_transform.createTransformedShape(shape)); - Freeform p = new Freeform(_group); + HSLFFreeformShape p = new HSLFFreeformShape(_group); p.setPath(path); p.getFill().setForegroundColor(null); applyStroke(p); @@ -250,12 +250,11 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable { * @see #setClip */ public void drawString(String s, float x, float y) { - TextBox txt = new TextBox(_group); - txt.getTextRun().supplySlideShow(_group.getSheet().getSlideShow()); - txt.getTextRun().setSheet(_group.getSheet()); + HSLFTextBox txt = new HSLFTextBox(_group); + txt.getTextParagraph().supplySheet(_group.getSheet()); txt.setText(s); - RichTextRun rt = txt.getTextRun().getRichTextRuns()[0]; + HSLFTextRun rt = txt.getTextParagraph().getRichTextRuns()[0]; rt.setFontSize(_font.getSize()); rt.setFontName(_font.getFamily()); @@ -267,9 +266,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable { txt.setMarginTop(0); txt.setMarginLeft(0); txt.setMarginRight(0); - txt.setWordWrap(TextBox.WrapNone); - txt.setHorizontalAlignment(TextBox.AlignLeft); - txt.setVerticalAlignment(TextBox.AnchorMiddle); + txt.setWordWrap(HSLFTextBox.WrapNone); + txt.setHorizontalAlignment(HSLFTextBox.AlignLeft); + txt.setVerticalAlignment(HSLFTextBox.AnchorMiddle); TextLayout layout = new TextLayout(s, _font, getFontRenderContext()); @@ -317,7 +316,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable { */ public void fill(Shape shape){ GeneralPath path = new GeneralPath(_transform.createTransformedShape(shape)); - Freeform p = new Freeform(_group); + HSLFFreeformShape p = new HSLFFreeformShape(_group); p.setPath(path); applyPaint(p); p.setLineColor(null); //Fills must be "No Line" @@ -1788,7 +1787,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable { } } - protected void applyStroke(SimpleShape shape) { + protected void applyStroke(HSLFSimpleShape shape) { if (_stroke instanceof BasicStroke){ BasicStroke bs = (BasicStroke)_stroke; shape.setLineWidth(bs.getLineWidth()); @@ -1800,7 +1799,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable { } } - protected void applyPaint(SimpleShape shape) { + protected void applyPaint(HSLFSimpleShape shape) { if (_paint instanceof Color) { shape.getFill().setForegroundColor((Color)_paint); } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java b/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java index 0e6052e969..470f6a4204 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java @@ -29,7 +29,7 @@ import java.io.ByteArrayOutputStream; * * @author Yegor Kozlov */ -public final class Placeholder extends TextBox { +public final class Placeholder extends HSLFTextBox { protected Placeholder(EscherContainerRecord escherRecord, ShapeContainer parent){ super(escherRecord, parent); diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java b/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java index 2d67c03fdc..7bfd95a571 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java @@ -29,7 +29,7 @@ import java.awt.geom.Point2D; * * @author Yegor Kozlov */ -public final class Polygon extends AutoShape { +public final class Polygon extends HSLFAutoShape { /** * Create a Polygon object and initialize it from the supplied Record container. * diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java b/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java index 01ac53855c..d21cf9dd2b 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java @@ -89,7 +89,7 @@ public final class ShapeFactory { ShapeType type = ShapeType.forId(spRecord.getShapeType(), false); switch (type){ case TEXT_BOX: - shape = new TextBox(spContainer, parent); + shape = new HSLFTextBox(spContainer, parent); break; case HOST_CONTROL: case FRAME: { @@ -110,7 +110,7 @@ public final class ShapeFactory { shape = new OLEShape(spContainer, parent); } - if(shape == null) shape = new Picture(spContainer, parent); + if(shape == null) shape = new HSLFPictureShape(spContainer, parent); break; } case LINE: @@ -120,16 +120,16 @@ public final class ShapeFactory { EscherOptRecord opt = HSLFShape.getEscherChild(spContainer, EscherOptRecord.RECORD_ID); EscherProperty prop = HSLFShape.getEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES); if(prop != null) - shape = new Freeform(spContainer, parent); + shape = new HSLFFreeformShape(spContainer, parent); else { logger.log(POILogger.WARN, "Creating AutoShape for a NotPrimitive shape"); - shape = new AutoShape(spContainer, parent); + shape = new HSLFAutoShape(spContainer, parent); } break; } default: - shape = new AutoShape(spContainer, parent); + shape = new HSLFAutoShape(spContainer, parent); break; } return shape; diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java b/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java index c9954a8dee..e9686a6120 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/ShapePainter.java @@ -35,7 +35,7 @@ import org.apache.poi.util.POILogger; public final class ShapePainter { protected static final POILogger logger = POILogFactory.getLogger(ShapePainter.class); - public static void paint(SimpleShape shape, Graphics2D graphics){ + public static void paint(HSLFSimpleShape shape, Graphics2D graphics){ Rectangle2D anchor = shape.getLogicalAnchor2D(); java.awt.Shape outline = shape.getOutline(); diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java b/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java index a103d09c77..859ceebb42 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java @@ -20,7 +20,7 @@ package org.apache.poi.hslf.model; import org.apache.poi.hslf.model.textproperties.TextProp; import org.apache.poi.hslf.model.textproperties.TextPropCollection; import org.apache.poi.hslf.record.*; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; /** * SlideMaster determines the graphics, layout, and formatting for all the slides in a given presentation. @@ -29,8 +29,8 @@ import org.apache.poi.hslf.usermodel.SlideShow; * * @author Yegor Kozlov */ -public final class SlideMaster extends MasterSheet { - private TextRun[] _runs; +public final class SlideMaster extends HSLFMasterSheet { + private HSLFTextParagraph[] _runs; /** * all TxMasterStyleAtoms available in this master @@ -51,14 +51,14 @@ public final class SlideMaster extends MasterSheet { /** * Returns an array of all the TextRuns found */ - public TextRun[] getTextRuns() { + public HSLFTextParagraph[] getTextRuns() { return _runs; } /** * Returns null since SlideMasters doen't have master sheet. */ - public MasterSheet getMasterSheet() { + public HSLFMasterSheet getMasterSheet() { return null; } @@ -112,7 +112,7 @@ public final class SlideMaster extends MasterSheet { * Assign SlideShow for this slide master. * (Used interanlly) */ - public void setSlideShow(SlideShow ss) { + public void setSlideShow(HSLFSlideShow ss) { super.setSlideShow(ss); //after the slide show is assigned collect all available style records @@ -130,12 +130,12 @@ public final class SlideMaster extends MasterSheet { } } - protected void onAddTextShape(TextShape shape) { - TextRun run = shape.getTextRun(); + protected void onAddTextShape(HSLFTextShape shape) { + HSLFTextParagraph run = shape.getTextParagraph(); - if(_runs == null) _runs = new TextRun[]{run}; + if(_runs == null) _runs = new HSLFTextParagraph[]{run}; else { - TextRun[] tmp = new TextRun[_runs.length + 1]; + HSLFTextParagraph[] tmp = new HSLFTextParagraph[_runs.length + 1]; System.arraycopy(_runs, 0, tmp, 0, _runs.length); tmp[tmp.length-1] = run; _runs = tmp; diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Table.java b/src/scratchpad/src/org/apache/poi/hslf/model/Table.java index f94bd7f5b6..99ee13f211 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Table.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Table.java @@ -115,7 +115,7 @@ public final class Table extends HSLFGroupShape { return cells.length; } - protected void afterInsert(Sheet sh){ + protected void afterInsert(HSLFSheet sh){ super.afterInsert(sh); EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0); @@ -165,7 +165,7 @@ public final class Table extends HSLFGroupShape { List> lst = new ArrayList>(); List row = null; for (HSLFShape sh : shapeList) { - if(sh instanceof TextShape){ + if(sh instanceof HSLFTextShape){ Rectangle anchor = sh.getAnchor(); if(anchor.y != y0){ y0 = anchor.y; @@ -180,7 +180,7 @@ public final class Table extends HSLFGroupShape { for (int i = 0; i < lst.size(); i++) { row = lst.get(i); for (int j = 0; j < row.size(); j++) { - TextShape tx = (TextShape)row.get(j); + HSLFTextShape tx = (HSLFTextShape)row.get(j); cells[i][j] = new TableCell(tx.getSpContainer(), getParent()); cells[i][j].setSheet(tx.getSheet()); } @@ -192,7 +192,7 @@ public final class Table extends HSLFGroupShape { * * @param sheet owner of this shape */ - public void setSheet(Sheet sheet){ + public void setSheet(HSLFSheet sheet){ super.setSheet(sheet); if(cells == null) initTable(); } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java b/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java index 715181cfad..18431a720c 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/TableCell.java @@ -30,7 +30,7 @@ import org.apache.poi.sl.usermodel.ShapeType; * * @author Yegor Kozlov */ -public final class TableCell extends TextBox { +public final class TableCell extends HSLFTextBox { protected static final int DEFAULT_WIDTH = 100; protected static final int DEFAULT_HEIGHT = 40; diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java b/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java index 4b8805c266..038e28a04d 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java @@ -35,7 +35,7 @@ import java.util.List; import java.util.Map; import org.apache.poi.hslf.record.TextRulerAtom; -import org.apache.poi.hslf.usermodel.RichTextRun; +import org.apache.poi.hslf.usermodel.HSLFTextRun; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; @@ -57,27 +57,27 @@ public final class TextPainter { */ protected static final char DEFAULT_BULLET_CHAR = '\u25a0'; - protected TextShape _shape; + protected HSLFTextShape _shape; - public TextPainter(TextShape shape){ + public TextPainter(HSLFTextShape shape){ _shape = shape; } - public AttributedString getAttributedString(TextRun txrun) { + public AttributedString getAttributedString(HSLFTextParagraph txrun) { return getAttributedString(txrun, null); } /** * Convert the underlying set of rich text runs into java.text.AttributedString */ - public AttributedString getAttributedString(TextRun txrun, Graphics2D graphics){ + public AttributedString getAttributedString(HSLFTextParagraph txrun, Graphics2D graphics){ String text = txrun.getText(); //TODO: properly process tabs text = text.replace('\t', ' '); text = text.replace((char)160, ' '); AttributedString at = new AttributedString(text); - RichTextRun[] rt = txrun.getRichTextRuns(); + HSLFTextRun[] rt = txrun.getRichTextRuns(); for (int i = 0; i < rt.length; i++) { int start = rt[i].getStartIndex(); int end = rt[i].getEndIndex(); @@ -157,15 +157,15 @@ public final class TextPainter { int valign = _shape.getVerticalAlignment(); double y0 = anchor.getY(); switch (valign){ - case TextShape.AnchorTopBaseline: - case TextShape.AnchorTop: + case HSLFTextShape.AnchorTopBaseline: + case HSLFTextShape.AnchorTop: y0 += _shape.getMarginTop(); break; - case TextShape.AnchorBottom: + case HSLFTextShape.AnchorBottom: y0 += anchor.getHeight() - textHeight - _shape.getMarginBottom(); break; default: - case TextShape.AnchorMiddle: + case HSLFTextShape.AnchorMiddle: float delta = (float)anchor.getHeight() - textHeight - _shape.getMarginTop() - _shape.getMarginBottom(); y0 += _shape.getMarginTop() + delta/2; break; @@ -205,14 +205,14 @@ public final class TextPainter { pen.y = y0; switch (elem[i]._align) { default: - case TextShape.AlignLeft: + case HSLFTextShape.AlignLeft: pen.x = anchor.getX() + _shape.getMarginLeft(); break; - case TextShape.AlignCenter: + case HSLFTextShape.AlignCenter: pen.x = anchor.getX() + _shape.getMarginLeft() + (anchor.getWidth() - elem[i].advance - _shape.getMarginLeft() - _shape.getMarginRight()) / 2; break; - case TextShape.AlignRight: + case HSLFTextShape.AlignRight: pen.x = anchor.getX() + _shape.getMarginLeft() + (anchor.getWidth() - elem[i].advance - _shape.getMarginLeft() - _shape.getMarginRight()); break; @@ -235,7 +235,7 @@ public final class TextPainter { } public TextElement[] getTextElements(float textWidth, FontRenderContext frc, Graphics2D graphics){ - TextRun run = _shape.getTextRun(); + HSLFTextParagraph run = _shape.getTextParagraph(); if (run == null) return null; String text = run.getText(); @@ -257,7 +257,7 @@ public final class TextPainter { boolean prStart = text.charAt(startIndex) == '\n'; if(prStart) measurer.setPosition(startIndex++); - RichTextRun rt = run.getRichTextRunAt(startIndex == text.length() ? (startIndex-1) : startIndex); + HSLFTextRun rt = run.getRichTextRunAt(startIndex == text.length() ? (startIndex-1) : startIndex); if(rt == null) { logger.log(POILogger.WARN, "RichTextRun not found at pos" + startIndex + "; text.length: " + text.length()); break; @@ -283,7 +283,7 @@ public final class TextPainter { if(bulletOffset > 0 || prStart || startIndex == 0) wrappingWidth -= textOffset; - if (_shape.getWordWrap() == TextShape.WrapNone) { + if (_shape.getWordWrap() == HSLFTextShape.WrapNone) { wrappingWidth = _shape.getSheet().getSlideShow().getPageSize().width; } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TitleMaster.java b/src/scratchpad/src/org/apache/poi/hslf/model/TitleMaster.java index 843f123890..8184c030fa 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TitleMaster.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/TitleMaster.java @@ -25,8 +25,8 @@ import org.apache.poi.hslf.record.*; * * @author Yegor Kozlov */ -public final class TitleMaster extends MasterSheet { - private TextRun[] _runs; +public final class TitleMaster extends HSLFMasterSheet { + private HSLFTextParagraph[] _runs; /** * Constructs a TitleMaster @@ -42,7 +42,7 @@ public final class TitleMaster extends MasterSheet { /** * Returns an array of all the TextRuns found */ - public TextRun[] getTextRuns() { + public HSLFTextParagraph[] getTextRuns() { return _runs; } @@ -50,14 +50,14 @@ public final class TitleMaster extends MasterSheet { * Delegate the call to the underlying slide master. */ public TextProp getStyleAttribute(int txtype, int level, String name, boolean isCharacter) { - MasterSheet master = getMasterSheet(); + HSLFMasterSheet master = getMasterSheet(); return master == null ? null : master.getStyleAttribute(txtype, level, name, isCharacter); } /** * Returns the slide master for this title master. */ - public MasterSheet getMasterSheet(){ + public HSLFMasterSheet getMasterSheet(){ SlideMaster[] master = getSlideShow().getSlidesMasters(); SlideAtom sa = ((org.apache.poi.hslf.record.Slide)getSheetContainer()).getSlideAtom(); int masterId = sa.getMasterID(); diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java similarity index 96% rename from src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java rename to src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java index bbef87a96c..f02ddbe785 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFObjectData.java @@ -26,7 +26,7 @@ import org.apache.poi.hslf.record.ExOleObjStg; * * @author Daniel Noll */ -public class ObjectData { +public class HSLFObjectData { /** * The record that contains the object data. */ @@ -37,7 +37,7 @@ public class ObjectData { * * @param storage the record that contains the object data. */ - public ObjectData(ExOleObjStg storage) { + public HSLFObjectData(ExOleObjStg storage) { this.storage = storage; } diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java similarity index 88% rename from src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java rename to src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java index 857ad5451e..9d9b0dc594 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java @@ -30,7 +30,7 @@ import org.apache.poi.hslf.blip.JPEG; import org.apache.poi.hslf.blip.PICT; import org.apache.poi.hslf.blip.PNG; import org.apache.poi.hslf.blip.WMF; -import org.apache.poi.hslf.model.Picture; +import org.apache.poi.hslf.model.HSLFPictureShape; import org.apache.poi.poifs.crypt.CryptoFunctions; import org.apache.poi.poifs.crypt.HashAlgorithm; import org.apache.poi.util.LittleEndian; @@ -42,7 +42,7 @@ import org.apache.poi.util.POILogger; * * @author Yegor Kozlov */ -public abstract class PictureData { +public abstract class HSLFPictureData { protected POILogger logger = POILogFactory.getLogger(this.getClass()); @@ -68,6 +68,14 @@ public abstract class PictureData { */ public abstract int getType(); + + /** + * Returns content type (mime type) of this picture. + * + * @return content type of this picture. + */ + public abstract String getContentType(); + /** * Returns the binary data of this Picture * @return picture data @@ -86,9 +94,9 @@ public abstract class PictureData { protected static final ImagePainter[] painters = new ImagePainter[8]; static { - PictureData.setImagePainter(Picture.PNG, new BitmapPainter()); - PictureData.setImagePainter(Picture.JPEG, new BitmapPainter()); - PictureData.setImagePainter(Picture.DIB, new BitmapPainter()); + HSLFPictureData.setImagePainter(HSLFPictureShape.PNG, new BitmapPainter()); + HSLFPictureData.setImagePainter(HSLFPictureShape.JPEG, new BitmapPainter()); + HSLFPictureData.setImagePainter(HSLFPictureShape.DIB, new BitmapPainter()); } /** @@ -173,25 +181,25 @@ public abstract class PictureData { * Must be one of the static constants defined in the Picture class. * @return concrete instance of PictureData */ - public static PictureData create(int type){ - PictureData pict; + public static HSLFPictureData create(int type){ + HSLFPictureData pict; switch (type){ - case Picture.EMF: + case HSLFPictureShape.EMF: pict = new EMF(); break; - case Picture.WMF: + case HSLFPictureShape.WMF: pict = new WMF(); break; - case Picture.PICT: + case HSLFPictureShape.PICT: pict = new PICT(); break; - case Picture.JPEG: + case HSLFPictureShape.JPEG: pict = new JPEG(); break; - case Picture.PNG: + case HSLFPictureShape.PNG: pict = new PNG(); break; - case Picture.DIB: + case HSLFPictureShape.DIB: pict = new DIB(); break; default: @@ -227,7 +235,7 @@ public abstract class PictureData { return getData().length; } - public void draw(Graphics2D graphics, Picture parent){ + public void draw(Graphics2D graphics, HSLFPictureShape parent){ ImagePainter painter = painters[getType()]; if(painter != null) painter.paint(graphics, this, parent); else logger.log(POILogger.WARN, "Rendering is not supported: " + getClass().getName()); diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java similarity index 94% rename from src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java rename to src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java index d6829b4b4e..1f9f6ca027 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java @@ -37,19 +37,9 @@ import org.apache.poi.ddf.EscherContainerRecord; import org.apache.poi.ddf.EscherOptRecord; import org.apache.poi.ddf.EscherRecord; import org.apache.poi.hpsf.ClassID; -import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException; import org.apache.poi.hslf.exceptions.HSLFException; -import org.apache.poi.hslf.model.HeadersFooters; -import org.apache.poi.hslf.model.Hyperlink; -import org.apache.poi.hslf.model.MovieShape; -import org.apache.poi.hslf.model.Notes; -import org.apache.poi.hslf.model.PPFont; -import org.apache.poi.hslf.model.Picture; -import org.apache.poi.hslf.model.HSLFShape; -import org.apache.poi.hslf.model.Slide; -import org.apache.poi.hslf.model.SlideMaster; -import org.apache.poi.hslf.model.TitleMaster; +import org.apache.poi.hslf.model.*; import org.apache.poi.hslf.record.Document; import org.apache.poi.hslf.record.DocumentAtom; import org.apache.poi.hslf.record.ExAviMovie; @@ -79,6 +69,7 @@ import org.apache.poi.hslf.record.SlidePersistAtom; import org.apache.poi.hslf.record.UserEditAtom; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.apache.poi.sl.usermodel.SlideShow; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; @@ -91,9 +82,9 @@ import org.apache.poi.util.POILogger; * @author Nick Burch * @author Yegor kozlov */ -public final class SlideShow { +public final class HSLFSlideShow implements SlideShow { // What we're based on - private HSLFSlideShow _hslfSlideShow; + private HSLFSlideShowImpl _hslfSlideShow; // Pointers to the most recent versions of the core records // (Document, Notes, Slide etc) @@ -108,8 +99,8 @@ public final class SlideShow { // Friendly objects for people to deal with private SlideMaster[] _masters; private TitleMaster[] _titleMasters; - private Slide[] _slides; - private Notes[] _notes; + private HSLFSlide[] _slides; + private HSLFNotes[] _notes; private FontCollection _fonts; // For logging @@ -128,7 +119,7 @@ public final class SlideShow { * * @param hslfSlideShow the HSLFSlideShow to base on */ - public SlideShow(HSLFSlideShow hslfSlideShow) { + public HSLFSlideShow(HSLFSlideShowImpl hslfSlideShow) { // Get useful things from our base slideshow _hslfSlideShow = hslfSlideShow; @@ -149,15 +140,15 @@ public final class SlideShow { /** * Constructs a new, empty, Powerpoint document. */ - public SlideShow() { - this(HSLFSlideShow.create()); + public HSLFSlideShow() { + this(HSLFSlideShowImpl.create()); } /** * Constructs a Powerpoint document from an input stream. */ - public SlideShow(InputStream inputStream) throws IOException { - this(new HSLFSlideShow(inputStream)); + public HSLFSlideShow(InputStream inputStream) throws IOException { + this(new HSLFSlideShowImpl(inputStream)); } /** @@ -417,21 +408,21 @@ public final class SlideShow { // Finally, generate model objects for everything // Notes first - _notes = new Notes[notesRecords.length]; + _notes = new HSLFNotes[notesRecords.length]; for (int i = 0; i < _notes.length; i++) { if (notesRecords[i] != null) { - _notes[i] = new Notes(notesRecords[i]); + _notes[i] = new HSLFNotes(notesRecords[i]); _notes[i].setSlideShow(this); } } // Then slides - _slides = new Slide[slidesRecords.length]; + _slides = new HSLFSlide[slidesRecords.length]; for (int i = 0; i < _slides.length; i++) { SlideAtomsSet sas = slidesSets[i]; int slideIdentifier = sas.getSlidePersistAtom().getSlideIdentifier(); // Do we have a notes for this? - Notes notes = null; + HSLFNotes notes = null; // Slide.SlideAtom.notesId references the corresponding notes slide. // 0 if slide has no notes. int noteId = slidesRecords[i].getSlideAtom().getNotesID(); @@ -445,7 +436,7 @@ public final class SlideShow { } // Now, build our slide - _slides[i] = new Slide(slidesRecords[i], notes, sas, slideIdentifier, (i + 1)); + _slides[i] = new HSLFSlide(slidesRecords[i], notes, sas, slideIdentifier, (i + 1)); _slides[i].setSlideShow(this); } } @@ -481,14 +472,14 @@ public final class SlideShow { /** * Returns an array of all the normal Slides found in the slideshow */ - public Slide[] getSlides() { + public HSLFSlide[] getSlides() { return _slides; } /** * Returns an array of all the normal Notes found in the slideshow */ - public Notes[] getNotes() { + public HSLFNotes[] getNotes() { return _notes; } @@ -509,22 +500,22 @@ public final class SlideShow { /** * Returns the data of all the pictures attached to the SlideShow */ - public PictureData[] getPictureData() { + public HSLFPictureData[] getPictureData() { return _hslfSlideShow.getPictures(); } /** * Returns the data of all the embedded OLE object in the SlideShow */ - public ObjectData[] getEmbeddedObjects() { + public HSLFObjectData[] getEmbeddedObjects() { return _hslfSlideShow.getEmbeddedObjects(); } /** * Returns the data of all the embedded sounds in the SlideShow */ - public SoundData[] getSoundData() { - return SoundData.find(_documentRecord); + public HSLFSoundData[] getSoundData() { + return HSLFSoundData.find(_documentRecord); } /** @@ -621,7 +612,7 @@ public final class SlideShow { * the index of the slide to remove (0-based) * @return the slide that was removed from the slide show. */ - public Slide removeSlide(int index) { + public HSLFSlide removeSlide(int index) { int lastSlideIdx = _slides.length - 1; if (index < 0 || index > lastSlideIdx) { throw new IllegalArgumentException("Slide index (" + index + ") is out of range (0.." @@ -631,13 +622,13 @@ public final class SlideShow { SlideListWithText slwt = _documentRecord.getSlideSlideListWithText(); SlideAtomsSet[] sas = slwt.getSlideAtomsSets(); - Slide removedSlide = null; + HSLFSlide removedSlide = null; ArrayList records = new ArrayList(); ArrayList sa = new ArrayList(); - ArrayList sl = new ArrayList(); + ArrayList sl = new ArrayList(); - ArrayList nt = new ArrayList(); - for (Notes notes : getNotes()) + ArrayList nt = new ArrayList(); + for (HSLFNotes notes : getNotes()) nt.add(notes); for (int i = 0, num = 0; i < _slides.length; i++) { @@ -658,7 +649,7 @@ public final class SlideShow { slwt.setSlideAtomsSets(sa.toArray(new SlideAtomsSet[sa.size()])); slwt.setChildRecord(records.toArray(new Record[records.size()])); } - _slides = sl.toArray(new Slide[sl.size()]); + _slides = sl.toArray(new HSLFSlide[sl.size()]); // if the removed slide had notes - remove references to them too @@ -685,7 +676,7 @@ public final class SlideShow { } } - _notes = nt.toArray(new Notes[nt.size()]); + _notes = nt.toArray(new HSLFNotes[nt.size()]); return removedSlide; } @@ -701,7 +692,7 @@ public final class SlideShow { * * @return the created Slide */ - public Slide createSlide() { + public HSLFSlide createSlide() { SlideListWithText slist = null; // We need to add the records to the SLWT that deals @@ -745,12 +736,12 @@ public final class SlideShow { slist.addSlidePersistAtom(sp); // Create a new Slide - Slide slide = new Slide(sp.getSlideIdentifier(), sp.getRefID(), _slides.length + 1); + HSLFSlide slide = new HSLFSlide(sp.getSlideIdentifier(), sp.getRefID(), _slides.length + 1); slide.setSlideShow(this); slide.onCreate(); // Add in to the list of Slides - Slide[] s = new Slide[_slides.length + 1]; + HSLFSlide[] s = new HSLFSlide[_slides.length + 1]; System.arraycopy(_slides, 0, s, 0, _slides.length); s[_slides.length] = slide; _slides = s; @@ -779,7 +770,7 @@ public final class SlideShow { * @return the index to this picture (1 based). */ public int addPicture(byte[] data, int format) throws IOException { - byte[] uid = PictureData.getChecksum(data); + byte[] uid = HSLFPictureData.getChecksum(data); EscherContainerRecord bstore; @@ -801,7 +792,7 @@ public final class SlideShow { } } - PictureData pict = PictureData.create(format); + HSLFPictureData pict = HSLFPictureData.create(format); pict.setData(data); int offset = _hslfSlideShow.addPicture(pict); @@ -815,12 +806,12 @@ public final class SlideShow { bse.setBlipTypeMacOS((byte) format); bse.setBlipTypeWin32((byte) format); - if (format == Picture.EMF) - bse.setBlipTypeMacOS((byte) Picture.PICT); - else if (format == Picture.WMF) - bse.setBlipTypeMacOS((byte) Picture.PICT); - else if (format == Picture.PICT) - bse.setBlipTypeWin32((byte) Picture.WMF); + if (format == HSLFPictureShape.EMF) + bse.setBlipTypeMacOS((byte) HSLFPictureShape.PICT); + else if (format == HSLFPictureShape.WMF) + bse.setBlipTypeMacOS((byte) HSLFPictureShape.PICT); + else if (format == HSLFPictureShape.PICT) + bse.setBlipTypeWin32((byte) HSLFPictureShape.WMF); bse.setRef(0); bse.setOffset(offset); @@ -1134,7 +1125,7 @@ public final class SlideShow { } protected int addPersistentObject(PositionDependentRecord slideRecord) { - slideRecord.setLastOnDiskOffset(HSLFSlideShow.UNSET_OFFSET); + slideRecord.setLastOnDiskOffset(HSLFSlideShowImpl.UNSET_OFFSET); _hslfSlideShow.appendRootLevelRecord((Record)slideRecord); // For position dependent records, hold where they were and now are diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SoundData.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSoundData.java similarity index 89% rename from src/scratchpad/src/org/apache/poi/hslf/usermodel/SoundData.java rename to src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSoundData.java index 9fd85e1bdb..7750b25f15 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/SoundData.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSoundData.java @@ -26,7 +26,7 @@ import java.util.ArrayList; * * @author Yegor Kozlov */ -public final class SoundData { +public final class HSLFSoundData { /** * The record that contains the object data. */ @@ -37,7 +37,7 @@ public final class SoundData { * * @param container the record that contains the sound data. */ - public SoundData(Sound container) { + public HSLFSoundData(Sound container) { this._container = container; } @@ -74,8 +74,8 @@ public final class SoundData { * @param document the document to find in * @return the array with the sound data */ - public static SoundData[] find(Document document){ - ArrayList lst = new ArrayList(); + public static HSLFSoundData[] find(Document document){ + ArrayList lst = new ArrayList(); Record[] ch = document.getChildRecords(); for (int i = 0; i < ch.length; i++) { if(ch[i].getRecordType() == RecordTypes.SoundCollection.typeID){ @@ -83,12 +83,12 @@ public final class SoundData { Record[] sr = col.getChildRecords(); for (int j = 0; j < sr.length; j++) { if(sr[j] instanceof Sound){ - lst.add(new SoundData((Sound)sr[j])); + lst.add(new HSLFSoundData((Sound)sr[j])); } } } } - return lst.toArray(new SoundData[lst.size()]); + return lst.toArray(new HSLFSoundData[lst.size()]); } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java similarity index 90% rename from src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java rename to src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java index 878f8c12eb..06980e9ff5 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java @@ -19,16 +19,14 @@ package org.apache.poi.hslf.usermodel; import java.awt.Color; -import org.apache.poi.hslf.model.MasterSheet; -import org.apache.poi.hslf.model.HSLFShape; -import org.apache.poi.hslf.model.Sheet; -import org.apache.poi.hslf.model.TextRun; +import org.apache.poi.hslf.model.*; import org.apache.poi.hslf.model.textproperties.BitMaskTextProp; import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp; import org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp; import org.apache.poi.hslf.model.textproperties.TextProp; import org.apache.poi.hslf.model.textproperties.TextPropCollection; import org.apache.poi.hslf.record.ColorSchemeAtom; +import org.apache.poi.sl.usermodel.TextRun; import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; @@ -37,13 +35,13 @@ import org.apache.poi.util.POILogger; * Represents a run of text, all with the same style * */ -public final class RichTextRun { +public final class HSLFTextRun implements TextRun { protected POILogger logger = POILogFactory.getLogger(this.getClass()); /** The TextRun we belong to */ - private TextRun parentRun; + private HSLFTextParagraph parentParagraph; /** The SlideShow we belong to */ - private SlideShow slideShow; + // private SlideShow slideShow; /** Where in the parent TextRun we start from */ private int startPos; @@ -68,7 +66,7 @@ public final class RichTextRun { * @param startAt * @param len */ - public RichTextRun(TextRun parent, int startAt, int len) { + public HSLFTextRun(HSLFTextParagraph parent, int startAt, int len) { this(parent, startAt, len, null, null, false, false); } /** @@ -81,10 +79,10 @@ public final class RichTextRun { * @param pShared The paragraph styles are shared with other runs * @param cShared The character styles are shared with other runs */ - public RichTextRun(TextRun parent, int startAt, int len, + public HSLFTextRun(HSLFTextParagraph parent, int startAt, int len, TextPropCollection pStyle, TextPropCollection cStyle, boolean pShared, boolean cShared) { - parentRun = parent; + parentParagraph = parent; startPos = startAt; length = len; paragraphStyle = pStyle; @@ -109,8 +107,7 @@ public final class RichTextRun { /** * Supply the SlideShow we belong to */ - public void supplySlideShow(SlideShow ss) { - slideShow = ss; + public void updateSheet() { if (_fontname != null) { setFontName(_fontname); _fontname = null; @@ -146,20 +143,20 @@ public final class RichTextRun { * Fetch the text, in output suitable form */ public String getText() { - return parentRun.getText().substring(startPos, startPos+length); + return parentParagraph.getText().substring(startPos, startPos+length); } /** * Fetch the text, in raw storage form */ public String getRawText() { - return parentRun.getRawText().substring(startPos, startPos+length); + return parentParagraph.getRawText().substring(startPos, startPos+length); } /** * Change the text */ public void setText(String text) { - String s = parentRun.normalize(text); + String s = parentParagraph.normalize(text); setRawText(s); } @@ -168,7 +165,7 @@ public final class RichTextRun { */ public void setRawText(String text) { length = text.length(); - parentRun.changeTextInRichTextRun(this,text); + parentParagraph.changeTextInRichTextRun(this,text); } /** @@ -207,10 +204,10 @@ public final class RichTextRun { prop = (BitMaskTextProp)props.findByName(propname); } if (prop == null){ - Sheet sheet = parentRun.getSheet(); + HSLFSheet sheet = parentParagraph.getSheet(); if(sheet != null){ - int txtype = parentRun.getRunType(); - MasterSheet master = sheet.getMasterSheet(); + int txtype = parentParagraph.getRunType(); + HSLFMasterSheet master = sheet.getMasterSheet(); if (master != null){ prop = (BitMaskTextProp)master.getStyleAttribute(txtype, getIndentLevel(), propname, isCharacter); } @@ -243,7 +240,7 @@ public final class RichTextRun { // Ensure we have the StyleTextProp atom we're going to need if(props == null) { - parentRun.ensureStyleAtomPresent(); + parentParagraph.ensureStyleAtomPresent(); props = isCharacter ? characterStyle : paragraphStyle; } @@ -279,9 +276,9 @@ public final class RichTextRun { } if (prop == null){ - Sheet sheet = parentRun.getSheet(); - int txtype = parentRun.getRunType(); - MasterSheet master = sheet.getMasterSheet(); + HSLFSheet sheet = parentParagraph.getSheet(); + int txtype = parentParagraph.getRunType(); + HSLFMasterSheet master = sheet.getMasterSheet(); if (master != null) prop = master.getStyleAttribute(txtype, getIndentLevel(), propName, true); } @@ -303,9 +300,9 @@ public final class RichTextRun { hardAttribute = maskProp != null && maskProp.getValue() == 0; } if (prop == null && !hardAttribute){ - Sheet sheet = parentRun.getSheet(); - int txtype = parentRun.getRunType(); - MasterSheet master = sheet.getMasterSheet(); + HSLFSheet sheet = parentParagraph.getSheet(); + int txtype = parentParagraph.getRunType(); + HSLFMasterSheet master = sheet.getMasterSheet(); if (master != null) prop = master.getStyleAttribute(txtype, getIndentLevel(), propName, false); } @@ -321,7 +318,7 @@ public final class RichTextRun { public void setParaTextPropVal(String propName, int val) { // Ensure we have the StyleTextProp atom we're going to need if(paragraphStyle == null) { - parentRun.ensureStyleAtomPresent(); + parentParagraph.ensureStyleAtomPresent(); // paragraphStyle will now be defined } @@ -337,7 +334,7 @@ public final class RichTextRun { public void setCharTextPropVal(String propName, int val) { // Ensure we have the StyleTextProp atom we're going to need if(characterStyle == null) { - parentRun.ensureStyleAtomPresent(); + parentParagraph.ensureStyleAtomPresent(); // characterStyle will now be defined } @@ -380,14 +377,14 @@ public final class RichTextRun { /** * Is the text underlined? */ - public boolean isUnderlined() { + public boolean isUnderline() { return isCharFlagsTextPropVal(CharFlagsTextProp.UNDERLINE_IDX); } /** * Is the text underlined? */ - public void setUnderlined(boolean underlined) { + public void setUnderline(boolean underlined) { setCharFlagsTextPropVal(CharFlagsTextProp.UNDERLINE_IDX, underlined); } @@ -486,21 +483,25 @@ public final class RichTextRun { * Sets the font name to use */ public void setFontName(String fontName) { - if (slideShow == null) { + HSLFSheet sheet = parentParagraph.getSheet(); + HSLFSlideShowImpl slideShow = (sheet == null) ? null : sheet.getSlideShow(); + if (sheet == null || slideShow == null) { //we can't set font since slideshow is not assigned yet _fontname = fontName; - } else { - // Get the index for this font (adding if needed) - int fontIdx = slideShow.getFontCollection().addFont(fontName); - setCharTextPropVal("font.index", fontIdx); + return; } + // Get the index for this font (adding if needed) + int fontIdx = slideShow.getFontCollection().addFont(fontName); + setCharTextPropVal("font.index", fontIdx); } /** * Gets the font name */ public String getFontName() { - if (slideShow == null) { + HSLFSheet sheet = parentParagraph.getSheet(); + HSLFSlideShowImpl slideShow = (sheet == null) ? null : sheet.getSlideShow(); + if (sheet == null || slideShow == null) { return _fontname; } int fontIdx = getCharTextPropVal("font.index"); @@ -517,7 +518,7 @@ public final class RichTextRun { int cidx = rgb >> 24; if (rgb % 0x1000000 == 0){ - ColorSchemeAtom ca = parentRun.getSheet().getColorScheme(); + ColorSchemeAtom ca = parentParagraph.getSheet().getColorScheme(); if(cidx >= 0 && cidx <= 7) rgb = ca.getColor(cidx); } Color tmp = new Color(rgb, true); @@ -673,7 +674,7 @@ public final class RichTextRun { int cidx = rgb >> 24; if (rgb % 0x1000000 == 0){ - ColorSchemeAtom ca = parentRun.getSheet().getColorScheme(); + ColorSchemeAtom ca = parentParagraph.getSheet().getColorScheme(); if(cidx >= 0 && cidx <= 7) rgb = ca.getColor(cidx); } Color tmp = new Color(rgb, true); diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawAutoShape.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawAutoShape.java index f28c2cbfd4..f9fc966575 100644 --- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawAutoShape.java +++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawAutoShape.java @@ -3,7 +3,7 @@ package org.apache.poi.sl.draw; import org.apache.poi.sl.usermodel.*; -public class DrawAutoShape> extends DrawTextShape { +public class DrawAutoShape>> extends DrawTextShape { public DrawAutoShape(T shape) { super(shape); } diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java index 80b95ee5f6..bf82208cdc 100644 --- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java +++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawFactory.java @@ -45,7 +45,7 @@ public class DrawFactory { boolean isHint = false; if (graphics != null) { factory = (DrawFactory)graphics.getRenderingHint(DRAW_FACTORY); - isHint = true; + isHint = (factory != null); } // secondly try the thread local default if (factory == null) { @@ -76,25 +76,25 @@ public class DrawFactory { } else if (shape instanceof Background) { return getDrawable((Background)shape); } else if (shape instanceof Slide) { - return getDrawable((Slide)shape); + return getDrawable((Slide)shape); } else if (shape instanceof MasterSheet) { - return getDrawable((MasterSheet)shape); + return getDrawable((MasterSheet)shape); } else if (shape instanceof Sheet) { - return getDrawable((Sheet)shape); + return getDrawable((Sheet)shape); } throw new IllegalArgumentException("Unsupported shape type: "+shape.getClass()); } - public > DrawSlide getDrawable(T sheet) { + public > DrawSlide getDrawable(T sheet) { return new DrawSlide(sheet); } - public > DrawSheet getDrawable(T sheet) { + public > DrawSheet getDrawable(T sheet) { return new DrawSheet(sheet); } - public > DrawMasterSheet getDrawable(T sheet) { + public > DrawMasterSheet getDrawable(T sheet) { return new DrawMasterSheet(sheet); } diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawMasterSheet.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawMasterSheet.java index 7a89828ede..452704a757 100644 --- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawMasterSheet.java +++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawMasterSheet.java @@ -3,7 +3,7 @@ package org.apache.poi.sl.draw; import org.apache.poi.sl.usermodel.*; -public class DrawMasterSheet> extends DrawSheet { +public class DrawMasterSheet> extends DrawSheet { public DrawMasterSheet(T sheet) { super(sheet); diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java index 77a0da740a..ca2346b207 100644 --- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java +++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java @@ -17,6 +17,7 @@ package org.apache.poi.sl.draw; +import static org.apache.poi.sl.usermodel.PaintStyle.TRANSPARENT_PAINT; import java.awt.*; import java.awt.MultipleGradientPaint.ColorSpaceType; import java.awt.MultipleGradientPaint.CycleMethod; @@ -35,7 +36,7 @@ import org.apache.poi.util.POILogger; public class DrawPaint { - public final static Color NO_PAINT = new Color(0xFF, 0xFF, 0xFF, 0); + private final static POILogger LOG = POILogFactory.getLogger(DrawPaint.class); protected PlaceableShape shape; @@ -43,6 +44,21 @@ public class DrawPaint { public DrawPaint(PlaceableShape shape) { this.shape = shape; } + + public static SolidPaint createSolidPaint(final Color color) { + return new SolidPaint() { + public ColorStyle getSolidColor() { + return new ColorStyle(){ + public Color getColor() { return color; } + public int getAlpha() { return -1; } + public int getLumOff() { return -1; } + public int getLumMod() { return -1; } + public int getShade() { return -1; } + public int getTint() { return -1; } + }; + } + }; + } public Paint getPaint(Graphics2D graphics, PaintStyle paint) { if (paint instanceof SolidPaint) { @@ -74,7 +90,7 @@ public class DrawPaint { protected Paint getTexturePaint(TexturePaint fill, Graphics2D graphics) { InputStream is = fill.getImageData(); - if (is == null) return NO_PAINT; + if (is == null) return TRANSPARENT_PAINT.getSolidColor().getColor(); assert(graphics != null); ImageRenderer renderer = (ImageRenderer)graphics.getRenderingHint(Drawable.IMAGE_RENDERER); @@ -84,7 +100,7 @@ public class DrawPaint { renderer.loadImage(fill.getImageData(), fill.getContentType()); } catch (IOException e) { LOG.log(POILogger.ERROR, "Can't load image data - using transparent color", e); - return NO_PAINT; + return TRANSPARENT_PAINT.getSolidColor().getColor(); } int alpha = fill.getAlpha(); @@ -105,7 +121,9 @@ public class DrawPaint { public static Color applyColorTransform(ColorStyle color){ Color result = color.getColor(); - if (result == null || color.getAlpha() == 100) return NO_PAINT; + if (result == null || color.getAlpha() == 100) { + return TRANSPARENT_PAINT.getSolidColor().getColor(); + } result = applyAlpha(result, color); result = applyLuminanace(result, color); diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java index 238bb1a116..ceda9280c4 100644 --- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java +++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawShapeGroup.java @@ -7,17 +7,12 @@ import java.awt.geom.Rectangle2D; import org.apache.poi.sl.usermodel.*; -public class DrawShapeGroup> implements Drawable { +public class DrawShapeGroup> extends DrawShape implements Drawable { - protected final T shape; - public DrawShapeGroup(T shape) { - this.shape = shape; + super(shape); } - public void applyTransform(Graphics2D context) { - } - public void draw(Graphics2D graphics) { // the coordinate system of this group of shape @@ -54,7 +49,4 @@ public class DrawShapeGroup> implements Dr graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, tx0); } - - public void drawContent(Graphics2D context) { - } } diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java index d3901b39b3..d0026f31dc 100644 --- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java +++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java @@ -6,7 +6,7 @@ import java.awt.geom.AffineTransform; import org.apache.poi.sl.usermodel.*; -public class DrawSheet> implements Drawable { +public class DrawSheet> implements Drawable { protected final T sheet; @@ -14,14 +14,9 @@ public class DrawSheet> implements Drawable { this.sheet = sheet; } - public void applyTransform(Graphics2D context) { - // TODO Auto-generated method stub - - } - public void draw(Graphics2D graphics) { DrawFactory drawFact = DrawFactory.getInstance(graphics); - MasterSheet master = sheet.getMasterSheet(); + MasterSheet master = sheet.getMasterSheet(); if(sheet.getFollowMasterGraphics() && master != null) { Drawable drawer = drawFact.getDrawable(master); @@ -53,9 +48,10 @@ public class DrawSheet> implements Drawable { } } + public void applyTransform(Graphics2D context) { + } + public void drawContent(Graphics2D context) { - // TODO Auto-generated method stub - } /** diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java index c5e5b4244c..4ff0034eba 100644 --- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java +++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java @@ -18,7 +18,7 @@ import org.apache.poi.sl.draw.geom.*; import org.apache.poi.sl.usermodel.*; import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize; import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint; -import org.apache.poi.sl.usermodel.StrokeStyle.LineDash; +import org.apache.poi.sl.usermodel.StrokeStyle.*; import org.apache.poi.util.Units; @@ -223,15 +223,22 @@ public class DrawSimpleShape extends DrawShape { if (lineWidth == 0.0f) lineWidth = 0.25f; // Both PowerPoint and OOo draw zero-length lines as 0.25pt LineDash lineDash = strokeStyle.getLineDash(); + if (lineDash == null) { + lineDash = LineDash.SOLID; + lineWidth = 0.0f; + } + int dashPatI[] = lineDash.pattern; float[] dashPatF = new float[dashPatI.length]; final float dash_phase = 0; for (int i=0; i extends DrawShape { int lineJoin = BasicStroke.JOIN_ROUND; - return new BasicStroke(lineWidth, lineCap, lineJoin, Math.max(1, lineWidth), dashPatF, dash_phase); + return new BasicStroke(lineWidth, lineCap, lineJoin, lineWidth, dashPatF, dash_phase); } protected void drawShadow( diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java index 8bc4eaf686..cada314ece 100644 --- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java +++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java @@ -5,7 +5,7 @@ import java.awt.Graphics2D; import org.apache.poi.sl.usermodel.*; -public class DrawSlide> extends DrawSheet { +public class DrawSlide> extends DrawSheet { public DrawSlide(T slide) { super(slide); diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextFragment.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextFragment.java index c9bf1f4085..4b2c79e378 100644 --- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextFragment.java +++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextFragment.java @@ -4,8 +4,6 @@ import java.awt.Graphics2D; import java.awt.font.TextLayout; import java.text.*; -import org.apache.poi.xslf.usermodel.XSLFRenderingHint; - public class DrawTextFragment implements Drawable { final TextLayout layout; final AttributedString str; @@ -29,8 +27,8 @@ public class DrawTextFragment implements Drawable { double yBaseline = y + layout.getAscent(); - Integer textMode = (Integer)graphics.getRenderingHint(XSLFRenderingHint.TEXT_RENDERING_MODE); - if(textMode != null && textMode == XSLFRenderingHint.TEXT_AS_SHAPES){ + Integer textMode = (Integer)graphics.getRenderingHint(Drawable.TEXT_RENDERING_MODE); + if(textMode != null && textMode == Drawable.TEXT_AS_SHAPES){ layout.draw(graphics, (float)x, (float)yBaseline); } else { graphics.drawString(str.getIterator(), (float)x, (float)yBaseline ); @@ -38,13 +36,9 @@ public class DrawTextFragment implements Drawable { } public void applyTransform(Graphics2D graphics) { - // TODO Auto-generated method stub - } public void drawContent(Graphics2D graphics) { - // TODO Auto-generated method stub - } public TextLayout getLayout() { diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextShape.java b/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextShape.java index cda6a1a88f..f0b4ff42b3 100644 --- a/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextShape.java +++ b/src/scratchpad/src/org/apache/poi/sl/draw/DrawTextShape.java @@ -8,7 +8,7 @@ import java.util.Iterator; import org.apache.poi.sl.usermodel.*; -public class DrawTextShape> extends DrawSimpleShape { +public class DrawTextShape>> extends DrawSimpleShape { public DrawTextShape(T shape) { super(shape); @@ -26,7 +26,7 @@ public class DrawTextShape> extends // Transform of text in flipped shapes is special. // At this point the flip and rotation transform is already applied - // (see XSLFShape#applyTransform ), but we need to restore it to avoid painting "upside down". + // (see DrawShape#applyTransform ), but we need to restore it to avoid painting "upside down". // See Bugzilla 54210. if(shape.getFlipVertical()){ @@ -84,12 +84,12 @@ public class DrawTextShape> extends Insets2D shapePadding = shape.getInsets(); double y0 = y; - Iterator paragraphs = shape.iterator(); + Iterator> paragraphs = shape.iterator(); boolean isFirstLine = true; while (paragraphs.hasNext()){ - TextParagraph p = paragraphs.next(); - DrawTextParagraph dp = fact.getDrawable(p); + TextParagraph p = paragraphs.next(); + DrawTextParagraph dp = fact.getDrawable(p); dp.setInsets(shapePadding); dp.breakText(graphics); diff --git a/src/scratchpad/src/org/apache/poi/sl/draw/geom/PresetGeometries.java b/src/scratchpad/src/org/apache/poi/sl/draw/geom/PresetGeometries.java index d876d1512a..736dc0d668 100644 --- a/src/scratchpad/src/org/apache/poi/sl/draw/geom/PresetGeometries.java +++ b/src/scratchpad/src/org/apache/poi/sl/draw/geom/PresetGeometries.java @@ -45,7 +45,7 @@ public class PresetGeometries extends LinkedHashMap { @SuppressWarnings("unused") public void init(InputStream is) throws XMLStreamException, JAXBException { - Reader xml = new InputStreamReader( is, Charset.forName("UTF-8") ); + // Reader xml = new InputStreamReader( is, Charset.forName("UTF-8") ); // StAX: @@ -58,7 +58,7 @@ public class PresetGeometries extends LinkedHashMap { long cntElem = 0; XMLInputFactory staxFactory = XMLInputFactory.newInstance(); - XMLEventReader staxReader = staxFactory.createXMLEventReader(xml); + XMLEventReader staxReader = staxFactory.createXMLEventReader(is); XMLEventReader staxFiltRd = staxFactory.createFilteredReader(staxReader, startElementFilter); // ignore StartElement: XMLEvent evDoc = staxFiltRd.nextEvent(); diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/AutoShape.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/AutoShape.java index 21c3a507fd..1bf073dfbb 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/AutoShape.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/AutoShape.java @@ -17,5 +17,5 @@ package org.apache.poi.sl.usermodel; -public interface AutoShape extends TextShape { +public interface AutoShape> extends TextShape { } diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/FreeformShape.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/FreeformShape.java index 09d61989df..e0843a11a1 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/FreeformShape.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/FreeformShape.java @@ -17,6 +17,6 @@ package org.apache.poi.sl.usermodel; -public interface FreeformShape extends AutoShape { +public interface FreeformShape> extends AutoShape { } diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/MasterSheet.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/MasterSheet.java index 8ba80156bd..727217d3fa 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/MasterSheet.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/MasterSheet.java @@ -17,6 +17,6 @@ package org.apache.poi.sl.usermodel; -public interface MasterSheet extends Sheet { +public interface MasterSheet extends Sheet { } diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/Notes.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/Notes.java index c16774c298..08f023cd9f 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/Notes.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/Notes.java @@ -17,6 +17,8 @@ package org.apache.poi.sl.usermodel; -public interface Notes extends Sheet { - public TextRun getTextRun(); +import java.util.List; + +public interface Notes extends Sheet { + List> getTextParagraphs(); } diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/PaintStyle.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/PaintStyle.java index 9dcd495e40..2551201692 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/PaintStyle.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/PaintStyle.java @@ -17,8 +17,11 @@ package org.apache.poi.sl.usermodel; +import java.awt.Color; import java.io.InputStream; +import org.apache.poi.sl.draw.DrawPaint; + public interface PaintStyle { @@ -55,4 +58,6 @@ public interface PaintStyle { */ int getAlpha(); } + + SolidPaint TRANSPARENT_PAINT = DrawPaint.createSolidPaint(new Color(0xFF, 0xFF, 0xFF, 0)); } diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/Shape.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/Shape.java index 6ad149b489..4de645d41f 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/Shape.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/Shape.java @@ -19,14 +19,11 @@ package org.apache.poi.sl.usermodel; public interface Shape { - ShapeContainer getParent(); + ShapeContainer getParent(); /** * * @return the sheet this shape belongs to */ - Sheet getSheet(); - - - + Sheet getSheet(); } diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeGroup.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeGroup.java index 8de1dbcb06..7bd940c36c 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeGroup.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeGroup.java @@ -19,6 +19,6 @@ package org.apache.poi.sl.usermodel; import java.awt.geom.Rectangle2D; -public interface ShapeGroup extends ShapeContainer, PlaceableShape { +public interface ShapeGroup extends Shape, ShapeContainer, PlaceableShape { Rectangle2D getInteriorAnchor(); } diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java index 64b53a3014..6f4ba0ac67 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/Sheet.java @@ -21,8 +21,8 @@ package org.apache.poi.sl.usermodel; /** * Common parent of Slides, Notes and Masters */ -public interface Sheet extends ShapeContainer { - SlideShow getSlideShow(); +public interface Sheet extends ShapeContainer { + SS getSlideShow(); /** * @return whether shapes on the master sheet should be shown. By default master graphics is turned off. @@ -31,7 +31,7 @@ public interface Sheet extends ShapeContainer { */ boolean getFollowMasterGraphics(); - MasterSheet getMasterSheet(); + MasterSheet getMasterSheet(); Background getBackground(); } diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java index 243d9a8174..b2027c182c 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java @@ -17,9 +17,9 @@ package org.apache.poi.sl.usermodel; -public interface Slide extends Sheet { - public Notes getNotes(); - public void setNotes(Notes notes); +public interface Slide extends Sheet { + public Notes getNotes(); + public void setNotes(Notes notes); public boolean getFollowMasterBackground(); public void setFollowMasterBackground(boolean follow); diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/SlideShow.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/SlideShow.java index 4505ca5843..e3007f6c17 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/SlideShow.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/SlideShow.java @@ -21,11 +21,11 @@ import java.awt.Dimension; import java.io.IOException; public interface SlideShow { - Slide createSlide() throws IOException; - MasterSheet createMasterSheet() throws IOException; + Slide createSlide() throws IOException; + MasterSheet createMasterSheet() throws IOException; - Slide[] getSlides(); - MasterSheet[] getMasterSheet(); + Slide[] getSlides(); + MasterSheet[] getMasterSheet(); Resources getResources(); diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java index c02e1a33f9..a55317740a 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java @@ -33,27 +33,75 @@ public interface StrokeStyle { * with actual line width */ enum LineDash { - SOLID(1), - DOT(1,1), - DASH(3,4), - LG_DASH(8,3), - DASH_DOT(4,3,1,3), - LG_DASH_DOT(8,3,1,3), - LG_DASH_DOT_DOT(8,3,1,3,1,3), - SYS_DASH(2,2), - SYS_DOT(1,1), - SYS_DASH_DOT, - SYS_DASH_DOT_DOT; + /** Solid (continuous) pen - native 1 */ + SOLID(1, 1), + /** square dot style - native 6 */ + DOT(6, 1,1), + /** dash style - native 7 */ + DASH(7, 3,4), + /** dash short dash - native 9*/ + DASH_DOT(9, 4,3,1,3), + /** long dash style - native 8 */ + LG_DASH(8, 8,3), + /** long dash short dash - native 10 */ + LG_DASH_DOT(10, 8,3,1,3), + /** long dash short dash short dash - native 11 */ + LG_DASH_DOT_DOT(11, 8,3,1,3,1,3), + /** PS_DASH system dash style - native 2 */ + SYS_DASH(2, 2,2), + /** PS_DOT system dash style - native 3 */ + SYS_DOT(3, 1,1), + /** PS_DASHDOT system dash style - native 4 */ + SYS_DASH_DOT(4, 2,2,1,1), + /** PS_DASHDOTDOT system dash style / native 5 */ + SYS_DASH_DOT_DOT(5, 2,2,1,1,1,1); - public int pattern[]; - - LineDash(int... pattern) { + public final int pattern[]; + public final int nativeId; + + LineDash(int nativeId, int... pattern) { + this.nativeId = nativeId; this.pattern = (pattern == null || pattern.length == 0) ? new int[]{1} : pattern; } + + public static LineDash fromNativeId(int nativeId) { + for (LineDash ld : values()) { + if (ld.nativeId == nativeId) return ld; + } + return null; + } } - + + enum LineCompound { + /** Single line (of width lineWidth) - native 0 / ooxml default */ + SINGLE(0), + /** Double lines of equal width - native 1 / ooxml "dbl" */ + DOUBLE(1), + /** Double lines, one thick, one thin - native 2 / ooxml "thickThin" */ + THICK_THIN(2), + /** Double lines, reverse order - native 3 / ooxml "thinThick" */ + THIN_THICK(3), + /** Three lines, thin, thick, thin - native 4 / ooxml "tri" */ + TRIPLE(4); + + public final int nativeId; + + LineCompound(int nativeId) { + this.nativeId = nativeId; + } + + public static LineCompound fromNativeId(int nativeId) { + for (LineCompound lc : values()) { + if (lc.nativeId == nativeId) return lc; + } + return null; + } + } + + PaintStyle getPaint(); LineCap getLineCap(); LineDash getLineDash(); + LineCompound getLineCompound(); double getLineWidth(); } diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/TextBox.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/TextBox.java index 9ac61d526a..3fa3bbe20d 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/TextBox.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/TextBox.java @@ -17,5 +17,5 @@ package org.apache.poi.sl.usermodel; -public interface TextBox extends AutoShape { +public interface TextBox> extends AutoShape { } diff --git a/src/scratchpad/src/org/apache/poi/sl/usermodel/TextShape.java b/src/scratchpad/src/org/apache/poi/sl/usermodel/TextShape.java index f9b1833610..a6a53fe1bd 100644 --- a/src/scratchpad/src/org/apache/poi/sl/usermodel/TextShape.java +++ b/src/scratchpad/src/org/apache/poi/sl/usermodel/TextShape.java @@ -19,7 +19,7 @@ package org.apache.poi.sl.usermodel; -public interface TextShape> extends SimpleShape, Iterable { +public interface TextShape> extends SimpleShape, Iterable { /** * Vertical Text Types */ diff --git a/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java b/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java index b3f91236ec..134f3e8ac0 100644 --- a/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java +++ b/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java @@ -22,9 +22,10 @@ package org.apache.poi; import junit.framework.TestCase; + import java.io.*; -import org.apache.poi.hslf.HSLFSlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hwpf.HWPFTestDataSamples; import org.apache.poi.poifs.filesystem.*; @@ -47,7 +48,7 @@ public final class TestPOIDocumentScratchpad extends TestCase { * a Word Document for our testing */ public void setUp() throws Exception { - doc = new HSLFSlideShow(POIDataSamples.getSlideShowInstance().openResourceAsStream("basic_test_ppt_file.ppt")); + doc = new HSLFSlideShowImpl(POIDataSamples.getSlideShowInstance().openResourceAsStream("basic_test_ppt_file.ppt")); doc2 = HWPFTestDataSamples.openSampleFile("test2.doc"); } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/HSLFTestDataSamples.java b/src/scratchpad/testcases/org/apache/poi/hslf/HSLFTestDataSamples.java index 6740708792..6207a4597d 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/HSLFTestDataSamples.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/HSLFTestDataSamples.java @@ -24,7 +24,8 @@ import java.io.IOException; import java.io.InputStream; import org.apache.poi.POIDataSamples; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; public class HSLFTestDataSamples { @@ -45,12 +46,12 @@ public class HSLFTestDataSamples { * from a ByteArrayInputStream.

* Useful for verifying that the serialisation round trip */ - public static HSLFSlideShow writeOutAndReadBack(HSLFSlideShow original) { + public static HSLFSlideShowImpl writeOutAndReadBack(HSLFSlideShowImpl original) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(4096); original.write(baos); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - return new HSLFSlideShow(bais); + return new HSLFSlideShowImpl(bais); } catch (IOException e) { throw new RuntimeException(e); } @@ -61,12 +62,12 @@ public class HSLFTestDataSamples { * from a ByteArrayInputStream.

* Useful for verifying that the serialisation round trip */ - public static SlideShow writeOutAndReadBack(SlideShow original) { + public static HSLFSlideShow writeOutAndReadBack(HSLFSlideShow original) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(4096); original.write(baos); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - return new SlideShow(bais); + return new HSLFSlideShow(bais); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/TestEncryptedFile.java b/src/scratchpad/testcases/org/apache/poi/hslf/TestEncryptedFile.java index da07810b86..3de6032ae5 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/TestEncryptedFile.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/TestEncryptedFile.java @@ -21,6 +21,7 @@ package org.apache.poi.hslf; import junit.framework.TestCase; import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.POIDataSamples; /** @@ -32,28 +33,28 @@ public final class TestEncryptedFile extends TestCase { private static POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); public void testLoadNonEncrypted() throws Exception { - HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); assertNotNull(hss); } public void testLoadEncrypted() throws Exception { try { - new HSLFSlideShow(slTests.openResourceAsStream("Password_Protected-hello.ppt")); + new HSLFSlideShowImpl(slTests.openResourceAsStream("Password_Protected-hello.ppt")); fail(); } catch(EncryptedPowerPointFileException e) { // Good } try { - new HSLFSlideShow(slTests.openResourceAsStream("Password_Protected-np-hello.ppt")); + new HSLFSlideShowImpl(slTests.openResourceAsStream("Password_Protected-np-hello.ppt")); fail(); } catch(EncryptedPowerPointFileException e) { // Good } try { - new HSLFSlideShow(slTests.openResourceAsStream("Password_Protected-56-hello.ppt")); + new HSLFSlideShowImpl(slTests.openResourceAsStream("Password_Protected-56-hello.ppt")); fail(); } catch(EncryptedPowerPointFileException e) { // Good diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java b/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java index 1398e747e1..ae64b3614d 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/TestReWrite.java @@ -25,7 +25,8 @@ import java.io.FileNotFoundException; import junit.framework.TestCase; import org.apache.poi.POIDataSamples; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.poifs.filesystem.DocumentEntry; import org.apache.poi.poifs.filesystem.POIFSFileSystem; @@ -37,9 +38,9 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; */ public final class TestReWrite extends TestCase { // HSLFSlideShow primed on the test data - private HSLFSlideShow hssA; - private HSLFSlideShow hssB; - private HSLFSlideShow hssC; + private HSLFSlideShowImpl hssA; + private HSLFSlideShowImpl hssB; + private HSLFSlideShowImpl hssC; // POIFS primed on the test data private POIFSFileSystem pfsA; private POIFSFileSystem pfsB; @@ -50,20 +51,20 @@ public final class TestReWrite extends TestCase { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); pfsA = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); - hssA = new HSLFSlideShow(pfsA); + hssA = new HSLFSlideShowImpl(pfsA); pfsB = new POIFSFileSystem(slTests.openResourceAsStream("ParagraphStylesShorterThanCharStyles.ppt")); - hssB = new HSLFSlideShow(pfsB); + hssB = new HSLFSlideShowImpl(pfsB); pfsC = new POIFSFileSystem(slTests.openResourceAsStream("WithMacros.ppt")); - hssC = new HSLFSlideShow(pfsC); + hssC = new HSLFSlideShowImpl(pfsC); } public void testWritesOutTheSame() throws Exception { assertWritesOutTheSame(hssA, pfsA); assertWritesOutTheSame(hssB, pfsB); } - public void assertWritesOutTheSame(HSLFSlideShow hss, POIFSFileSystem pfs) throws Exception { + public void assertWritesOutTheSame(HSLFSlideShowImpl hss, POIFSFileSystem pfs) throws Exception { // Write out to a byte array ByteArrayOutputStream baos = new ByteArrayOutputStream(); hss.write(baos); @@ -129,9 +130,9 @@ public final class TestReWrite extends TestCase { // We need to identify and fix that first //assertSlideShowWritesOutTheSame(hssB, pfsB); } - public void assertSlideShowWritesOutTheSame(HSLFSlideShow hss, POIFSFileSystem pfs) throws Exception { + public void assertSlideShowWritesOutTheSame(HSLFSlideShowImpl hss, POIFSFileSystem pfs) throws Exception { // Create a slideshow covering it - SlideShow ss = new SlideShow(hss); + HSLFSlideShow ss = new HSLFSlideShow(hss); ss.getSlides(); ss.getNotes(); @@ -163,7 +164,7 @@ public final class TestReWrite extends TestCase { } public void test48593() throws Exception { - SlideShow slideShow = new SlideShow(); + HSLFSlideShow slideShow = new HSLFSlideShow(); slideShow.createSlide(); slideShow = HSLFTestDataSamples.writeOutAndReadBack(slideShow); slideShow.createSlide(); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java b/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java index ae76116a41..31a80ae306 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java @@ -19,8 +19,11 @@ package org.apache.poi.hslf; import junit.framework.TestCase; + import java.io.*; import java.util.*; + +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.*; import org.apache.poi.poifs.filesystem.*; import org.apache.poi.POIDataSamples; @@ -33,14 +36,14 @@ import org.apache.poi.POIDataSamples; */ public final class TestReWriteSanity extends TestCase { // HSLFSlideShow primed on the test data - private HSLFSlideShow ss; + private HSLFSlideShowImpl ss; // POIFS primed on the test data private POIFSFileSystem pfs; public TestReWriteSanity() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); - ss = new HSLFSlideShow(pfs); + ss = new HSLFSlideShowImpl(pfs); } public void testUserEditAtomsRight() throws Exception { @@ -52,7 +55,7 @@ public final class TestReWriteSanity extends TestCase { ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); // Create a new one from that - HSLFSlideShow wss = new HSLFSlideShow(bais); + HSLFSlideShowImpl wss = new HSLFSlideShowImpl(bais); // Find the location of the PersistPtrIncrementalBlocks and // UserEditAtoms diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java b/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java index 5d509b6203..732f609381 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/TestRecordCounts.java @@ -19,6 +19,8 @@ package org.apache.poi.hslf; import junit.framework.TestCase; + +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.*; import org.apache.poi.POIDataSamples; @@ -30,11 +32,11 @@ import org.apache.poi.POIDataSamples; */ public final class TestRecordCounts extends TestCase { // HSLFSlideShow primed on the test data - private HSLFSlideShow ss; + private HSLFSlideShowImpl ss; public TestRecordCounts() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - ss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + ss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); } public void testSheetsCount() { diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java index 7fc234f8ef..a00d75d03e 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java @@ -23,9 +23,9 @@ import java.util.List; import org.apache.poi.POIDataSamples; import org.apache.poi.POITestCase; -import org.apache.poi.hslf.HSLFSlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.model.OLEShape; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.poifs.filesystem.DirectoryNode; @@ -140,7 +140,7 @@ public final class TestExtractor extends POITestCase { POIFSFileSystem fs = new POIFSFileSystem( POIDataSamples.getSpreadSheetInstance().openResourceAsStream("excel_with_embeded.xls") ); - HSLFSlideShow ss; + HSLFSlideShowImpl ss; DirectoryNode dirA = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B6"); @@ -151,14 +151,14 @@ public final class TestExtractor extends POITestCase { assertNotNull(dirB.getEntry("PowerPoint Document")); // Check the first file - ss = new HSLFSlideShow(dirA); + ss = new HSLFSlideShowImpl(dirA); ppe = new PowerPointExtractor(ss); assertEquals("Sample PowerPoint file\nThis is the 1st file\nNot much too it\n", ppe.getText(true, false) ); // And the second - ss = new HSLFSlideShow(dirB); + ss = new HSLFSlideShowImpl(dirB); ppe = new PowerPointExtractor(ss); assertEquals("Sample PowerPoint file\nThis is the 2nd file\nNot much too it either\n", ppe.getText(true, false) @@ -186,7 +186,7 @@ public final class TestExtractor extends POITestCase { num_doc++; } else if ("Presentation".equals(name)) { num_ppt++; - SlideShow ppt = new SlideShow(data); + HSLFSlideShow ppt = new HSLFSlideShow(data); } } assertEquals("Expected 2 embedded Word Documents", 2, num_doc); @@ -241,8 +241,8 @@ public final class TestExtractor extends POITestCase { String text; // With a header on the notes - HSLFSlideShow hslf = new HSLFSlideShow(slTests.openResourceAsStream("45537_Header.ppt")); - SlideShow ss = new SlideShow(hslf); + HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("45537_Header.ppt")); + HSLFSlideShow ss = new HSLFSlideShow(hslf); assertNotNull(ss.getNotesHeadersFooters()); assertEquals("testdoc test phrase", ss.getNotesHeadersFooters().getHeaderText()); @@ -259,8 +259,8 @@ public final class TestExtractor extends POITestCase { // And with a footer, also on notes - hslf = new HSLFSlideShow(slTests.openResourceAsStream("45537_Footer.ppt")); - ss = new SlideShow(hslf); + hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("45537_Footer.ppt")); + ss = new HSLFSlideShow(hslf); assertNotNull(ss.getNotesHeadersFooters()); assertEquals("testdoc test phrase", ss.getNotesHeadersFooters().getFooterText()); @@ -281,7 +281,7 @@ public final class TestExtractor extends POITestCase { String masterTitleText = "This is the Master Title"; String masterRandomText = "This text comes from the Master Slide"; String masterFooterText = "Footer from the master slide"; - HSLFSlideShow hslf = new HSLFSlideShow(slTests.openResourceAsStream("WithMaster.ppt")); + HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithMaster.ppt")); ppe = new PowerPointExtractor(hslf); @@ -309,7 +309,7 @@ public final class TestExtractor extends POITestCase { // Now with another file only containing master text // Will always show up String masterText = "Footer from the master slide"; - HSLFSlideShow hslf = new HSLFSlideShow(slTests.openResourceAsStream("WithMaster.ppt")); + HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithMaster.ppt")); ppe = new PowerPointExtractor(hslf); @@ -322,7 +322,7 @@ public final class TestExtractor extends POITestCase { * Bug #54880 Chinese text not extracted properly */ public void testChineseText() throws Exception { - HSLFSlideShow hslf = new HSLFSlideShow(slTests.openResourceAsStream("54880_chinese.ppt")); + HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("54880_chinese.ppt")); ppe = new PowerPointExtractor(hslf); String text = ppe.getText(); @@ -360,7 +360,7 @@ public final class TestExtractor extends POITestCase { // Open via a HWPFDocument for(DirectoryNode dir : files) { - HSLFSlideShow slideshow = new HSLFSlideShow(dir); + HSLFSlideShowImpl slideshow = new HSLFSlideShowImpl(dir); PowerPointExtractor extractor = new PowerPointExtractor(slideshow); assertEquals(expectText, extractor.getText()); } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java index 8838561501..0d1cfd9e09 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java @@ -32,9 +32,8 @@ import org.apache.poi.ddf.EscherOptRecord; import org.apache.poi.ddf.EscherProperties; import org.apache.poi.ddf.EscherRecord; import org.apache.poi.ddf.EscherSimpleProperty; -import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.record.Document; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.sl.usermodel.ShapeType; import org.junit.Test; @@ -52,16 +51,16 @@ public final class TestBackground { */ @Test public void defaults() { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); - assertEquals(Fill.FILL_SOLID, ppt.getSlidesMasters()[0].getBackground().getFill().getFillType()); + assertEquals(HSLFFill.FILL_SOLID, ppt.getSlidesMasters()[0].getBackground().getFill().getFillType()); - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); assertTrue(slide.getFollowMasterBackground()); - assertEquals(Fill.FILL_SOLID, slide.getBackground().getFill().getFillType()); + assertEquals(HSLFFill.FILL_SOLID, slide.getBackground().getFill().getFillType()); - HSLFShape shape = new AutoShape(ShapeType.RECT); - assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType()); + HSLFShape shape = new HSLFAutoShape(ShapeType.RECT); + assertEquals(HSLFFill.FILL_SOLID, shape.getFill().getFillType()); } /** @@ -69,31 +68,31 @@ public final class TestBackground { */ @Test public void readBackground() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("backgrounds.ppt")); - Fill fill; + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("backgrounds.ppt")); + HSLFFill fill; HSLFShape shape; - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); fill = slide[0].getBackground().getFill(); - assertEquals(Fill.FILL_PICTURE, fill.getFillType()); + assertEquals(HSLFFill.FILL_PICTURE, fill.getFillType()); shape = slide[0].getShapes()[0]; - assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType()); + assertEquals(HSLFFill.FILL_SOLID, shape.getFill().getFillType()); fill = slide[1].getBackground().getFill(); - assertEquals(Fill.FILL_PATTERN, fill.getFillType()); + assertEquals(HSLFFill.FILL_PATTERN, fill.getFillType()); shape = slide[1].getShapes()[0]; - assertEquals(Fill.FILL_BACKGROUND, shape.getFill().getFillType()); + assertEquals(HSLFFill.FILL_BACKGROUND, shape.getFill().getFillType()); fill = slide[2].getBackground().getFill(); - assertEquals(Fill.FILL_TEXTURE, fill.getFillType()); + assertEquals(HSLFFill.FILL_TEXTURE, fill.getFillType()); shape = slide[2].getShapes()[0]; - assertEquals(Fill.FILL_PICTURE, shape.getFill().getFillType()); + assertEquals(HSLFFill.FILL_PICTURE, shape.getFill().getFillType()); fill = slide[3].getBackground().getFill(); - assertEquals(Fill.FILL_SHADE_CENTER, fill.getFillType()); + assertEquals(HSLFFill.FILL_SHADE_CENTER, fill.getFillType()); shape = slide[3].getShapes()[0]; - assertEquals(Fill.FILL_SHADE, shape.getFill().getFillType()); + assertEquals(HSLFFill.FILL_SHADE, shape.getFill().getFillType()); } /** @@ -101,9 +100,9 @@ public final class TestBackground { */ @Test public void backgroundPicture() throws Exception { - SlideShow ppt = new SlideShow(); - Slide slide; - Fill fill; + HSLFSlideShow ppt = new HSLFSlideShow(); + HSLFSlide slide; + HSLFFill fill; HSLFShape shape; int idx; @@ -111,45 +110,45 @@ public final class TestBackground { slide = ppt.createSlide(); slide.setFollowMasterBackground(false); fill = slide.getBackground().getFill(); - idx = ppt.addPicture(_slTests.readFile("tomcat.png"), Picture.PNG); - fill.setFillType(Fill.FILL_PICTURE); + idx = ppt.addPicture(_slTests.readFile("tomcat.png"), HSLFPictureShape.PNG); + fill.setFillType(HSLFFill.FILL_PICTURE); fill.setPictureData(idx); - shape = new AutoShape(ShapeType.RECT); + shape = new HSLFAutoShape(ShapeType.RECT); shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200)); fill = shape.getFill(); - fill.setFillType(Fill.FILL_SOLID); + fill.setFillType(HSLFFill.FILL_SOLID); slide.addShape(shape); //slide 2 slide = ppt.createSlide(); slide.setFollowMasterBackground(false); fill = slide.getBackground().getFill(); - idx = ppt.addPicture(_slTests.readFile("tomcat.png"), Picture.PNG); - fill.setFillType(Fill.FILL_PATTERN); + idx = ppt.addPicture(_slTests.readFile("tomcat.png"), HSLFPictureShape.PNG); + fill.setFillType(HSLFFill.FILL_PATTERN); fill.setPictureData(idx); fill.setBackgroundColor(Color.green); fill.setForegroundColor(Color.red); - shape = new AutoShape(ShapeType.RECT); + shape = new HSLFAutoShape(ShapeType.RECT); shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200)); fill = shape.getFill(); - fill.setFillType(Fill.FILL_BACKGROUND); + fill.setFillType(HSLFFill.FILL_BACKGROUND); slide.addShape(shape); //slide 3 slide = ppt.createSlide(); slide.setFollowMasterBackground(false); fill = slide.getBackground().getFill(); - idx = ppt.addPicture(_slTests.readFile("tomcat.png"), Picture.PNG); - fill.setFillType(Fill.FILL_TEXTURE); + idx = ppt.addPicture(_slTests.readFile("tomcat.png"), HSLFPictureShape.PNG); + fill.setFillType(HSLFFill.FILL_TEXTURE); fill.setPictureData(idx); - shape = new AutoShape(ShapeType.RECT); + shape = new HSLFAutoShape(ShapeType.RECT); shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200)); fill = shape.getFill(); - fill.setFillType(Fill.FILL_PICTURE); - idx = ppt.addPicture(_slTests.readFile("clock.jpg"), Picture.JPEG); + fill.setFillType(HSLFFill.FILL_PICTURE); + idx = ppt.addPicture(_slTests.readFile("clock.jpg"), HSLFPictureShape.JPEG); fill.setPictureData(idx); slide.addShape(shape); @@ -157,14 +156,14 @@ public final class TestBackground { slide = ppt.createSlide(); slide.setFollowMasterBackground(false); fill = slide.getBackground().getFill(); - fill.setFillType(Fill.FILL_SHADE_CENTER); + fill.setFillType(HSLFFill.FILL_SHADE_CENTER); fill.setBackgroundColor(Color.white); fill.setForegroundColor(Color.darkGray); - shape = new AutoShape(ShapeType.RECT); + shape = new HSLFAutoShape(ShapeType.RECT); shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200)); fill = shape.getFill(); - fill.setFillType(Fill.FILL_SHADE); + fill.setFillType(HSLFFill.FILL_SHADE); fill.setBackgroundColor(Color.red); fill.setForegroundColor(Color.green); slide.addShape(shape); @@ -174,42 +173,42 @@ public final class TestBackground { ppt.write(out); out.close(); - ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); - Slide[] slides = ppt.getSlides(); + ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray()))); + HSLFSlide[] slides = ppt.getSlides(); fill = slides[0].getBackground().getFill(); - assertEquals(Fill.FILL_PICTURE, fill.getFillType()); + assertEquals(HSLFFill.FILL_PICTURE, fill.getFillType()); assertEquals(3, getFillPictureRefCount(slides[0].getBackground(), fill)); shape = slides[0].getShapes()[0]; - assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType()); + assertEquals(HSLFFill.FILL_SOLID, shape.getFill().getFillType()); fill = slides[1].getBackground().getFill(); - assertEquals(Fill.FILL_PATTERN, fill.getFillType()); + assertEquals(HSLFFill.FILL_PATTERN, fill.getFillType()); shape = slides[1].getShapes()[0]; - assertEquals(Fill.FILL_BACKGROUND, shape.getFill().getFillType()); + assertEquals(HSLFFill.FILL_BACKGROUND, shape.getFill().getFillType()); fill = slides[2].getBackground().getFill(); - assertEquals(Fill.FILL_TEXTURE, fill.getFillType()); + assertEquals(HSLFFill.FILL_TEXTURE, fill.getFillType()); assertEquals(3, getFillPictureRefCount(slides[2].getBackground(), fill)); shape = slides[2].getShapes()[0]; - assertEquals(Fill.FILL_PICTURE, shape.getFill().getFillType()); + assertEquals(HSLFFill.FILL_PICTURE, shape.getFill().getFillType()); assertEquals(1, getFillPictureRefCount(shape, fill)); fill = slides[3].getBackground().getFill(); - assertEquals(Fill.FILL_SHADE_CENTER, fill.getFillType()); + assertEquals(HSLFFill.FILL_SHADE_CENTER, fill.getFillType()); shape = slides[3].getShapes()[0]; - assertEquals(Fill.FILL_SHADE, shape.getFill().getFillType()); + assertEquals(HSLFFill.FILL_SHADE, shape.getFill().getFillType()); } - private int getFillPictureRefCount(HSLFShape shape, Fill fill) { + private int getFillPictureRefCount(HSLFShape shape, HSLFFill fill) { EscherOptRecord opt = shape.getEscherOptRecord(); EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE); if(p != null) { int idx = p.getPropertyValue(); - Sheet sheet = shape.getSheet(); - SlideShow ppt = sheet.getSlideShow(); + HSLFSheet sheet = shape.getSheet(); + HSLFSlideShow ppt = sheet.getSlideShow(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java index 6ff4870386..6d1365efbe 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java @@ -43,7 +43,7 @@ public final class TestFreeform extends TestCase { path1.lineTo(100, 200); path1.closePath(); - Freeform p = new Freeform(); + HSLFFreeformShape p = new HSLFFreeformShape(); p.setPath(path1); java.awt.Shape path2 = p.getOutline(); @@ -54,7 +54,7 @@ public final class TestFreeform extends TestCase { GeneralPath path1 = new GeneralPath(new Line2D.Double(100, 100, 200, 100)); - Freeform p = new Freeform(); + HSLFFreeformShape p = new HSLFFreeformShape(); p.setPath(path1); java.awt.Shape path2 = p.getOutline(); @@ -65,7 +65,7 @@ public final class TestFreeform extends TestCase { GeneralPath path1 = new GeneralPath(new Rectangle2D.Double(100, 100, 200, 50)); - Freeform p = new Freeform(); + HSLFFreeformShape p = new HSLFFreeformShape(); p.setPath(path1); java.awt.Shape path2 = p.getOutline(); @@ -78,7 +78,7 @@ public final class TestFreeform extends TestCase { */ public void test54188() { - Freeform p = new Freeform(); + HSLFFreeformShape p = new HSLFFreeformShape(); GeneralPath path = (GeneralPath)p.getOutline(); GeneralPath emptyPath = new GeneralPath(); assertEquals(emptyPath.getBounds2D(), path.getBounds2D()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java index 1e86b8c3af..8239a359d5 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java @@ -18,7 +18,7 @@ package org.apache.poi.hslf.model; import java.io.*; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.POIDataSamples; import junit.framework.TestCase; @@ -33,7 +33,7 @@ public final class TestHeadersFooters extends TestCase public void testRead() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("headers_footers.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("headers_footers.ppt")); HeadersFooters slideHdd = ppt.getSlideHeadersFooters(); assertTrue(slideHdd.isFooterVisible()); @@ -53,7 +53,7 @@ public final class TestHeadersFooters extends TestCase assertTrue(notesHdd.isUserDateVisible()); assertNull(notesHdd.getDateTimeText()); - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); //the first slide uses presentation-scope headers / footers HeadersFooters hd1 = slide[0].getHeadersFooters(); assertEquals(slideHdd.isFooterVisible(), hd1.isFooterVisible()); @@ -77,7 +77,7 @@ public final class TestHeadersFooters extends TestCase */ public void testReadNoHeadersFooters() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("basic_test_ppt_file.ppt")); HeadersFooters slideHdd = ppt.getSlideHeadersFooters(); assertFalse(slideHdd.isFooterVisible()); @@ -97,7 +97,7 @@ public final class TestHeadersFooters extends TestCase assertFalse(notesHdd.isUserDateVisible()); assertNull(notesHdd.getDateTimeText()); - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); for(int i=0 ; i < slide.length; i++){ HeadersFooters hd1 = slide[i].getHeadersFooters(); assertFalse(hd1.isFooterVisible()); @@ -114,7 +114,7 @@ public final class TestHeadersFooters extends TestCase */ public void testRead2007() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("headers_footers_2007.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("headers_footers_2007.ppt")); HeadersFooters slideHdd = ppt.getSlideHeadersFooters(); assertTrue(slideHdd.isFooterVisible()); @@ -137,7 +137,7 @@ public final class TestHeadersFooters extends TestCase //assertEquals("08/12/08", notesHdd.getDateTimeText()); //per-slide headers / footers - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); //the first slide uses presentation-scope headers / footers HeadersFooters hd1 = slide[0].getHeadersFooters(); assertTrue(hd1.isFooterVisible()); @@ -174,7 +174,7 @@ public final class TestHeadersFooters extends TestCase public void testCreateSlideFooters() throws Exception { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); HeadersFooters hdd = ppt.getSlideHeadersFooters(); hdd.setFootersText("My slide footer"); hdd.setSlideNumberVisible(true); @@ -183,7 +183,7 @@ public final class TestHeadersFooters extends TestCase ppt.write(out); byte[] b = out.toByteArray(); - SlideShow ppt2 = new SlideShow(new ByteArrayInputStream(b)); + HSLFSlideShow ppt2 = new HSLFSlideShow(new ByteArrayInputStream(b)); HeadersFooters hdd2 = ppt2.getSlideHeadersFooters(); assertTrue(hdd2.isSlideNumberVisible()); assertTrue(hdd2.isFooterVisible()); @@ -192,7 +192,7 @@ public final class TestHeadersFooters extends TestCase public void testCreateNotesFooters() throws Exception { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); HeadersFooters hdd = ppt.getNotesHeadersFooters(); hdd.setFootersText("My notes footer"); hdd.setHeaderText("My notes header"); @@ -202,7 +202,7 @@ public final class TestHeadersFooters extends TestCase ppt.write(out); byte[] b = out.toByteArray(); - SlideShow ppt2 = new SlideShow(new ByteArrayInputStream(b)); + HSLFSlideShow ppt2 = new HSLFSlideShow(new ByteArrayInputStream(b)); HeadersFooters hdd2 = ppt2.getNotesHeadersFooters(); assertTrue(hdd2.isSlideNumberVisible()); assertTrue(hdd2.isFooterVisible()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java index 6f9f9eb8b4..83e6ca6582 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHyperlink.java @@ -19,7 +19,7 @@ package org.apache.poi.hslf.model; import junit.framework.TestCase; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.POIDataSamples; /** @@ -31,10 +31,10 @@ public final class TestHyperlink extends TestCase { private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); public void testTextRunHyperlinks() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("WithLinks.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("WithLinks.ppt")); - TextRun[] run; - Slide slide; + HSLFTextParagraph[] run; + HSLFSlide slide; slide = ppt.getSlides()[0]; run = slide.getTextRuns(); for (int i = 0; i < run.length; i++) { diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java index 9de8cad43e..11a64f6379 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestImagePainter.java @@ -23,7 +23,7 @@ import junit.framework.TestCase; import org.apache.poi.hslf.blip.BitmapPainter; import org.apache.poi.hslf.blip.ImagePainter; -import org.apache.poi.hslf.usermodel.PictureData; +import org.apache.poi.hslf.usermodel.HSLFPictureData; /** * Test Picture shape. @@ -36,19 +36,19 @@ public final class TestImagePainter extends TestCase { public CustomImagePainter() { // no fields to initialise } - public void paint(Graphics2D graphics, PictureData pict, Picture parent){ + public void paint(Graphics2D graphics, HSLFPictureData pict, HSLFPictureShape parent){ //do noting } } public void testImagePainter() { - ImagePainter pntr = PictureData.getImagePainter(Picture.PNG); - assertTrue(PictureData.getImagePainter(Picture.PNG) instanceof BitmapPainter); - assertTrue(PictureData.getImagePainter(Picture.JPEG) instanceof BitmapPainter); - assertTrue(PictureData.getImagePainter(Picture.DIB) instanceof BitmapPainter); + ImagePainter pntr = HSLFPictureData.getImagePainter(HSLFPictureShape.PNG); + assertTrue(HSLFPictureData.getImagePainter(HSLFPictureShape.PNG) instanceof BitmapPainter); + assertTrue(HSLFPictureData.getImagePainter(HSLFPictureShape.JPEG) instanceof BitmapPainter); + assertTrue(HSLFPictureData.getImagePainter(HSLFPictureShape.DIB) instanceof BitmapPainter); - PictureData.setImagePainter(Picture.WMF, new CustomImagePainter()); - assertTrue(PictureData.getImagePainter(Picture.WMF) instanceof CustomImagePainter); + HSLFPictureData.setImagePainter(HSLFPictureShape.WMF, new CustomImagePainter()); + assertTrue(HSLFPictureData.getImagePainter(HSLFPictureShape.WMF) instanceof CustomImagePainter); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java index 735fa30466..413ff8ebe8 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java @@ -21,7 +21,7 @@ import java.awt.Color; import junit.framework.TestCase; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; /** * Test Line shape. @@ -31,9 +31,9 @@ import org.apache.poi.hslf.usermodel.SlideShow; public final class TestLine extends TestCase { public void testCreateLines() { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); slide.addTitle().setText("Lines tester"); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java index 9460642bb4..1b5bbd3298 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java @@ -23,7 +23,7 @@ import java.io.ByteArrayOutputStream; import junit.framework.TestCase; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.POIDataSamples; /** @@ -36,13 +36,13 @@ public final class TestMovieShape extends TestCase { private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); public void testCreate() throws Exception { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); String path = "/test-movie.mpg"; int movieIdx = ppt.addMovie(path, MovieShape.MOVIE_MPEG); - int thumbnailIdx = ppt.addPicture(_slTests.readFile("tomcat.png"), Picture.PNG); + int thumbnailIdx = ppt.addPicture(_slTests.readFile("tomcat.png"), HSLFPictureShape.PNG); MovieShape shape = new MovieShape(movieIdx, thumbnailIdx); shape.setAnchor(new Rectangle2D.Float(300,225,120,90)); @@ -56,7 +56,7 @@ public final class TestMovieShape extends TestCase { ByteArrayOutputStream out = new ByteArrayOutputStream(); ppt.write(out); - ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray())); + ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())); slide = ppt.getSlides()[0]; shape = (MovieShape)slide.getShapes()[0]; assertEquals(path, shape.getPath()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java index 249c4ee964..410f48226a 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java @@ -28,10 +28,9 @@ import java.io.InputStream; import junit.framework.TestCase; import org.apache.poi.POIDataSamples; -import org.apache.poi.hslf.HSLFSlideShow; -import org.apache.poi.hslf.usermodel.ObjectData; -import org.apache.poi.hslf.usermodel.PictureData; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFObjectData; +import org.apache.poi.hslf.usermodel.HSLFPictureData; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hwpf.HWPFDocument; @@ -46,31 +45,31 @@ public final class TestOleEmbedding extends TestCase { * @throws Exception if an error occurs. */ public void testOleEmbedding2003() throws Exception { - HSLFSlideShow slideShow = new HSLFSlideShow(_slTests.openResourceAsStream("ole2-embedding-2003.ppt")); + HSLFSlideShowImpl slideShow = new HSLFSlideShowImpl(_slTests.openResourceAsStream("ole2-embedding-2003.ppt")); // Placeholder EMFs for clients that don't support the OLE components. - PictureData[] pictures = slideShow.getPictures(); + HSLFPictureData[] pictures = slideShow.getPictures(); assertEquals("Should be two pictures", 2, pictures.length); //assertDigestEquals("Wrong data for picture 1", "8d1fbadf4814f321bb1ccdd056e3c788", pictures[0].getData()); //assertDigestEquals("Wrong data for picture 2", "987a698e83559cf3d38a0deeba1cc63b", pictures[1].getData()); // Actual embedded objects. - ObjectData[] objects = slideShow.getEmbeddedObjects(); + HSLFObjectData[] objects = slideShow.getEmbeddedObjects(); assertEquals("Should be two objects", 2, objects.length); //assertDigestEquals("Wrong data for objecs 1", "0d1fcc61a83de5c4894dc0c88e9a019d", objects[0].getData()); //assertDigestEquals("Wrong data for object 2", "b323604b2003a7299c77c2693b641495", objects[1].getData()); } public void testOLEShape() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("ole2-embedding-2003.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("ole2-embedding-2003.ppt")); - Slide slide = ppt.getSlides()[0]; + HSLFSlide slide = ppt.getSlides()[0]; HSLFShape[] sh = slide.getShapes(); int cnt = 0; for (int i = 0; i < sh.length; i++) { if(sh[i] instanceof OLEShape){ cnt++; OLEShape ole = (OLEShape)sh[i]; - ObjectData data = ole.getObjectData(); + HSLFObjectData data = ole.getObjectData(); if("Worksheet".equals(ole.getInstanceName())){ //Voila! we created a workbook from the embedded OLE data HSSFWorkbook wb = new HSSFWorkbook(data.getData()); @@ -94,11 +93,11 @@ public final class TestOleEmbedding extends TestCase { } public void testEmbedding() throws Exception { - HSLFSlideShow _hslfSlideShow = HSLFSlideShow.create(); - SlideShow ppt = new SlideShow(_hslfSlideShow); + HSLFSlideShowImpl _hslfSlideShow = HSLFSlideShowImpl.create(); + HSLFSlideShow ppt = new HSLFSlideShow(_hslfSlideShow); File pict = POIDataSamples.getSlideShowInstance().getFile("clock.jpg"); - int pictId = ppt.addPicture(pict, Picture.JPEG); + int pictId = ppt.addPicture(pict, HSLFPictureShape.JPEG); InputStream is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("Employee.xls"); POIFSFileSystem poiData1 = new POIFSFileSystem(is); @@ -106,14 +105,14 @@ public final class TestOleEmbedding extends TestCase { int oleObjectId1 = ppt.addEmbed(poiData1); - Slide slide1 = ppt.createSlide(); + HSLFSlide slide1 = ppt.createSlide(); OLEShape oleShape1 = new OLEShape(pictId); oleShape1.setObjectID(oleObjectId1); slide1.addShape(oleShape1); oleShape1.setAnchor(new Rectangle2D.Double(100,100,100,100)); // add second slide with different order in object creation - Slide slide2 = ppt.createSlide(); + HSLFSlide slide2 = ppt.createSlide(); OLEShape oleShape2 = new OLEShape(pictId); is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("SimpleWithImages.xls"); @@ -129,7 +128,7 @@ public final class TestOleEmbedding extends TestCase { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ppt.write(bos); - ppt = new SlideShow(new ByteArrayInputStream(bos.toByteArray())); + ppt = new HSLFSlideShow(new ByteArrayInputStream(bos.toByteArray())); OLEShape comp = (OLEShape)ppt.getSlides()[0].getShapes()[0]; byte compData[] = IOUtils.toByteArray(comp.getObjectData().getData()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java index aff848dfc5..fb04ccf5dd 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPFont.java @@ -18,7 +18,7 @@ package org.apache.poi.hslf.model; import junit.framework.TestCase; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; /** * Test adding fonts to the presenataion resources @@ -28,7 +28,7 @@ import org.apache.poi.hslf.usermodel.SlideShow; public final class TestPPFont extends TestCase{ public void testCreate() { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); assertEquals(1, ppt.getNumberOfFonts()); assertEquals("Arial", ppt.getFont(0).getFontName()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java index b58dbadecf..b71ce01035 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPPGraphics2D.java @@ -18,12 +18,11 @@ package org.apache.poi.hslf.model; import junit.framework.TestCase; -import org.apache.poi.hslf.usermodel.SlideShow; -import org.apache.poi.hslf.HSLFSlideShow; + +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.POIDataSamples; import java.awt.*; -import java.awt.Rectangle; import java.io.ByteArrayOutputStream; import java.io.ByteArrayInputStream; @@ -34,10 +33,10 @@ import java.io.ByteArrayInputStream; */ public final class TestPPGraphics2D extends TestCase { private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); - private SlideShow ppt; + private HSLFSlideShow ppt; protected void setUp() throws Exception { - ppt = new SlideShow(_slTests.openResourceAsStream("empty.ppt")); + ppt = new HSLFSlideShow(_slTests.openResourceAsStream("empty.ppt")); } public void testGraphics() throws Exception { @@ -45,7 +44,7 @@ public final class TestPPGraphics2D extends TestCase { assertEquals(0, ppt.getSlides().length); // Add a slide - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); assertEquals(1, ppt.getSlides().length); // Add some stuff into it @@ -73,7 +72,7 @@ public final class TestPPGraphics2D extends TestCase { out.close(); // And read it back in - ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); + ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray()))); assertEquals(1, ppt.getSlides().length); slide = ppt.getSlides()[0]; diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java index fabf63beee..08077f0e00 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestPicture.java @@ -36,9 +36,8 @@ import javax.imageio.ImageIO; import org.apache.poi.POIDataSamples; import org.apache.poi.ddf.EscherBSERecord; -import org.apache.poi.hslf.HSLFSlideShow; -import org.apache.poi.hslf.usermodel.PictureData; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFPictureData; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.util.JvmBugs; import org.junit.Ignore; import org.junit.Test; @@ -58,16 +57,16 @@ public final class TestPicture { */ @Test public void multiplePictures() throws Exception { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); - Slide s = ppt.createSlide(); - Slide s2 = ppt.createSlide(); - Slide s3 = ppt.createSlide(); + HSLFSlide s = ppt.createSlide(); + HSLFSlide s2 = ppt.createSlide(); + HSLFSlide s3 = ppt.createSlide(); - int idx = ppt.addPicture(_slTests.readFile("clock.jpg"), Picture.JPEG); - Picture pict = new Picture(idx); - Picture pict2 = new Picture(idx); - Picture pict3 = new Picture(idx); + int idx = ppt.addPicture(_slTests.readFile("clock.jpg"), HSLFPictureShape.JPEG); + HSLFPictureShape pict = new HSLFPictureShape(idx); + HSLFPictureShape pict2 = new HSLFPictureShape(idx); + HSLFPictureShape pict3 = new HSLFPictureShape(idx); pict.setAnchor(new Rectangle(10,10,100,100)); s.addShape(pict); @@ -93,12 +92,12 @@ public final class TestPicture { */ @Test public void bug46122() { - SlideShow ppt = new SlideShow(); - Slide slide = ppt.createSlide(); + HSLFSlideShow ppt = new HSLFSlideShow(); + HSLFSlide slide = ppt.createSlide(); - Picture pict = new Picture(-1); //index to non-existing picture data + HSLFPictureShape pict = new HSLFPictureShape(-1); //index to non-existing picture data pict.setSheet(slide); - PictureData data = pict.getPictureData(); + HSLFPictureData data = pict.getPictureData(); assertNull(data); BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); @@ -108,9 +107,9 @@ public final class TestPicture { @Test public void macImages() throws Exception { - HSLFSlideShow hss = new HSLFSlideShow(_slTests.openResourceAsStream("53446.ppt")); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(_slTests.openResourceAsStream("53446.ppt")); - PictureData[] pictures = hss.getPictures(); + HSLFPictureData[] pictures = hss.getPictures(); assertEquals(15, pictures.length); int[][] expectedSizes = { @@ -134,7 +133,7 @@ public final class TestPicture { for (int i = 0; i < pictures.length; i++) { BufferedImage image = ImageIO.read(new ByteArrayInputStream(pictures[i].getData())); - if (pictures[i].getType() != Picture.WMF && pictures[i].getType() != Picture.EMF) { + if (pictures[i].getType() != HSLFPictureShape.WMF && pictures[i].getType() != HSLFPictureShape.EMF) { assertNotNull(image); int[] dimensions = expectedSizes[i]; @@ -163,12 +162,12 @@ public final class TestPicture { // System.out.println("########################"); InputStream is = _slTests.openResourceAsStream("54541_cropped_bitmap.ppt"); - SlideShow ss = new SlideShow(is); + HSLFSlideShow ss = new HSLFSlideShow(is); is.close(); Dimension pg = ss.getPageSize(); int i=1; - for(Slide slide : ss.getSlides()) { + for(HSLFSlide slide : ss.getSlides()) { BufferedImage img = new BufferedImage(pg.width, pg.height, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics(); fixFonts(graphics); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java index 23b798fd6f..e1703626ca 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSetBoldItalic.java @@ -18,9 +18,9 @@ package org.apache.poi.hslf.model; import junit.framework.TestCase; -import org.apache.poi.hslf.usermodel.SlideShow; -import org.apache.poi.hslf.usermodel.RichTextRun; -import org.apache.poi.hslf.HSLFSlideShow; + +import org.apache.poi.hslf.usermodel.HSLFSlideShow; +import org.apache.poi.hslf.usermodel.HSLFTextRun; import java.io.ByteArrayOutputStream; import java.io.ByteArrayInputStream; @@ -36,15 +36,15 @@ public final class TestSetBoldItalic extends TestCase { * and set some of the style attributes */ public void testTextBoxWrite() throws Exception { - SlideShow ppt = new SlideShow(); - Slide sl = ppt.createSlide(); - RichTextRun rt; + HSLFSlideShow ppt = new HSLFSlideShow(); + HSLFSlide sl = ppt.createSlide(); + HSLFTextRun rt; String val = "Hello, World!"; // Create a new textbox, and give it lots of properties - TextBox txtbox = new TextBox(); - rt = txtbox.getTextRun().getRichTextRuns()[0]; + HSLFTextBox txtbox = new HSLFTextBox(); + rt = txtbox.getTextParagraph().getRichTextRuns()[0]; txtbox.setText(val); rt.setFontSize(42); rt.setBold(true); @@ -53,7 +53,7 @@ public final class TestSetBoldItalic extends TestCase { sl.addShape(txtbox); // Check it before save - rt = txtbox.getTextRun().getRichTextRuns()[0]; + rt = txtbox.getTextParagraph().getRichTextRuns()[0]; assertEquals(val, rt.getText()); assertEquals(42, rt.getFontSize()); assertTrue(rt.isBold()); @@ -64,11 +64,11 @@ public final class TestSetBoldItalic extends TestCase { ppt.write(out); out.close(); - ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); + ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray()))); sl = ppt.getSlides()[0]; - txtbox = (TextBox)sl.getShapes()[0]; - rt = txtbox.getTextRun().getRichTextRuns()[0]; + txtbox = (HSLFTextBox)sl.getShapes()[0]; + rt = txtbox.getTextParagraph().getRichTextRuns()[0]; // Check after save assertEquals(val, rt.getText()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java index 700b758a1e..9456c211f8 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java @@ -38,9 +38,8 @@ import org.apache.poi.ddf.EscherDggRecord; import org.apache.poi.ddf.EscherOptRecord; import org.apache.poi.ddf.EscherProperties; import org.apache.poi.ddf.EscherSimpleProperty; -import org.apache.poi.hslf.HSLFSlideShow; -import org.apache.poi.hslf.usermodel.RichTextRun; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFTextRun; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.sl.usermodel.ShapeType; import org.junit.Before; import org.junit.Test; @@ -53,17 +52,17 @@ import org.junit.Test; public final class TestShapes { private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); - private SlideShow ppt; - private SlideShow pptB; + private HSLFSlideShow ppt; + private HSLFSlideShow pptB; @Before public void setUp() throws Exception { InputStream is1 = null, is2 = null; try { is1 = _slTests.openResourceAsStream("empty.ppt"); - ppt = new SlideShow(is1); + ppt = new HSLFSlideShow(is1); is2 = _slTests.openResourceAsStream("empty_textbox.ppt"); - pptB = new SlideShow(is2); + pptB = new HSLFSlideShow(is2); } finally { is1.close(); is2.close(); @@ -72,7 +71,7 @@ public final class TestShapes { @Test public void graphics() throws Exception { - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); Line line = new Line(); java.awt.Rectangle lineAnchor = new java.awt.Rectangle(100, 200, 50, 60); @@ -82,7 +81,7 @@ public final class TestShapes { line.setLineColor(Color.red); slide.addShape(line); - AutoShape ellipse = new AutoShape(ShapeType.ELLIPSE); + HSLFAutoShape ellipse = new HSLFAutoShape(ShapeType.ELLIPSE); java.awt.Rectangle ellipseAnchor = new Rectangle(320, 154, 55, 111); ellipse.setAnchor(ellipseAnchor); ellipse.setLineWidth(2); @@ -97,7 +96,7 @@ public final class TestShapes { //read ppt from byte array - ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); + ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray()))); assertEquals(1, ppt.getSlides().length); slide = ppt.getSlides()[0]; @@ -107,7 +106,7 @@ public final class TestShapes { assertTrue(shape[0] instanceof Line); //group shape assertEquals(lineAnchor, shape[0].getAnchor()); //group shape - assertTrue(shape[1] instanceof AutoShape); //group shape + assertTrue(shape[1] instanceof HSLFAutoShape); //group shape assertEquals(ellipseAnchor, shape[1].getAnchor()); //group shape } @@ -117,17 +116,17 @@ public final class TestShapes { */ @Test public void textBoxRead() throws Exception { - ppt = new SlideShow(_slTests.openResourceAsStream("with_textbox.ppt")); - Slide sl = ppt.getSlides()[0]; + ppt = new HSLFSlideShow(_slTests.openResourceAsStream("with_textbox.ppt")); + HSLFSlide sl = ppt.getSlides()[0]; HSLFShape[] sh = sl.getShapes(); for (int i = 0; i < sh.length; i++) { - assertTrue(sh[i] instanceof TextBox); - TextBox txtbox = (TextBox)sh[i]; + assertTrue(sh[i] instanceof HSLFTextBox); + HSLFTextBox txtbox = (HSLFTextBox)sh[i]; String text = txtbox.getText(); assertNotNull(text); - assertEquals(txtbox.getTextRun().getRichTextRuns().length, 1); - RichTextRun rt = txtbox.getTextRun().getRichTextRuns()[0]; + assertEquals(txtbox.getTextParagraph().getRichTextRuns().length, 1); + HSLFTextRun rt = txtbox.getTextParagraph().getRichTextRuns()[0]; if (text.equals("Hello, World!!!")){ assertEquals(32, rt.getFontSize()); @@ -153,15 +152,15 @@ public final class TestShapes { */ @Test public void textBoxWriteBytes() throws Exception { - ppt = new SlideShow(); - Slide sl = ppt.createSlide(); - RichTextRun rt; + ppt = new HSLFSlideShow(); + HSLFSlide sl = ppt.createSlide(); + HSLFTextRun rt; String val = "Hello, World!"; // Create a new textbox, and give it lots of properties - TextBox txtbox = new TextBox(); - rt = txtbox.getTextRun().getRichTextRuns()[0]; + HSLFTextBox txtbox = new HSLFTextBox(); + rt = txtbox.getTextParagraph().getRichTextRuns()[0]; txtbox.setText(val); rt.setFontName("Arial"); rt.setFontSize(42); @@ -172,7 +171,7 @@ public final class TestShapes { sl.addShape(txtbox); // Check it before save - rt = txtbox.getTextRun().getRichTextRuns()[0]; + rt = txtbox.getTextParagraph().getRichTextRuns()[0]; assertEquals(val, rt.getText()); assertEquals(42, rt.getFontSize()); assertTrue(rt.isBold()); @@ -186,11 +185,11 @@ public final class TestShapes { ppt.write(out); out.close(); - ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); + ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray()))); sl = ppt.getSlides()[0]; - txtbox = (TextBox)sl.getShapes()[0]; - rt = txtbox.getTextRun().getRichTextRuns()[0]; + txtbox = (HSLFTextBox)sl.getShapes()[0]; + rt = txtbox.getTextParagraph().getRichTextRuns()[0]; // Check after save assertEquals(val, rt.getText()); @@ -208,8 +207,8 @@ public final class TestShapes { @Test public void emptyTextBox() { assertEquals(2, pptB.getSlides().length); - Slide s1 = pptB.getSlides()[0]; - Slide s2 = pptB.getSlides()[1]; + HSLFSlide s1 = pptB.getSlides()[0]; + HSLFSlide s2 = pptB.getSlides()[1]; // Check we can get the shapes count assertEquals(2, s1.getShapes().length); @@ -231,11 +230,11 @@ public final class TestShapes { } private void textBoxSet(String filename) throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream(filename)); - Slide[] sl = ppt.getSlides(); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream(filename)); + HSLFSlide[] sl = ppt.getSlides(); for (int k = 0; k < sl.length; k++) { ArrayList lst1 = new ArrayList(); - TextRun[] txt = sl[k].getTextRuns(); + HSLFTextParagraph[] txt = sl[k].getTextRuns(); for (int i = 0; i < txt.length; i++) { lst1.add(txt[i].getText()); } @@ -243,8 +242,8 @@ public final class TestShapes { ArrayList lst2 = new ArrayList(); HSLFShape[] sh = sl[k].getShapes(); for (int i = 0; i < sh.length; i++) { - if (sh[i] instanceof TextShape){ - TextShape tbox = (TextShape)sh[i]; + if (sh[i] instanceof HSLFTextShape){ + HSLFTextShape tbox = (HSLFTextShape)sh[i]; lst2.add(tbox.getText()); } } @@ -258,9 +257,9 @@ public final class TestShapes { */ @Test public void shapeGroup() throws Exception { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); Dimension pgsize = ppt.getPageSize(); HSLFGroupShape group = new HSLFGroupShape(); @@ -268,8 +267,8 @@ public final class TestShapes { group.setAnchor(new Rectangle(0, 0, (int)pgsize.getWidth(), (int)pgsize.getHeight())); slide.addShape(group); - int idx = ppt.addPicture(_slTests.readFile("clock.jpg"), Picture.JPEG); - Picture pict = new Picture(idx, group); + int idx = ppt.addPicture(_slTests.readFile("clock.jpg"), HSLFPictureShape.JPEG); + HSLFPictureShape pict = new HSLFPictureShape(idx, group); pict.setAnchor(new Rectangle(0, 0, 200, 200)); group.addShape(pict); @@ -283,7 +282,7 @@ public final class TestShapes { out.close(); ByteArrayInputStream is = new ByteArrayInputStream(out.toByteArray()); - ppt = new SlideShow(is); + ppt = new HSLFSlideShow(is); is.close(); slide = ppt.getSlides()[0]; @@ -295,10 +294,10 @@ public final class TestShapes { group = (HSLFGroupShape)shape[0]; HSLFShape[] grshape = group.getShapes(); assertEquals(2, grshape.length); - assertTrue(grshape[0] instanceof Picture); + assertTrue(grshape[0] instanceof HSLFPictureShape); assertTrue(grshape[1] instanceof Line); - pict = (Picture)grshape[0]; + pict = (HSLFPictureShape)grshape[0]; assertEquals(new Rectangle(0, 0, 200, 200), pict.getAnchor()); line = (Line)grshape[1]; @@ -311,8 +310,8 @@ public final class TestShapes { @Test public void removeShapes() throws IOException { String file = "with_textbox.ppt"; - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream(file)); - Slide sl = ppt.getSlides()[0]; + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream(file)); + HSLFSlide sl = ppt.getSlides()[0]; HSLFShape[] sh = sl.getShapes(); assertEquals("expected four shaped in " + file, 4, sh.length); //remove all @@ -328,30 +327,30 @@ public final class TestShapes { ppt.write(out); out.close(); - ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray())); + ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())); sl = ppt.getSlides()[0]; assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().length); } @Test public void lineWidth() { - SimpleShape sh = new AutoShape(ShapeType.RT_TRIANGLE); + HSLFSimpleShape sh = new HSLFAutoShape(ShapeType.RT_TRIANGLE); EscherOptRecord opt = sh.getEscherOptRecord(); - EscherSimpleProperty prop = SimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH); + EscherSimpleProperty prop = HSLFSimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH); assertNull(prop); - assertEquals(SimpleShape.DEFAULT_LINE_WIDTH, sh.getLineWidth(), 0); + assertEquals(HSLFSimpleShape.DEFAULT_LINE_WIDTH, sh.getLineWidth(), 0); sh.setLineWidth(1.0); - prop = SimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH); + prop = HSLFSimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH); assertNotNull(prop); assertEquals(1.0, sh.getLineWidth(), 0); } @Test public void shapeId() { - SlideShow ppt = new SlideShow(); - Slide slide = ppt.createSlide(); + HSLFSlideShow ppt = new HSLFSlideShow(); + HSLFSlide slide = ppt.createSlide(); HSLFShape shape = null; //EscherDgg is a document-level record which keeps track of the drawing groups @@ -400,25 +399,25 @@ public final class TestShapes { @Test public void lineColor() throws IOException { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("51731.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("51731.ppt")); HSLFShape[] shape = ppt.getSlides()[0].getShapes(); assertEquals(4, shape.length); - TextShape sh1 = (TextShape)shape[0]; + HSLFTextShape sh1 = (HSLFTextShape)shape[0]; assertEquals("Hello Apache POI", sh1.getText()); assertNull(sh1.getLineColor()); - TextShape sh2 = (TextShape)shape[1]; + HSLFTextShape sh2 = (HSLFTextShape)shape[1]; assertEquals("Why are you showing this border?", sh2.getText()); assertNull(sh2.getLineColor()); - TextShape sh3 = (TextShape)shape[2]; + HSLFTextShape sh3 = (HSLFTextShape)shape[2]; assertEquals("Text in a black border", sh3.getText()); assertEquals(Color.black, sh3.getLineColor()); assertEquals(0.75, sh3.getLineWidth(), 0); - TextShape sh4 = (TextShape)shape[3]; + HSLFTextShape sh4 = (HSLFTextShape)shape[3]; assertEquals("Border width is 5 pt", sh4.getText()); assertEquals(Color.black, sh4.getLineColor()); assertEquals(5.0, sh4.getLineWidth(), 0); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java index a22e7eb3f9..60b8ca42e2 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSheet.java @@ -23,7 +23,7 @@ import junit.framework.TestCase; import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException; import org.apache.poi.hslf.record.ColorSchemeAtom; import org.apache.poi.hslf.record.PPDrawing; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.POIDataSamples; /** @@ -42,7 +42,7 @@ public final class TestSheet extends TestCase { String[] tests = {"SampleShow.ppt", "backgrounds.ppt", "text_shapes.ppt", "pictures.ppt"}; for (String file : tests) { try { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream(file)); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream(file)); doSlideShow(ppt); } catch (EncryptedPowerPointFileException e){ ; //skip encrypted ppt @@ -50,21 +50,21 @@ public final class TestSheet extends TestCase { } } - private void doSlideShow(SlideShow ppt) { - Slide[] slide = ppt.getSlides(); + private void doSlideShow(HSLFSlideShow ppt) { + HSLFSlide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { verify(slide[i]); - Notes notes = slide[i].getNotesSheet(); + HSLFNotes notes = slide[i].getNotesSheet(); if(notes != null) verify(notes); - MasterSheet master = slide[i].getMasterSheet(); + HSLFMasterSheet master = slide[i].getMasterSheet(); assertNotNull(master); verify(master); } } - private void verify(Sheet sheet){ + private void verify(HSLFSheet sheet){ assertNotNull(sheet.getSlideShow()); ColorSchemeAtom colorscheme = sheet.getColorScheme(); @@ -73,13 +73,13 @@ public final class TestSheet extends TestCase { PPDrawing ppdrawing = sheet.getPPDrawing(); assertNotNull(ppdrawing); - Background background = sheet.getBackground(); + HSLFBackground background = sheet.getBackground(); assertNotNull(background); assertTrue(sheet._getSheetNumber() != 0); assertTrue(sheet._getSheetRefId() != 0); - TextRun[] txt = sheet.getTextRuns(); + HSLFTextParagraph[] txt = sheet.getTextRuns(); if (txt == null) { throw new AssertionFailedError("no text runs"); } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java index 71c95f87b7..2d4fe15131 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideChangeNotes.java @@ -20,9 +20,8 @@ package org.apache.poi.hslf.model; import junit.framework.TestCase; -import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.record.SlideAtom; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.POIDataSamples; /** @@ -32,16 +31,16 @@ import org.apache.poi.POIDataSamples; */ public final class TestSlideChangeNotes extends TestCase { // SlideShow primed on the test data - private SlideShow ss; + private HSLFSlideShow ss; public TestSlideChangeNotes() throws Exception { POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); - HSLFSlideShow hss = new HSLFSlideShow(_slTests.openResourceAsStream("basic_test_ppt_file.ppt")); - ss = new SlideShow(hss); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(_slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + ss = new HSLFSlideShow(hss); } public void testSetToNone() { - Slide slideOne = ss.getSlides()[0]; + HSLFSlide slideOne = ss.getSlides()[0]; SlideAtom sa = slideOne.getSlideRecord().getSlideAtom(); slideOne.setNotes(null); @@ -50,8 +49,8 @@ public final class TestSlideChangeNotes extends TestCase { } public void testSetToSomething() { - Slide slideOne = ss.getSlides()[0]; - Notes notesOne = ss.getNotes()[1]; + HSLFSlide slideOne = ss.getSlides()[0]; + HSLFNotes notesOne = ss.getNotes()[1]; SlideAtom sa = slideOne.getSlideRecord().getSlideAtom(); slideOne.setNotes(notesOne); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java index 45c3c0c2bc..ffb6563da5 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlideMaster.java @@ -22,12 +22,11 @@ import java.io.ByteArrayOutputStream; import junit.framework.TestCase; -import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp; import org.apache.poi.hslf.record.Environment; import org.apache.poi.hslf.record.TextHeaderAtom; -import org.apache.poi.hslf.usermodel.RichTextRun; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFTextRun; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.POIDataSamples; /** @@ -43,7 +42,7 @@ public final class TestSlideMaster extends TestCase{ * Check we can read their attributes. */ public void testSlideMaster() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("slide_master.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt")); Environment env = ppt.getDocumentRecord().getEnvironment(); @@ -83,7 +82,7 @@ public final class TestSlideMaster extends TestCase{ * Test we can read default text attributes for a title master sheet */ public void testTitleMasterTextAttributes() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("slide_master.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt")); TitleMaster[] master = ppt.getTitleMasters(); assertEquals(1, master.length); @@ -104,14 +103,14 @@ public final class TestSlideMaster extends TestCase{ * Slide 3 has title layout and follows the TitleMaster. Verify that. */ public void testTitleMaster() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("slide_master.ppt")); - Slide slide = ppt.getSlides()[2]; - MasterSheet masterSheet = slide.getMasterSheet(); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt")); + HSLFSlide slide = ppt.getSlides()[2]; + HSLFMasterSheet masterSheet = slide.getMasterSheet(); assertTrue(masterSheet instanceof TitleMaster); - TextRun[] txt = slide.getTextRuns(); + HSLFTextParagraph[] txt = slide.getTextRuns(); for (int i = 0; i < txt.length; i++) { - RichTextRun rt = txt[i].getRichTextRuns()[0]; + HSLFTextRun rt = txt[i].getRichTextRuns()[0]; switch(txt[i].getRunType()){ case TextHeaderAtom.CENTER_TITLE_TYPE: assertEquals("Arial", rt.getFontName()); @@ -133,20 +132,20 @@ public final class TestSlideMaster extends TestCase{ * If a style attribute is not set ensure it is read from the master */ public void testMasterAttributes() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("slide_master.ppt")); - Slide[] slide = ppt.getSlides(); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt")); + HSLFSlide[] slide = ppt.getSlides(); assertEquals(3, slide.length); - TextRun[] trun; + HSLFTextParagraph[] trun; trun = slide[0].getTextRuns(); for (int i = 0; i < trun.length; i++) { if (trun[i].getRunType() == TextHeaderAtom.TITLE_TYPE){ - RichTextRun rt = trun[i].getRichTextRuns()[0]; + HSLFTextRun rt = trun[i].getRichTextRuns()[0]; assertEquals(40, rt.getFontSize()); assertEquals(true, rt.isUnderlined()); assertEquals("Arial", rt.getFontName()); } else if (trun[i].getRunType() == TextHeaderAtom.BODY_TYPE){ - RichTextRun rt; + HSLFTextRun rt; rt = trun[i].getRichTextRuns()[0]; assertEquals(0, rt.getIndentLevel()); assertEquals(32, rt.getFontSize()); @@ -163,12 +162,12 @@ public final class TestSlideMaster extends TestCase{ trun = slide[1].getTextRuns(); for (int i = 0; i < trun.length; i++) { if (trun[i].getRunType() == TextHeaderAtom.TITLE_TYPE){ - RichTextRun rt = trun[i].getRichTextRuns()[0]; + HSLFTextRun rt = trun[i].getRichTextRuns()[0]; assertEquals(48, rt.getFontSize()); assertEquals(true, rt.isItalic()); assertEquals("Georgia", rt.getFontName()); } else if (trun[i].getRunType() == TextHeaderAtom.BODY_TYPE){ - RichTextRun rt; + HSLFTextRun rt; rt = trun[i].getRichTextRuns()[0]; assertEquals(0, rt.getIndentLevel()); assertEquals(32, rt.getFontSize()); @@ -182,9 +181,9 @@ public final class TestSlideMaster extends TestCase{ * Check we can dynamically assign a slide master to a slide. */ public void testChangeSlideMaster() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("slide_master.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt")); SlideMaster[] master = ppt.getSlidesMasters(); - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); int sheetNo; //each slide uses its own master @@ -203,7 +202,7 @@ public final class TestSlideMaster extends TestCase{ ppt.write(out); out.close(); - ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); + ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray()))); master = ppt.getSlidesMasters(); slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { @@ -216,19 +215,19 @@ public final class TestSlideMaster extends TestCase{ * (typical for the "bullted body" placeholder) */ public void testIndentation() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("slide_master.ppt")); - Slide slide = ppt.getSlides()[0]; - TextRun[] trun; + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("slide_master.ppt")); + HSLFSlide slide = ppt.getSlides()[0]; + HSLFTextParagraph[] trun; trun = slide.getTextRuns(); for (int i = 0; i < trun.length; i++) { if (trun[i].getRunType() == TextHeaderAtom.TITLE_TYPE){ - RichTextRun rt = trun[i].getRichTextRuns()[0]; + HSLFTextRun rt = trun[i].getRichTextRuns()[0]; assertEquals(40, rt.getFontSize()); assertEquals(true, rt.isUnderlined()); assertEquals("Arial", rt.getFontName()); } else if (trun[i].getRunType() == TextHeaderAtom.BODY_TYPE){ - RichTextRun[] rt = trun[i].getRichTextRuns(); + HSLFTextRun[] rt = trun[i].getRichTextRuns(); for (int j = 0; j < rt.length; j++) { int indent = rt[j].getIndentLevel(); switch (indent){ diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java index 11889f4409..f5e0abef59 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java @@ -18,8 +18,8 @@ package org.apache.poi.hslf.model; import junit.framework.TestCase; -import org.apache.poi.hslf.HSLFSlideShow; -import org.apache.poi.hslf.usermodel.SlideShow; + +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.POIDataSamples; import java.io.ByteArrayOutputStream; @@ -39,10 +39,10 @@ public final class TestSlides extends TestCase { * @throws Exception */ public void testAddSlides1() throws Exception { - SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") )); + HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") )); assertTrue(ppt.getSlides().length == 0); - Slide s1 = ppt.createSlide(); + HSLFSlide s1 = ppt.createSlide(); assertTrue(ppt.getSlides().length == 1); assertEquals(3, s1._getSheetRefId()); assertEquals(256, s1._getSheetNumber()); @@ -53,7 +53,7 @@ public final class TestSlides extends TestCase { ppt.write(out); out.close(); - ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); + ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray()))); assertTrue(ppt.getSlides().length == 1); } @@ -62,16 +62,16 @@ public final class TestSlides extends TestCase { * @throws Exception */ public void testAddSlides2() throws Exception { - SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") )); + HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") )); assertTrue(ppt.getSlides().length == 0); - Slide s1 = ppt.createSlide(); + HSLFSlide s1 = ppt.createSlide(); assertTrue(ppt.getSlides().length == 1); assertEquals(3, s1._getSheetRefId()); assertEquals(256, s1._getSheetNumber()); assertEquals(1, s1.getSlideNumber()); - Slide s2 = ppt.createSlide(); + HSLFSlide s2 = ppt.createSlide(); assertTrue(ppt.getSlides().length == 2); assertEquals(4, s2._getSheetRefId()); assertEquals(257, s2._getSheetNumber()); @@ -82,7 +82,7 @@ public final class TestSlides extends TestCase { ppt.write(out); out.close(); - ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); + ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray()))); assertTrue(ppt.getSlides().length == 2); } @@ -91,22 +91,22 @@ public final class TestSlides extends TestCase { * @throws Exception */ public void testAddSlides3() throws Exception { - SlideShow ppt = new SlideShow(new HSLFSlideShow( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") )); + HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl( TestSlides.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt") )); assertTrue(ppt.getSlides().length == 0); - Slide s1 = ppt.createSlide(); + HSLFSlide s1 = ppt.createSlide(); assertTrue(ppt.getSlides().length == 1); assertEquals(3, s1._getSheetRefId()); assertEquals(256, s1._getSheetNumber()); assertEquals(1, s1.getSlideNumber()); - Slide s2 = ppt.createSlide(); + HSLFSlide s2 = ppt.createSlide(); assertTrue(ppt.getSlides().length == 2); assertEquals(4, s2._getSheetRefId()); assertEquals(257, s2._getSheetNumber()); assertEquals(2, s2.getSlideNumber()); - Slide s3 = ppt.createSlide(); + HSLFSlide s3 = ppt.createSlide(); assertTrue(ppt.getSlides().length == 3); assertEquals(5, s3._getSheetRefId()); assertEquals(258, s3._getSheetNumber()); @@ -118,7 +118,7 @@ public final class TestSlides extends TestCase { ppt.write(out); out.close(); - ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); + ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray()))); assertTrue(ppt.getSlides().length == 3); // Check IDs are still right @@ -139,22 +139,22 @@ public final class TestSlides extends TestCase { */ public void testAddSlides2to3() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - SlideShow ppt = new SlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); assertTrue(ppt.getSlides().length == 2); // First slide is 256 / 4 - Slide s1 = ppt.getSlides()[0]; + HSLFSlide s1 = ppt.getSlides()[0]; assertEquals(256, s1._getSheetNumber()); assertEquals(4, s1._getSheetRefId()); // Last slide is 257 / 6 - Slide s2 = ppt.getSlides()[1]; + HSLFSlide s2 = ppt.getSlides()[1]; assertEquals(257, s2._getSheetNumber()); assertEquals(6, s2._getSheetRefId()); // Add another slide, goes in at the end - Slide s3 = ppt.createSlide(); + HSLFSlide s3 = ppt.createSlide(); assertTrue(ppt.getSlides().length == 3); assertEquals(258, s3._getSheetNumber()); assertEquals(8, s3._getSheetRefId()); @@ -165,7 +165,7 @@ public final class TestSlides extends TestCase { ppt.write(out); out.close(); - ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); + ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray()))); assertTrue(ppt.getSlides().length == 3); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java index 480fd8ab65..d3fb354063 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java @@ -23,7 +23,7 @@ import java.io.ByteArrayOutputStream; import junit.framework.TestCase; import org.apache.poi.hslf.record.TextHeaderAtom; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; /** * Test Table object. @@ -36,16 +36,16 @@ public final class TestTable extends TestCase { * Test that ShapeFactory works properly and returns Table */ public void testShapeFactory() throws Exception { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); Table tbl = new Table(2, 5); slide.addShape(tbl); TableCell cell = tbl.getCell(0, 0); //table cells have type=TextHeaderAtom.OTHER_TYPE, see bug #46033 - assertEquals(TextHeaderAtom.OTHER_TYPE, cell.getTextRun().getRunType()); + assertEquals(TextHeaderAtom.OTHER_TYPE, cell.getTextParagraph().getRunType()); assertTrue(slide.getShapes()[0] instanceof Table); Table tbl2 = (Table)slide.getShapes()[0]; @@ -56,7 +56,7 @@ public final class TestTable extends TestCase { ppt.write(out); out.close(); - ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray())); + ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())); slide = ppt.getSlides()[0]; assertTrue(slide.getShapes()[0] instanceof Table); Table tbl3 = (Table)slide.getShapes()[0]; @@ -68,8 +68,8 @@ public final class TestTable extends TestCase { * Error constructing Table when rownum=1 */ public void test45889(){ - SlideShow ppt = new SlideShow(); - Slide slide = ppt.createSlide(); + HSLFSlideShow ppt = new HSLFSlideShow(); + HSLFSlide slide = ppt.createSlide(); HSLFShape[] shapes; Table tbl1 = new Table(1, 5); assertEquals(5, tbl1.getNumberOfColumns()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRun.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRun.java index 1b0119307a..01ce6a0534 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRun.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRun.java @@ -30,8 +30,8 @@ import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.TextBytesAtom; import org.apache.poi.hslf.record.TextCharsAtom; import org.apache.poi.hslf.record.TextHeaderAtom; -import org.apache.poi.hslf.usermodel.RichTextRun; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFTextRun; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.POIDataSamples; /** @@ -43,24 +43,24 @@ public final class TestTextRun extends TestCase { private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); // SlideShow primed on the test data - private SlideShow ss; - private SlideShow ssRich; + private HSLFSlideShow ss; + private HSLFSlideShow ssRich; protected void setUp() throws IOException { // Basic (non rich) test file - ss = new SlideShow(_slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + ss = new HSLFSlideShow(_slTests.openResourceAsStream("basic_test_ppt_file.ppt")); // Rich test file - ssRich = new SlideShow(_slTests.openResourceAsStream("Single_Coloured_Page.ppt")); + ssRich = new HSLFSlideShow(_slTests.openResourceAsStream("Single_Coloured_Page.ppt")); } /** * Test to ensure that getting the text works correctly */ public void testGetText() { - Slide slideOne = ss.getSlides()[0]; - TextRun[] textRuns = slideOne.getTextRuns(); + HSLFSlide slideOne = ss.getSlides()[0]; + HSLFTextParagraph[] textRuns = slideOne.getTextRuns(); assertEquals(2, textRuns.length); @@ -74,8 +74,8 @@ public final class TestTextRun extends TestCase { // Now check on a rich text run - Slide slideOneR = ssRich.getSlides()[0]; - TextRun[] textRunsR = slideOneR.getTextRuns(); + HSLFSlide slideOneR = ssRich.getSlides()[0]; + HSLFTextParagraph[] textRunsR = slideOneR.getTextRuns(); assertEquals(2, textRunsR.length); assertEquals("This is a title, it\u2019s in black", textRunsR[0].getText()); @@ -88,9 +88,9 @@ public final class TestTextRun extends TestCase { * Test to ensure changing non rich text bytes->bytes works correctly */ public void testSetText() { - Slide slideOne = ss.getSlides()[0]; - TextRun[] textRuns = slideOne.getTextRuns(); - TextRun run = textRuns[0]; + HSLFSlide slideOne = ss.getSlides()[0]; + HSLFTextParagraph[] textRuns = slideOne.getTextRuns(); + HSLFTextParagraph run = textRuns[0]; // Check current text assertEquals("This is a test title", run.getText()); @@ -110,8 +110,8 @@ public final class TestTextRun extends TestCase { * chars works correctly */ public void testAdvancedSetText() { - Slide slideOne = ss.getSlides()[0]; - TextRun run = slideOne.getTextRuns()[0]; + HSLFSlide slideOne = ss.getSlides()[0]; + HSLFTextParagraph run = slideOne.getTextRuns()[0]; TextHeaderAtom tha = run._headerAtom; TextBytesAtom tba = run._byteAtom; @@ -171,19 +171,19 @@ public final class TestTextRun extends TestCase { * set up for it */ public void testGetRichTextNonRich() { - Slide slideOne = ss.getSlides()[0]; - TextRun[] textRuns = slideOne.getTextRuns(); + HSLFSlide slideOne = ss.getSlides()[0]; + HSLFTextParagraph[] textRuns = slideOne.getTextRuns(); assertEquals(2, textRuns.length); - TextRun trA = textRuns[0]; - TextRun trB = textRuns[1]; + HSLFTextParagraph trA = textRuns[0]; + HSLFTextParagraph trB = textRuns[1]; assertEquals(1, trA.getRichTextRuns().length); assertEquals(1, trB.getRichTextRuns().length); - RichTextRun rtrA = trA.getRichTextRuns()[0]; - RichTextRun rtrB = trB.getRichTextRuns()[0]; + HSLFTextRun rtrA = trA.getRichTextRuns()[0]; + HSLFTextRun rtrB = trB.getRichTextRuns()[0]; assertEquals(trA.getText(), rtrA.getText()); assertEquals(trB.getText(), rtrB.getText()); @@ -198,21 +198,21 @@ public final class TestTextRun extends TestCase { * Tests to ensure that the rich text runs are built up correctly */ public void testGetRichText() { - Slide slideOne = ssRich.getSlides()[0]; - TextRun[] textRuns = slideOne.getTextRuns(); + HSLFSlide slideOne = ssRich.getSlides()[0]; + HSLFTextParagraph[] textRuns = slideOne.getTextRuns(); assertEquals(2, textRuns.length); - TextRun trA = textRuns[0]; - TextRun trB = textRuns[1]; + HSLFTextParagraph trA = textRuns[0]; + HSLFTextParagraph trB = textRuns[1]; assertEquals(1, trA.getRichTextRuns().length); assertEquals(3, trB.getRichTextRuns().length); - RichTextRun rtrA = trA.getRichTextRuns()[0]; - RichTextRun rtrB = trB.getRichTextRuns()[0]; - RichTextRun rtrC = trB.getRichTextRuns()[1]; - RichTextRun rtrD = trB.getRichTextRuns()[2]; + HSLFTextRun rtrA = trA.getRichTextRuns()[0]; + HSLFTextRun rtrB = trB.getRichTextRuns()[0]; + HSLFTextRun rtrC = trB.getRichTextRuns()[1]; + HSLFTextRun rtrD = trB.getRichTextRuns()[2]; assertEquals(trA.getText(), rtrA.getText()); @@ -244,12 +244,12 @@ public final class TestTextRun extends TestCase { * ensuring that everything stays with the same default styling */ public void testSetTextWhereNotRich() { - Slide slideOne = ss.getSlides()[0]; - TextRun[] textRuns = slideOne.getTextRuns(); - TextRun trB = textRuns[1]; + HSLFSlide slideOne = ss.getSlides()[0]; + HSLFTextParagraph[] textRuns = slideOne.getTextRuns(); + HSLFTextParagraph trB = textRuns[1]; assertEquals(1, trB.getRichTextRuns().length); - RichTextRun rtrB = trB.getRichTextRuns()[0]; + HSLFTextRun rtrB = trB.getRichTextRuns()[0]; assertEquals(trB.getText(), rtrB.getText()); assertNull(rtrB._getRawCharacterStyle()); assertNull(rtrB._getRawParagraphStyle()); @@ -268,14 +268,14 @@ public final class TestTextRun extends TestCase { * sets everything to the same styling */ public void testSetTextWhereRich() { - Slide slideOne = ssRich.getSlides()[0]; - TextRun[] textRuns = slideOne.getTextRuns(); - TextRun trB = textRuns[1]; + HSLFSlide slideOne = ssRich.getSlides()[0]; + HSLFTextParagraph[] textRuns = slideOne.getTextRuns(); + HSLFTextParagraph trB = textRuns[1]; assertEquals(3, trB.getRichTextRuns().length); - RichTextRun rtrB = trB.getRichTextRuns()[0]; - RichTextRun rtrC = trB.getRichTextRuns()[1]; - RichTextRun rtrD = trB.getRichTextRuns()[2]; + HSLFTextRun rtrB = trB.getRichTextRuns()[0]; + HSLFTextRun rtrC = trB.getRichTextRuns()[1]; + HSLFTextRun rtrD = trB.getRichTextRuns()[2]; TextPropCollection tpBP = rtrB._getRawParagraphStyle(); TextPropCollection tpBC = rtrB._getRawCharacterStyle(); TextPropCollection tpCP = rtrC._getRawParagraphStyle(); @@ -316,12 +316,12 @@ public final class TestTextRun extends TestCase { * in a rich text run, that doesn't happen to actually be rich */ public void testChangeTextInRichTextRunNonRich() { - Slide slideOne = ss.getSlides()[0]; - TextRun[] textRuns = slideOne.getTextRuns(); - TextRun trB = textRuns[1]; + HSLFSlide slideOne = ss.getSlides()[0]; + HSLFTextParagraph[] textRuns = slideOne.getTextRuns(); + HSLFTextParagraph trB = textRuns[1]; assertEquals(1, trB.getRichTextRuns().length); - RichTextRun rtrB = trB.getRichTextRuns()[0]; + HSLFTextRun rtrB = trB.getRichTextRuns()[0]; assertEquals(trB.getText(), rtrB.getText()); assertNull(rtrB._getRawCharacterStyle()); assertNull(rtrB._getRawParagraphStyle()); @@ -341,16 +341,16 @@ public final class TestTextRun extends TestCase { * correctly */ public void testChangeTextInRichTextRun() { - Slide slideOne = ssRich.getSlides()[0]; - TextRun[] textRuns = slideOne.getTextRuns(); - TextRun trB = textRuns[1]; + HSLFSlide slideOne = ssRich.getSlides()[0]; + HSLFTextParagraph[] textRuns = slideOne.getTextRuns(); + HSLFTextParagraph trB = textRuns[1]; assertEquals(3, trB.getRichTextRuns().length); // We start with 3 text runs, each with their own set of styles, // but all sharing the same paragraph styles - RichTextRun rtrB = trB.getRichTextRuns()[0]; - RichTextRun rtrC = trB.getRichTextRuns()[1]; - RichTextRun rtrD = trB.getRichTextRuns()[2]; + HSLFTextRun rtrB = trB.getRichTextRuns()[0]; + HSLFTextRun rtrC = trB.getRichTextRuns()[1]; + HSLFTextRun rtrD = trB.getRichTextRuns()[2]; TextPropCollection tpBP = rtrB._getRawParagraphStyle(); TextPropCollection tpBC = rtrB._getRawCharacterStyle(); TextPropCollection tpCP = rtrC._getRawParagraphStyle(); @@ -421,11 +421,11 @@ public final class TestTextRun extends TestCase { * */ public void testBug41015() throws IOException { - RichTextRun[] rt; + HSLFTextRun[] rt; - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("bug-41015.ppt")); - Slide sl = ppt.getSlides()[0]; - TextRun[] txt = sl.getTextRuns(); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("bug-41015.ppt")); + HSLFSlide sl = ppt.getSlides()[0]; + HSLFTextParagraph[] txt = sl.getTextRuns(); assertEquals(2, txt.length); rt = txt[0].getRichTextRuns(); @@ -448,24 +448,24 @@ public final class TestTextRun extends TestCase { * Test creation of TextRun objects. */ public void testAddTextRun() { - SlideShow ppt = new SlideShow(); - Slide slide = ppt.createSlide(); + HSLFSlideShow ppt = new HSLFSlideShow(); + HSLFSlide slide = ppt.createSlide(); assertNull(slide.getTextRuns()); - TextBox shape1 = new TextBox(); - TextRun run1 = shape1.getTextRun(); + HSLFTextBox shape1 = new HSLFTextBox(); + HSLFTextParagraph run1 = shape1.getTextParagraph(); assertSame(run1, shape1.createTextRun()); run1.setText("Text 1"); slide.addShape(shape1); //The array of Slide's text runs must be updated when new text shapes are added. - TextRun[] runs = slide.getTextRuns(); + HSLFTextParagraph[] runs = slide.getTextRuns(); assertNotNull(runs); assertSame(run1, runs[0]); - TextBox shape2 = new TextBox(); - TextRun run2 = shape2.getTextRun(); + HSLFTextBox shape2 = new HSLFTextBox(); + HSLFTextParagraph run2 = shape2.getTextParagraph(); assertSame(run2, shape2.createTextRun()); run2.setText("Text 2"); slide.addShape(shape2); @@ -479,14 +479,14 @@ public final class TestTextRun extends TestCase { //as getShapes() HSLFShape[] sh = slide.getShapes(); assertEquals(2, sh.length); - assertTrue(sh[0] instanceof TextBox); - TextBox box1 = (TextBox)sh[0]; - assertSame(run1, box1.getTextRun()); - TextBox box2 = (TextBox)sh[1]; - assertSame(run2, box2.getTextRun()); + assertTrue(sh[0] instanceof HSLFTextBox); + HSLFTextBox box1 = (HSLFTextBox)sh[0]; + assertSame(run1, box1.getTextParagraph()); + HSLFTextBox box2 = (HSLFTextBox)sh[1]; + assertSame(run2, box2.getTextParagraph()); //test Table - a complex group of shapes containing text objects - Slide slide2 = ppt.createSlide(); + HSLFSlide slide2 = ppt.createSlide(); assertNull(slide2.getTextRuns()); Table table = new Table(2, 2); slide2.addShape(table); @@ -496,12 +496,12 @@ public final class TestTextRun extends TestCase { } public void test48916() throws IOException { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("SampleShow.ppt")); - for(Slide slide : ppt.getSlides()){ + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("SampleShow.ppt")); + for(HSLFSlide slide : ppt.getSlides()){ for(HSLFShape sh : slide.getShapes()){ - if(sh instanceof TextShape){ - TextShape tx = (TextShape)sh; - TextRun run = tx.getTextRun(); + if(sh instanceof HSLFTextShape){ + HSLFTextShape tx = (HSLFTextShape)sh; + HSLFTextParagraph run = tx.getTextParagraph(); //verify that records cached in TextRun and EscherTextboxWrapper are the same Record[] runChildren = run.getRecords(); Record[] txboxChildren = tx.getEscherTextboxWrapper().getChildRecords(); @@ -517,13 +517,13 @@ public final class TestTextRun extends TestCase { } ByteArrayOutputStream out = new ByteArrayOutputStream(); ppt.write(out); - ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray())); - for(Slide slide : ppt.getSlides()){ + ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())); + for(HSLFSlide slide : ppt.getSlides()){ for(HSLFShape sh : slide.getShapes()){ - if(sh instanceof TextShape){ - TextShape tx = (TextShape)sh; - TextRun run = tx.getTextRun(); - RichTextRun rt = run.getRichTextRuns()[0]; + if(sh instanceof HSLFTextShape){ + HSLFTextShape tx = (HSLFTextShape)sh; + HSLFTextParagraph run = tx.getTextParagraph(); + HSLFTextRun rt = run.getRichTextRuns()[0]; assertTrue(rt.isBold()); assertEquals(rt.getFontColor(), Color.RED); } @@ -533,9 +533,9 @@ public final class TestTextRun extends TestCase { } public void test52244() throws IOException { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("52244.ppt")); - Slide slide = ppt.getSlides()[0]; - TextRun[] runs = slide.getTextRuns(); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("52244.ppt")); + HSLFSlide slide = ppt.getSlides()[0]; + HSLFTextParagraph[] runs = slide.getTextRuns(); assertEquals("Arial", runs[0].getRichTextRuns()[0].getFontName()); assertEquals(36, runs[0].getRichTextRuns()[0].getFontSize()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java index db55a2c052..c5a01341ae 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextRunReWrite.java @@ -19,11 +19,11 @@ package org.apache.poi.hslf.model; import junit.framework.TestCase; + import java.io.*; -import org.apache.poi.hslf.HSLFSlideShow; -import org.apache.poi.hslf.usermodel.RichTextRun; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFTextRun; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.poifs.filesystem.*; import org.apache.poi.POIDataSamples; @@ -36,9 +36,9 @@ import org.apache.poi.POIDataSamples; */ public final class TestTextRunReWrite extends TestCase { // HSLFSlideShow primed on the test data - private HSLFSlideShow hss; + private HSLFSlideShowImpl hss; // HSLFSlideShow primed on the test data - private SlideShow ss; + private HSLFSlideShow ss; // POIFS primed on the test data private POIFSFileSystem pfs; @@ -49,14 +49,14 @@ public final class TestTextRunReWrite extends TestCase { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); String filename = "Single_Coloured_Page_With_Fonts_and_Alignments.ppt"; pfs = new POIFSFileSystem(slTests.openResourceAsStream(filename)); - hss = new HSLFSlideShow(pfs); - ss = new SlideShow(hss); + hss = new HSLFSlideShowImpl(pfs); + ss = new HSLFSlideShow(hss); } public void testWritesOutTheSameNonRich() throws Exception { // Grab the first text run on the first sheet - TextRun tr1 = ss.getSlides()[0].getTextRuns()[0]; - TextRun tr2 = ss.getSlides()[0].getTextRuns()[1]; + HSLFTextParagraph tr1 = ss.getSlides()[0].getTextRuns()[0]; + HSLFTextParagraph tr2 = ss.getSlides()[0].getTextRuns()[1]; // Ensure the text lengths are as we'd expect to start with assertEquals(1, ss.getSlides().length); @@ -112,10 +112,10 @@ public final class TestTextRunReWrite extends TestCase { public void testWritesOutTheSameRich() throws Exception { // Grab the first text run on the first sheet - TextRun tr1 = ss.getSlides()[0].getTextRuns()[0]; + HSLFTextParagraph tr1 = ss.getSlides()[0].getTextRuns()[0]; // Get the first rich text run - RichTextRun rtr1 = tr1.getRichTextRuns()[0]; + HSLFTextRun rtr1 = tr1.getRichTextRuns()[0]; // Check that the text sizes are as expected diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java index 542d608d8e..5666b8db0e 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java @@ -34,7 +34,7 @@ import java.util.Map; import org.apache.poi.POIDataSamples; import org.apache.poi.hslf.record.TextHeaderAtom; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.sl.usermodel.ShapeType; import org.junit.Test; @@ -48,14 +48,14 @@ public final class TestTextShape { @Test public void createAutoShape(){ - TextShape shape = new AutoShape(ShapeType.TRAPEZOID); - assertNull(shape.getTextRun()); + HSLFTextShape shape = new HSLFAutoShape(ShapeType.TRAPEZOID); + assertNull(shape.getTextParagraph()); assertNull(shape.getText()); assertNull(shape.getEscherTextboxWrapper()); - TextRun run = shape.createTextRun(); + HSLFTextParagraph run = shape.createTextRun(); assertNotNull(run); - assertNotNull(shape.getTextRun()); + assertNotNull(shape.getTextParagraph()); assertNotNull(shape.getEscherTextboxWrapper()); assertEquals("", shape.getText()); assertSame(run, shape.createTextRun()); @@ -64,14 +64,14 @@ public final class TestTextShape { @Test public void createTextBox(){ - TextShape shape = new TextBox(); - TextRun run = shape.getTextRun(); + HSLFTextShape shape = new HSLFTextBox(); + HSLFTextParagraph run = shape.getTextParagraph(); assertNotNull(run); assertNotNull(shape.getText()); assertNotNull(shape.getEscherTextboxWrapper()); assertSame(run, shape.createTextRun()); - assertNotNull(shape.getTextRun()); + assertNotNull(shape.getTextParagraph()); assertNotNull(shape.getEscherTextboxWrapper()); assertEquals("", shape.getText()); @@ -85,15 +85,15 @@ public final class TestTextShape { */ @Test public void read() throws IOException { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("text_shapes.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("text_shapes.ppt")); List lst1 = new ArrayList(); - Slide slide = ppt.getSlides()[0]; + HSLFSlide slide = ppt.getSlides()[0]; HSLFShape[] shape = slide.getShapes(); for (int i = 0; i < shape.length; i++) { - assertTrue("Expected TextShape but found " + shape[i].getClass().getName(), shape[i] instanceof TextShape); - TextShape tx = (TextShape)shape[i]; - TextRun run = tx.getTextRun(); + assertTrue("Expected TextShape but found " + shape[i].getClass().getName(), shape[i] instanceof HSLFTextShape); + HSLFTextShape tx = (HSLFTextShape)shape[i]; + HSLFTextParagraph run = tx.getTextParagraph(); assertNotNull(run); int runType = run.getRunType(); @@ -125,7 +125,7 @@ public final class TestTextShape { } List lst2 = new ArrayList(); - TextRun[] run = slide.getTextRuns(); + HSLFTextParagraph[] run = slide.getTextRuns(); for (int i = 0; i < run.length; i++) { lst2.add(run[i].getText()); } @@ -135,18 +135,18 @@ public final class TestTextShape { @Test public void readWrite() throws IOException { - SlideShow ppt = new SlideShow(); - Slide slide = ppt.createSlide(); + HSLFSlideShow ppt = new HSLFSlideShow(); + HSLFSlide slide = ppt.createSlide(); - TextShape shape1 = new TextBox(); - TextRun run1 = shape1.createTextRun(); + HSLFTextShape shape1 = new HSLFTextBox(); + HSLFTextParagraph run1 = shape1.createTextRun(); run1.setText("Hello, World!"); slide.addShape(shape1); shape1.moveTo(100, 100); - TextShape shape2 = new AutoShape(ShapeType.RIGHT_ARROW); - TextRun run2 = shape2.createTextRun(); + HSLFTextShape shape2 = new HSLFAutoShape(ShapeType.RIGHT_ARROW); + HSLFTextParagraph run2 = shape2.createTextRun(); run2.setText("Testing TextShape"); slide.addShape(shape2); shape2.moveTo(300, 300); @@ -155,37 +155,37 @@ public final class TestTextShape { ppt.write(out); out.close(); - ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray())); + ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())); slide = ppt.getSlides()[0]; HSLFShape[] shape = slide.getShapes(); - assertTrue(shape[0] instanceof TextShape); - shape1 = (TextShape)shape[0]; + assertTrue(shape[0] instanceof HSLFTextShape); + shape1 = (HSLFTextShape)shape[0]; assertEquals(ShapeType.TEXT_BOX, shape1.getShapeType()); - assertEquals("Hello, World!", shape1.getTextRun().getText()); + assertEquals("Hello, World!", shape1.getTextParagraph().getText()); - assertTrue(shape[1] instanceof TextShape); - shape1 = (TextShape)shape[1]; + assertTrue(shape[1] instanceof HSLFTextShape); + shape1 = (HSLFTextShape)shape[1]; assertEquals(ShapeType.RIGHT_ARROW, shape1.getShapeType()); - assertEquals("Testing TextShape", shape1.getTextRun().getText()); + assertEquals("Testing TextShape", shape1.getTextParagraph().getText()); } @Test public void margins() throws IOException { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("text-margins.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("text-margins.ppt")); - Slide slide = ppt.getSlides()[0]; + HSLFSlide slide = ppt.getSlides()[0]; - Map map = new HashMap(); + Map map = new HashMap(); HSLFShape[] shape = slide.getShapes(); for (int i = 0; i < shape.length; i++) { - if(shape[i] instanceof TextShape){ - TextShape tx = (TextShape)shape[i]; + if(shape[i] instanceof HSLFTextShape){ + HSLFTextShape tx = (HSLFTextShape)shape[i]; map.put(tx.getText(), tx); } } - TextShape tx; + HSLFTextShape tx; tx = map.get("TEST1"); assertEquals(0.1, tx.getMarginLeft()*HSLFShape.EMU_PER_POINT/HSLFShape.EMU_PER_INCH, 0.01); @@ -214,22 +214,22 @@ public final class TestTextShape { @Test public void bug52599() throws IOException { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("52599.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("52599.ppt")); - Slide slide = ppt.getSlides()[0]; + HSLFSlide slide = ppt.getSlides()[0]; HSLFShape[] sh = slide.getShapes(); assertEquals(3, sh.length); - TextShape sh0 = (TextShape)sh[0]; + HSLFTextShape sh0 = (HSLFTextShape)sh[0]; assertEquals(null, sh0.getText()); - assertEquals(null, sh0.getTextRun()); + assertEquals(null, sh0.getTextParagraph()); - TextShape sh1 = (TextShape)sh[1]; + HSLFTextShape sh1 = (HSLFTextShape)sh[1]; assertEquals(null, sh1.getText()); - assertEquals(null, sh1.getTextRun()); + assertEquals(null, sh1.getTextParagraph()); - TextShape sh2 = (TextShape)sh[2]; + HSLFTextShape sh2 = (HSLFTextShape)sh[2]; assertEquals("this box should be shown just once", sh2.getText()); - assertEquals(-1, sh2.getTextRun().getIndex()); + assertEquals(-1, sh2.getTextParagraph().getIndex()); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TextPainterTest.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TextPainterTest.java index 7db3ca6c8e..7e37b47a43 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TextPainterTest.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TextPainterTest.java @@ -19,7 +19,7 @@ package org.apache.poi.hslf.model; import org.apache.poi.hslf.record.StyleTextPropAtom; import org.apache.poi.hslf.record.TextCharsAtom; import org.apache.poi.hslf.record.TextHeaderAtom; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.hssf.usermodel.DummyGraphics2d; import org.junit.Test; @@ -27,22 +27,22 @@ import org.junit.Test; public class TextPainterTest { @Test public void testTextPainter() { - TextShape shape = new Polygon(); + HSLFTextShape shape = new Polygon(); TextPainter painter = new TextPainter(shape); - painter.getAttributedString(new TextRun(null, new TextCharsAtom(), null)); + painter.getAttributedString(new HSLFTextParagraph(null, new TextCharsAtom(), null)); painter.paint(new DummyGraphics2d()); painter.getTextElements((float)1.0, null); } @Test public void testTextPainterWithText() { - TextShape shape = new Polygon(); + HSLFTextShape shape = new Polygon(); TextPainter painter = new TextPainter(shape); TextCharsAtom tca = new TextCharsAtom(); tca.setText("some text to read"); - TextRun txrun = new TextRun(new TextHeaderAtom(), tca, new StyleTextPropAtom(10)); - Slide sheet = new Slide(1, 1, 1); - sheet.setSlideShow(new SlideShow()); + HSLFTextParagraph txrun = new HSLFTextParagraph(new TextHeaderAtom(), tca, new StyleTextPropAtom(10)); + HSLFSlide sheet = new HSLFSlide(1, 1, 1); + sheet.setSlideShow(new HSLFSlideShow()); txrun.setSheet(sheet); painter.getAttributedString(txrun, new DummyGraphics2d()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java index 05478e3374..60aee0f49d 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestCurrentUserAtom.java @@ -24,8 +24,8 @@ import java.io.ByteArrayOutputStream; import java.io.InputStream; import org.apache.poi.POIDataSamples; -import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.poifs.filesystem.DocumentEntry; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.junit.Test; @@ -72,7 +72,7 @@ public final class TestCurrentUserAtom { new CurrentUserAtom(fs); assertTrue(true); // not yet failed - new HSLFSlideShow(fs); + new HSLFSlideShowImpl(fs); } @Test diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java index 114a41da8d..d7de61c877 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocument.java @@ -19,7 +19,7 @@ package org.apache.poi.hslf.record; import junit.framework.TestCase; -import org.apache.poi.hslf.HSLFSlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.poifs.filesystem.*; import org.apache.poi.POIDataSamples; @@ -30,14 +30,14 @@ import org.apache.poi.POIDataSamples; */ public final class TestDocument extends TestCase { // HSLFSlideShow primed on the test data - private HSLFSlideShow ss; + private HSLFSlideShowImpl ss; // POIFS primed on the test data private POIFSFileSystem pfs; public TestDocument() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); pfs = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); - ss = new HSLFSlideShow(pfs); + ss = new HSLFSlideShowImpl(pfs); } private Document getDocRecord() { diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java index d9e3717842..12c114b344 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java @@ -33,11 +33,11 @@ import org.apache.poi.hpsf.DocumentSummaryInformation; import org.apache.poi.hpsf.PropertySet; import org.apache.poi.hpsf.PropertySetFactory; import org.apache.poi.hpsf.SummaryInformation; -import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException; -import org.apache.poi.hslf.model.Slide; -import org.apache.poi.hslf.usermodel.PictureData; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.model.HSLFSlide; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; +import org.apache.poi.hslf.usermodel.HSLFPictureData; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; import org.apache.poi.poifs.crypt.CryptoFunctions; import org.apache.poi.poifs.crypt.EncryptionInfo; @@ -71,8 +71,8 @@ public class TestDocumentEncryption { for (String pptFile : encPpts) { try { NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile(pptFile), true); - HSLFSlideShow hss = new HSLFSlideShow(fs); - new SlideShow(hss); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs); + new HSLFSlideShow(hss); fs.close(); } catch (EncryptedPowerPointFileException e) { fail(pptFile+" can't be decrypted"); @@ -85,9 +85,9 @@ public class TestDocumentEncryption { String pptFile = "cryptoapi-proc2356.ppt"; Biff8EncryptionKey.setCurrentUserPassword("crypto"); NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile(pptFile), true); - HSLFSlideShow hss = new HSLFSlideShow(fs); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs); // need to cache data (i.e. read all data) before changing the key size - PictureData picsExpected[] = hss.getPictures(); + HSLFPictureData picsExpected[] = hss.getPictures(); hss.getDocumentSummaryInformation(); EncryptionInfo ei = hss.getDocumentEncryptionAtom().getEncryptionInfo(); ((CryptoAPIEncryptionHeader)ei.getHeader()).setKeySize(0x78); @@ -97,8 +97,8 @@ public class TestDocumentEncryption { fs.close(); fs = new NPOIFSFileSystem(new ByteArrayInputStream(bos.toByteArray())); - hss = new HSLFSlideShow(fs); - PictureData picsActual[] = hss.getPictures(); + hss = new HSLFSlideShowImpl(fs); + HSLFPictureData picsActual[] = hss.getPictures(); fs.close(); assertEquals(picsExpected.length, picsActual.length); @@ -112,7 +112,7 @@ public class TestDocumentEncryption { /* documents with multiple edits need to be normalized for encryption */ String pptFile = "57272_corrupted_usereditatom.ppt"; NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile(pptFile), true); - HSLFSlideShow hss = new HSLFSlideShow(fs); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs); hss.normalizeRecords(); // normalized ppt @@ -128,7 +128,7 @@ public class TestDocumentEncryption { // decrypted ByteArrayInputStream bis = new ByteArrayInputStream(encrypted.toByteArray()); fs = new NPOIFSFileSystem(bis); - hss = new HSLFSlideShow(fs); + hss = new HSLFSlideShowImpl(fs); Biff8EncryptionKey.setCurrentUserPassword(null); ByteArrayOutputStream actual = new ByteArrayOutputStream(); hss.write(actual); @@ -143,10 +143,10 @@ public class TestDocumentEncryption { // http://blogs.msdn.com/b/openspecification/archive/2009/05/08/dominic-salemno.aspx Biff8EncryptionKey.setCurrentUserPassword("crypto"); NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile("cryptoapi-proc2356.ppt")); - HSLFSlideShow hss = new HSLFSlideShow(fs); - SlideShow ss = new SlideShow(hss); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs); + HSLFSlideShow ss = new HSLFSlideShow(hss); - Slide slide = ss.getSlides()[0]; + HSLFSlide slide = ss.getSlides()[0]; assertEquals("Dominic Salemno", slide.getTextRuns()[0].getText()); String picCmp[][] = { @@ -160,9 +160,9 @@ public class TestDocumentEncryption { }; MessageDigest md = CryptoFunctions.getMessageDigest(HashAlgorithm.sha1); - PictureData pd[] = hss.getPictures(); + HSLFPictureData pd[] = hss.getPictures(); int i = 0; - for (PictureData p : pd) { + for (HSLFPictureData p : pd) { byte hash[] = md.digest(p.getData()); assertEquals(Integer.parseInt(picCmp[i][0]), p.getOffset()); assertEquals(picCmp[i][1], Base64.encodeBase64String(hash)); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java index fff9d7286e..f712e20a6d 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java @@ -25,8 +25,8 @@ import java.util.List; import junit.framework.AssertionFailedError; import junit.framework.TestCase; -import org.apache.poi.hslf.HSLFSlideShow; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.POIDataSamples; /** @@ -99,8 +99,8 @@ public final class TestExHyperlink extends TestCase { public void testRealFile() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("WithLinks.ppt")); - SlideShow ss = new SlideShow(hss); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithLinks.ppt")); + HSLFSlideShow ss = new HSLFSlideShow(hss); // Get the document Document doc = ss.getDocumentRecord(); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjList.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjList.java index d3739ec3b8..836016666e 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjList.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjList.java @@ -20,8 +20,8 @@ package org.apache.poi.hslf.record; import junit.framework.TestCase; -import org.apache.poi.hslf.HSLFSlideShow; -import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; +import org.apache.poi.hslf.usermodel.HSLFSlideShow; import org.apache.poi.POIDataSamples; /** @@ -32,8 +32,8 @@ import org.apache.poi.POIDataSamples; public class TestExObjList extends TestCase { public void testRealFile() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("WithLinks.ppt")); - SlideShow ss = new SlideShow(hss); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithLinks.ppt")); + HSLFSlideShow ss = new HSLFSlideShow(hss); // Get the document Document doc = ss.getDocumentRecord(); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java index 8481cbc70f..cecf3ee319 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java @@ -20,7 +20,7 @@ package org.apache.poi.hslf.record; import junit.framework.TestCase; -import org.apache.poi.hslf.HSLFSlideShow; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.POIDataSamples; /** @@ -149,7 +149,7 @@ public final class TestRecordContainer extends TestCase { // Find a real RecordContainer record POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); Record[] r = hss.getRecords(); for(int i=0; i notesMap = new HashMap(); @@ -143,10 +128,10 @@ public final class TestBugs { notesMap.put(Integer.valueOf(7), "Although multiply and square root are easier"); notesMap.put(Integer.valueOf(8), "The bus Z is split into Z_H and Z_L"); - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { Integer slideNumber = Integer.valueOf(slide[i].getSlideNumber()); - Notes notes = slide[i].getNotesSheet(); + HSLFNotes notes = slide[i].getNotesSheet(); if (notesMap.containsKey(slideNumber)){ assertNotNull(notes); String text = notes.getTextRuns()[0].getRawText(); @@ -162,18 +147,18 @@ public final class TestBugs { */ @Test public void bug42485 () throws Exception { - HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42485.ppt")); + HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42485.ppt")); - SlideShow ppt = new SlideShow(hslf); + HSLFSlideShow ppt = new HSLFSlideShow(hslf); HSLFShape[] shape = ppt.getSlides()[0].getShapes(); for (int i = 0; i < shape.length; i++) { if(shape[i] instanceof HSLFGroupShape){ HSLFGroupShape group = (HSLFGroupShape)shape[i]; HSLFShape[] sh = group.getShapes(); for (int j = 0; j < sh.length; j++) { - if( sh[j] instanceof TextBox){ - TextBox txt = (TextBox)sh[j]; - assertNotNull(txt.getTextRun()); + if( sh[j] instanceof HSLFTextBox){ + HSLFTextBox txt = (HSLFTextBox)sh[j]; + assertNotNull(txt.getTextParagraph()); } } } @@ -185,9 +170,9 @@ public final class TestBugs { */ @Test public void bug42484 () throws Exception { - HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42485.ppt")); + HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42485.ppt")); - SlideShow ppt = new SlideShow(hslf); + HSLFSlideShow ppt = new HSLFSlideShow(hslf); HSLFShape[] shape = ppt.getSlides()[0].getShapes(); for (int i = 0; i < shape.length; i++) { if(shape[i] instanceof HSLFGroupShape){ @@ -207,16 +192,16 @@ public final class TestBugs { */ @Test public void bug41381() throws Exception { - HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("alterman_security.ppt")); + HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("alterman_security.ppt")); - SlideShow ppt = new SlideShow(hslf); + HSLFSlideShow ppt = new HSLFSlideShow(hslf); assertTrue("No Exceptions while reading file", true); assertEquals(1, ppt.getSlidesMasters().length); assertEquals(1, ppt.getTitleMasters().length); - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { - MasterSheet master = slide[i].getMasterSheet(); + HSLFMasterSheet master = slide[i].getMasterSheet(); if (i == 0) assertTrue(master instanceof TitleMaster); //the first slide follows TitleMaster else assertTrue(master instanceof SlideMaster); } @@ -227,10 +212,10 @@ public final class TestBugs { */ @Test public void bug42486 () throws Exception { - HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42486.ppt")); + HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42486.ppt")); - SlideShow ppt = new SlideShow(hslf); - Slide[] slide = ppt.getSlides(); + HSLFSlideShow ppt = new HSLFSlideShow(hslf); + HSLFSlide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { @SuppressWarnings("unused") HSLFShape[] shape = slide[i].getShapes(); @@ -244,11 +229,11 @@ public final class TestBugs { */ @Test public void bug42524 () throws Exception { - HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42486.ppt")); + HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42486.ppt")); - SlideShow ppt = new SlideShow(hslf); + HSLFSlideShow ppt = new HSLFSlideShow(hslf); //walk down the tree and see if there were no errors while reading - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { HSLFShape[] shape = slide[i].getShapes(); for (int j = 0; j < shape.length; j++) { @@ -272,17 +257,17 @@ public final class TestBugs { */ @Test public void bug42520 () throws Exception { - HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42520.ppt")); + HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42520.ppt")); - SlideShow ppt = new SlideShow(hslf); + HSLFSlideShow ppt = new HSLFSlideShow(hslf); //test case from the bug report HSLFGroupShape shapeGroup = (HSLFGroupShape)ppt.getSlides()[11].getShapes()[10]; - Picture picture = (Picture)shapeGroup.getShapes()[0]; + HSLFPictureShape picture = (HSLFPictureShape)shapeGroup.getShapes()[0]; picture.getPictureData(); //walk down the tree and see if there were no errors while reading - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { HSLFShape[] shape = slide[i].getShapes(); for (int j = 0; j < shape.length; j++) { @@ -291,9 +276,9 @@ public final class TestBugs { HSLFShape[] comps = group.getShapes(); for (int k = 0; k < comps.length; k++) { HSLFShape comp = comps[k]; - if (comp instanceof Picture){ + if (comp instanceof HSLFPictureShape){ @SuppressWarnings("unused") - PictureData pict = ((Picture)comp).getPictureData(); + HSLFPictureData pict = ((HSLFPictureShape)comp).getPictureData(); } } } @@ -310,13 +295,13 @@ public final class TestBugs { */ @Test public void bug38256 () throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("38256.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("38256.ppt")); assertTrue("No Exceptions while reading file", true); - Slide[] slide = ppt.getSlides(); + HSLFSlide[] slide = ppt.getSlides(); assertEquals(1, slide.length); - TextRun[] runs = slide[0].getTextRuns(); + HSLFTextParagraph[] runs = slide[0].getTextRuns(); assertEquals(4, runs.length); Set txt = new HashSet(); @@ -338,13 +323,13 @@ public final class TestBugs { */ @Test public void bug43781 () throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("43781.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("43781.ppt")); assertTrue("No Exceptions while reading file", true); // Check the first slide - Slide slide = ppt.getSlides()[0]; - TextRun[] slTr = slide.getTextRuns(); + HSLFSlide slide = ppt.getSlides()[0]; + HSLFTextParagraph[] slTr = slide.getTextRuns(); // Has two text runs, one from slide text, one from drawing assertEquals(2, slTr.length); @@ -354,11 +339,11 @@ public final class TestBugs { assertEquals("Second run", slTr[1].getText()); // Check the shape based text runs - List lst = new ArrayList(); + List lst = new ArrayList(); HSLFShape[] shape = slide.getShapes(); for (int i = 0; i < shape.length; i++) { - if( shape[i] instanceof TextShape){ - TextRun textRun = ((TextShape)shape[i]).getTextRun(); + if( shape[i] instanceof HSLFTextShape){ + HSLFTextParagraph textRun = ((HSLFTextShape)shape[i]).getTextParagraph(); if(textRun != null) { lst.add(textRun); } @@ -377,17 +362,17 @@ public final class TestBugs { */ @Test public void bug44296 () throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("44296.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("44296.ppt")); - Slide slide = ppt.getSlides()[0]; + HSLFSlide slide = ppt.getSlides()[0]; - Background b = slide.getBackground(); - Fill f = b.getFill(); - assertEquals(Fill.FILL_PICTURE, f.getFillType()); + HSLFBackground b = slide.getBackground(); + HSLFFill f = b.getFill(); + assertEquals(HSLFFill.FILL_PICTURE, f.getFillType()); - PictureData pict = f.getPictureData(); + HSLFPictureData pict = f.getPictureData(); assertNotNull(pict); - assertEquals(Picture.JPEG, pict.getType()); + assertEquals(HSLFPictureShape.JPEG, pict.getType()); } /** @@ -396,7 +381,7 @@ public final class TestBugs { @Test public void bug44770() throws Exception { try { - new SlideShow(_slTests.openResourceAsStream("44770.ppt")); + new HSLFSlideShow(_slTests.openResourceAsStream("44770.ppt")); } catch (RuntimeException e) { if (e.getMessage().equals("Couldn't instantiate the class for type with id 1036 on class class org.apache.poi.hslf.record.PPDrawing")) { throw new AssertionFailedError("Identified bug 44770"); @@ -410,16 +395,16 @@ public final class TestBugs { */ @Test public void bug41071() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("41071.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("41071.ppt")); - Slide slide = ppt.getSlides()[0]; + HSLFSlide slide = ppt.getSlides()[0]; HSLFShape[] sh = slide.getShapes(); assertEquals(1, sh.length); - assertTrue(sh[0] instanceof TextShape); - TextShape tx = (TextShape)sh[0]; - assertEquals("Fundera, planera och involvera.", tx.getTextRun().getText()); + assertTrue(sh[0] instanceof HSLFTextShape); + HSLFTextShape tx = (HSLFTextShape)sh[0]; + assertEquals("Fundera, planera och involvera.", tx.getTextParagraph().getText()); - TextRun[] run = slide.getTextRuns(); + HSLFTextParagraph[] run = slide.getTextRuns(); assertEquals(1, run.length); assertEquals("Fundera, planera och involvera.", run[0].getText()); } @@ -431,10 +416,10 @@ public final class TestBugs { @Test(expected=OldPowerPointFormatException.class) public void bug41711() throws Exception { // New file is fine - new SlideShow(_slTests.openResourceAsStream("SampleShow.ppt")); + new HSLFSlideShow(_slTests.openResourceAsStream("SampleShow.ppt")); // PowerPoint 95 gives an old format exception - new SlideShow(_slTests.openResourceAsStream("PPT95.ppt")); + new HSLFSlideShow(_slTests.openResourceAsStream("PPT95.ppt")); } /** @@ -442,9 +427,9 @@ public final class TestBugs { */ @Test public void bug49648() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("49648.ppt")); - for(Slide slide : ppt.getSlides()) { - for(TextRun run : slide.getTextRuns()) { + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("49648.ppt")); + for(HSLFSlide slide : ppt.getSlides()) { + for(HSLFTextParagraph run : slide.getTextRuns()) { String text = run.getRawText(); text.replace("{txtTot}", "With \u0123\u1234\u5678 unicode"); run.setRawText(text); @@ -458,10 +443,10 @@ public final class TestBugs { @Test public void bug41246a() throws Exception { InputStream fis = _slTests.openResourceAsStream("41246-1.ppt"); - HSLFSlideShow hslf = new HSLFSlideShow(fis); + HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(fis); fis.close(); - SlideShow ppt = new SlideShow(hslf); + HSLFSlideShow ppt = new HSLFSlideShow(hslf); assertTrue("No Exceptions while reading file", true); ppt = HSLFTestDataSamples.writeOutAndReadBack(ppt); @@ -471,10 +456,10 @@ public final class TestBugs { @Test public void bug41246b() throws Exception { InputStream fis = _slTests.openResourceAsStream("41246-2.ppt"); - HSLFSlideShow hslf = new HSLFSlideShow(fis); + HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(fis); fis.close(); - SlideShow ppt = new SlideShow(hslf); + HSLFSlideShow ppt = new HSLFSlideShow(hslf); assertTrue("No Exceptions while reading file", true); ppt = HSLFTestDataSamples.writeOutAndReadBack(ppt); @@ -487,14 +472,14 @@ public final class TestBugs { @Test public void bug45776() throws Exception { InputStream is = _slTests.openResourceAsStream("45776.ppt"); - SlideShow ppt = new SlideShow(new HSLFSlideShow(is)); + HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl(is)); is.close(); // get slides - for (Slide slide : ppt.getSlides()) { + for (HSLFSlide slide : ppt.getSlides()) { for (HSLFShape shape : slide.getShapes()) { - if (!(shape instanceof TextBox)) continue; - TextBox tb = (TextBox) shape; + if (!(shape instanceof HSLFTextBox)) continue; + HSLFTextBox tb = (HSLFTextBox) shape; // work with TextBox String str = tb.getText(); @@ -502,7 +487,7 @@ public final class TestBugs { str = str.replace("$$DATE$$", new Date().toString()); tb.setText(str); - TextRun tr = tb.getTextRun(); + HSLFTextParagraph tr = tb.getTextParagraph(); assertEquals(str.length()+1,tr.getStyleTextPropAtom().getParagraphStyles().getFirst().getCharactersCovered()); assertEquals(str.length()+1,tr.getStyleTextPropAtom().getCharacterStyles().getFirst().getCharactersCovered()); } @@ -513,12 +498,12 @@ public final class TestBugs { public void bug55732() throws Exception { File file = _slTests.getFile("bug55732.ppt"); - HSLFSlideShow ss = new HSLFSlideShow(file.getAbsolutePath()); - SlideShow _show = new SlideShow(ss); - Slide[] _slides = _show.getSlides(); + HSLFSlideShowImpl ss = new HSLFSlideShowImpl(file.getAbsolutePath()); + HSLFSlideShow _show = new HSLFSlideShow(ss); + HSLFSlide[] _slides = _show.getSlides(); /* Iterate over slides and extract text */ - for( Slide slide : _slides ) { + for( HSLFSlide slide : _slides ) { HeadersFooters hf = slide.getHeadersFooters(); /*boolean visible =*/ hf.isHeaderVisible(); // exception happens here } @@ -529,9 +514,9 @@ public final class TestBugs { public void bug56260() throws Exception { File file = _slTests.getFile("56260.ppt"); - HSLFSlideShow ss = new HSLFSlideShow(file.getAbsolutePath()); - SlideShow _show = new SlideShow(ss); - Slide[] _slides = _show.getSlides(); + HSLFSlideShowImpl ss = new HSLFSlideShowImpl(file.getAbsolutePath()); + HSLFSlideShow _show = new HSLFSlideShow(ss); + HSLFSlide[] _slides = _show.getSlides(); assertEquals(13, _slides.length); // Check the number of TextHeaderAtoms on Slide 1 @@ -553,7 +538,7 @@ public final class TestBugs { // Check the number of text runs based on the slide (not textbox) // Will have skipped the empty one int str = 0; - for (TextRun tr : _slides[0].getTextRuns()) { + for (HSLFTextParagraph tr : _slides[0].getTextRuns()) { if (! tr.isDrawingBased()) str++; } assertEquals(1, str); @@ -563,10 +548,10 @@ public final class TestBugs { public void bug37625() throws IOException { InputStream inputStream = new FileInputStream(_slTests.getFile("37625.ppt")); try { - SlideShow slideShow = new SlideShow(inputStream); + HSLFSlideShow slideShow = new HSLFSlideShow(inputStream); assertEquals(29, slideShow.getSlides().length); - SlideShow slideBack = HSLFTestDataSamples.writeOutAndReadBack(slideShow); + HSLFSlideShow slideBack = HSLFTestDataSamples.writeOutAndReadBack(slideShow); assertNotNull(slideBack); assertEquals(29, slideBack.getSlides().length); } finally { @@ -578,10 +563,10 @@ public final class TestBugs { public void bug57272() throws Exception { InputStream inputStream = new FileInputStream(_slTests.getFile("57272_corrupted_usereditatom.ppt")); try { - SlideShow slideShow = new SlideShow(inputStream); + HSLFSlideShow slideShow = new HSLFSlideShow(inputStream); assertEquals(6, slideShow.getSlides().length); - SlideShow slideBack = HSLFTestDataSamples.writeOutAndReadBack(slideShow); + HSLFSlideShow slideBack = HSLFTestDataSamples.writeOutAndReadBack(slideShow); assertNotNull(slideBack); assertEquals(6, slideBack.getSlides().length); } finally { @@ -593,10 +578,10 @@ public final class TestBugs { public void bug49541() throws Exception { InputStream inputStream = new FileInputStream(_slTests.getFile("49541_symbol_map.ppt")); try { - SlideShow slideShow = new SlideShow(inputStream); - Slide slide = slideShow.getSlides()[0]; + HSLFSlideShow slideShow = new HSLFSlideShow(inputStream); + HSLFSlide slide = slideShow.getSlides()[0]; HSLFGroupShape sg = (HSLFGroupShape)slide.getShapes()[0]; - TextBox tb = (TextBox)sg.getShapes()[0]; + HSLFTextBox tb = (HSLFTextBox)sg.getShapes()[0]; String text = StringUtil.mapMsCodepointString(tb.getText()); assertEquals("\u226575 years", text); } finally { @@ -608,7 +593,7 @@ public final class TestBugs { public void bug47261() throws Exception { InputStream inputStream = new FileInputStream(_slTests.getFile("bug47261.ppt")); try { - SlideShow slideShow = new SlideShow(inputStream); + HSLFSlideShow slideShow = new HSLFSlideShow(inputStream); slideShow.removeSlide(0); slideShow.createSlide(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -622,7 +607,7 @@ public final class TestBugs { public void bug56240() throws Exception { InputStream inputStream = new FileInputStream(_slTests.getFile("bug56240.ppt")); try { - SlideShow slideShow = new SlideShow(inputStream); + HSLFSlideShow slideShow = new HSLFSlideShow(inputStream); int slideCnt = slideShow.getSlides().length; assertEquals(105, slideCnt); ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -637,8 +622,8 @@ public final class TestBugs { public void bug46441() throws Exception { InputStream inputStream = new FileInputStream(_slTests.getFile("bug46441.ppt")); try { - SlideShow slideShow = new SlideShow(inputStream); - AutoShape as = (AutoShape)slideShow.getSlides()[0].getShapes()[0]; + HSLFSlideShow slideShow = new HSLFSlideShow(inputStream); + HSLFAutoShape as = (HSLFAutoShape)slideShow.getSlides()[0].getShapes()[0]; EscherOptRecord opt = as.getEscherOptRecord(); EscherArrayProperty ep = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__SHADECOLORS); double exp[][] = { diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java index eb84e7711a..dbee82742f 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java @@ -19,6 +19,7 @@ package org.apache.poi.hslf.usermodel; import junit.framework.TestCase; + import org.apache.poi.hslf.*; import org.apache.poi.hslf.model.*; import org.apache.poi.POIDataSamples; @@ -30,16 +31,16 @@ import org.apache.poi.POIDataSamples; */ public final class TestCounts extends TestCase { // SlideShow primed on the test data - private SlideShow ss; + private HSLFSlideShow ss; public TestCounts() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); - ss = new SlideShow(hss); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + ss = new HSLFSlideShow(hss); } public void testSheetsCount() { - Slide[] slides = ss.getSlides(); + HSLFSlide[] slides = ss.getSlides(); // Two sheets - master sheet is separate assertEquals(2, slides.length); @@ -57,7 +58,7 @@ public final class TestCounts extends TestCase { } public void testNotesCount() { - Notes[] notes = ss.getNotes(); + HSLFNotes[] notes = ss.getNotes(); // Two sheets -> two notes // Note: there are also notes on the slide master //assertEquals(3, notes.length); // When we do slide masters diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java index a6fa770059..37b7bb6965 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java @@ -39,7 +39,7 @@ import java.util.Map; import javax.imageio.ImageIO; import org.apache.poi.POIDataSamples; -import org.apache.poi.hslf.model.Slide; +import org.apache.poi.hslf.model.HSLFSlide; import org.apache.poi.hslf.model.TextPainter; import org.apache.poi.util.TempFile; import org.junit.Ignore; @@ -82,12 +82,12 @@ public class TestFontRendering { } InputStream is = slTests.openResourceAsStream("bug55902-mixedFontChineseCharacters.ppt"); - SlideShow ss = new SlideShow(is); + HSLFSlideShow ss = new HSLFSlideShow(is); is.close(); Dimension pgsize = ss.getPageSize(); - Slide slide = ss.getSlides()[0]; + HSLFSlide slide = ss.getSlides()[0]; // render it double zoom = 1; diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java index ce68b7a2d8..088dbb0cee 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java @@ -19,7 +19,9 @@ package org.apache.poi.hslf.usermodel; import junit.framework.TestCase; + import org.apache.poi.hslf.*; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.*; import org.apache.poi.POIDataSamples; @@ -30,14 +32,14 @@ import org.apache.poi.POIDataSamples; */ public final class TestMostRecentRecords extends TestCase { // HSLFSlideShow primed on the test data - private HSLFSlideShow hss; + private HSLFSlideShowImpl hss; // SlideShow primed on the test data - private SlideShow ss; + private HSLFSlideShow ss; public TestMostRecentRecords() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); - ss = new SlideShow(hss); + hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + ss = new HSLFSlideShow(hss); } public void testCount() { diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java index 3def468f9e..22b40a22e2 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java @@ -19,6 +19,7 @@ package org.apache.poi.hslf.usermodel; import junit.framework.TestCase; + import org.apache.poi.hslf.*; import org.apache.poi.hslf.model.*; import org.apache.poi.POIDataSamples; @@ -30,16 +31,16 @@ import org.apache.poi.POIDataSamples; */ public final class TestNotesText extends TestCase { // SlideShow primed on the test data - private SlideShow ss; + private HSLFSlideShow ss; public TestNotesText() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); - ss = new SlideShow(hss); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + ss = new HSLFSlideShow(hss); } public void testNotesOne() { - Notes notes = ss.getNotes()[0]; + HSLFNotes notes = ss.getNotes()[0]; String[] expectText = new String[] {"These are the notes for page 1"}; assertEquals(expectText.length, notes.getTextRuns().length); @@ -49,7 +50,7 @@ public final class TestNotesText extends TestCase { } public void testNotesTwo() { - Notes notes = ss.getNotes()[1]; + HSLFNotes notes = ss.getNotes()[1]; String[] expectText = new String[] {"These are the notes on page two, again lacking formatting"}; assertEquals(expectText.length, notes.getTextRuns().length); for(int i=0; i 3 assertEquals(s1._getSheetNumber(), _s3._getSheetNumber()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java index 5475dae9c1..c15bacd1f2 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java @@ -19,7 +19,9 @@ package org.apache.poi.hslf.usermodel; import junit.framework.TestCase; + import org.apache.poi.hslf.*; +import org.apache.poi.hslf.model.HSLFSlideShowImpl; import org.apache.poi.hslf.record.ParentAwareRecord; import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.RecordContainer; @@ -34,13 +36,13 @@ import org.apache.poi.POIDataSamples; */ public final class TestRecordSetup extends TestCase { // SlideShow primed on the test data - private SlideShow ss; - private HSLFSlideShow hss; + private HSLFSlideShow ss; + private HSLFSlideShowImpl hss; public TestRecordSetup() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); - ss = new SlideShow(hss); + hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + ss = new HSLFSlideShow(hss); } public void testHandleParentAwareRecords() { diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java index a71b72a28b..267e9ec7a4 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java @@ -23,10 +23,7 @@ import java.io.FileInputStream; import org.apache.poi.POIDataSamples; import org.apache.poi.POITestCase; -import org.apache.poi.hslf.HSLFSlideShow; -import org.apache.poi.hslf.model.Slide; -import org.apache.poi.hslf.model.TextBox; -import org.apache.poi.hslf.model.TextRun; +import org.apache.poi.hslf.model.*; import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.SlideListWithText; @@ -39,40 +36,40 @@ public final class TestRichTextRun extends POITestCase { private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); // SlideShow primed on the test data - private SlideShow ss; - private SlideShow ssRichA; - private SlideShow ssRichB; - private SlideShow ssRichC; - private SlideShow ssChinese; - private HSLFSlideShow hss; - private HSLFSlideShow hssRichA; - private HSLFSlideShow hssRichB; - private HSLFSlideShow hssRichC; - private HSLFSlideShow hssChinese; + private HSLFSlideShow ss; + private HSLFSlideShow ssRichA; + private HSLFSlideShow ssRichB; + private HSLFSlideShow ssRichC; + private HSLFSlideShow ssChinese; + private HSLFSlideShowImpl hss; + private HSLFSlideShowImpl hssRichA; + private HSLFSlideShowImpl hssRichB; + private HSLFSlideShowImpl hssRichC; + private HSLFSlideShowImpl hssChinese; private static String filenameC; protected void setUp() throws Exception { // Basic (non rich) test file - hss = new HSLFSlideShow(_slTests.openResourceAsStream("basic_test_ppt_file.ppt")); - ss = new SlideShow(hss); + hss = new HSLFSlideShowImpl(_slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + ss = new HSLFSlideShow(hss); // Rich test file A - hssRichA = new HSLFSlideShow(_slTests.openResourceAsStream("Single_Coloured_Page.ppt")); - ssRichA = new SlideShow(hssRichA); + hssRichA = new HSLFSlideShowImpl(_slTests.openResourceAsStream("Single_Coloured_Page.ppt")); + ssRichA = new HSLFSlideShow(hssRichA); // Rich test file B - hssRichB = new HSLFSlideShow(_slTests.openResourceAsStream("Single_Coloured_Page_With_Fonts_and_Alignments.ppt")); - ssRichB = new SlideShow(hssRichB); + hssRichB = new HSLFSlideShowImpl(_slTests.openResourceAsStream("Single_Coloured_Page_With_Fonts_and_Alignments.ppt")); + ssRichB = new HSLFSlideShow(hssRichB); // Rich test file C - has paragraph styles that run out before // the character ones do filenameC = "ParagraphStylesShorterThanCharStyles.ppt"; - hssRichC = new HSLFSlideShow(_slTests.openResourceAsStream(filenameC)); - ssRichC = new SlideShow(hssRichC); + hssRichC = new HSLFSlideShowImpl(_slTests.openResourceAsStream(filenameC)); + ssRichC = new HSLFSlideShow(hssRichC); // Rich test file with Chinese + English text in it - hssChinese = new HSLFSlideShow(_slTests.openResourceAsStream("54880_chinese.ppt")); - ssChinese = new SlideShow(hssChinese); + hssChinese = new HSLFSlideShowImpl(_slTests.openResourceAsStream("54880_chinese.ppt")); + ssChinese = new HSLFSlideShow(hssChinese); } /** @@ -80,9 +77,9 @@ public final class TestRichTextRun extends POITestCase { * on a non rich text run */ public void testBoldNonRich() { - Slide slideOne = ss.getSlides()[0]; - TextRun[] textRuns = slideOne.getTextRuns(); - RichTextRun rtr = textRuns[0].getRichTextRuns()[0]; + HSLFSlide slideOne = ss.getSlides()[0]; + HSLFTextParagraph[] textRuns = slideOne.getTextRuns(); + HSLFTextRun rtr = textRuns[0].getRichTextRuns()[0]; assertNull(rtr._getRawCharacterStyle()); assertNull(rtr._getRawParagraphStyle()); @@ -108,9 +105,9 @@ public final class TestRichTextRun extends POITestCase { * on a rich text run */ public void testBoldRich() { - Slide slideOneR = ssRichA.getSlides()[0]; - TextRun[] textRunsR = slideOneR.getTextRuns(); - RichTextRun[] rtrs = textRunsR[1].getRichTextRuns(); + HSLFSlide slideOneR = ssRichA.getSlides()[0]; + HSLFTextParagraph[] textRunsR = slideOneR.getTextRuns(); + HSLFTextRun[] rtrs = textRunsR[1].getRichTextRuns(); assertEquals(3, rtrs.length); assertTrue(rtrs[0].isBold()); @@ -136,15 +133,15 @@ public final class TestRichTextRun extends POITestCase { */ public void testFontSize() { - Slide slideOne = ss.getSlides()[0]; - TextRun[] textRuns = slideOne.getTextRuns(); - RichTextRun rtr = textRuns[0].getRichTextRuns()[0]; + HSLFSlide slideOne = ss.getSlides()[0]; + HSLFTextParagraph[] textRuns = slideOne.getTextRuns(); + HSLFTextRun rtr = textRuns[0].getRichTextRuns()[0]; - Slide slideOneR = ssRichB.getSlides()[0]; - TextRun[] textRunsR = slideOneR.getTextRuns(); - RichTextRun rtrRa = textRunsR[0].getRichTextRuns()[0]; - RichTextRun rtrRb = textRunsR[1].getRichTextRuns()[0]; - RichTextRun rtrRc = textRunsR[1].getRichTextRuns()[3]; + HSLFSlide slideOneR = ssRichB.getSlides()[0]; + HSLFTextParagraph[] textRunsR = slideOneR.getTextRuns(); + HSLFTextRun rtrRa = textRunsR[0].getRichTextRuns()[0]; + HSLFTextRun rtrRb = textRunsR[1].getRichTextRuns()[0]; + HSLFTextRun rtrRc = textRunsR[1].getRichTextRuns()[3]; String defaultFont = "Arial"; @@ -195,14 +192,14 @@ public final class TestRichTextRun extends POITestCase { } public void testChangeWriteRead() throws Exception { - HSLFSlideShow[] h = new HSLFSlideShow[] { hss, hssRichA, hssRichB }; - Slide[] s = new Slide[] { ss.getSlides()[0], ssRichA.getSlides()[0], ssRichB.getSlides()[0] }; + HSLFSlideShowImpl[] h = new HSLFSlideShowImpl[] { hss, hssRichA, hssRichB }; + HSLFSlide[] s = new HSLFSlide[] { ss.getSlides()[0], ssRichA.getSlides()[0], ssRichB.getSlides()[0] }; for(int i=0; i(text a)(text a)(text b) // TR: // (text) - TextRun[] s7tr = slideSevenC.getTextRuns(); - RichTextRun[] s7rtr0 = s7tr[0].getRichTextRuns(); - RichTextRun[] s7rtr1 = s7tr[1].getRichTextRuns(); - RichTextRun[] s7rtr2 = s7tr[2].getRichTextRuns(); + HSLFTextParagraph[] s7tr = slideSevenC.getTextRuns(); + HSLFTextRun[] s7rtr0 = s7tr[0].getRichTextRuns(); + HSLFTextRun[] s7rtr1 = s7tr[1].getRichTextRuns(); + HSLFTextRun[] s7rtr2 = s7tr[2].getRichTextRuns(); assertEquals(1, s7rtr0.length); assertEquals(3, s7rtr1.length); @@ -334,11 +331,11 @@ public final class TestRichTextRun extends POITestCase { assertMatchesSLTWC(ssRichC); assertMatchesFileC(ssRichC); - Slide slideSevenC = ssRichC.getSlides()[6]; - TextRun[] s7tr = slideSevenC.getTextRuns(); - RichTextRun[] s7rtr0 = s7tr[0].getRichTextRuns(); - RichTextRun[] s7rtr1 = s7tr[1].getRichTextRuns(); - RichTextRun[] s7rtr2 = s7tr[2].getRichTextRuns(); + HSLFSlide slideSevenC = ssRichC.getSlides()[6]; + HSLFTextParagraph[] s7tr = slideSevenC.getTextRuns(); + HSLFTextRun[] s7rtr0 = s7tr[0].getRichTextRuns(); + HSLFTextRun[] s7rtr1 = s7tr[1].getRichTextRuns(); + HSLFTextRun[] s7rtr2 = s7tr[2].getRichTextRuns(); String oldText; @@ -374,9 +371,9 @@ public final class TestRichTextRun extends POITestCase { * contents. * @param s */ - private void assertMatchesSLTWC(SlideShow s) throws Exception { + private void assertMatchesSLTWC(HSLFSlideShow s) throws Exception { // Grab a new copy of slideshow C - SlideShow refC = new SlideShow(_slTests.openResourceAsStream(filenameC)); + HSLFSlideShow refC = new HSLFSlideShow(_slTests.openResourceAsStream(filenameC)); // Write out the 2nd SLWT in the active document SlideListWithText refSLWT = refC.getDocumentRecord().getSlideListWithTexts()[1]; @@ -411,7 +408,7 @@ public final class TestRichTextRun extends POITestCase { * Checks that the supplied slideshow still matches the bytes * of slideshow c */ - private static void assertMatchesFileC(SlideShow s) throws Exception { + private static void assertMatchesFileC(HSLFSlideShow s) throws Exception { if (true) { // TODO - test is disabled, pending fix of bug #39800 // System.err.println("Skipping test, as would be marked as failed due to bug #39800"); // return; @@ -450,12 +447,12 @@ if(false) { } public void testIndentationLevel() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("ParagraphStylesShorterThanCharStyles.ppt")); - Slide[] sl = ppt.getSlides(); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("ParagraphStylesShorterThanCharStyles.ppt")); + HSLFSlide[] sl = ppt.getSlides(); for (int i = 0; i < sl.length; i++) { - TextRun[] txt = sl[i].getTextRuns(); + HSLFTextParagraph[] txt = sl[i].getTextRuns(); for (int j = 0; j < txt.length; j++) { - RichTextRun[] rt = txt[j].getRichTextRuns(); + HSLFTextRun[] rt = txt[j].getRichTextRuns(); for (int k = 0; k < rt.length; k++) { int indent = rt[k].getIndentLevel(); assertTrue(indent >= 0 && indent <= 4 ); @@ -466,12 +463,12 @@ if(false) { } public void testReadParagraphStyles() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("bullets.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("bullets.ppt")); assertTrue("No Exceptions while reading file", true); - RichTextRun rt; - TextRun[] txt; - Slide[] slide = ppt.getSlides(); + HSLFTextRun rt; + HSLFTextParagraph[] txt; + HSLFSlide[] slide = ppt.getSlides(); assertEquals(2, slide.length); txt = slide[0].getTextRuns(); @@ -516,12 +513,12 @@ if(false) { } public void testSetParagraphStyles() throws Exception { - SlideShow ppt = new SlideShow(); + HSLFSlideShow ppt = new HSLFSlideShow(); - Slide slide = ppt.createSlide(); + HSLFSlide slide = ppt.createSlide(); - TextBox shape = new TextBox(); - RichTextRun rt = shape.getTextRun().getRichTextRuns()[0]; + HSLFTextBox shape = new HSLFTextBox(); + HSLFTextRun rt = shape.getTextParagraph().getRichTextRuns()[0]; shape.setText( "Hello, World!\r" + "This should be\r" + @@ -547,10 +544,10 @@ if(false) { ppt.write(out); out.close(); - ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray())); + ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())); slide = ppt.getSlides()[0]; - shape = (TextBox)slide.getShapes()[0]; - rt = shape.getTextRun().getRichTextRuns()[0]; + shape = (HSLFTextBox)slide.getShapes()[0]; + rt = shape.getTextParagraph().getRichTextRuns()[0]; assertEquals(42, rt.getFontSize()); assertEquals(true, rt.isBullet()); assertEquals(50, rt.getTextOffset()); @@ -559,12 +556,12 @@ if(false) { } public void testAddText() throws Exception { - SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("bullets.ppt")); + HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("bullets.ppt")); assertTrue("No Exceptions while reading file", true); - RichTextRun rt; - TextRun[] txt; - Slide[] slides = ppt.getSlides(); + HSLFTextRun rt; + HSLFTextParagraph[] txt; + HSLFSlide[] slides = ppt.getSlides(); assertEquals(2, slides.length); txt = slides[0].getTextRuns(); @@ -605,7 +602,7 @@ if(false) { ppt.write(out); out.close(); - ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray())); + ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())); slides = ppt.getSlides(); assertEquals(2, slides.length); @@ -628,10 +625,10 @@ if(false) { } public void testChineseParagraphs() throws Exception { - RichTextRun[] rts; - RichTextRun rt; - TextRun[] txt; - Slide[] slides = ssChinese.getSlides(); + HSLFTextRun[] rts; + HSLFTextRun rt; + HSLFTextParagraph[] txt; + HSLFSlide[] slides = ssChinese.getSlides(); // One slide assertEquals(1, slides.length); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java index cb27d3ee92..fda2aba0d0 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestSheetText.java @@ -19,6 +19,7 @@ package org.apache.poi.hslf.usermodel; import junit.framework.TestCase; + import org.apache.poi.hslf.*; import org.apache.poi.hslf.model.*; import org.apache.poi.POIDataSamples; @@ -30,16 +31,16 @@ import org.apache.poi.POIDataSamples; */ public final class TestSheetText extends TestCase { // SlideShow primed on the test data - private SlideShow ss; + private HSLFSlideShow ss; public TestSheetText() throws Exception { POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - HSLFSlideShow hss = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); - ss = new SlideShow(hss); + HSLFSlideShowImpl hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt")); + ss = new HSLFSlideShow(hss); } public void testSheetOne() { - Sheet slideOne = ss.getSlides()[0]; + HSLFSheet slideOne = ss.getSlides()[0]; String[] expectText = new String[] {"This is a test title","This is a test subtitle\nThis is on page 1"}; assertEquals(expectText.length, slideOne.getTextRuns().length); @@ -49,7 +50,7 @@ public final class TestSheetText extends TestCase { } public void testSheetTwo() { - Sheet slideTwo = ss.getSlides()[1]; + HSLFSheet slideTwo = ss.getSlides()[1]; String[] expectText = new String[] {"This is the title on page 2","This is page two\nIt has several blocks of text\nNone of them have formatting"}; assertEquals(expectText.length, slideTwo.getTextRuns().length); for(int i=0; i