Bug 51800 - Text replacement is not proper for SlideShow
Summary: Text replacement is not proper for SlideShow
Status: RESOLVED DUPLICATE of bug 45088
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: 3.8-dev
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-11 13:25 UTC by sanmoy
Modified: 2015-11-01 19:54 UTC (History)
0 users



Attachments
input file (254.00 KB, application/vnd.ms-powerpoint)
2011-09-11 13:25 UTC, sanmoy
Details
output file (247.50 KB, application/octet-stream)
2011-09-11 13:29 UTC, sanmoy
Details
log file of microsoft binary file format validator (5.74 KB, text/xml)
2011-09-24 15:23 UTC, sanmoy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sanmoy 2011-09-11 13:25:00 UTC
Created attachment 27483 [details]
input file

I had written a code to replace text from a .ppt document

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

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

public class PPTHandler2 {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = new FileInputStream("C:/simple.ppt");
		OutputStream outputStream = new FileOutputStream("C:/simple_out.ppt");

		SlideShow aSlideShow = new SlideShow(inputStream);
		Slide[] pptSlides = aSlideShow.getSlides();
		
		for (Slide aSlide : pptSlides) 
		{
			TextRun[] textRuns = aSlide.getTextRuns();
			for (TextRun aTextRun : textRuns) 
			{
					String inputText= aTextRun.getText();
					aTextRun.setText(inputText+"added");
			}
		}

		aSlideShow.write(outputStream);
		inputStream.close();
		outputStream.close();
		
	}
}

But the output file is corrupted after operation. Where as, if I use the same text, aTextRun.setText(inputText), output file is fine.
Comment 1 sanmoy 2011-09-11 13:29:58 UTC
Created attachment 27484 [details]
output file

while opening the output file, office showed error.

Tested with latest nightly build available 20110911
Comment 2 sanmoy 2011-09-24 15:23:46 UTC
Created attachment 27582 [details]
log file of microsoft binary file format validator

I have run bffvalidator tool and log has been generated. But couldn't understand the reason behind the validation failure.
Comment 3 Nick Burch 2011-09-24 16:46:45 UTC
It looks like there's a problem with the value at 39057, the ULONG in the PFMasks. There is a link to the documentation covering that part, I'd suggest reading through that and comparing what it says should be there with what actually is. If need be, step up the types list reading about those
Comment 4 sanmoy 2011-09-25 05:05:08 UTC
(In reply to comment #3)
> It looks like there's a problem with the value at 39057, the ULONG in the
> PFMasks. There is a link to the documentation covering that part, I'd suggest
> reading through that and comparing what it says should be there with what
> actually is. If need be, step up the types list reading about those

Thanks for providing the pointers. 

After reading the documents and the exception report, I found the below points :

childId="27", which means, the 27th field in the structure is failing validation. According to the msdn doc, the last 6 bits are reserved and must be 0 and must be ignored. If I convert the decimal data to binary, 89->1011001, it is clear that the fields are wrong. 

Is this conclusion correct? If so, please tell where to look in the code now..
Comment 5 Nick Burch 2011-09-26 15:43:13 UTC
Take a look at the code for that record (I think it's StyleTextPropAtom) and see how it generates the value
Comment 6 Andreas Beeker 2015-11-01 19:54:46 UTC

*** This bug has been marked as a duplicate of bug 45088 ***