From bdb4db0bbc0fdaa9f72af41b947f06fca76b250a Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 2 Mar 2009 10:19:01 +0000 Subject: AFP Output: Tag Logical Element (TLE) is now also allowed on fo:page-sequence (page group level). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@749258 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/afp/AFPDocumentHandler.java | 42 +++++++++++++--------- .../org/apache/fop/render/afp/AFPRenderer.java | 5 +++ .../render/afp/extensions/AFPPageSetupElement.java | 14 ++++++-- 3 files changed, 41 insertions(+), 20 deletions(-) (limited to 'src/java/org/apache/fop/render') diff --git a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java index 1e08b917e..8d29145cf 100644 --- a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java @@ -245,28 +245,36 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler public void handleExtensionObject(Object extension) throws IFException { if (extension instanceof AFPPageSetup) { AFPPageSetup aps = (AFPPageSetup)extension; - if (this.location != LOC_IN_PAGE_HEADER) { - throw new IFException( - "AFP page setup extension encountered outside the page header: " + aps, null); - } String element = aps.getElementName(); - if (AFPElementMapping.INCLUDE_PAGE_OVERLAY.equals(element)) { - String overlay = aps.getName(); - if (overlay != null) { - dataStream.createIncludePageOverlay(overlay); + if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(element)) { + if (this.location != LOC_IN_PAGE_HEADER + && this.location != LOC_FOLLOWING_PAGE_SEQUENCE) { + throw new IFException( + "TLE extension must be in the page header or between page-sequence" + + " and the first page: " + aps, null); } - } else if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(element)) { - String name = aps.getName(); - String source = aps.getValue(); - pageSegmentMap.put(source, name); - } else if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(element)) { String name = aps.getName(); String value = aps.getValue(); dataStream.createTagLogicalElement(name, value); - } else if (AFPElementMapping.NO_OPERATION.equals(element)) { - String content = aps.getContent(); - if (content != null) { - dataStream.createNoOperation(content); + } else { + if (this.location != LOC_IN_PAGE_HEADER) { + throw new IFException( + "AFP page setup extension encountered outside the page header: " + aps, null); + } + if (AFPElementMapping.INCLUDE_PAGE_OVERLAY.equals(element)) { + String overlay = aps.getName(); + if (overlay != null) { + dataStream.createIncludePageOverlay(overlay); + } + } else if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(element)) { + String name = aps.getName(); + String source = aps.getValue(); + pageSegmentMap.put(source, name); + } else if (AFPElementMapping.NO_OPERATION.equals(element)) { + String content = aps.getContent(); + if (content != null) { + dataStream.createNoOperation(content); + } } } } else if (extension instanceof AFPInvokeMediumMap) { diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index 03e7a9977..94fd05dc8 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -231,6 +231,11 @@ public class AFPRenderer extends AbstractPathOrientedRenderer implements AFPCust if (mediumMap != null) { dataStream.createInvokeMediumMap(mediumMap); } + } else if (attachment instanceof AFPPageSetup) { + AFPPageSetup aps = (AFPPageSetup)attachment; + String name = aps.getName(); + String value = aps.getValue(); + dataStream.createTagLogicalElement(name, value); } } } diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java b/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java index 0774913b5..0c6dfadc4 100755 --- a/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java @@ -53,9 +53,17 @@ public class AFPPageSetupElement extends AbstractAFPExtensionObject { /** {@inheritDoc} */ protected void startOfNode() throws FOPException { super.startOfNode(); - if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) { - invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), - "rule.childOfSPM"); + if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(getLocalName())) { + if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER + && parent.getNameId() != Constants.FO_PAGE_SEQUENCE) { + invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), + "rule.childOfPageSequenceOrSPM"); + } + } else { + if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) { + invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), + "rule.childOfSPM"); + } } } -- cgit v1.2.3