Author: cbowditch
Date: Tue Aug 4 15:44:16 2009
New Revision: 800852
URL: http://svn.apache.org/viewvc?rev=800852&view=rev
Log:
added support for IMM Extension on fo:simple-page-master element in the AFP
Renderer
Modified:
xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java
xmlgraphics/fop/trunk/status.xml
Modified: xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml?rev=800852&r1=800851&r2=800852&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml
(original)
+++ xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml Tue
Aug 4 15:44:16 2009
@@ -857,10 +857,10 @@
]]></source>
<p>
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.
</p>
</section>
<section id="afp-form-maps">
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java?rev=800852&r1=800851&r2=800852&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
Tue Aug 4 15:44:16 2009
@@ -77,6 +77,9 @@
private Map/*<String,String>*/pageSegmentMap
= new java.util.HashMap/*<String,String>*/();
+ /** 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 @@
}
}
} 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;
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java?rev=800852&r1=800851&r2=800852&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java
Tue Aug 4 15:44:16 2009
@@ -181,6 +181,9 @@
/** 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 @@
int resolution = paintingState.getResolution();
+ // IMM should occur before BPG
+ renderInvokeMediumMap(pageViewport);
+
dataStream.startPage(pageWidth, pageHeight, pageRotation,
resolution, resolution);
@@ -704,6 +710,35 @@
}
/**
+ * 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.
* <p>
*
@@ -720,27 +755,29 @@
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);
+ }
}
}
}
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java?rev=800852&r1=800851&r2=800852&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java
Tue Aug 4 15:44:16 2009
@@ -26,8 +26,8 @@
/**
* 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 @@
/** {...@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");
}
Modified: xmlgraphics/fop/trunk/status.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=800852&r1=800851&r2=800852&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Tue Aug 4 15:44:16 2009
@@ -58,6 +58,9 @@
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="CB" type="add">
+ AFP Output: Added support for IMM Extension on fo:simple-page-master.
+ </action>
<action context="Renderers" dev="JM" type="add" fixes-bug="47311"
due-to="Peter Coppens">
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.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]