DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=39177>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39177 Summary: Bug: TextRun.setText sets incorrect length of text in the underlying StyleTextPropAtom. Product: POI Version: unspecified Platform: Other OS/Version: All Status: NEW Severity: major Priority: P2 Component: HSLF AssignedTo: [email protected] ReportedBy: [EMAIL PROTECTED] Nick, it seems there is a bug with stylings. I'm implementing TextBox shape and get corrupted files. Description: If change text via TextRun.setText and save the resulting ppt the output has correct structure but when opening it in PowerPoint it looks corrupted. Test case: public void testChangeText() throws Exception { String dirname = System.getProperty("HSLF.testdata.path"); String filename = dirname + "/with_textbox.ppt"; HSLFSlideShow hss = new HSLFSlideShow(filename); SlideShow ppt = new SlideShow(hss); Slide sl = ppt.getSlides()[0]; TextRun[] txt = sl.getTextRuns(); for (int i = 0; i < txt.length; i++) { String text = txt[i].getText(); //everything should remain the same. Existing data structures must be preserved. txt[i].setText(text); } FileOutputStream out = new FileOutputStream("text_poi.ppt"); ppt.write(out); out.close(); //open it and see that it is corrupted } If you compare the original file and the re-saved one you will see thast the differences are only in StyleTextPropAtom. For example, for "Plain Text" string: before after paragraph.length 12 11 characters.length 12 11 for "This is Times New Roman": before after paragraph.length 24 23 characters.length 24 23 That is the length of text in stylings is always text.length while it should be text.length+1. If text consists of multiple RichTextRun object then the total size of all text runs must be rawtext.length+1. Quick fix: Lines 277 and 288 in TextRun.setText should be changed as follows: pCol.updateTextSize(s.length()+1); cCol.updateTextSize(s.length()+1); With this fix everything works right. The re-saved ppt have the same structure as the original file. Regards, Yegor -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] Mailing List: http://jakarta.apache.org/site/mail2.html#poi The Apache Jakarta POI Project: http://jakarta.apache.org/poi/
