Author: ssteiner
Date: Tue Dec  7 08:18:20 2021
New Revision: 1895653

URL: http://svn.apache.org/viewvc?rev=1895653&view=rev
Log:
FOP-3039: AFP include-page-overlay missing X and Y via IF

Modified:
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java
    
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java?rev=1895653&r1=1895652&r2=1895653&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
 Tue Dec  7 08:18:20 2021
@@ -95,11 +95,20 @@ public class AFPExtensionHandler extends
                 }
                 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;
 

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java?rev=1895653&r1=1895652&r2=1895653&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java
 Tue Dec  7 08:18:20 2021
@@ -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 AFPE
 
     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 AFPE
         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);
     }

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java?rev=1895653&r1=1895652&r2=1895653&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java
 Tue Dec  7 08:18:20 2021
@@ -39,8 +39,8 @@ import org.apache.fop.fo.extensions.Exte
  */
 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).

Modified: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java?rev=1895653&r1=1895652&r2=1895653&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/afp/PageOverlayTestCase.java
 Tue Dec  7 08:18:20 2021
@@ -27,9 +27,13 @@ import javax.xml.transform.stream.Stream
 
 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);
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org

Reply via email to