aboutsummaryrefslogtreecommitdiffstats
path: root/fop-core
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2021-12-07 08:18:20 +0000
committerSimon Steiner <ssteiner@apache.org>2021-12-07 08:18:20 +0000
commita90d19d6ef388448fb1cf49f029ff11f43f7561c (patch)
treef2d7c83724e54b04901d531e2b38823fb151e7aa /fop-core
parent69ce536bf92f774d4d0a09d9068c1dbc972715f7 (diff)
downloadxmlgraphics-fop-a90d19d6ef388448fb1cf49f029ff11f43f7561c.tar.gz
xmlgraphics-fop-a90d19d6ef388448fb1cf49f029ff11f43f7561c.zip
FOP-3039: AFP include-page-overlay missing X and Y via IF
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1895653 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core')
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java11
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java10
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java4
-rw-r--r--fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java18
4 files changed, 35 insertions, 8 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
index abf6e359e..b3cc0a4cb 100644
--- a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
+++ b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
@@ -95,11 +95,20 @@ public class AFPExtensionHandler extends DefaultHandler
}
this.returnedObject = formMap;
} else if (AFPElementMapping.INCLUDE_PAGE_OVERLAY.equals(localName)) {
- this.returnedObject = new AFPPageOverlay();
+ AFPPageOverlay afpPageOverlay = new AFPPageOverlay();
+ this.returnedObject = afpPageOverlay;
String name = lastAttributes.getValue("name");
if (name != null) {
returnedObject.setName(name);
}
+ String x = lastAttributes.getValue("x");
+ if (x != null) {
+ afpPageOverlay.setX(Integer.parseInt(x));
+ }
+ String y = lastAttributes.getValue("y");
+ if (y != null) {
+ afpPageOverlay.setY(Integer.parseInt(y));
+ }
} else if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(localName)) {
AFPPageSegmentSetup pageSetupExtn = null;
diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java
index 7af76b649..b44d57cd0 100644
--- a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java
+++ b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java
@@ -23,6 +23,9 @@ import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
+import static org.apache.fop.render.afp.extensions.AFPPageOverlayElement.ATT_X;
+import static org.apache.fop.render.afp.extensions.AFPPageOverlayElement.ATT_Y;
+
/**
* This extension allows to include an AFP Page Overlay resource. It is implemented as an extension
* attachment ({@link org.apache.fop.fo.extensions.ExtensionAttachment}).
@@ -31,11 +34,6 @@ public class AFPPageOverlay extends AFPExtensionAttachment {
private static final long serialVersionUID = 8548056652642588919L;
- /** X coordinate attribute */
- protected static final String ATT_X = "X";
- /** X coordinate attribute */
- protected static final String ATT_Y = "Y";
-
/**
* The x coordinate
*/
@@ -91,6 +89,8 @@ public class AFPPageOverlay extends AFPExtensionAttachment {
if (name != null && name.length() > 0) {
atts.addAttribute("", ATT_NAME, ATT_NAME, "CDATA", name);
}
+ atts.addAttribute(null, ATT_X, ATT_X, "CDATA", String.valueOf(x));
+ atts.addAttribute(null, ATT_Y, ATT_Y, "CDATA", String.valueOf(y));
handler.startElement(CATEGORY, elementName, elementName, atts);
handler.endElement(CATEGORY, elementName, elementName);
}
diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java
index 1ab259e69..bd221ad58 100644
--- a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java
+++ b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java
@@ -39,8 +39,8 @@ import org.apache.fop.fo.extensions.ExtensionAttachment;
*/
public class AFPPageOverlayElement extends AbstractAFPExtensionObject {
- private static final String ATT_X = "x";
- private static final String ATT_Y = "y";
+ protected static final String ATT_X = "x";
+ protected static final String ATT_Y = "y";
/**
* Constructs an AFP object (called by Maker).
diff --git a/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java b/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java
index 673c64313..dc908eb59 100644
--- a/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java
@@ -27,9 +27,13 @@ import javax.xml.transform.stream.StreamResult;
import org.junit.Assert;
import org.junit.Test;
+import org.xml.sax.helpers.AttributesImpl;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FopFactory;
+import org.apache.fop.render.afp.extensions.AFPElementMapping;
+import org.apache.fop.render.afp.extensions.AFPExtensionAttachment;
+import org.apache.fop.render.afp.extensions.AFPExtensionHandler;
import org.apache.fop.render.afp.extensions.AFPPageOverlay;
import org.apache.fop.render.intermediate.IFContext;
@@ -69,4 +73,18 @@ public class PageOverlayTestCase {
new AFPParser(true).read(new ByteArrayInputStream(outputStream.toByteArray()), sb);
return sb.toString();
}
+
+ @Test
+ public void testXY() throws Exception {
+ AFPExtensionHandler extensionHandler = new AFPExtensionHandler();
+ AttributesImpl attributes = new AttributesImpl();
+ attributes.addAttribute(null, null, "x", null, "1");
+ attributes.addAttribute(null, null, "y", null, "1");
+ extensionHandler.startElement(AFPExtensionAttachment.CATEGORY, AFPElementMapping.INCLUDE_PAGE_OVERLAY, null,
+ attributes);
+ extensionHandler.endElement(AFPExtensionAttachment.CATEGORY, AFPElementMapping.INCLUDE_PAGE_OVERLAY, null);
+ AFPPageOverlay pageOverlay = (AFPPageOverlay) extensionHandler.getObject();
+ Assert.assertEquals(pageOverlay.getX(), 1);
+ Assert.assertEquals(pageOverlay.getY(), 1);
+ }
}