ASF Bugzilla – Attachment 29961 Details for
Bug 48593
[PATCH] Multiple Saves Causes Slide Corruption
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
My example of the same problem
Main.java (text/x-java-source), 2.10 KB, created by
Rafael Lopez
on 2013-02-18 07:22:19 UTC
(
hide
)
Description:
My example of the same problem
Filename:
MIME Type:
Creator:
Rafael Lopez
Created:
2013-02-18 07:22:19 UTC
Size:
2.10 KB
patch
obsolete
>import java.io.File; >import java.io.FileOutputStream; >import java.io.IOException; > >import org.apache.poi.hslf.HSLFSlideShow; >import org.apache.poi.hslf.usermodel.SlideShow; > >public class Main { > > public static void main(String[] args) { > try { > //method1(); > method2(); > } catch (Exception e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > > public static void method1() > throws IOException { > String presentationId = "3.ppt"; > SlideShow slideShow = new SlideShow(); > slideShow.createSlide(); > slideShow.createSlide(); > slideShow.createSlide(); > slideShow.createSlide(); > savePresentation(presentationId, slideShow, true); > SlideShow slideShow2 = getPresentation(presentationId); > } > > public static void method2() > throws IOException, InterruptedException { > String presentationId = "3.ppt"; > SlideShow slideShow = new SlideShow(); > slideShow.createSlide(); > savePresentation(presentationId, slideShow, true); > Thread.sleep(2000); > SlideShow slideShow2 = getPresentation(presentationId); > slideShow2.createSlide(); > savePresentation(presentationId, slideShow2, true); > Thread.sleep(2000); > SlideShow slideShow3 = getPresentation(presentationId); > slideShow3.createSlide(); > savePresentation(presentationId, slideShow3, true); > Thread.sleep(2000); > SlideShow slideShow4 = getPresentation(presentationId); > slideShow4.createSlide(); > savePresentation(presentationId, slideShow4, true); > } > > public static SlideShow getPresentation(String presentationId) > throws IOException { > File pptFile = new File("/home/rlopezga/ppt", presentationId); > return new SlideShow(new HSLFSlideShow(pptFile.getCanonicalPath())); > } > > public static void savePresentation(String presentationId, SlideShow slideShow, boolean overwrite) > throws IOException { > File pptFile = new File("/home/rlopezga/ppt", presentationId); > if (!overwrite && pptFile.exists()) { > //TODO maybe it is convenient to do something here. > } else { > if (!pptFile.exists()) { > pptFile.createNewFile(); > } > > FileOutputStream out = new FileOutputStream(pptFile); > slideShow.write(out); > out.flush(); > out.close(); > } > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 48593
:
24881
| 29961 |
30944
|
30948
|
31161