Bug 45124 - inserting text or images wipes out boldness and makes everything italic
Summary: inserting text or images wipes out boldness and makes everything italic
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.7-FINAL
Hardware: PC Windows XP
: P1 major with 2 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords: JDK1.5
Depends on:
Blocks: 50764 51302
  Show dependency tree
 
Reported: 2008-06-03 11:29 UTC by Eric Hamacher
Modified: 2015-11-01 23:24 UTC (History)
1 user (show)



Attachments
The input ppt -- see slide 1 before running (822.50 KB, application/vnd.ms-powerpoint)
2008-06-03 11:29 UTC, Eric Hamacher
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Hamacher 2008-06-03 11:29:54 UTC
Created attachment 22064 [details]
The input ppt -- see slide 1 before running

Hello:

If you run the code below:
------------------------------------------
package hslf;

import java.io.FileOutputStream;
import java.io.IOException;

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

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/bug2.ppt"));
        Slide slide1 = ppt.getSlides()[1];
        
        TextBox res = new TextBox();
        res.setAnchor(new java.awt.Rectangle(60, 150, 700, 100));
        res.setText("I am italic-false, bold-true inserted text");
        res.setHorizontalAlignment(TextBox.AlignLeft);
        res.setVerticalAlignment(TextBox.AlignCenter);
        
        RichTextRun rt2 = res.getTextRun().getRichTextRuns()[0];
        rt2.setFontSize(32);
        rt2.setItalic(false);
        rt2.setBulletOffset(0);
        rt2.setBold(true);
        rt2.setBullet(true);
        rt2.setBulletChar('\u00B7');
        rt2.setFontName("Arial Narrow");
        
        slide1.addShape(res);        
 
        FileOutputStream out = new FileOutputStream("c:/test/bug2.ppt");
        ppt.write(out);
        out.close(); 
    }
    
}
--------------------------------

the inserted text will not be bold and will be italic.  In addition, all text on every slide that was bold and not italic loses its boldness and becomes italic.
For example, the text on slide 1 in bug.ppt reacts this way when text is inserted on slide 2.

Eric Hamacher
Comment 1 Eric Hamacher 2008-06-04 13:15:23 UTC
when inserting images the following message is generated:

Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4006
Comment 2 Eric Hamacher 2008-06-11 08:36:05 UTC
Just a note:  The input file is uploaded to a web app by a user, altered, then downloaded to the user.
Comment 3 Yegor Kozlov 2008-09-03 11:05:12 UTC
Partially fixed. 
Styles are now preserved across read/write.

The inserted text still has wrong styles. Actually, HSLF sets the style bytes correctly. It is PowerPoint who has special master-level style info which causes the text style to be inverted. setBold(false) causes the text to be bold and setBold(true) to be not-bold. 

Which version of PowerPoint was used to create/edit this ppt?  

Yegor
Comment 4 shafiexp 2011-05-28 08:38:27 UTC
Hi,
when adding new image to the existing excel file(which contains already pictures) the previous pictures are not visisble.

Please give me the solution

Thanks,
Shafiulla
Comment 5 Dominik Stadler 2015-10-30 18:25:41 UTC
Not sure if this is still relevant, it seems to be about HSLF only the last comment is about Excel, let's create new bug entries if there is still a problem with the latest slideshow-code which was pretty much rewritten lately.
Comment 6 Andreas Beeker 2015-10-31 23:08:12 UTC
Fixed with r1711704
The problem was, that the bold state was inherited from the slide layout and 
the method to set the text (paragraph) properties hasn't checked for that 
inheritance ...
Furthermore there was an error in setting bullet styles.