aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2009-03-02 10:19:01 +0000
committerJeremias Maerki <jeremias@apache.org>2009-03-02 10:19:01 +0000
commitbdb4db0bbc0fdaa9f72af41b947f06fca76b250a (patch)
treeb023199b649137865c013b83e0f865291f666d5b
parent593cb69d65d69473cf985ce627095387fa1450ec (diff)
downloadxmlgraphics-fop-bdb4db0bbc0fdaa9f72af41b947f06fca76b250a.tar.gz
xmlgraphics-fop-bdb4db0bbc0fdaa9f72af41b947f06fca76b250a.zip
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
-rw-r--r--src/documentation/content/xdocs/trunk/output.xml18
-rw-r--r--src/java/org/apache/fop/events/EventFormatter.xml1
-rw-r--r--src/java/org/apache/fop/render/afp/AFPDocumentHandler.java42
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRenderer.java5
-rwxr-xr-xsrc/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java14
-rw-r--r--status.xml4
-rw-r--r--test/layoutengine/standard-testcases/afp-extension_1.xml31
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();]]></source>
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
+ [..]
+ <fo:page-sequence master-reference="simple">
+ <afp:tag-logical-element name="foo" value="bar"/>
+ <fo:flow flow-name="xsl-region-body">
+ [..]
]]></source>
- <p>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.
+ <p>
+ 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.
</p>
- <note>
- 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).
- </note>
</section>
<section id="afp-no-operation">
<title>No Operation (NOP) Extension</title>
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 @@
<message key="rule.childOfSPMorDeclarations">The element must be a child of fo:declarations or fo:simple-page-master.</message>
<message key="rule.childOfInstreamForeignObjectorExternalGraphic">The element must be a child of fo:instream-foreign-object or fo:external-graphic.</message>
<message key="rule.childOfPageSequence">The element must be a child of fo:page-sequence.</message>
+ <message key="rule.childOfPageSequenceOrSPM">The element must be a child of fo:page-sequence or fo:simple-page-master.</message>
<message key="rule.wrapperInvalidChildForParent">An fo:wrapper is only permitted to have children that would be permitted for its parent.</message>
<message key="org.apache.fop.fo.FOValidationEventProducer.tooManyNodes">For "{elementName}", only one "{offendingNode}" may be declared.{{locator}}</message>
<message key="org.apache.fop.fo.FOValidationEventProducer.nodeOutOfOrder">For "{elementName}", "{tooLateNode}" must be declared before "{tooEarlyNode}"!{{locator}}</message>
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.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Renderers" dev="JM" type="add">
+ AFP Output: Tag Logical Element (TLE) is now also allowed on fo:page-sequence
+ (page group level).
+ </action>
<action context="Layout" dev="JM" type="fix">
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 @@
</info>
<fo>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
+ xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp"
+ xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
<fo:layout-master-set>
<fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
<afp:include-page-overlay name="O1SAMP1 "/>
@@ -35,8 +36,9 @@
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
- <fo:page-sequence master-reference="normal" afp:test-ignore="this">
+ <fo:page-sequence master-reference="normal" fox:test-ignore="this">
<afp:invoke-medium-map name="MYMAP"/>
+ <afp:tag-logical-element name="foo" value="bar"/>
<fo:flow flow-name="xsl-region-body">
<fo:block>Text on page <fo:page-number/>.</fo:block>
<fo:block break-before="page">Text on page <fo:page-number/>.</fo:block>
@@ -44,7 +46,7 @@
</fo:page-sequence>
</fo:root>
</fo>
- <checks xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
+ <checks xmlns:afp="apache:fop:extensions:afp">
<eval expected="4" xpath="count(/areaTree/pageSequence/pageViewport[@nr=1]/page/extension-attachments/child::*)"/>
<eval expected="O1SAMP1 " xpath="/areaTree/pageSequence/pageViewport[@nr=1]/page/extension-attachments/child::*[1]/@name"/>
<eval expected="S1ISLOGO" xpath="/areaTree/pageSequence/pageViewport[@nr=1]/page/extension-attachments/child::*[2]/@name"/>
@@ -54,15 +56,28 @@
<eval expected="4" xpath="count(/areaTree/pageSequence/pageViewport[@nr=2]/page/extension-attachments/child::*)"/>
- <eval expected="1" xpath="count(/areaTree/pageSequence/extension-attachments)"/>
+ <eval expected="2" xpath="count(/areaTree/pageSequence/extension-attachments/child::*)"/>
<eval expected="MYMAP" xpath="/areaTree/pageSequence/extension-attachments/child::*[1]/@name"/>
+ <eval expected="bar" xpath="/areaTree/pageSequence/extension-attachments/afp:tag-logical-element[@name = 'foo']/@value"/>
<!-- This just tests if extension attributes make it through to the PageSequence object. -->
- <eval expected="this" xpath="/areaTree/pageSequence/@afp:test-ignore"/>
+ <eval expected="this" xpath="/areaTree/pageSequence/@fox:test-ignore" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"/>
</checks>
<if-checks xmlns:if="http://xmlgraphics.apache.org/fop/intermediate"
- xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
- <eval expected="this" xpath="//if:page-sequence/@afp:test-ignore"/>
- <eval expected="MYMAP" xpath="//if:page-sequence/afp:invoke-medium-map/@name" xmlns:afp="apache:fop:extensions:afp"/>
+ xmlns:afp="apache:fop:extensions:afp">
+ <eval expected="4" xpath="count(//if:page[@name = '1']/if:page-header/child::*)"/>
+ <eval expected="O1SAMP1 " xpath="//if:page[@name = '1']/if:page-header/afp:include-page-overlay[1]/@name"/>
+ <eval expected="S1ISLOGO" xpath="//if:page[@name = '1']/if:page-header/afp:include-page-segment[1]/@name"/>
+ <eval expected="The TLE Value" xpath="//if:page[@name = '1']/if:page-header/afp:tag-logical-element[@name = 'The TLE Name']/@value"/>
+ <eval expected="My NOP" xpath="//if:page[@name = '1']/if:page-header/afp:no-operation[1]/@name"/>
+ <eval expected="insert up to 32k of character data here!" xpath="//if:page[@name = '1']/if:page-header/afp:no-operation[1]"/>
+
+ <eval expected="4" xpath="count(//if:page[@name = '2']/if:page-header/child::*)"/>
+
+ <eval expected="MYMAP" xpath="//if:page-sequence/afp:invoke-medium-map/@name"/>
+ <eval expected="bar" xpath="//if:page-sequence/afp:tag-logical-element[@name = 'foo']/@value"/>
+
+ <!-- This just tests if extension attributes make it through to the PageSequence object. -->
+ <eval expected="this" xpath="//if:page-sequence/@fox:test-ignore" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"/>
</if-checks>
</testcase>