开发者

Title in POI created PowerPoint slide not preserving formatting when copying

I'm creating a PowerPoint slide using POI and I need to be able to copy and paste it to another presentation. I'm running into a problem where the title of the generated slide adopts a bulleted list style when copying it. Any ideas on how can I fix this? I tried both the production version (3.6-20091214) and the beta version (3.7-beta1-20100620).

To reproduce you can just run the following code:

import java.io.FileOutputStream;

import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.model.TextBox;
import org.apache.poi.hslf.usermodel.SlideShow;

public class TestPPT {

   /**
    * @param args
    */
   public static void main(String[] args) {
           try{
                   SlideShow slideShow = new SlideShow();
                   Slide slide = slideShow.createSlide();
                   TextBox tit开发者_如何学Cle = slide.addTitle();
                   title.setText("Test Title");
                   FileOutputStream out =
                       new FileOutputStream("C:/slideshow.ppt");
                   slideShow.write(out);
                   out.close();
           }catch(Exception e){}}
}

open the slideshow.ppt, select the slide, copy and paste it right there and you should see a new slide with a bullet list with one entry reading "Test Title". See below.

alt text http://www.freeimagehosting.net/uploads/69bef4b86b.gif


I notice that this also happens when applying a different slide-design/layout on the created slide. Apparently the added title has some markup that isn't showing unless you start copying or applying a design.

Mind you that hslf is part of the scratchpad; meaning that -if I understand correctly - you have to be careful relying on it for production purposes. I guess the best thing you can do is report this as a bug on the appropriate mailing list or bug tracking system.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜