diff options
author | Simon Steiner <ssteiner@apache.org> | 2020-02-11 13:41:06 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2020-02-11 13:41:06 +0000 |
commit | 43219348518d68482fdb7f92eeedb5b6102fef57 (patch) | |
tree | 9df7df003129a305f917038ddc14f52d73ce01aa | |
parent | d1022f8e33ad8c234c13e7109fba2fe5797f5a64 (diff) | |
download | xmlgraphics-fop-43219348518d68482fdb7f92eeedb5b6102fef57.tar.gz xmlgraphics-fop-43219348518d68482fdb7f92eeedb5b6102fef57.zip |
FOP-2911: Add endpage event for FO to IF
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1873909 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java | 8 | ||||
-rw-r--r-- | fop-core/src/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java | 18 |
2 files changed, 26 insertions, 0 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java b/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java index dd8a946c2..d12c13b35 100644 --- a/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -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, IFDocumentNavigationHandler { private String currentID = ""; private IFStructureTreeBuilder structureTreeBuilder; + private int pageNumberEnded; public IFSerializer(IFContext context) { super(context); @@ -384,6 +387,11 @@ implements IFConstants, IFPainter, IFDocumentNavigationHandler { } 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 ===--- diff --git a/fop-core/src/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java b/fop-core/src/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java index 0340c190e..0dbcddbdf 100644 --- a/fop-core/src/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/intermediate/IFSerializerTestCase.java @@ -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.loader.ImageManager; 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(); + } } |