From e234d476d32c4f71aad1c02965d5376ebbe4cce3 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Mon, 20 Oct 2008 13:12:22 +0000 Subject: [PATCH] Merged revisions 705529,706135 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r705529 | vhennebert | 2008-10-17 10:36:40 +0100 (Fri, 17 Oct 2008) | 2 lines Removed superfluous brackets ........ r706135 | jeremias | 2008-10-20 08:16:47 +0100 (Mon, 20 Oct 2008) | 1 line Check for plan namespace to avoid errors while parsing plan XML. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@706271 13f79535-47bb-0310-9956-ffa450edef68 --- .../plan/src/org/apache/fop/plan/PreloaderPlan.java | 12 ++++++++++-- src/java/org/apache/fop/layoutmgr/TraitSetter.java | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java b/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java index b8a7a612c..f99c94af9 100644 --- a/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java +++ b/examples/plan/src/org/apache/fop/plan/PreloaderPlan.java @@ -30,6 +30,7 @@ import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stream.StreamSource; import org.w3c.dom.Document; +import org.w3c.dom.Element; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -66,7 +67,7 @@ public class PreloaderPlan extends AbstractImagePreloader { return info; } - private ImageInfo getImage(String uri, Source src, ImageContext context) { + private ImageInfo getImage(String uri, Source src, ImageContext context) throws IOException { InputStream in = new UnclosableInputStream(ImageUtil.needInputStream(src)); try { @@ -78,7 +79,14 @@ public class PreloaderPlan extends AbstractImagePreloader { //Have to render the plan to know its size PlanRenderer pr = new PlanRenderer(); - Document svgDoc = pr.createSVGDocument((Document)res.getNode()); + Document planDoc = (Document)res.getNode(); + Element rootEl = planDoc.getDocumentElement(); + if (!PlanElementMapping.NAMESPACE.equals(rootEl.getNamespaceURI())) { + in.reset(); + return null; + } + + Document svgDoc = pr.createSVGDocument(planDoc); float width = pr.getWidth(); float height = pr.getHeight(); diff --git a/src/java/org/apache/fop/layoutmgr/TraitSetter.java b/src/java/org/apache/fop/layoutmgr/TraitSetter.java index c6939d9ff..9cab6322b 100644 --- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java +++ b/src/java/org/apache/fop/layoutmgr/TraitSetter.java @@ -395,7 +395,7 @@ public class TraitSetter { width += backProps.getPaddingStart(false, context); width += backProps.getPaddingEnd(false, context); int imageWidthMpt = back.getImageInfo().getSize().getWidthMpt(); - int lengthBaseValue = (width - imageWidthMpt); + int lengthBaseValue = width - imageWidthMpt; SimplePercentBaseContext simplePercentBaseContext = new SimplePercentBaseContext(context, LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL, @@ -419,7 +419,7 @@ public class TraitSetter { height += backProps.getPaddingBefore(false, context); height += backProps.getPaddingAfter(false, context); int imageHeightMpt = back.getImageInfo().getSize().getHeightMpt(); - int lengthBaseValue = (height - imageHeightMpt); + int lengthBaseValue = height - imageHeightMpt; SimplePercentBaseContext simplePercentBaseContext = new SimplePercentBaseContext(context, LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL, -- 2.39.5