Bug 49648 - Hslf Error :Can not replace special characters (€)
Summary: Hslf Error :Can not replace special characters (€)
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: 3.6-FINAL
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2010-07-26 08:34 UTC by LuK@
Modified: 2011-06-24 11:19 UTC (History)
0 users

PowerPoint for test (13.00 KB, application/vnd.ms-powerpoint)
2010-07-26 08:34 UTC, LuK@

Note You need to log in before you can comment on or make changes to this bug.
Description LuK@ 2010-07-26 08:34:49 UTC
Created attachment 25802 [details]
PowerPoint for test

I urgently need your help. 
First I apologize for my bad English. 
I am a newbie of POI, I'm just venturing into their use. 
My environment is this: 
J2SE 1.5 
POI 03/06 (20091214) 

I have this problem, I can not replace the text within a text to be replaced when the ppt contains special characters. An example of a special character is €  

Exception in thread "main" java.lang.NullPointerException 
        at org.apache.poi.hslf.model.TextRun.storeText(TextRun.java:350) 
        at org.apache.poi.hslf.model.TextRun.setRawText(TextRun.java:464) 
        at org.apache.poi.hslf.model.TextRun.setText(TextRun.java:498) 
        at ExampleError.main(ExampleError.java:41)

Banging his head on, but unable to solve. 

Below the code that I'm using: 

import org.apache.poi.hslf.HSLFSlideShow; 
import org.apache.poi.hslf.model.Slide; 
import org.apache.poi.hslf.model.TextRun; 
import org.apache.poi.hslf.usermodel.RichTextRun; 
import org.apache.poi.hslf.usermodel.SlideShow; 
import org.apache.poi.poifs.filesystem.POIFSFileSystem; 

public class ExampleError { 

        public static void main(String[] args) { 
                POIFSFileSystem fs; 

                try { 
                        fs = new POIFSFileSystem(new FileInputStream("c://temp//template_test.ppt")); 
                        SlideShow ppt = new SlideShow(new HSLFSlideShow(fs)); 
                        Slide[] slides = ppt.getSlides(); 
                        String replace = "Amount €100"; 
                        int nSlide = slides.length; 

                        for (int i = 0; i < nSlide; i++) { 
                                TextRun[] txtRun = slides[i].getTextRuns(); 
                                for (int j = 0; j < txtRun.length; j++) { 
                                        String textGet = txtRun[j].getText(); 
                                        String txtReplaced = textGet.replace("{txtTot}", replace); 
                                        System.out.println("Replaced: " + txtReplaced); 
                        FileOutputStream out = new FileOutputStream("c://temp//template_final.ppt"); 
                } catch (FileNotFoundException e) { 
                } catch (IOException e) { 



Please find attached a ppt that I use for simple tests. 
Please help I no longer go forward suggestions are welcome, Changes to my code are welcome, you run a small example, would be ideal ... any help is greatly appreciated. 

Best Regards.
Comment 1 Nick Burch 2011-06-24 11:19:29 UTC
I've run your sample program with your file on 3.8 beta 3, and I can change the text to contain unicode characters without error