[prev in list] [next in list] [prev in thread] [next in thread] 

List:       poi-dev
Subject:    DO NOT REPLY [Bug 49648] New: Hslf Error :Can not replace special
From:       bugzilla () apache ! org
Date:       2010-07-26 12:34:54
Message-ID: bug-49648-47293 () https ! issues ! apache ! org/bugzilla/
[Download RAW message or body]

https://issues.apache.org/bugzilla/show_bug.cgi?id=49648

           Summary: Hslf Error :Can not replace special characters (€)
           Product: POI
           Version: 3.6
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: HSLF
        AssignedTo: dev@poi.apache.org
        ReportedBy: registro72@gmail.com


Created an attachment (id=25802)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=25802)
PowerPoint for test

Hi, 
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 
Eclipse 
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); 
                                        txtRun[j].setText(txtReplaced); 
                                } 
                        } 

                        FileOutputStream out = new
FileOutputStream("c://temp//template_final.ppt"); 
                        ppt.write(out); 
                        out.close(); 

                } catch (FileNotFoundException e) { 
                        e.printStackTrace(); 
                } catch (IOException e) { 
                        e.printStackTrace(); 
                } 

        } 

} 

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.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic