You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/03/20 00:44:25 UTC
svn commit: r1667902 [7/8] - in /poi/branches/common_sl/src:
examples/src/org/apache/poi/hslf/examples/
examples/src/org/apache/poi/hssf/usermodel/examples/
examples/src/org/apache/poi/xslf/usermodel/
examples/src/org/apache/poi/xssf/usermodel/examples...
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Thu Mar 19 23:44:23 2015
@@ -41,24 +41,9 @@ import org.apache.poi.ddf.EscherArrayPro
import org.apache.poi.ddf.EscherColorRef;
import org.apache.poi.ddf.EscherOptRecord;
import org.apache.poi.ddf.EscherProperties;
-import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.HSLFTestDataSamples;
import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
-import org.apache.poi.hslf.model.AutoShape;
-import org.apache.poi.hslf.model.Background;
-import org.apache.poi.hslf.model.Fill;
-import org.apache.poi.hslf.model.HeadersFooters;
-import org.apache.poi.hslf.model.MasterSheet;
-import org.apache.poi.hslf.model.Notes;
-import org.apache.poi.hslf.model.Picture;
-import org.apache.poi.hslf.model.HSLFShape;
-import org.apache.poi.hslf.model.HSLFGroupShape;
-import org.apache.poi.hslf.model.Slide;
-import org.apache.poi.hslf.model.SlideMaster;
-import org.apache.poi.hslf.model.TextBox;
-import org.apache.poi.hslf.model.TextRun;
-import org.apache.poi.hslf.model.TextShape;
-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.Record;
import org.apache.poi.hslf.record.SlideListWithText;
@@ -83,17 +68,17 @@ public final class TestBugs {
*/
@Test
public void bug41384() throws Exception {
- HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("41384.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("41384.ppt"));
- SlideShow ppt = new SlideShow(hslf);
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
assertTrue("No Exceptions while reading file", true);
assertEquals(1, ppt.getSlides().length);
- PictureData[] pict = ppt.getPictureData();
+ HSLFPictureData[] pict = ppt.getPictureData();
assertEquals(2, pict.length);
- assertEquals(Picture.JPEG, pict[0].getType());
- assertEquals(Picture.JPEG, pict[1].getType());
+ assertEquals(HSLFPictureShape.JPEG, pict[0].getType());
+ assertEquals(HSLFPictureShape.JPEG, pict[1].getType());
}
/**
@@ -102,14 +87,14 @@ public final class TestBugs {
*/
@Test
public void bug42474_1() throws Exception {
- HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42474-1.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42474-1.ppt"));
- SlideShow ppt = new SlideShow(hslf);
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
assertTrue("No Exceptions while reading file", true);
assertEquals(2, ppt.getSlides().length);
- TextRun txrun;
- Notes notes;
+ HSLFTextParagraph txrun;
+ HSLFNotes notes;
notes = ppt.getSlides()[0].getNotesSheet();
assertNotNull(notes);
@@ -131,9 +116,9 @@ public final class TestBugs {
*/
@Test
public void bug42474_2() throws Exception {
- HSLFSlideShow hslf = new HSLFSlideShow(_slTests.openResourceAsStream("42474-2.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(_slTests.openResourceAsStream("42474-2.ppt"));
- SlideShow ppt = new SlideShow(hslf);
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
//map slide number and starting phrase of its notes
Map<Integer, String> notesMap = new HashMap<Integer, String>();
@@ -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<String> txt = new HashSet<String>();
@@ -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<TextRun> lst = new ArrayList<TextRun>();
+ List<HSLFTextParagraph> lst = new ArrayList<HSLFTextParagraph>();
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[][] = {
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestCounts.java Thu Mar 19 23:44:23 2015
@@ -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 Te
}
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
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestFontRendering.java Thu Mar 19 23:44:23 2015
@@ -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;
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java Thu Mar 19 23:44:23 2015
@@ -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() {
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNotesText.java Thu Mar 19 23:44:23 2015
@@ -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
}
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<expectText.length; i++) {
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java Thu Mar 19 23:44:23 2015
@@ -23,8 +23,8 @@ import java.util.List;
import junit.framework.TestCase;
-import org.apache.poi.hslf.model.Slide;
-import org.apache.poi.hslf.model.TextRun;
+import org.apache.poi.hslf.model.HSLFSlide;
+import org.apache.poi.hslf.model.HSLFTextParagraph;
import org.apache.poi.hslf.model.textproperties.TextPFException9;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.record.EscherTextboxWrapper;
@@ -46,15 +46,15 @@ public final class TestNumberedList exte
}
public void testNumberedList() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("numbers.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("numbers.ppt"));
assertTrue("No Exceptions while reading file", true);
- final Slide[] slides = ppt.getSlides();
+ final HSLFSlide[] slides = ppt.getSlides();
assertEquals(2, slides.length);
checkSlide0(slides[0]);
checkSlide1(slides[1]);
}
- private void checkSlide0(final Slide s) {
+ private void checkSlide0(final HSLFSlide s) {
final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
assertNotNull(numberedListArray);
assertEquals(1, numberedListArray.length);//Just one text box here
@@ -70,10 +70,10 @@ public final class TestNumberedList exte
assertNull(autoNumbers[1].getAutoNumberScheme());
assertTrue(TextAutoNumberSchemeEnum.ANM_AlphaLcParenRight == autoNumbers[2].getAutoNumberScheme());
- TextRun[] textRuns = s.getTextRuns();
+ HSLFTextParagraph[] textRuns = s.getTextRuns();
assertEquals(2, textRuns.length);
- RichTextRun textRun = textRuns[0].getRichTextRuns()[0];
+ HSLFTextRun textRun = textRuns[0].getRichTextRuns()[0];
assertEquals("titTe", textRun.getRawText());
assertEquals(1, textRuns[0].getRichTextRuns().length);
assertFalse(textRun.isBullet());
@@ -90,7 +90,7 @@ public final class TestNumberedList exte
assertEquals(34, props[1].getCharactersCovered());
assertEquals(68, props[2].getCharactersCovered());
}
- private void checkSlide1(final Slide s) {
+ private void checkSlide1(final HSLFSlide s) {
final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
assertNotNull(numberedListArray);
assertEquals(1, numberedListArray.length);//Just one text box here
@@ -106,10 +106,10 @@ public final class TestNumberedList exte
assertNull(autoNumbers[1].getAutoNumberScheme());
assertTrue(TextAutoNumberSchemeEnum.ANM_AlphaUcPeriod == autoNumbers[2].getAutoNumberScheme());
- final TextRun[] textRuns = s.getTextRuns();
+ final HSLFTextParagraph[] textRuns = s.getTextRuns();
assertEquals(2, textRuns.length);
- RichTextRun textRun = textRuns[0].getRichTextRuns()[0];
+ HSLFTextRun textRun = textRuns[0].getRichTextRuns()[0];
assertEquals("Second Slide Title", textRun.getRawText());
assertEquals(1, textRuns[0].getRichTextRuns().length);
assertFalse(textRun.isBullet());
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java Thu Mar 19 23:44:23 2015
@@ -23,8 +23,8 @@ import java.util.List;
import junit.framework.TestCase;
-import org.apache.poi.hslf.model.Slide;
-import org.apache.poi.hslf.model.TextRun;
+import org.apache.poi.hslf.model.HSLFSlide;
+import org.apache.poi.hslf.model.HSLFTextParagraph;
import org.apache.poi.hslf.model.textproperties.TextPFException9;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.record.EscherTextboxWrapper;
@@ -49,15 +49,15 @@ public final class TestNumberedList2 ext
}
public void testNumberedList() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("numbers2.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("numbers2.ppt"));
assertTrue("No Exceptions while reading file", true);
- final Slide[] slides = ppt.getSlides();
+ final HSLFSlide[] slides = ppt.getSlides();
assertEquals(2, slides.length);
checkSlide0(slides[0]);
checkSlide1(slides[1]);
}
- private void checkSlide0(final Slide s) {
+ private void checkSlide0(final HSLFSlide s) {
final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
assertNotNull(numberedListArray);
assertEquals(2, numberedListArray.length);
@@ -75,10 +75,10 @@ public final class TestNumberedList2 ext
assertTrue(TextAutoNumberSchemeEnum.ANM_ArabicPeriod == autoNumbersOfTextBox1[0].getAutoNumberScheme());
- TextRun[] textRuns = s.getTextRuns();
+ HSLFTextParagraph[] textRuns = s.getTextRuns();
assertEquals(2, textRuns.length);
- RichTextRun textRun = textRuns[0].getRichTextRuns()[0];
+ HSLFTextRun textRun = textRuns[0].getRichTextRuns()[0];
assertEquals("List Item One\rList Item Two\rList Item Three", textRun.getRawText());
assertEquals(1, textRuns[0].getRichTextRuns().length);
assertTrue(textRun.isBullet());
@@ -90,7 +90,7 @@ public final class TestNumberedList2 ext
checkSingleRunWrapper(44, styleAtoms[0]);
checkSingleRunWrapper(130, styleAtoms[1]);
}
- private void checkSlide1(final Slide s) {
+ private void checkSlide1(final HSLFSlide s) {
final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
assertNotNull(numberedListArray);
assertEquals(1, numberedListArray.length);
@@ -101,10 +101,10 @@ public final class TestNumberedList2 ext
assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox[0].getAutoNumberStartNumber());//Default value = 1 will be used
assertTrue(TextAutoNumberSchemeEnum.ANM_ArabicPeriod == autoNumbersOfTextBox[0].getAutoNumberScheme());
- TextRun[] textRuns = s.getTextRuns();
+ HSLFTextParagraph[] textRuns = s.getTextRuns();
assertEquals(3, textRuns.length);
- RichTextRun textRun = textRuns[0].getRichTextRuns()[0];
+ HSLFTextRun textRun = textRuns[0].getRichTextRuns()[0];
assertEquals("Bulleted list\rMore bullets", textRun.getRawText());
assertEquals(1, textRuns[0].getRichTextRuns().length);
assertTrue(textRun.isBullet());
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java Thu Mar 19 23:44:23 2015
@@ -23,8 +23,8 @@ import java.util.List;
import junit.framework.TestCase;
-import org.apache.poi.hslf.model.Slide;
-import org.apache.poi.hslf.model.TextRun;
+import org.apache.poi.hslf.model.HSLFSlide;
+import org.apache.poi.hslf.model.HSLFTextParagraph;
import org.apache.poi.hslf.model.textproperties.TextPFException9;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
import org.apache.poi.hslf.record.EscherTextboxWrapper;
@@ -49,15 +49,15 @@ public final class TestNumberedList3 ext
}
public void testNumberedList() throws Exception {
- SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("numbers3.ppt"));
+ HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("numbers3.ppt"));
assertTrue("No Exceptions while reading file", true);
- final Slide[] slides = ppt.getSlides();
+ final HSLFSlide[] slides = ppt.getSlides();
assertEquals(1, slides.length);
- final Slide slide = slides[0];
+ final HSLFSlide slide = slides[0];
checkSlide(slide);
}
- private void checkSlide(final Slide s) {
+ private void checkSlide(final HSLFSlide s) {
final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
assertNotNull(numberedListArray);
assertEquals(1, numberedListArray.length);
@@ -68,7 +68,7 @@ public final class TestNumberedList3 ext
assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getAutoNumberStartNumber());//Default value = 1 will be used
assertTrue(TextAutoNumberSchemeEnum.ANM_ArabicPeriod == autoNumbersOfTextBox0[0].getAutoNumberScheme());
- final TextRun[] textRuns = s.getTextRuns();
+ final HSLFTextParagraph[] textRuns = s.getTextRuns();
assertEquals(3, textRuns.length);
assertEquals("Bulleted list\rMore bullets\rNo bullets here", textRuns[0].getRawText());
assertEquals("Numbered list between two bulleted lists\rSecond numbered list item", textRuns[1].getRawText());
@@ -91,7 +91,7 @@ public final class TestNumberedList3 ext
assertEquals(67, textProp.getCharactersCovered());
- RichTextRun textRun = textRuns[0].getRichTextRuns()[0];
+ HSLFTextRun textRun = textRuns[0].getRichTextRuns()[0];
assertTrue(textRun.isBullet());
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java Thu Mar 19 23:44:23 2015
@@ -26,16 +26,13 @@ import java.net.URL;
import junit.framework.TestCase;
import org.apache.poi.POIDataSamples;
-import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.blip.DIB;
import org.apache.poi.hslf.blip.EMF;
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.HSLFShape;
-import org.apache.poi.hslf.model.Slide;
+import org.apache.poi.hslf.model.*;
/**
* Test adding/reading pictures
@@ -51,12 +48,12 @@ public final class TestPictures extends
* Test read/write Macintosh PICT
*/
public void testPICT() throws Exception {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
byte[] src_bytes = slTests.readFile("cow.pict");
- int idx = ppt.addPicture(src_bytes, Picture.PICT);
- Picture pict = new Picture(idx);
+ int idx = ppt.addPicture(src_bytes, HSLFPictureShape.PICT);
+ HSLFPictureShape pict = new HSLFPictureShape(idx);
assertEquals(idx, pict.getPictureIndex());
slide.addShape(pict);
@@ -65,21 +62,21 @@ public final class TestPictures extends
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
//make sure we can read this picture shape and it refers to the correct picture data
HSLFShape[] sh = ppt.getSlides()[0].getShapes();
assertEquals(1, sh.length);
- pict = (Picture)sh[0];
+ pict = (HSLFPictureShape)sh[0];
assertEquals(idx, pict.getPictureIndex());
//check picture data
- PictureData[] pictures = ppt.getPictureData();
+ HSLFPictureData[] pictures = ppt.getPictureData();
//the Picture shape refers to the PictureData object in the Presentation
assertEquals(pict.getPictureData(), pictures[0]);
assertEquals(1, pictures.length);
- assertEquals(Picture.PICT, pictures[0].getType());
+ assertEquals(HSLFPictureShape.PICT, pictures[0].getType());
assertTrue(pictures[0] instanceof PICT);
//compare the content of the initial file with what is stored in the PictureData
byte[] ppt_bytes = pictures[0].getData();
@@ -96,12 +93,12 @@ public final class TestPictures extends
* Test read/write WMF
*/
public void testWMF() throws Exception {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
byte[] src_bytes = slTests.readFile("santa.wmf");
- int idx = ppt.addPicture(src_bytes, Picture.WMF);
- Picture pict = new Picture(idx);
+ int idx = ppt.addPicture(src_bytes, HSLFPictureShape.WMF);
+ HSLFPictureShape pict = new HSLFPictureShape(idx);
assertEquals(idx, pict.getPictureIndex());
slide.addShape(pict);
@@ -110,21 +107,21 @@ public final class TestPictures extends
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
//make sure we can read this picture shape and it refers to the correct picture data
HSLFShape[] sh = ppt.getSlides()[0].getShapes();
assertEquals(1, sh.length);
- pict = (Picture)sh[0];
+ pict = (HSLFPictureShape)sh[0];
assertEquals(idx, pict.getPictureIndex());
//check picture data
- PictureData[] pictures = ppt.getPictureData();
+ HSLFPictureData[] pictures = ppt.getPictureData();
//the Picture shape refers to the PictureData object in the Presentation
assertEquals(pict.getPictureData(), pictures[0]);
assertEquals(1, pictures.length);
- assertEquals(Picture.WMF, pictures[0].getType());
+ assertEquals(HSLFPictureShape.WMF, pictures[0].getType());
assertTrue(pictures[0] instanceof WMF);
//compare the content of the initial file with what is stored in the PictureData
byte[] ppt_bytes = pictures[0].getData();
@@ -141,13 +138,13 @@ public final class TestPictures extends
* Test read/write EMF
*/
public void testEMF() throws Exception {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
byte[] src_bytes = slTests.readFile("wrench.emf");
- int idx = ppt.addPicture(src_bytes, Picture.EMF);
+ int idx = ppt.addPicture(src_bytes, HSLFPictureShape.EMF);
- Picture pict = new Picture(idx);
+ HSLFPictureShape pict = new HSLFPictureShape(idx);
assertEquals(idx, pict.getPictureIndex());
slide.addShape(pict);
@@ -156,21 +153,21 @@ public final class TestPictures extends
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
//make sure we can get this picture shape and it refers to the correct picture data
HSLFShape[] sh = ppt.getSlides()[0].getShapes();
assertEquals(1, sh.length);
- pict = (Picture)sh[0];
+ pict = (HSLFPictureShape)sh[0];
assertEquals(idx, pict.getPictureIndex());
//check picture data
- PictureData[] pictures = ppt.getPictureData();
+ HSLFPictureData[] pictures = ppt.getPictureData();
//the Picture shape refers to the PictureData object in the Presentation
assertEquals(pict.getPictureData(), pictures[0]);
assertEquals(1, pictures.length);
- assertEquals(Picture.EMF, pictures[0].getType());
+ assertEquals(HSLFPictureShape.EMF, pictures[0].getType());
assertTrue(pictures[0] instanceof EMF);
//compare the content of the initial file with what is stored in the PictureData
byte[] ppt_bytes = pictures[0].getData();
@@ -181,12 +178,12 @@ public final class TestPictures extends
* Test read/write PNG
*/
public void testPNG() throws Exception {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
byte[] src_bytes = slTests.readFile("tomcat.png");
- int idx = ppt.addPicture(src_bytes, Picture.PNG);
- Picture pict = new Picture(idx);
+ int idx = ppt.addPicture(src_bytes, HSLFPictureShape.PNG);
+ HSLFPictureShape pict = new HSLFPictureShape(idx);
assertEquals(idx, pict.getPictureIndex());
slide.addShape(pict);
@@ -195,21 +192,21 @@ public final class TestPictures extends
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
//make sure we can read this picture shape and it refers to the correct picture data
HSLFShape[] sh = ppt.getSlides()[0].getShapes();
assertEquals(1, sh.length);
- pict = (Picture)sh[0];
+ pict = (HSLFPictureShape)sh[0];
assertEquals(idx, pict.getPictureIndex());
//check picture data
- PictureData[] pictures = ppt.getPictureData();
+ HSLFPictureData[] pictures = ppt.getPictureData();
//the Picture shape refers to the PictureData object in the Presentation
assertEquals(pict.getPictureData(), pictures[0]);
assertEquals(1, pictures.length);
- assertEquals(Picture.PNG, pictures[0].getType());
+ assertEquals(HSLFPictureShape.PNG, pictures[0].getType());
assertTrue(pictures[0] instanceof PNG);
//compare the content of the initial file with what is stored in the PictureData
byte[] ppt_bytes = pictures[0].getData();
@@ -220,13 +217,13 @@ public final class TestPictures extends
* Test read/write JPEG
*/
public void testJPEG() throws Exception {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
byte[] src_bytes = slTests.readFile("clock.jpg");
- int idx = ppt.addPicture(src_bytes, Picture.JPEG);
+ int idx = ppt.addPicture(src_bytes, HSLFPictureShape.JPEG);
- Picture pict = new Picture(idx);
+ HSLFPictureShape pict = new HSLFPictureShape(idx);
assertEquals(idx, pict.getPictureIndex());
slide.addShape(pict);
@@ -235,21 +232,21 @@ public final class TestPictures extends
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
//make sure we can read this picture shape and it refers to the correct picture data
HSLFShape[] sh = ppt.getSlides()[0].getShapes();
assertEquals(1, sh.length);
- pict = (Picture)sh[0];
+ pict = (HSLFPictureShape)sh[0];
assertEquals(idx, pict.getPictureIndex());
//check picture data
- PictureData[] pictures = ppt.getPictureData();
+ HSLFPictureData[] pictures = ppt.getPictureData();
//the Picture shape refers to the PictureData object in the Presentation
assertEquals(pict.getPictureData(), pictures[0]);
assertEquals(1, pictures.length);
- assertEquals(Picture.JPEG, pictures[0].getType());
+ assertEquals(HSLFPictureShape.JPEG, pictures[0].getType());
assertTrue(pictures[0] instanceof JPEG);
//compare the content of the initial file with what is stored in the PictureData
byte[] ppt_bytes = pictures[0].getData();
@@ -260,12 +257,12 @@ public final class TestPictures extends
* Test read/write DIB
*/
public void testDIB() throws Exception {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
byte[] src_bytes = slTests.readFile("clock.dib");
- int idx = ppt.addPicture(src_bytes, Picture.DIB);
- Picture pict = new Picture(idx);
+ int idx = ppt.addPicture(src_bytes, HSLFPictureShape.DIB);
+ HSLFPictureShape pict = new HSLFPictureShape(idx);
assertEquals(idx, pict.getPictureIndex());
slide.addShape(pict);
@@ -274,21 +271,21 @@ public final class TestPictures extends
ppt.write(out);
out.close();
- ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
+ ppt = new HSLFSlideShow(new HSLFSlideShowImpl(new ByteArrayInputStream(out.toByteArray())));
//make sure we can read this picture shape and it refers to the correct picture data
HSLFShape[] sh = ppt.getSlides()[0].getShapes();
assertEquals(1, sh.length);
- pict = (Picture)sh[0];
+ pict = (HSLFPictureShape)sh[0];
assertEquals(idx, pict.getPictureIndex());
//check picture data
- PictureData[] pictures = ppt.getPictureData();
+ HSLFPictureData[] pictures = ppt.getPictureData();
//the Picture shape refers to the PictureData object in the Presentation
assertEquals(pict.getPictureData(), pictures[0]);
assertEquals(1, pictures.length);
- assertEquals(Picture.DIB, pictures[0].getType());
+ assertEquals(HSLFPictureShape.DIB, pictures[0].getType());
assertTrue(pictures[0] instanceof DIB);
//compare the content of the initial file with what is stored in the PictureData
byte[] ppt_bytes = pictures[0].getData();
@@ -301,34 +298,34 @@ public final class TestPictures extends
public void testReadPictures() throws Exception {
byte[] src_bytes, ppt_bytes, b1, b2;
- Picture pict;
- PictureData pdata;
+ HSLFPictureShape pict;
+ HSLFPictureData pdata;
- SlideShow ppt = new SlideShow(slTests.openResourceAsStream("pictures.ppt"));
- Slide[] slides = ppt.getSlides();
- PictureData[] pictures = ppt.getPictureData();
+ HSLFSlideShow ppt = new HSLFSlideShow(slTests.openResourceAsStream("pictures.ppt"));
+ HSLFSlide[] slides = ppt.getSlides();
+ HSLFPictureData[] pictures = ppt.getPictureData();
assertEquals(5, pictures.length);
- pict = (Picture)slides[0].getShapes()[0]; //the first slide contains JPEG
+ pict = (HSLFPictureShape)slides[0].getShapes()[0]; //the first slide contains JPEG
pdata = pict.getPictureData();
assertTrue(pdata instanceof JPEG);
- assertEquals(Picture.JPEG, pdata.getType());
+ assertEquals(HSLFPictureShape.JPEG, pdata.getType());
src_bytes = pdata.getData();
ppt_bytes = slTests.readFile("clock.jpg");
assertArrayEquals(src_bytes, ppt_bytes);
- pict = (Picture)slides[1].getShapes()[0]; //the second slide contains PNG
+ pict = (HSLFPictureShape)slides[1].getShapes()[0]; //the second slide contains PNG
pdata = pict.getPictureData();
assertTrue(pdata instanceof PNG);
- assertEquals(Picture.PNG, pdata.getType());
+ assertEquals(HSLFPictureShape.PNG, pdata.getType());
src_bytes = pdata.getData();
ppt_bytes = slTests.readFile("tomcat.png");
assertArrayEquals(src_bytes, ppt_bytes);
- pict = (Picture)slides[2].getShapes()[0]; //the third slide contains WMF
+ pict = (HSLFPictureShape)slides[2].getShapes()[0]; //the third slide contains WMF
pdata = pict.getPictureData();
assertTrue(pdata instanceof WMF);
- assertEquals(Picture.WMF, pdata.getType());
+ assertEquals(HSLFPictureShape.WMF, pdata.getType());
src_bytes = pdata.getData();
ppt_bytes = slTests.readFile("santa.wmf");
assertEquals(src_bytes.length, ppt_bytes.length);
@@ -339,10 +336,10 @@ public final class TestPictures extends
System.arraycopy(ppt_bytes, 22, b2, 0, b2.length);
assertArrayEquals(b1, b2);
- pict = (Picture)slides[3].getShapes()[0]; //the forth slide contains PICT
+ pict = (HSLFPictureShape)slides[3].getShapes()[0]; //the forth slide contains PICT
pdata = pict.getPictureData();
assertTrue(pdata instanceof PICT);
- assertEquals(Picture.PICT, pdata.getType());
+ assertEquals(HSLFPictureShape.PICT, pdata.getType());
src_bytes = pdata.getData();
ppt_bytes = slTests.readFile("cow.pict");
assertEquals(src_bytes.length, ppt_bytes.length);
@@ -353,10 +350,10 @@ public final class TestPictures extends
System.arraycopy(ppt_bytes, 512, b2, 0, b2.length);
assertArrayEquals(b1, b2);
- pict = (Picture)slides[4].getShapes()[0]; //the fifth slide contains EMF
+ pict = (HSLFPictureShape)slides[4].getShapes()[0]; //the fifth slide contains EMF
pdata = pict.getPictureData();
assertTrue(pdata instanceof EMF);
- assertEquals(Picture.EMF, pdata.getType());
+ assertEquals(HSLFPictureShape.EMF, pdata.getType());
src_bytes = pdata.getData();
ppt_bytes = slTests.readFile("wrench.emf");
assertArrayEquals(src_bytes, ppt_bytes);
@@ -368,33 +365,33 @@ public final class TestPictures extends
* crazy pictures of type 0, we do our best.
*/
public void testZeroPictureType() throws Exception {
- HSLFSlideShow hslf = new HSLFSlideShow(slTests.openResourceAsStream("PictureTypeZero.ppt"));
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("PictureTypeZero.ppt"));
// Should still have 2 real pictures
assertEquals(2, hslf.getPictures().length);
// Both are real pictures, both WMF
- assertEquals(Picture.WMF, hslf.getPictures()[0].getType());
- assertEquals(Picture.WMF, hslf.getPictures()[1].getType());
+ assertEquals(HSLFPictureShape.WMF, hslf.getPictures()[0].getType());
+ assertEquals(HSLFPictureShape.WMF, hslf.getPictures()[1].getType());
// Now test what happens when we use the SlideShow interface
- SlideShow ppt = new SlideShow(hslf);
- Slide[] slides = ppt.getSlides();
- PictureData[] pictures = ppt.getPictureData();
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
+ HSLFSlide[] slides = ppt.getSlides();
+ HSLFPictureData[] pictures = ppt.getPictureData();
assertEquals(12, slides.length);
assertEquals(2, pictures.length);
- Picture pict;
- PictureData pdata;
+ HSLFPictureShape pict;
+ HSLFPictureData pdata;
- pict = (Picture)slides[0].getShapes()[1]; // 2nd object on 1st slide
+ pict = (HSLFPictureShape)slides[0].getShapes()[1]; // 2nd object on 1st slide
pdata = pict.getPictureData();
assertTrue(pdata instanceof WMF);
- assertEquals(Picture.WMF, pdata.getType());
+ assertEquals(HSLFPictureShape.WMF, pdata.getType());
- pict = (Picture)slides[0].getShapes()[2]; // 3rd object on 1st slide
+ pict = (HSLFPictureShape)slides[0].getShapes()[2]; // 3rd object on 1st slide
pdata = pict.getPictureData();
assertTrue(pdata instanceof WMF);
- assertEquals(Picture.WMF, pdata.getType());
+ assertEquals(HSLFPictureShape.WMF, pdata.getType());
}
/**
@@ -404,42 +401,42 @@ public final class TestPictures extends
public void disabled_testZeroPictureLength() throws Exception {
// take the data from www instead of test directory
URL url = new URL("http://www.cs.sfu.ca/~anoop/courses/CMPT-882-Fall-2002/chris.ppt");
- HSLFSlideShow hslf = new HSLFSlideShow(url.openStream());
+ HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(url.openStream());
// Should still have 2 real pictures
assertEquals(2, hslf.getPictures().length);
// Both are real pictures, both WMF
- assertEquals(Picture.WMF, hslf.getPictures()[0].getType());
- assertEquals(Picture.WMF, hslf.getPictures()[1].getType());
+ assertEquals(HSLFPictureShape.WMF, hslf.getPictures()[0].getType());
+ assertEquals(HSLFPictureShape.WMF, hslf.getPictures()[1].getType());
// Now test what happens when we use the SlideShow interface
- SlideShow ppt = new SlideShow(hslf);
- Slide[] slides = ppt.getSlides();
- PictureData[] pictures = ppt.getPictureData();
+ HSLFSlideShow ppt = new HSLFSlideShow(hslf);
+ HSLFSlide[] slides = ppt.getSlides();
+ HSLFPictureData[] pictures = ppt.getPictureData();
assertEquals(27, slides.length);
assertEquals(2, pictures.length);
- Picture pict;
- PictureData pdata;
+ HSLFPictureShape pict;
+ HSLFPictureData pdata;
- pict = (Picture)slides[6].getShapes()[13];
+ pict = (HSLFPictureShape)slides[6].getShapes()[13];
pdata = pict.getPictureData();
assertTrue(pdata instanceof WMF);
- assertEquals(Picture.WMF, pdata.getType());
+ assertEquals(HSLFPictureShape.WMF, pdata.getType());
- pict = (Picture)slides[7].getShapes()[13];
+ pict = (HSLFPictureShape)slides[7].getShapes()[13];
pdata = pict.getPictureData();
assertTrue(pdata instanceof WMF);
- assertEquals(Picture.WMF, pdata.getType());
+ assertEquals(HSLFPictureShape.WMF, pdata.getType());
//add a new picture, it should be correctly appended to the Pictures stream
ByteArrayOutputStream out = new ByteArrayOutputStream();
- for(PictureData p : pictures) p.write(out);
+ for(HSLFPictureData p : pictures) p.write(out);
out.close();
int streamSize = out.size();
- PictureData data = PictureData.create(Picture.JPEG);
+ HSLFPictureData data = HSLFPictureData.create(HSLFPictureShape.JPEG);
data.setData(new byte[100]);
int offset = hslf.addPicture(data);
assertEquals(streamSize, offset);
@@ -448,20 +445,20 @@ public final class TestPictures extends
}
public void testGetPictureName() throws Exception {
- SlideShow ppt = new SlideShow(slTests.openResourceAsStream("ppt_with_png.ppt"));
- Slide slide = ppt.getSlides()[0];
+ HSLFSlideShow ppt = new HSLFSlideShow(slTests.openResourceAsStream("ppt_with_png.ppt"));
+ HSLFSlide slide = ppt.getSlides()[0];
- Picture p = (Picture)slide.getShapes()[0]; //the first slide contains JPEG
+ HSLFPictureShape p = (HSLFPictureShape)slide.getShapes()[0]; //the first slide contains JPEG
assertEquals("test", p.getPictureName());
}
public void testSetPictureName() throws Exception {
- SlideShow ppt = new SlideShow();
+ HSLFSlideShow ppt = new HSLFSlideShow();
- Slide slide = ppt.createSlide();
+ HSLFSlide slide = ppt.createSlide();
byte[] img = slTests.readFile("tomcat.png");
- int idx = ppt.addPicture(img, Picture.PNG);
- Picture pict = new Picture(idx);
+ int idx = ppt.addPicture(img, HSLFPictureShape.PNG);
+ HSLFPictureShape pict = new HSLFPictureShape(idx);
pict.setPictureName("tomcat.png");
slide.addShape(pict);
@@ -470,9 +467,9 @@ public final class TestPictures extends
ppt.write(out);
out.close();
- ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+ ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
- Picture p = (Picture)ppt.getSlides()[0].getShapes()[0];
+ HSLFPictureShape p = (HSLFPictureShape)ppt.getSlides()[0].getShapes()[0];
assertEquals("tomcat.png", p.getPictureName());
}
}
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestReOrderingSlides.java Thu Mar 19 23:44:23 2015
@@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import junit.framework.TestCase;
+
import org.apache.poi.hslf.*;
import org.apache.poi.hslf.model.*;
import org.apache.poi.POIDataSamples;
@@ -33,16 +34,16 @@ import org.apache.poi.POIDataSamples;
*/
public final class TestReOrderingSlides extends TestCase {
// A SlideShow with one slide
- private HSLFSlideShow hss_one;
- private SlideShow ss_one;
+ private HSLFSlideShowImpl hss_one;
+ private HSLFSlideShow ss_one;
// A SlideShow with two slides
- private HSLFSlideShow hss_two;
- private SlideShow ss_two;
+ private HSLFSlideShowImpl hss_two;
+ private HSLFSlideShow ss_two;
// A SlideShow with three slides
- private HSLFSlideShow hss_three;
- private SlideShow ss_three;
+ private HSLFSlideShowImpl hss_three;
+ private HSLFSlideShow ss_three;
/**
* Create/open the slideshows
@@ -50,14 +51,14 @@ public final class TestReOrderingSlides
public void setUp() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
- hss_one = new HSLFSlideShow(slTests.openResourceAsStream("Single_Coloured_Page.ppt"));
- ss_one = new SlideShow(hss_one);
+ hss_one = new HSLFSlideShowImpl(slTests.openResourceAsStream("Single_Coloured_Page.ppt"));
+ ss_one = new HSLFSlideShow(hss_one);
- hss_two = new HSLFSlideShow(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
- ss_two = new SlideShow(hss_two);
+ hss_two = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
+ ss_two = new HSLFSlideShow(hss_two);
- hss_three = new HSLFSlideShow(slTests.openResourceAsStream("incorrect_slide_order.ppt"));
- ss_three = new SlideShow(hss_three);
+ hss_three = new HSLFSlideShowImpl(slTests.openResourceAsStream("incorrect_slide_order.ppt"));
+ ss_three = new HSLFSlideShow(hss_three);
}
/**
@@ -66,7 +67,7 @@ public final class TestReOrderingSlides
public void testReOrder1() throws Exception {
// Has one slide
assertEquals(1, ss_one.getSlides().length);
- Slide s1 = ss_one.getSlides()[0];
+ HSLFSlide s1 = ss_one.getSlides()[0];
// Check slide 1 is as expected
assertEquals(256, s1._getSheetNumber());
@@ -81,8 +82,8 @@ public final class TestReOrderingSlides
hss_one.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- HSLFSlideShow hss_read = new HSLFSlideShow(bais);
- SlideShow ss_read = new SlideShow(hss_read);
+ HSLFSlideShowImpl hss_read = new HSLFSlideShowImpl(bais);
+ HSLFSlideShow ss_read = new HSLFSlideShow(hss_read);
// Check it still has 1 slide
assertEquals(1, ss_read.getSlides().length);
@@ -101,8 +102,8 @@ public final class TestReOrderingSlides
public void testReOrder2() throws Exception {
// Has two slides
assertEquals(2, ss_two.getSlides().length);
- Slide s1 = ss_two.getSlides()[0];
- Slide s2 = ss_two.getSlides()[1];
+ HSLFSlide s1 = ss_two.getSlides()[0];
+ HSLFSlide s2 = ss_two.getSlides()[1];
// Check slide 1 is as expected
assertEquals(256, s1._getSheetNumber());
@@ -121,8 +122,8 @@ public final class TestReOrderingSlides
hss_two.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- HSLFSlideShow hss_read = new HSLFSlideShow(bais);
- SlideShow ss_read = new SlideShow(hss_read);
+ HSLFSlideShowImpl hss_read = new HSLFSlideShowImpl(bais);
+ HSLFSlideShow ss_read = new HSLFSlideShow(hss_read);
// Check it still has 2 slides
assertEquals(2, ss_read.getSlides().length);
@@ -144,8 +145,8 @@ public final class TestReOrderingSlides
public void testReOrder2swap() throws Exception {
// Has two slides
assertEquals(2, ss_two.getSlides().length);
- Slide s1 = ss_two.getSlides()[0];
- Slide s2 = ss_two.getSlides()[1];
+ HSLFSlide s1 = ss_two.getSlides()[0];
+ HSLFSlide s2 = ss_two.getSlides()[1];
// Check slide 1 is as expected
assertEquals(256, s1._getSheetNumber());
@@ -164,8 +165,8 @@ public final class TestReOrderingSlides
hss_two.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- HSLFSlideShow hss_read = new HSLFSlideShow(bais);
- SlideShow ss_read = new SlideShow(hss_read);
+ HSLFSlideShowImpl hss_read = new HSLFSlideShowImpl(bais);
+ HSLFSlideShow ss_read = new HSLFSlideShow(hss_read);
// Check it still has 2 slides
assertEquals(2, ss_read.getSlides().length);
@@ -188,9 +189,9 @@ public final class TestReOrderingSlides
public void testReOrder3() throws Exception {
// Has three slides
assertEquals(3, ss_three.getSlides().length);
- Slide s1 = ss_three.getSlides()[0];
- Slide s2 = ss_three.getSlides()[1];
- Slide s3 = ss_three.getSlides()[2];
+ HSLFSlide s1 = ss_three.getSlides()[0];
+ HSLFSlide s2 = ss_three.getSlides()[1];
+ HSLFSlide s3 = ss_three.getSlides()[2];
// Check slide 1 is as expected
assertEquals(256, s1._getSheetNumber());
@@ -213,8 +214,8 @@ public final class TestReOrderingSlides
hss_three.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- HSLFSlideShow hss_read = new HSLFSlideShow(bais);
- SlideShow ss_read = new SlideShow(hss_read);
+ HSLFSlideShowImpl hss_read = new HSLFSlideShowImpl(bais);
+ HSLFSlideShow ss_read = new HSLFSlideShow(hss_read);
// Check it still has 3 slides
assertEquals(3, ss_read.getSlides().length);
@@ -241,9 +242,9 @@ public final class TestReOrderingSlides
public void testReOrder3swap() throws Exception {
// Has three slides
assertEquals(3, ss_three.getSlides().length);
- Slide s1 = ss_three.getSlides()[0];
- Slide s2 = ss_three.getSlides()[1];
- Slide s3 = ss_three.getSlides()[2];
+ HSLFSlide s1 = ss_three.getSlides()[0];
+ HSLFSlide s2 = ss_three.getSlides()[1];
+ HSLFSlide s3 = ss_three.getSlides()[2];
// Check slide 1 is as expected
assertEquals(256, s1._getSheetNumber());
@@ -267,16 +268,16 @@ public final class TestReOrderingSlides
hss_three.write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- HSLFSlideShow hss_read = new HSLFSlideShow(bais);
- SlideShow ss_read = new SlideShow(hss_read);
+ HSLFSlideShowImpl hss_read = new HSLFSlideShowImpl(bais);
+ HSLFSlideShow ss_read = new HSLFSlideShow(hss_read);
// Check it still has 3 slides
assertEquals(3, ss_read.getSlides().length);
// And check it's as expected
- Slide _s1 = ss_read.getSlides()[0];
- Slide _s2 = ss_read.getSlides()[1];
- Slide _s3 = ss_read.getSlides()[2];
+ HSLFSlide _s1 = ss_read.getSlides()[0];
+ HSLFSlide _s2 = ss_read.getSlides()[1];
+ HSLFSlide _s3 = ss_read.getSlides()[2];
// 1 --> 3
assertEquals(s1._getSheetNumber(), _s3._getSheetNumber());
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRecordSetup.java Thu Mar 19 23:44:23 2015
@@ -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() {
Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java?rev=1667902&r1=1667901&r2=1667902&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java Thu Mar 19 23:44:23 2015
@@ -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 exten
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 exten
* 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 exten
* 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 exten
*/
public void testFontSize() {
- Slide slideOne = ss.getSlides()[0];
- TextRun[] textRuns = slideOne.getTextRuns();
- RichTextRun 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 slideOne = ss.getSlides()[0];
+ HSLFTextParagraph[] textRuns = slideOne.getTextRuns();
+ HSLFTextRun rtr = textRuns[0].getRichTextRuns()[0];
+
+ 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 exten
}
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<h.length; i++) {
// Change
- Slide slideOne = s[i];
- TextRun[] textRuns = slideOne.getTextRuns();
- RichTextRun rtr = textRuns[0].getRichTextRuns()[0];
+ HSLFSlide slideOne = s[i];
+ HSLFTextParagraph[] textRuns = slideOne.getTextRuns();
+ HSLFTextRun rtr = textRuns[0].getRichTextRuns()[0];
rtr.setBold(true);
rtr.setFontSize(18);
@@ -218,8 +215,8 @@ public final class TestRichTextRun exten
h[i].write(baos);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- HSLFSlideShow readHSLF = new HSLFSlideShow(bais);
- SlideShow readS = new SlideShow(readHSLF);
+ HSLFSlideShowImpl readHSLF = new HSLFSlideShowImpl(bais);
+ HSLFSlideShow readS = new HSLFSlideShow(readHSLF);
// Tweak existing one again, to ensure really worked
rtr.setBold(false);
@@ -234,9 +231,9 @@ public final class TestRichTextRun exten
// Now, look at the one we changed, wrote out, and read back in
// Ensure it does contain our original modifications
- Slide slideOneRR = readS.getSlides()[0];
- TextRun[] textRunsRR = slideOneRR.getTextRuns();
- RichTextRun rtrRRa = textRunsRR[0].getRichTextRuns()[0];
+ HSLFSlide slideOneRR = readS.getSlides()[0];
+ HSLFTextParagraph[] textRunsRR = slideOneRR.getTextRuns();
+ HSLFTextRun rtrRRa = textRunsRR[0].getRichTextRuns()[0];
assertEquals(true, rtrRRa.isBold());
assertEquals(18, rtrRRa.getFontSize());
@@ -250,12 +247,12 @@ public final class TestRichTextRun exten
*/
public void testParagraphStylesShorterTheCharStyles() {
// Check we have the right number of sheets
- Slide[] slides = ssRichC.getSlides();
+ HSLFSlide[] slides = ssRichC.getSlides();
assertEquals(14, slides.length);
// Check the number of text runs on interesting sheets
- Slide slideThreeC = ssRichC.getSlides()[2];
- Slide slideSevenC = ssRichC.getSlides()[6];
+ HSLFSlide slideThreeC = ssRichC.getSlides()[2];
+ HSLFSlide slideSevenC = ssRichC.getSlides()[6];
assertEquals(3, slideThreeC.getTextRuns().length);
assertEquals(5, slideSevenC.getTextRuns().length);
@@ -269,10 +266,10 @@ public final class TestRichTextRun exten
// Illustrative Example
// .
- TextRun[] s3tr = slideThreeC.getTextRuns();
- RichTextRun[] s3rtr0 = s3tr[0].getRichTextRuns();
- RichTextRun[] s3rtr1 = s3tr[1].getRichTextRuns();
- RichTextRun[] s3rtr2 = s3tr[2].getRichTextRuns();
+ HSLFTextParagraph[] s3tr = slideThreeC.getTextRuns();
+ HSLFTextRun[] s3rtr0 = s3tr[0].getRichTextRuns();
+ HSLFTextRun[] s3rtr1 = s3tr[1].getRichTextRuns();
+ HSLFTextRun[] s3rtr2 = s3tr[2].getRichTextRuns();
assertEquals(2, s3rtr0.length);
assertEquals(1, s3rtr1.length);
@@ -303,10 +300,10 @@ public final class TestRichTextRun exten
// <ps>(text a)</ps><ps>(text a)(text b)</ps>
// 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 exten
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 exten
* 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 exten
* 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);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org