aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.xml8
-rw-r--r--src/documentation/content/xdocs/trunk/output.xml40
-rw-r--r--src/java/org/apache/fop/afp/AFPGraphics2D.java111
-rw-r--r--src/java/org/apache/fop/afp/AFPResourceInfo.java14
-rw-r--r--src/java/org/apache/fop/afp/AFPResourceLevelDefaults.java110
-rw-r--r--src/java/org/apache/fop/afp/AFPResourceManager.java18
-rw-r--r--src/java/org/apache/fop/render/afp/AFPCustomizable.java9
-rw-r--r--src/java/org/apache/fop/render/afp/AFPDocumentHandler.java13
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java15
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java16
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRenderer.java6
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java22
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRendererContext.java11
-rw-r--r--src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java20
-rw-r--r--status.xml4
15 files changed, 335 insertions, 82 deletions
diff --git a/build.xml b/build.xml
index 220437eea..5fff5d903 100644
--- a/build.xml
+++ b/build.xml
@@ -714,7 +714,7 @@ list of possible build targets.
<src path="${basedir}/test/java"/>
<patternset refid="test-sources"/>
<classpath>
- <path refid="libs-build-classpath"/>
+ <path refid="libs-build-tools-classpath"/>
<fileset dir="${build.dir}">
<include name="fop.jar"/>
</fileset>
@@ -952,7 +952,9 @@ list of possible build targets.
<test name="org.apache.fop.text.linebreak.LineBreakStatusTest" todir="${junit.reports.dir}"/>
</junit>
</target>
- <target name="junit" depends="junit-userconfig, junit-basic, junit-transcoder, junit-text-linebreak, junit-layout, junit-fotree, junit-area-tree-xml-format, junit-intermediate-format" description="Runs all of FOP's JUnit tests" if="junit.present">
+ <target name="junit-reduced" depends="junit-userconfig, junit-basic, junit-transcoder, junit-text-linebreak, junit-fotree"/>
+ <target name="junit-full" depends="junit-reduced, junit-layout, junit-area-tree-xml-format, junit-intermediate-format"/>
+ <target name="junit" depends="junit-full" description="Runs all of FOP's JUnit tests" if="junit.present">
<fail><condition><or><isset property="fop.junit.error"/><isset property="fop.junit.failure"/><not><isset property="hyphenation.present"/></not></or></condition>
NOTE:
**************************************************************************
@@ -1298,7 +1300,7 @@ NOTE:
<!-- =================================================================== -->
<!-- Special target for Gump -->
<!-- =================================================================== -->
- <target name="gump" depends="all, javadocs"/>
+ <target name="gump" depends="junit-reduced"/>
<!-- =================================================================== -->
<!-- Clean targets -->
<!-- =================================================================== -->
diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml
index d8f396a42..83e730de9 100644
--- a/src/documentation/content/xdocs/trunk/output.xml
+++ b/src/documentation/content/xdocs/trunk/output.xml
@@ -461,6 +461,7 @@ out = proc.getOutputStream();]]></source>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Advanced_Function_Presentation">AFP (Advanced Function Presentation)</a></li>
<li><a href="http://wiki.apache.org/xmlgraphics-fop/AFPResources">AFP Resources on the FOP WIKI</a></li>
+ <li><a href="http://wiki.apache.org/xmlgraphics-fop/AFPOutput">Technical notes on AFP output in FOP</a></li>
</ul>
</section>
<section id="afp-limitations">
@@ -476,6 +477,19 @@ out = proc.getOutputStream();]]></source>
</li>
</ul>
</section>
+ <section id="afp-compatibility">
+ <title>Deployment in older environments</title>
+ <p>
+ There are still a big number of older (or limited) MO:DCA/IPDS environments in production
+ out there. AFP has grown in functionality over time and not every environment supports the
+ latest features. We're trying to make AFP output work in as many environments as possible.
+ However, to make AFP output work on older environments it is recommended to set to
+ configuration to 1 bit per pixel (see below on how to do this). In this case, all images
+ are converted to bi-level images using IOCA function set 10 (FS10). If a higher number of
+ bits per pixel is configured, FOP has to switch to at least FS11 which may not work
+ everywhere.
+ </p>
+ </section>
<section id="afp-configuration">
<title>Configuration</title>
<section id="afp-font-config">
@@ -643,6 +657,26 @@ out = proc.getOutputStream();]]></source>
]]></source>
<note>Be careful when using this option not to overwrite existing resource files from previous rendering runs.</note>
</section>
+ <section id="afp-resource-level-defaults">
+ <title>Resource Level Defaults</title>
+ <p>
+ By default, bitmap image objects (or page segments derived from them) are put in the
+ print-file-level resource group and GOCA graphics are inlined for compatibility with
+ the AFP Workbench tool.
+ </p>
+ <p>
+ It is possible to override these defaults, either per image (see the
+ <link href="#afp-foreign-attributes-resource">afp:resource-level</link>
+ extension attribute below) or by specifying different defaults in the configuration:
+ </p>
+ <source><![CDATA[
+<default-resource-levels goca="print-file" bitmap="inline"/>]]></source>
+ <p>
+ "goca" refers to GOCA graphics and "bitmap" refers to IOCA images. The possible values
+ for the attributes are "inline" and "print-file". In the future,
+ additional possibilities may be added.
+ </p>
+ </section>
</section>
<section id="afp-extensions">
<title>Extensions</title>
@@ -758,8 +792,10 @@ out = proc.getOutputStream();]]></source>
]]></source>
<p>The resource-level attribute where the resource object will reside in the AFP output datastream.
The possible values for this are "inline", "print-file" and "external".
- When no resource-level attribute is provided, resources are by default placed at "print-file" level.
- When "external" is used a resource-group-file attribute must also be specified.</p>
+ When "external" is used a resource-group-file attribute must also be specified.
+ Please refer to the <link href="#afp-resource-level-defaults">Resource Level Defaults</link>
+ above to see what is used if the resource-level attribute is not specified.
+ </p>
<p></p>
</section>
</section>
diff --git a/src/java/org/apache/fop/afp/AFPGraphics2D.java b/src/java/org/apache/fop/afp/AFPGraphics2D.java
index 6f552ae5b..2e176e5ab 100644
--- a/src/java/org/apache/fop/afp/AFPGraphics2D.java
+++ b/src/java/org/apache/fop/afp/AFPGraphics2D.java
@@ -131,10 +131,10 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
AFPResourceManager resourceManager, AFPResourceInfo resourceInfo,
FontInfo fontInfo) {
super(textAsShapes);
- this.paintingState = paintingState;
- this.resourceManager = resourceManager;
- this.resourceInfo = resourceInfo;
- this.fontInfo = fontInfo;
+ setPaintingState(paintingState);
+ setResourceManager(resourceManager);
+ setResourceInfo(resourceInfo);
+ setFontInfo(fontInfo);
}
/**
@@ -160,7 +160,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
*
* @param resourceManager the AFP resource manager
*/
- public void setResourceManager(AFPResourceManager resourceManager) {
+ private void setResourceManager(AFPResourceManager resourceManager) {
this.resourceManager = resourceManager;
}
@@ -169,11 +169,65 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
*
* @param resourceInfo the AFP resource info
*/
- public void setResourceInfo(AFPResourceInfo resourceInfo) {
+ private void setResourceInfo(AFPResourceInfo resourceInfo) {
this.resourceInfo = resourceInfo;
}
/**
+ * Returns the GOCA graphics object
+ *
+ * @return the GOCA graphics object
+ */
+ public GraphicsObject getGraphicsObject() {
+ return this.graphicsObj;
+ }
+
+ /**
+ * Sets the GOCA graphics object
+ *
+ * @param obj the GOCA graphics object
+ */
+ public void setGraphicsObject(GraphicsObject obj) {
+ this.graphicsObj = obj;
+ }
+
+ /**
+ * Sets the AFP painting state
+ *
+ * @param paintingState the AFP painting state
+ */
+ private void setPaintingState(AFPPaintingState paintingState) {
+ this.paintingState = paintingState;
+ }
+
+ /**
+ * Returns the AFP painting state
+ *
+ * @return the AFP painting state
+ */
+ public AFPPaintingState getPaintingState() {
+ return this.paintingState;
+ }
+
+ /**
+ * Sets the FontInfo
+ *
+ * @param fontInfo the FontInfo
+ */
+ private void setFontInfo(FontInfo fontInfo) {
+ this.fontInfo = fontInfo;
+ }
+
+ /**
+ * Returns the FontInfo
+ *
+ * @return the FontInfo
+ */
+ public FontInfo getFontInfo() {
+ return this.fontInfo;
+ }
+
+ /**
* Sets the GraphicContext
*
* @param gc
@@ -653,51 +707,6 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
this.customTextHandler = handler;
}
- /**
- * Returns the GOCA graphics object
- *
- * @return the GOCA graphics object
- */
- public GraphicsObject getGraphicsObject() {
- return this.graphicsObj;
- }
-
- /**
- * Sets the GOCA graphics object
- *
- * @param obj the GOCA graphics object
- */
- public void setGraphicsObject(GraphicsObject obj) {
- this.graphicsObj = obj;
- }
-
- /**
- * Sets the AFP painting state
- *
- * @param paintingState the AFP painting state
- */
- public void setPaintingState(AFPPaintingState paintingState) {
- this.paintingState = paintingState;
- }
-
- /**
- * Returns the AFP painting state
- *
- * @return the AFP painting state
- */
- public AFPPaintingState getPaintingState() {
- return this.paintingState;
- }
-
- /**
- * Returns the FontInfo
- *
- * @return the FontInfo
- */
- public FontInfo getFontInfo() {
- return this.fontInfo;
- }
-
/** {@inheritDoc} */
public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
log.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform);
diff --git a/src/java/org/apache/fop/afp/AFPResourceInfo.java b/src/java/org/apache/fop/afp/AFPResourceInfo.java
index 99b3d7417..43ba2a238 100644
--- a/src/java/org/apache/fop/afp/AFPResourceInfo.java
+++ b/src/java/org/apache/fop/afp/AFPResourceInfo.java
@@ -26,10 +26,12 @@ import java.awt.Dimension;
* The level at which a resource is to reside in the AFP output
*/
public class AFPResourceInfo {
- private static final AFPResourceLevel DEFAULT_LEVEL
+
+ /** the general default resource level */
+ public static final AFPResourceLevel DEFAULT_LEVEL
= new AFPResourceLevel(AFPResourceLevel.PRINT_FILE);
- /** the uri of this resource */
+ /** the URI of this resource */
private String uri = null;
/**
@@ -48,18 +50,18 @@ public class AFPResourceInfo {
private boolean levelChanged = false;
/**
- * Sets the data object uri
+ * Sets the data object URI.
*
- * @param uri the data object uri
+ * @param uri the data object URI
*/
public void setUri(String uri) {
this.uri = uri;
}
/**
- * Returns the uri of this data object
+ * Returns the URI of this data object.
*
- * @return the uri of this data object
+ * @return the URI of this data object
*/
public String getUri() {
return uri;
diff --git a/src/java/org/apache/fop/afp/AFPResourceLevelDefaults.java b/src/java/org/apache/fop/afp/AFPResourceLevelDefaults.java
new file mode 100644
index 000000000..8cb0ebaaf
--- /dev/null
+++ b/src/java/org/apache/fop/afp/AFPResourceLevelDefaults.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.afp;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.fop.afp.modca.ResourceObject;
+
+/**
+ * This class holds resource levels defaults for the various resource types.
+ */
+public class AFPResourceLevelDefaults {
+
+ private static final Map RESOURCE_TYPE_NAMES = new java.util.HashMap();
+
+ static {
+ //Map to be extended as need arises:
+ registerResourceTypeName("goca", ResourceObject.TYPE_GRAPHIC);
+ registerResourceTypeName("bitmap", ResourceObject.TYPE_IMAGE);
+ }
+
+ private static void registerResourceTypeName(String name, byte type) {
+ RESOURCE_TYPE_NAMES.put(name.toLowerCase(), new Byte(type));
+ }
+
+ private static byte getResourceType(String resourceTypeName) {
+ Byte result = (Byte)RESOURCE_TYPE_NAMES.get(resourceTypeName.toLowerCase());
+ if (result == null) {
+ throw new IllegalArgumentException("Unknown resource type name: " + resourceTypeName);
+ }
+ return result.byteValue();
+ }
+
+ private Map defaultResourceLevels = new java.util.HashMap();
+
+ /**
+ * Creates a new instance with default values.
+ */
+ public AFPResourceLevelDefaults() {
+ // level not explicitly set/changed so default to inline for GOCA graphic objects
+ // (due to a bug in the IBM AFP Workbench Viewer (2.04.01.07), hard copy works just fine)
+ setDefaultResourceLevel(ResourceObject.TYPE_GRAPHIC,
+ new AFPResourceLevel(AFPResourceLevel.INLINE));
+ }
+
+ /**
+ * Sets the default resource level for a particular resource type.
+ * @param type the resource type name
+ * @param level the resource level
+ */
+ public void setDefaultResourceLevel(String type, AFPResourceLevel level) {
+ setDefaultResourceLevel(getResourceType(type), level);
+ }
+
+ /**
+ * Sets the default resource level for a particular resource type.
+ * @param type the resource type ({@link ResourceObject}.TYPE_*)
+ * @param level the resource level
+ */
+ public void setDefaultResourceLevel(byte type, AFPResourceLevel level) {
+ this.defaultResourceLevels.put(new Byte(type), level);
+ }
+
+ /**
+ * Returns the default resource level for a particular resource type.
+ * @param type the resource type ({@link ResourceObject}.TYPE_*)
+ * @return the default resource level
+ */
+ public AFPResourceLevel getDefaultResourceLevel(byte type) {
+ AFPResourceLevel result = (AFPResourceLevel)this.defaultResourceLevels.get(new Byte(type));
+ if (result == null) {
+ result = AFPResourceInfo.DEFAULT_LEVEL;
+ }
+ return result;
+ }
+
+ /**
+ * Allows to merge the values from one instance into another. Values from the instance passed
+ * in as a parameter override values of this instance.
+ * @param other the other instance to get the defaults from
+ */
+ public void mergeFrom(AFPResourceLevelDefaults other) {
+ Iterator iter = other.defaultResourceLevels.entrySet().iterator();
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ Byte type = (Byte)entry.getKey();
+ AFPResourceLevel level = (AFPResourceLevel)entry.getValue();
+ this.defaultResourceLevels.put(type, level);
+ }
+ }
+
+}
diff --git a/src/java/org/apache/fop/afp/AFPResourceManager.java b/src/java/org/apache/fop/afp/AFPResourceManager.java
index 2e36c82a0..9218ea8e4 100644
--- a/src/java/org/apache/fop/afp/AFPResourceManager.java
+++ b/src/java/org/apache/fop/afp/AFPResourceManager.java
@@ -53,6 +53,8 @@ public class AFPResourceManager {
private Map pageSegmentMap = new java.util.HashMap();
+ private AFPResourceLevelDefaults resourceLevelDefaults = new AFPResourceLevelDefaults();
+
/**
* Main constructor
*/
@@ -218,4 +220,20 @@ public class AFPResourceManager {
currentPage.createIncludePageSegment(pageSegmentName, x, y, createHardPageSegments);
}
+ /**
+ * Sets resource level defaults. The existing defaults over merged with the ones passed in
+ * as parameter.
+ * @param defaults the new defaults
+ */
+ public void setResourceLevelDefaults(AFPResourceLevelDefaults defaults) {
+ this.resourceLevelDefaults.mergeFrom(defaults);
+ }
+
+ /**
+ * Returns the resource level defaults in use with this resource manager.
+ * @return the resource level defaults
+ */
+ public AFPResourceLevelDefaults getResourceLevelDefaults() {
+ return this.resourceLevelDefaults;
+ }
} \ No newline at end of file
diff --git a/src/java/org/apache/fop/render/afp/AFPCustomizable.java b/src/java/org/apache/fop/render/afp/AFPCustomizable.java
index 20588a579..ff4fb0100 100644
--- a/src/java/org/apache/fop/render/afp/AFPCustomizable.java
+++ b/src/java/org/apache/fop/render/afp/AFPCustomizable.java
@@ -19,6 +19,8 @@
package org.apache.fop.render.afp;
+import org.apache.fop.afp.AFPResourceLevelDefaults;
+
/**
* Interface used to customize the AFP renderer or document handler.
*/
@@ -69,4 +71,11 @@ public interface AFPCustomizable {
*/
void setDefaultResourceGroupFilePath(String filePath);
+ /**
+ * Sets the resource level defaults. The object passed in provides information which resource
+ * level shall be used by default for various kinds of resources.
+ * @param defaults the resource level defaults
+ */
+ void setResourceLevelDefaults(AFPResourceLevelDefaults defaults);
+
}
diff --git a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
index e9d4615be..b2a1b3a3b 100644
--- a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
+++ b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
@@ -25,10 +25,8 @@ import java.awt.geom.AffineTransform;
import java.io.IOException;
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import org.apache.fop.afp.AFPPaintingState;
+import org.apache.fop.afp.AFPResourceLevelDefaults;
import org.apache.fop.afp.AFPResourceManager;
import org.apache.fop.afp.AFPUnitConverter;
import org.apache.fop.afp.DataStream;
@@ -53,8 +51,8 @@ import org.apache.fop.render.intermediate.IFPainter;
public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
implements AFPCustomizable {
- /** logging instance */
- private static Log log = LogFactory.getLog(AFPDocumentHandler.class);
+ //** logging instance */
+ //private static Log log = LogFactory.getLog(AFPDocumentHandler.class);
/** the resource manager */
private AFPResourceManager resourceManager;
@@ -311,6 +309,11 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
resourceManager.setDefaultResourceGroupFilePath(filePath);
}
+ /** {@inheritDoc} */
+ public void setResourceLevelDefaults(AFPResourceLevelDefaults defaults) {
+ resourceManager.setResourceLevelDefaults(defaults);
+ }
+
/**
* Returns the page segment name for a given URI if it actually represents a page segment.
* Otherwise, it just returns null.
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
index 572cc0415..32a95b445 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
@@ -33,7 +33,8 @@ import org.apache.fop.afp.AFPGraphics2D;
import org.apache.fop.afp.AFPGraphicsObjectInfo;
import org.apache.fop.afp.AFPPaintingState;
import org.apache.fop.afp.AFPResourceInfo;
-import org.apache.fop.afp.AFPResourceLevel;
+import org.apache.fop.afp.AFPResourceManager;
+import org.apache.fop.afp.modca.ResourceObject;
import org.apache.fop.render.ImageHandler;
import org.apache.fop.render.ImageHandlerUtil;
import org.apache.fop.render.RenderingContext;
@@ -70,7 +71,7 @@ public class AFPImageHandlerGraphics2D extends AFPImageHandler implements ImageH
AFPGraphicsObjectInfo graphicsObjectInfo
= (AFPGraphicsObjectInfo)super.generateDataObjectInfo(rendererImageInfo);
- setDefaultToInlineResourceLevel(graphicsObjectInfo);
+ setDefaultResourceLevel(graphicsObjectInfo, afpInfo.getResourceManager());
// set mime type (unsupported by MOD:CA registry)
graphicsObjectInfo.setMimeType(MimeConstants.MIME_AFP_GOCA);
@@ -88,12 +89,12 @@ public class AFPImageHandlerGraphics2D extends AFPImageHandler implements ImageH
}
}
- private void setDefaultToInlineResourceLevel(AFPGraphicsObjectInfo graphicsObjectInfo) {
+ private void setDefaultResourceLevel(AFPGraphicsObjectInfo graphicsObjectInfo,
+ AFPResourceManager resourceManager) {
AFPResourceInfo resourceInfo = graphicsObjectInfo.getResourceInfo();
- //level not explicitly set/changed so default to inline for GOCA graphic objects
- // (due to a bug in the IBM AFP Workbench Viewer (2.04.01.07), hard copy works just fine)
if (!resourceInfo.levelChanged()) {
- resourceInfo.setLevel(new AFPResourceLevel(AFPResourceLevel.INLINE));
+ resourceInfo.setLevel(resourceManager.getResourceLevelDefaults()
+ .getDefaultResourceLevel(ResourceObject.TYPE_GRAPHIC));
}
}
@@ -133,7 +134,7 @@ public class AFPImageHandlerGraphics2D extends AFPImageHandler implements ImageH
graphicsObjectInfo.setObjectAreaInfo(
createObjectAreaInfo(afpContext.getPaintingState(), pos));
- setDefaultToInlineResourceLevel(graphicsObjectInfo);
+ setDefaultResourceLevel(graphicsObjectInfo, afpContext.getResourceManager());
// Image content
ImageGraphics2D imageG2D = (ImageGraphics2D)image;
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
index 80f36c331..8f7918583 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
@@ -42,6 +42,9 @@ import org.apache.fop.afp.AFPDataObjectInfo;
import org.apache.fop.afp.AFPImageObjectInfo;
import org.apache.fop.afp.AFPObjectAreaInfo;
import org.apache.fop.afp.AFPPaintingState;
+import org.apache.fop.afp.AFPResourceInfo;
+import org.apache.fop.afp.AFPResourceManager;
+import org.apache.fop.afp.modca.ResourceObject;
import org.apache.fop.render.ImageHandler;
import org.apache.fop.render.RenderingContext;
import org.apache.fop.util.bitmap.BitmapImageUtil;
@@ -68,6 +71,9 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima
AFPRendererContext rendererContext
= (AFPRendererContext)rendererImageInfo.getRendererContext();
AFPInfo afpInfo = rendererContext.getInfo();
+
+ setDefaultResourceLevel(imageObjectInfo, afpInfo.getResourceManager());
+
AFPPaintingState paintingState = afpInfo.getPaintingState();
ImageRendered imageRendered = (ImageRendered) rendererImageInfo.img;
Dimension targetSize = new Dimension(afpInfo.getWidth(), afpInfo.getHeight());
@@ -216,6 +222,15 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima
return imageObjectInfo;
}
+ private void setDefaultResourceLevel(AFPImageObjectInfo imageObjectInfo,
+ AFPResourceManager resourceManager) {
+ AFPResourceInfo resourceInfo = imageObjectInfo.getResourceInfo();
+ if (!resourceInfo.levelChanged()) {
+ resourceInfo.setLevel(resourceManager.getResourceLevelDefaults()
+ .getDefaultResourceLevel(ResourceObject.TYPE_IMAGE));
+ }
+ }
+
/** {@inheritDoc} */
protected AFPDataObjectInfo createDataObjectInfo() {
return new AFPImageObjectInfo();
@@ -247,6 +262,7 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima
setResourceInformation(imageObjectInfo,
image.getInfo().getOriginalURI(),
afpContext.getForeignAttributes());
+ setDefaultResourceLevel(imageObjectInfo, afpContext.getResourceManager());
// Positioning
imageObjectInfo.setObjectAreaInfo(createObjectAreaInfo(afpContext.getPaintingState(), pos));
diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java
index 5edb3b310..d1d2bec3b 100644
--- a/src/java/org/apache/fop/render/afp/AFPRenderer.java
+++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java
@@ -46,6 +46,7 @@ import org.apache.fop.afp.AFPDataObjectInfo;
import org.apache.fop.afp.AFPEventProducer;
import org.apache.fop.afp.AFPPaintingState;
import org.apache.fop.afp.AFPRectanglePainter;
+import org.apache.fop.afp.AFPResourceLevelDefaults;
import org.apache.fop.afp.AFPResourceManager;
import org.apache.fop.afp.AFPTextDataInfo;
import org.apache.fop.afp.AFPUnitConverter;
@@ -722,6 +723,11 @@ public class AFPRenderer extends AbstractPathOrientedRenderer implements AFPCust
}
/** {@inheritDoc} */
+ public void setResourceLevelDefaults(AFPResourceLevelDefaults defaults) {
+ resourceManager.setResourceLevelDefaults(defaults);
+ }
+
+ /** {@inheritDoc} */
protected void establishTransformationMatrix(AffineTransform at) {
saveGraphicsState();
concatenateTransformationMatrix(at);
diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
index 7c6ee5771..fffba85a1 100644
--- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
@@ -25,6 +25,8 @@ import java.util.List;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.fop.afp.AFPResourceLevel;
+import org.apache.fop.afp.AFPResourceLevelDefaults;
import org.apache.fop.afp.fonts.AFPFontCollection;
import org.apache.fop.afp.fonts.AFPFontInfo;
import org.apache.fop.afp.fonts.CharacterSet;
@@ -296,6 +298,26 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
+ resourceGroupDest + "'");
}
}
+
+ Configuration defaultResourceLevelCfg = cfg.getChild("default-resource-levels", false);
+ if (defaultResourceLevelCfg != null) {
+ AFPResourceLevelDefaults defaults = new AFPResourceLevelDefaults();
+ String[] types = defaultResourceLevelCfg.getAttributeNames();
+ for (int i = 0, c = types.length; i < c; i++) {
+ String type = types[i];
+ try {
+ String level = defaultResourceLevelCfg.getAttribute(type);
+ defaults.setDefaultResourceLevel(type, AFPResourceLevel.valueOf(level));
+ } catch (IllegalArgumentException iae) {
+ LogUtil.handleException(log, iae,
+ userAgent.getFactory().validateUserConfigStrictly());
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e,
+ userAgent.getFactory().validateUserConfigStrictly());
+ }
+ }
+ customizable.setResourceLevelDefaults(defaults);
+ }
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/render/afp/AFPRendererContext.java b/src/java/org/apache/fop/render/afp/AFPRendererContext.java
index ab2e73779..cd00a078b 100644
--- a/src/java/org/apache/fop/render/afp/AFPRendererContext.java
+++ b/src/java/org/apache/fop/render/afp/AFPRendererContext.java
@@ -25,8 +25,8 @@ import org.apache.avalon.framework.configuration.Configuration;
import org.apache.fop.afp.AFPPaintingState;
import org.apache.fop.afp.AFPResourceInfo;
-import org.apache.fop.afp.AFPResourceLevel;
import org.apache.fop.afp.AFPResourceManager;
+import org.apache.fop.afp.modca.ResourceObject;
import org.apache.fop.render.AbstractRenderer;
import org.apache.fop.render.ImageHandlerUtil;
import org.apache.fop.render.RendererContext;
@@ -76,9 +76,12 @@ public class AFPRendererContext extends RendererContext {
= new AFPForeignAttributeReader();
AFPResourceInfo resourceInfo
= foreignAttributeReader.getResourceInfo(foreignAttributes);
- // default to inline level if painted as GOCA
- if (!resourceInfo.levelChanged() && !paintAsBitmap) {
- resourceInfo.setLevel(new AFPResourceLevel(AFPResourceLevel.INLINE));
+ // set default resource level if an explicit one hasn't been set
+ if (!resourceInfo.levelChanged()) {
+ byte resourceType = paintAsBitmap
+ ? ResourceObject.TYPE_IMAGE : ResourceObject.TYPE_GRAPHIC;
+ resourceInfo.setLevel(info.getResourceManager().getResourceLevelDefaults()
+ .getDefaultResourceLevel(resourceType));
}
info.setResourceInfo(resourceInfo);
}
diff --git a/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java b/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java
index 247ab6d6f..1228365f2 100644
--- a/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java
+++ b/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java
@@ -32,6 +32,9 @@ import org.apache.xmlgraphics.image.loader.impl.ImageRawStream;
import org.apache.fop.afp.AFPDataObjectInfo;
import org.apache.fop.afp.AFPObjectAreaInfo;
import org.apache.fop.afp.AFPPaintingState;
+import org.apache.fop.afp.AFPResourceInfo;
+import org.apache.fop.afp.AFPResourceManager;
+import org.apache.fop.afp.modca.ResourceObject;
import org.apache.fop.render.ImageHandler;
import org.apache.fop.render.RenderingContext;
@@ -46,9 +49,11 @@ public abstract class AbstractAFPImageHandlerRawStream extends AFPImageHandler
AFPRendererImageInfo rendererImageInfo) throws IOException {
AFPDataObjectInfo dataObjectInfo = super.generateDataObjectInfo(rendererImageInfo);
ImageRawStream rawStream = (ImageRawStream) rendererImageInfo.getImage();
+ AFPRendererContext rendererContext
+ = (AFPRendererContext)rendererImageInfo.getRendererContext();
+ AFPInfo afpInfo = rendererContext.getInfo();
-
- updateDataObjectInfo(dataObjectInfo, rawStream);
+ updateDataObjectInfo(dataObjectInfo, rawStream, afpInfo.getResourceManager());
setAdditionalParameters(dataObjectInfo, rawStream);
return dataObjectInfo;
@@ -66,8 +71,15 @@ public abstract class AbstractAFPImageHandlerRawStream extends AFPImageHandler
}
private void updateDataObjectInfo(AFPDataObjectInfo dataObjectInfo,
- ImageRawStream rawStream) throws IOException {
+ ImageRawStream rawStream, AFPResourceManager resourceManager) throws IOException {
dataObjectInfo.setMimeType(rawStream.getFlavor().getMimeType());
+
+ AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
+ if (!resourceInfo.levelChanged()) {
+ resourceInfo.setLevel(resourceManager.getResourceLevelDefaults()
+ .getDefaultResourceLevel(ResourceObject.TYPE_IMAGE));
+ }
+
InputStream inputStream = rawStream.createInputStream();
try {
dataObjectInfo.setData(IOUtils.toByteArray(inputStream));
@@ -111,7 +123,7 @@ public abstract class AbstractAFPImageHandlerRawStream extends AFPImageHandler
// Image content
ImageRawStream imageStream = (ImageRawStream)image;
- updateDataObjectInfo(dataObjectInfo, imageStream);
+ updateDataObjectInfo(dataObjectInfo, imageStream, afpContext.getResourceManager());
setAdditionalParameters(dataObjectInfo, imageStream);
// Create image
diff --git a/status.xml b/status.xml
index 64e3dbd1a..f4d479c42 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: Added a configuration option to override the resource level defaults in the
+ code.
+ </action>
<action context="Code" dev="VH" type="fix" fixes-bug="46638">
MinOptMaxUtil.toMinOptMax was converting LengthRangeProperty objects into illegal MinOptMax
objects (in some cases opt could be inferior to min).