From: Chris Bowditch Date: Tue, 4 Aug 2009 15:44:16 +0000 (+0000) Subject: added support for IMM Extension on fo:simple-page-master element in the AFP Renderer X-Git-Tag: fop-1_0~193 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5ab295cc5a91af48dde5c81f5da53f4bf28931e6;p=xmlgraphics-fop.git added support for IMM Extension on fo:simple-page-master element in the AFP Renderer git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@800852 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml index 6dec9171a..9c88c27d0 100644 --- a/src/documentation/content/xdocs/trunk/output.xml +++ b/src/documentation/content/xdocs/trunk/output.xml @@ -857,10 +857,10 @@ out = proc.getOutputStream();]]> ]]>

The invoke-medium-map element is allowed as child of fo:page-sequence (page group - level). It is NOT supported on document level (fo:root), yet. FOP also doesn't support - specifying medium maps inside XML (using BMM/EMM). It can only reference an existing - medium map by name. The medium map has to be constructed through different means and - available on the target platform. + level) or fo:simple-page-master. It is NOT supported on document level (fo:root), yet. + FOP also doesn't support specifying medium maps inside XML (using BMM/EMM). It can + only reference an existing medium map by name. The medium map has to be constructed + through different means and available on the target platform.

diff --git a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java index d8a2d04e9..073d43e20 100644 --- a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java @@ -77,6 +77,9 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler private Map/**/pageSegmentMap = new java.util.HashMap/**/(); + /** Medium Map referenced on previous page **/ + private String lastMediumMap; + private static final int LOC_ELSEWHERE = 0; private static final int LOC_FOLLOWING_PAGE_SEQUENCE = 1; private static final int LOC_IN_PAGE_HEADER = 2; @@ -299,15 +302,19 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler } } } else if (extension instanceof AFPInvokeMediumMap) { - if (this.location != LOC_FOLLOWING_PAGE_SEQUENCE) { + if (this.location != LOC_FOLLOWING_PAGE_SEQUENCE + && this.location != LOC_IN_PAGE_HEADER) { + throw new IFException( - "AFP IMM extension must be between page-sequence and the first page: " - + extension, null); + "AFP IMM extension must be between page-sequence" + + " and the first page or child of page-header: " + + extension, null); } AFPInvokeMediumMap imm = (AFPInvokeMediumMap)extension; String mediumMap = imm.getName(); - if (mediumMap != null) { + if (mediumMap != null && !mediumMap.equals(lastMediumMap)) { dataStream.createInvokeMediumMap(mediumMap); + lastMediumMap = mediumMap; } } else if (extension instanceof AFPIncludeFormMap) { AFPIncludeFormMap formMap = (AFPIncludeFormMap)extension; diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index e23cf7825..e106ac712 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -181,6 +181,9 @@ public class AFPRenderer extends AbstractPathOrientedRenderer implements AFPCust /** the shading mode for filled rectangles */ private AFPShadingMode shadingMode = AFPShadingMode.COLOR; + /** medium map referenced used on previous page **/ + private String lastMediumMap; + /** * Constructor for AFPRenderer. */ @@ -380,6 +383,9 @@ public class AFPRenderer extends AbstractPathOrientedRenderer implements AFPCust int resolution = paintingState.getResolution(); + // IMM should occur before BPG + renderInvokeMediumMap(pageViewport); + dataStream.startPage(pageWidth, pageHeight, pageRotation, resolution, resolution); @@ -703,6 +709,35 @@ public class AFPRenderer extends AbstractPathOrientedRenderer implements AFPCust return MimeConstants.MIME_AFP; } + /** + * checks for IMM Extension and renders if found and different + * from previous page + * + * @param pageViewport the page object + */ + private void renderInvokeMediumMap(PageViewport pageViewport) { + if (pageViewport.getExtensionAttachments() != null + && pageViewport.getExtensionAttachments().size() > 0) { + Iterator it = pageViewport.getExtensionAttachments().iterator(); + while (it.hasNext()) { + ExtensionAttachment attachment = (ExtensionAttachment) it.next(); + if (AFPExtensionAttachment.CATEGORY.equals(attachment.getCategory())) { + AFPExtensionAttachment aea = (AFPExtensionAttachment)attachment; + if (AFPElementMapping.INVOKE_MEDIUM_MAP.equals(aea.getElementName())) { + AFPInvokeMediumMap imm = (AFPInvokeMediumMap)attachment; + String mediumMap = imm.getName(); + if (mediumMap != null) { + if (!mediumMap.equals(lastMediumMap)) { + dataStream.createInvokeMediumMap(mediumMap); + lastMediumMap = mediumMap; + } + } + } + } + } + } + } + /** * Method to render the page extension. *

@@ -720,27 +755,29 @@ public class AFPRenderer extends AbstractPathOrientedRenderer implements AFPCust while (it.hasNext()) { ExtensionAttachment attachment = (ExtensionAttachment) it.next(); if (AFPPageSetup.CATEGORY.equals(attachment.getCategory())) { - AFPPageSetup aps = (AFPPageSetup) attachment; - String element = aps.getElementName(); - 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.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); + if (attachment instanceof AFPPageSetup) { + AFPPageSetup aps = (AFPPageSetup) attachment; + String element = aps.getElementName(); + 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.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); + } } } } diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java b/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java index 99805edd4..f36bd3e12 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java @@ -26,8 +26,8 @@ import org.apache.fop.fo.extensions.ExtensionAttachment; /** * This class represents an AFP-specific extension element to embed Invoke Medium Map (IMM) - * fields at the beginning of a page group. The element is optional and expected as a direct child - * of an fo:page-sequence. + * fields at the beginning of a page group or just prior to a Page. The element is optional + * and expected as a direct child of an fo:page-sequence or fo:simple-page-master */ public class AFPInvokeMediumMapElement extends AbstractAFPExtensionObject { @@ -42,7 +42,9 @@ public class AFPInvokeMediumMapElement extends AbstractAFPExtensionObject { /** {@inheritDoc} */ protected void startOfNode() throws FOPException { super.startOfNode(); - if (parent.getNameId() != Constants.FO_PAGE_SEQUENCE) { + if (parent.getNameId() != Constants.FO_PAGE_SEQUENCE + && parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) { + invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), "rule.childOfPageSequence"); } diff --git a/status.xml b/status.xml index 21ce1b8dd..8eae1a9cf 100644 --- a/status.xml +++ b/status.xml @@ -58,6 +58,9 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + AFP Output: Added support for IMM Extension on fo:simple-page-master. + Added an initial set of extensions for prepress support (fox:bleed, fox:crop-offset, fox:crop-box and fox:scale). This is currently supported only by PDF and Java2D renderers.