Hi,
I seem to get PptEditException's thrown, when simulating reading writing and updating the presentation object. I have two tests one for only 3 cycles and one for 20 cycles.
The three cycles runs fine. The 20 cycles throws a PptEditException.
What's going on?
The test:
public class TestLoadingAndSavingProblem extends TestCase {
String filename = "c:/temp/aspose/SaveAndLoadIssue.ppt";
File theFile = new File(filename);
public void testSavingThenLoadingOnlyAFewTimes() throws Exception {
Presentation presentation = new Presentation();
for (int i=0; i<3; i++){
save(presentation);
presentation = load(theFile);
}
}
public void testSavingThenLoadingMoreTimes() throws Exception {
Presentation presentation = new Presentation();
for (int i=0; i<20; i++){
System.out.println(i);
save(presentation);
presentation.addEmptySlide();
presentation = load(theFile);
}
}
private Presentation load(File theFile) throws Exception {
assertTrue(theFile.exists());
FileInputStream in = new FileInputStream(theFile);
Presentation loaded = new Presentation(in);
in.close();
return loaded;
}
private void save(Presentation presentation) throws Exception {
FileOutputStream out = new FileOutputStream(new File(filename));
presentation.write(out);
out.close();
}
}
The Exception stack trace....
com.aspose.slides.PptEditException: Error inserting new slide to a presentation.
at com.aspose.slides.Presentation.addEmptySlide(SourceFile:2093)
at powerpoint.TestLoadingAndSavingProblem.testSavingThenLoadingMoreTimes(TestLoadingAndSavingProblem.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
at java.lang.reflect.Method.invoke(Method.java:391)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:436)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:311)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: com.aspose.slides.PptEditException: Slide cloning error.
at com.aspose.slides.Presentation.cloneSlide(SourceFile:1482)
at com.aspose.slides.Presentation.addEmptySlide(SourceFile:2082)
... 17 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 30
at java.io.ByteArrayInputStream.read(ByteArrayInputStream.java(Inlined Compiled Code))
at com.aspose.slides.aP.do(SourceFile(Compiled Code))
at com.aspose.slides.aP.do(SourceFile:57)
at com.aspose.slides.dS.(SourceFile:43)
at com.aspose.slides.eo.(SourceFile:38)
at com.aspose.slides.aP.(SourceFile:45)
at com.aspose.slides.bB.do(SourceFile:19)
at com.aspose.slides.aS.do(SourceFile(Compiled Code))
at com.aspose.slides.ag.do(SourceFile(Inlined Compiled Code))
at com.aspose.slides.dn.do(SourceFile(Compiled Code))
at com.aspose.slides.ci.do(SourceFile:82)
at com.aspose.slides.aS.do(SourceFile(Compiled Code))
at com.aspose.slides.ag.do(SourceFile(Inlined Compiled Code))
at com.aspose.slides.dn.do(SourceFile(Compiled Code))
at com.aspose.slides.ci.do(SourceFile:82)
at com.aspose.slides.aS.do(SourceFile(Compiled Code))
at com.aspose.slides.ag.do(SourceFile(Inlined Compiled Code))
at com.aspose.slides.dn.do(SourceFile(Compiled Code))
at com.aspose.slides.ci.do(SourceFile:82)
at com.aspose.slides.aS.do(SourceFile(Compiled Code))
at com.aspose.slides.ag.do(SourceFile(Compiled Code))
at com.aspose.slides.eD.do(SourceFile:34)
at com.aspose.slides.dS.(SourceFile(Inlined Compiled Code))
at com.aspose.slides.eo.(SourceFile(Inlined Compiled Code))
at com.aspose.slides.eD.(SourceFile(Inlined Compiled Code))
at com.aspose.slides.an.do(SourceFile(Compiled Code))
at com.aspose.slides.an.do(SourceFile(Compiled Code))
at com.aspose.slides.an.do(SourceFile:38)
at com.aspose.slides.J.do(SourceFile:30)
at com.aspose.slides.dS.(SourceFile:43)
at com.aspose.slides.eo.(SourceFile:38)
at com.aspose.slides.J.(SourceFile:23)
at com.aspose.slides.MainMaster.do(SourceFile:242)
at com.aspose.slides.Presentation.do(SourceFile:1322)
at com.aspose.slides.Presentation.cloneSlide(SourceFile:1469)
... 18 more