Can you create a bug in bugzilla and attach the ppt template and
source code?
Regards,
Yegor
> I had written a short program which splices some text into a
> RichTextRun.
>
> Here is my exception:
>
> Exception in thread "main" java.lang.StringIndexOutOfBoundsException:
> String index out of range: 178
> at java.lang.String.substring(String.java:1765)
> at
> org.apache.poi.hslf.usermodel.RichTextRun.getText(RichTextRun.java:133)
> at hslf.InsertText.insertText(InsertText.java:39)
> at hslf.InsertText.main(InsertText.java:19)
> Process exited with exit code 1.
>
>
> Here is my code. The location of the exception is marked:
>
>
>
> public class InsertText {
> public InsertText() {
> }
>
> public static void main(String[] args) throws IOException {
> InsertText insertText = new InsertText();
> insertText.insertText();
> }
>
> public void insertText() throws IOException {
> SlideShow ppt = new SlideShow(new
> HSLFSlideShow("c:/test/test2.ppt"));
> Slide slide2 = ppt.getSlides()[1];
>
> String contchan = "9.9";
> String actreflect = "8";
> String indOrg = "0.090";
>
> Shape[] sh = slide2.getShapes();
> for (int j = 0; j < sh.length; j++) {
>
> if (sh[j] instanceof TextBox){
> TextBox shape = (TextBox)sh[j];
> if (shape.getTextRun() != null) {
> RichTextRun[] rtr =
> shape.getTextRun().getRichTextRuns();
> for (RichTextRun rich: rtr) {
>
> //EXCEPTION OCCURS HERE (NEXT LINE) AFTER NEXT
> BLOCK OF CODE HAS EXECUTED AND LOOPED
>
> if
> (rich.getText().trim().startsWith("Continuity")) {
> String master = rich.getText();
> int pos1 = master.indexOf("=");
> String b4contchan = master.substring(0, pos1
> + 2);
> int pos2 = master.indexOf("Action");
> String aftcontchan = master.substring(pos2 -
> 1);
> master = b4contchan + contchan +
> aftcontchan;
> System.err.println("master = " + master);
> rich.setText(master);
> }
> }
> }
> }
> }
>
>
> FileOutputStream out = new
> FileOutputStream("c:/test/test2.ppt");
> ppt.write(out);
> out.close();
> }
>
> }
>
>
> If I comment out rich.setText(master) the program runs to completion but
> doesn't of course change the RichTextRun in test2.ppt. It doesn't make
> any sense . . . it seems as though setting this text is affecting the
> entire array of RichTextRuns. I mean after rich.setText(master) the
> loop ends and goes on to the text position in the array. This next loop
> is affected. I don't know why.
>
> Thanks.
>
> Regards,
> Eric Hamacher
>
> ******************************
> THIS EMAIL IS INTENDED ONLY FOR THE REVIEW OF THE ADDRESSEE(S), AND MAY
> CONTAIN CONFIDENTIAL AND LEGALLY PRIVILEGED INFORMATION. INTERCEPTION,
> COPYING, DISSEMINATION, OR OTHER USE BY OTHER THAN THE ADDRESSEE(S) IS
> PROHIBITED AND MAY BE PENALIZED UNDER APPLICABLE PRIVACY LAWS. IF YOU
> RECEIVED THIS EMAIL IN ERROR, PLEASE DELETE IT AND NOTIFY ME BY RETURN
> EMAIL TO [EMAIL PROTECTED] *******************************
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]