Hi

When creating PPT-file with HSLF we use CharFlagsTextProp to set
StrikeThrough of TextBOx.It doesn't work in PowerPoint2007, but it works
well in PowerPoint2003 . I insert two images one is excuted result the other
one is what it expectd to be 
 
Below is my programe:

import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;

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


public class StrikeThroughPOI {
   public static void main(String args[]) throws IOException {
    //create a new empty slide show
      SlideShow ppt = new SlideShow();
      //add first slide
      Slide s1 = ppt.createSlide();
      //add second slide
      Slide s2 = ppt.createSlide();
      //TextBox
      TextBox txt = new TextBox();
      txt.setText("Hello, World!");
      txt.setAnchor(new java.awt.Rectangle(300, 100, 300, 50));

      RichTextRun rt = txt.getTextRun().getRichTextRuns()[0];
      rt.setFontSize(32);
      rt.setFontName("Arial");
      rt.setBold(true);
      rt.setItalic(true);
      rt.setUnderlined(true);
      rt.setFontColor(Color.red);

      // add strike through
      TextPropCollection characterStyle = rt._getRawCharacterStyle();
      // fetch / Add the TextProp
      TextProp tp = characterStyle.findByName("char_flags");

      if(tp == null) {
         tp = characterStyle.addWithName("char_flags");
      }

      CharFlagsTextProp cftp = (CharFlagsTextProp) tp;
      cftp.setSubValue(true, CharFlagsTextProp.STRIKETHROUGH_IDX);

      rt.setAlignment(TextBox.AlignRight);
      s1.addShape(txt);

      //save changes in a file
      FileOutputStream out = new FileOutputStream("d:/slideshow.ppt");
      ppt.write(out);
      out.close();
   }

}
http://www.nabble.com/file/p16547357/expected.jpg 

-- 
View this message in context: 
http://www.nabble.com/StrikeThrough-in-PowerPoint2007-looks-like-doesn%27t-work-tp16547357p16547357.html
Sent from the POI - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to