From bdb4db0bbc0fdaa9f72af41b947f06fca76b250a Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 2 Mar 2009 10:19:01 +0000 Subject: [PATCH] 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 --- .../content/xdocs/trunk/output.xml | 18 ++++---- .../org/apache/fop/events/EventFormatter.xml | 1 + .../fop/render/afp/AFPDocumentHandler.java | 42 +++++++++++-------- .../apache/fop/render/afp/AFPRenderer.java | 5 +++ .../afp/extensions/AFPPageSetupElement.java | 14 +++++-- status.xml | 4 ++ .../standard-testcases/afp-extension_1.xml | 31 ++++++++++---- 7 files changed, 79 insertions(+), 36 deletions(-) diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml index 74e22ccf1..393624b6b 100644 --- a/src/documentation/content/xdocs/trunk/output.xml +++ b/src/documentation/content/xdocs/trunk/output.xml @@ -759,16 +759,18 @@ out = proc.getOutputStream();]]> + [..] + + + + [..] ]]> -

The tag-logical-element extension element can only occur within a simple-page-master. - Multiple tag-logical-element extension elements within a simple-page-master are allowed. - The name and value attributes are mandatory. +

+ The tag-logical-element extension element can appear within a simple-page-master + (page level) or it can appear as child of page-sequence (page group level). + Multiple tag-logical-element extension elements within a simple-page-master or + page-sequence are allowed. The name and value attributes are mandatory.

- - Currently, TLEs are only possible inside simple-page-master (i.e. on page leve). - At this time, it is not possible to add TLE's at page-group level (i.e. as direct child - of fo:page-sequence). -
No Operation (NOP) Extension diff --git a/src/java/org/apache/fop/events/EventFormatter.xml b/src/java/org/apache/fop/events/EventFormatter.xml index c79105f77..07ac2111e 100644 --- a/src/java/org/apache/fop/events/EventFormatter.xml +++ b/src/java/org/apache/fop/events/EventFormatter.xml @@ -28,6 +28,7 @@ The element must be a child of fo:declarations or fo:simple-page-master. The element must be a child of fo:instream-foreign-object or fo:external-graphic. The element must be a child of fo:page-sequence. + The element must be a child of fo:page-sequence or fo:simple-page-master. An fo:wrapper is only permitted to have children that would be permitted for its parent. For "{elementName}", only one "{offendingNode}" may be declared.{{locator}} For "{elementName}", "{tooLateNode}" must be declared before "{tooEarlyNode}"!{{locator}} 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"); + } } } diff --git a/status.xml b/status.xml index fdb653399..57b41166d 100644 --- a/status.xml +++ b/status.xml @@ -58,6 +58,10 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + AFP Output: Tag Logical Element (TLE) is now also allowed on fo:page-sequence + (page group level). + Fixed BPD trait and border painting for leaders with leader-pattern="space" (and similar cases). diff --git a/test/layoutengine/standard-testcases/afp-extension_1.xml b/test/layoutengine/standard-testcases/afp-extension_1.xml index cc3bebac3..70bbef450 100644 --- a/test/layoutengine/standard-testcases/afp-extension_1.xml +++ b/test/layoutengine/standard-testcases/afp-extension_1.xml @@ -25,7 +25,8 @@ + xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp" + xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"> @@ -35,8 +36,9 @@ - + + Text on page . Text on page . @@ -44,7 +46,7 @@ - + @@ -54,15 +56,28 @@ - + + - + - - + xmlns:afp="apache:fop:extensions:afp"> + + + + + + + + + + + + + + -- 2.39.5