}
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;
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}).
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
*/
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);
}
*/
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).
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;
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);
+ }
}