From 452d3bc7c01536d332c9cdb2bb6529ec9ce64310 Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Mon, 1 Jul 2019 11:10:12 +0000 Subject: [PATCH] FOP-2868: OBJR should be a child of each link git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1862368 13f79535-47bb-0310-9956-ffa450edef68 --- .../intermediate/extensions/URIAction.java | 3 + .../IFStructureTreeBuilderTestCase.java | 59 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/URIAction.java b/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/URIAction.java index a9a9e7bbc..774f27b43 100644 --- a/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/URIAction.java +++ b/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/URIAction.java @@ -79,6 +79,9 @@ public class URIAction extends AbstractAction implements DocumentNavigationExten if (isNewWindow() != otherAction.isNewWindow()) { return false; } + if (getStructureTreeElement() != null) { + return getStructureTreeElement().equals(other.getStructureTreeElement()); + } return true; } diff --git a/fop-core/src/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java b/fop-core/src/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java index 5546e5905..72aea3223 100644 --- a/fop-core/src/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java @@ -19,6 +19,19 @@ package org.apache.fop.render.intermediate; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; + +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.sax.SAXResult; +import javax.xml.transform.stream.StreamSource; + +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatcher; @@ -36,6 +49,10 @@ import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.Fop; +import org.apache.fop.apps.FopFactory; +import org.apache.fop.apps.MimeConstants; import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fo.extensions.InternalElementMapping; @@ -166,4 +183,46 @@ public class IFStructureTreeBuilderTestCase { return true; } } + + @Test + public void checkLinkStructRef() throws TransformerException, SAXException { + String fo = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 1 www.a.net" + + "\n" + + " 2 www.a.net" + + "\n" + + " \n" + + " \n" + + " \n" + + ""; + String ifXML = foToIF(fo); + Assert.assertTrue(ifXML, ifXML.contains("")); + Assert.assertTrue(ifXML, ifXML.contains("")); + } + + private String foToIF(String fo) throws SAXException, TransformerException { + FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); + FOUserAgent userAgent = fopFactory.newFOUserAgent(); + userAgent.setAccessibility(true); + IFSerializer serializer = new IFSerializer(new IFContext(userAgent)); + IFDocumentHandler targetHandler + = userAgent.getRendererFactory().createDocumentHandler(userAgent, MimeConstants.MIME_PDF); + serializer.mimicDocumentHandler(targetHandler); + userAgent.setDocumentHandlerOverride(serializer); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_IF, userAgent, out); + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Source src = new StreamSource(new ByteArrayInputStream(fo.getBytes())); + Result res = new SAXResult(fop.getDefaultHandler()); + transformer.transform(src, res); + return out.toString(); + } } -- 2.39.5