aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/svg
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-11-14 14:28:59 +0000
committerJeremias Maerki <jeremias@apache.org>2005-11-14 14:28:59 +0000
commit7827a12bd930176d38d71c3c00ff75754c5aaec3 (patch)
treef1d8c75a7e0ce0e9effab9c0c075e5fd429019a5 /src/java/org/apache/fop/svg
parent5d275dd2d63972a2ba9f865b3813f602c163c7f5 (diff)
downloadxmlgraphics-fop-7827a12bd930176d38d71c3c00ff75754c5aaec3.tar.gz
xmlgraphics-fop-7827a12bd930176d38d71c3c00ff75754c5aaec3.zip
Bugzilla #37330:
1) The jpeg registration now includes the hashCode in addition to the jpegCount as this prevents images being rused when multiple SVG fragments are included in a single FO. 2) Added a createBridgeContext to PDFBridgeContext so that 'sub contexts' (image element) inherit the new bridges. Submitted by: Thomas Deweese <deweese.at.apache.org> git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@344130 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/svg')
-rw-r--r--src/java/org/apache/fop/svg/PDFBridgeContext.java39
-rw-r--r--src/java/org/apache/fop/svg/PDFGraphics2D.java5
2 files changed, 36 insertions, 8 deletions
diff --git a/src/java/org/apache/fop/svg/PDFBridgeContext.java b/src/java/org/apache/fop/svg/PDFBridgeContext.java
index 486cadb97..354fec690 100644
--- a/src/java/org/apache/fop/svg/PDFBridgeContext.java
+++ b/src/java/org/apache/fop/svg/PDFBridgeContext.java
@@ -21,6 +21,7 @@ package org.apache.fop.svg;
import java.awt.geom.AffineTransform;
import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.DocumentLoader;
import org.apache.batik.bridge.UserAgent;
import org.apache.fop.fonts.FontInfo;
@@ -37,9 +38,28 @@ public class PDFBridgeContext extends BridgeContext {
/**
* Constructs a new bridge context.
* @param userAgent the user agent
- * @param fontInfo the font list for the text painter, may be null in which case text is
- * painted as shapes
- * @param linkTransform AffineTransform to properly place links, may be null
+ * @param loader the Document Loader to use for referenced documents.
+ * @param fontInfo the font list for the text painter, may be null
+ * in which case text is painted as shapes
+ * @param linkTransform AffineTransform to properly place links,
+ * may be null
+ */
+ public PDFBridgeContext(UserAgent userAgent,
+ DocumentLoader loader,
+ FontInfo fontInfo,
+ AffineTransform linkTransform) {
+ super(userAgent, loader);
+ this.fontInfo = fontInfo;
+ this.linkTransform = linkTransform;
+ }
+
+ /**
+ * Constructs a new bridge context.
+ * @param userAgent the user agent
+ * @param fontInfo the font list for the text painter, may be null
+ * in which case text is painted as shapes
+ * @param linkTransform AffineTransform to properly place links,
+ * may be null
*/
public PDFBridgeContext(UserAgent userAgent, FontInfo fontInfo,
AffineTransform linkTransform) {
@@ -51,8 +71,8 @@ public class PDFBridgeContext extends BridgeContext {
/**
* Constructs a new bridge context.
* @param userAgent the user agent
- * @param fontInfo the font list for the text painter, may be null in which case text is
- * painted as shapes
+ * @param fontInfo the font list for the text painter, may be null
+ * in which case text is painted as shapes
*/
public PDFBridgeContext(UserAgent userAgent, FontInfo fontInfo) {
this(userAgent, fontInfo, null);
@@ -76,5 +96,10 @@ public class PDFBridgeContext extends BridgeContext {
putBridge(new PDFImageElementBridge());
}
-
-} \ No newline at end of file
+
+ // Make sure any 'sub bridge contexts' also have our bridges.
+ public BridgeContext createBridgeContext() {
+ return new PDFBridgeContext(getUserAgent(), getDocumentLoader(),
+ fontInfo, linkTransform);
+ }
+}
diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java
index 7a1454710..398e36f39 100644
--- a/src/java/org/apache/fop/svg/PDFGraphics2D.java
+++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java
@@ -382,7 +382,10 @@ public class PDFGraphics2D extends AbstractGraphics2D {
public void addJpegImage(JpegImage jpeg, float x, float y,
float width, float height) {
preparePainting();
- String key = "__AddJPEG_" + jpegCount[0];
+ // Need to include hash code as when invoked from FO you
+ // may have several 'independent' PDFGraphics2D so the
+ // count is not enough.
+ String key = "__AddJPEG_" + hashCode() + "_" + jpegCount[0];
jpegCount[0]++;
FopPDFImage fopimage = new FopPDFImage(jpeg, key);
int xObjectNum = this.pdfDoc.addImage(resourceContext,