Author: ssteiner Date: Tue Feb 11 13:41:06 2020 New Revision: 1873909 URL: http://svn.apache.org/viewvc?rev=1873909&view=rev Log: FOP-2911: Add endpage event for FO to IF
Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java?rev=1873909&r1=1873908&r2=1873909&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java Tue Feb 11 13:41:06 2020 @@ -40,9 +40,11 @@ import org.apache.xmlgraphics.util.QName import org.apache.xmlgraphics.util.XMLizable; import org.apache.fop.accessibility.StructureTreeEventHandler; +import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.extensions.InternalElementMapping; import org.apache.fop.fonts.FontInfo; import org.apache.fop.render.DefaultRendererConfigurator; +import org.apache.fop.render.RendererEventProducer; import org.apache.fop.render.RenderingContext; import org.apache.fop.render.intermediate.IFRendererConfig.IFRendererConfigParser; import org.apache.fop.render.intermediate.IFStructureTreeBuilder.IFStructureTreeElement; @@ -85,6 +87,7 @@ implements IFConstants, IFPainter, IFDoc private String currentID = ""; private IFStructureTreeBuilder structureTreeBuilder; + private int pageNumberEnded; public IFSerializer(IFContext context) { super(context); @@ -384,6 +387,11 @@ implements IFConstants, IFPainter, IFDoc } catch (SAXException e) { throw new IFException("SAX error in endPage()", e); } + if (mimicHandler != null) { + pageNumberEnded++; + FOUserAgent userAgent = mimicHandler.getContext().getUserAgent(); + RendererEventProducer.Provider.get(userAgent.getEventBroadcaster()).endPage(this, pageNumberEnded); + } } //---=== IFPainter ===--- Modified: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java?rev=1873909&r1=1873908&r2=1873909&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java Tue Feb 11 13:41:06 2020 @@ -20,6 +20,9 @@ package org.apache.fop.render.intermediate; import java.awt.Rectangle; +import java.io.File; +import java.util.HashMap; +import java.util.Map; import javax.xml.transform.sax.SAXResult; @@ -38,6 +41,9 @@ import org.apache.xmlgraphics.image.load import org.apache.xmlgraphics.image.loader.ImageSessionContext; import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.FopFactory; +import org.apache.fop.events.EventChecker; +import org.apache.fop.render.afp.AFPDocumentHandler; public class IFSerializerTestCase { @@ -90,4 +96,16 @@ public class IFSerializerTestCase { verify(imageManager).closeImage(eq(IMAGE), any(ImageSessionContext.class)); } + @Test + public void testPageEvent() throws IFException { + FOUserAgent userAgent = FopFactory.newInstance(new File(".").toURI()).newFOUserAgent(); + Map<String, Object> params = new HashMap<String, Object>(); + params.put("number", 1); + EventChecker eventChecker = new EventChecker("org.apache.fop.render.RendererEventProducer.endPage", params); + userAgent.getEventBroadcaster().addEventListener(eventChecker); + sut.mimicDocumentHandler(new AFPDocumentHandler(new IFContext(userAgent))); + sut.setResult(new SAXResult(new DefaultHandler())); + sut.endPage(); + eventChecker.end(); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org