Bug 52244

Summary: The method getFontName() & getFontSize() returns error value.
Product: POI Reporter: Andrew <andy20050125>
Component: HSLFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: andy20050125
Priority: P2    
Version: 3.8-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Attachment is the template file.

Description Andrew 2011-11-25 10:03:59 UTC
Created attachment 27984 [details]
Attachment is the template file.

The template font is Arial, but the program says it's Times New Roman.


		String url = "D:\\Temp\\template.ppt";
		
		org.apache.poi.hslf.HSLFSlideShow hslf = null;
		try {
			hslf = new HSLFSlideShow(url);
		} catch (IOException e) {
			e.printStackTrace();
		}
		org.apache.poi.hslf.usermodel.SlideShow slidePPT = new org.apache.poi.hslf.usermodel.SlideShow(hslf);
		org.apache.poi.hslf.model.Slide[] slides = slidePPT.getSlides();

		for(org.apache.poi.hslf.model.Slide slide: slides){
			TextRun[] textRuns = slide.getTextRuns();
			for(TextRun rt : textRuns){
				RichTextRun[] rtrs = rt.getRichTextRuns();
				for(RichTextRun rtr : rtrs){
					System.out.println("Text: " + rtr.getText());
					System.out.println("Color: " + rtr.getFontColor());
					System.out.println("FontName: " + rtr.getFontName());
					System.out.println("FontSize: " + rtr.getFontSize());
					System.out.println("Alignment: " + rtr.getAlignment());
					System.out.println();
				}
			}
		}
Comment 1 Andrew 2011-11-28 02:41:48 UTC
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
Found a TextHeaderAtom not followed by a TextBytesAtom or TextCharsAtom: Followed by 4002
com.open.framework.exception.BaseException: java.lang.ArrayIndexOutOfBoundsException: 36
	at com.open.framework.view.DispatchAction.dispatchMethod(DispatchAction.java:286)
	at com.open.framework.view.DispatchAction.executeAct(DispatchAction.java:195)
	at com.open.framework.view.BaseAction.execute(BaseAction.java:467)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.open.security.authority.AuthorityFilter.doFilter(AuthorityFilter.java:137)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.open.framework.view.contoller.CharsetEncodingFilter.doFilter(CharsetEncodingFilter.java:121)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 36
	at org.apache.poi.util.LittleEndian.getInt(LittleEndian.java:95)
	at org.apache.poi.hslf.record.StyleTextPropAtom.setParentTextSize(StyleTextPropAtom.java:323)
	at org.apache.poi.hslf.model.TextRun.<init>(TextRun.java:100)
	at org.apache.poi.hslf.model.TextRun.<init>(TextRun.java:77)
	at org.apache.poi.hslf.model.Sheet.findTextRuns(Sheet.java:175)
	at org.apache.poi.hslf.model.Sheet.findTextRuns(Sheet.java:132)
	at org.apache.poi.hslf.model.Slide.<init>(Slide.java:70)
	at org.apache.poi.hslf.usermodel.SlideShow.buildSlidesAndNotes(SlideShow.java:411)
	at org.apache.poi.hslf.usermodel.SlideShow.<init>(SlideShow.java:109)
	at com.open.common.ppt.ReportUtility.writePPT(ReportUtility.java:1689)
	at com.auchan.crs.service.report.templatemgt.ReportAjaxService.ajaxCreateReportNew(ReportAjaxService.java:716)
	at com.auchan.crs.view.action.report.templatemgt.ReportAjaxAction.ajaxCreateReportNew(ReportAjaxAction.java:789)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.open.framework.view.DispatchAction.dispatchMethod(DispatchAction.java:264)
	... 26 more
Comment 2 Andrew 2011-11-28 02:43:14 UTC
There is also have this bug in POI 3.7
Comment 3 Yegor Kozlov 2012-03-01 09:07:28 UTC
The problem with incorrect font name and size should be fixed in r1295478

The attached document has colliding master styles. Strictly speaking it is a violation of the format, but PowerPoint  resolves such cases OK and I fixed POI to do so.

Yegor