| Summary: | ClassCastException happened when event handle class added to an image item. | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | yadong xu <sssxyd> | ||||
| Component: | BIRT | Assignee: | Birt-ReportEngine-inbox <Birt-ReportEngine-inbox> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Xiaoying Gu <bluesoldier> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | bluesoldier, jianchao.li, jouyang | ||||
| Version: | 2.6.1 | ||||||
| Target Milestone: | 3.7.1 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
yadong xu
Caused by: java.lang.ClassCastException: org.eclipse.birt.report.engine.content.impl.TextContent cannot be cast to org.eclipse.birt.report.engine.content.IImageContent at org.eclipse.birt.report.engine.script.internal.OnPageBreakScriptVisitor$OnPageBreakExecutor.visitImageItem(OnPageBreakScriptVisitor.java:210) at org.eclipse.birt.report.engine.ir.ImageItemDesign.accept(ImageItemDesign.java:89) at org.eclipse.birt.report.engine.script.internal.OnPageBreakScriptVisitor.onPageBreak(OnPageBreakScriptVisitor.java:132) at org.eclipse.birt.report.engine.executor.OnPageBreakLayoutPageHandle.onPage(OnPageBreakLayoutPageHandle.java:207) at org.eclipse.birt.report.engine.layout.CompositeLayoutPageHandler.onPage(CompositeLayoutPageHandler.java:33) at org.eclipse.birt.report.engine.nLayout.LayoutEngine.outputPage(LayoutEngine.java:829) at org.eclipse.birt.report.engine.nLayout.area.impl.PageArea.outputPage(PageArea.java:704) at org.eclipse.birt.report.engine.nLayout.area.impl.PageArea.close(PageArea.java:684) at org.eclipse.birt.report.engine.nLayout.area.impl.RootArea.close(RootArea.java:215) at org.eclipse.birt.report.engine.nLayout.LayoutEngine.closeContainer(LayoutEngine.java:360) at org.eclipse.birt.report.engine.nLayout.LayoutEngine._endContainer(LayoutEngine.java:437) at org.eclipse.birt.report.engine.nLayout.LayoutEngine.endContainer(LayoutEngine.java:346) at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.endPage(ContentEmitterAdapter.java:70) at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.endContent(ContentEmitterUtil.java:102) at org.eclipse.birt.report.engine.layout.html.buffer.PageNode.end(PageNode.java:33) at org.eclipse.birt.report.engine.layout.html.buffer.HTMLPageBuffer.endPage(HTMLPageBuffer.java:292) at org.eclipse.birt.report.engine.layout.html.buffer.HTMLPageBuffer.endContainer(HTMLPageBuffer.java:136) at org.eclipse.birt.report.engine.layout.html.buffer.TableBreakBuffer.endContainer(TableBreakBuffer.java:421) at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.end(HTMLPageLM.java:181) at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:96) at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:99) at org.eclipse.birt.report.engine.presentation.ReportDocumentBuilder.build(ReportDocumentBuilder.java:249) at org.eclipse.birt.report.engine.api.impl.RunTask.doRun(RunTask.java:260) ... 50 more Please attach the report design. If remove the event handler, is the image displayed or is it displayed as alt text? when i remove the image's event handle class, it display ok. I have no report design file for standard birt. I modified birt to write,compile and load event handle class for easy, but the invoke part is same as the original. (In reply to comment #2) > Please attach the report design. > > If remove the event handler, is the image displayed or is it displayed as alt > text? (In reply to comment #3) > when i remove the image's event handle class, it display ok. > I have no report design file for standard birt. > I modified birt to write,compile and load event handle class for easy, but the > invoke part is same as the original. > (In reply to comment #2) > > Please attach the report design. > > > > If remove the event handler, is the image displayed or is it displayed as alt > > text? in the class: org.eclipse.birt.report.engine.script.internal.OnPageBreakScriptVisitor after i comment the pagebreak event of the image, the image display ok. public Object visitImageItem( ImageItemDesign image, Object value ) { //ImageScriptExecutor.handleOnPageBreak( (IImageContent) value,context ); return value; } create an UnsupportedImageInstance for TextContent, which always do nothing excepting returning the text as the altText for the image item. (In reply to comment #5) > create an UnsupportedImageInstance for TextContent, which always do nothing > excepting returning the text as the altText for the image item. I don't konw how to do this, and i can't find the class: UnsupportedImageInstance. I hope you can fix this bug in next version and i comment image's pagebreak event now. Jianchao, can you give yadong a patch? (In reply to comment #7) > Jianchao, can you give yadong a patch? SourceCode is ok ,i can build and jar myself. Created attachment 198782 [details]
patch.txt
Please apply the attached patch against BIRT 2.6.1
(In reply to comment #9) > Created attachment 198782 [details] > patch.txt > > Please apply the attached patch against BIRT 2.6.1 Thank you very much! Does it mean when i use image' pagebreak event, i should convert the first argument ImageInstance to UnsupportedImageInstance at first? public void onPageBreak(IImageInstance image, IReportContext reportcontext) throws ScriptException { UnsupportedImageInstance ui = (UnsupportedImageInstance) image; ..... } It depends if you have to distinguish if it's an image supported or not. For an unsupported image, only get/setAltText is valid. Other "getters" return null, "setters" do nothing. (In reply to comment #11) > It depends if you have to distinguish if it's an image supported or not. > > For an unsupported image, only get/setAltText is valid. Other "getters" return > null, "setters" do nothing. I know. We want to our programmer can change the image by get/set URI, and thanks again. |