You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by jg...@apache.org on 2026/04/09 15:57:22 UTC

(xmlgraphics-fop) branch main updated: FOP-3307 Use parent content area IPD to scale image to cell size

This is an automated email from the ASF dual-hosted git repository.

jgoncalves pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/xmlgraphics-fop.git


The following commit(s) were added to refs/heads/main by this push:
     new 2a31b84c8 FOP-3307 Use parent content area IPD to scale image to cell size
2a31b84c8 is described below

commit 2a31b84c8943f380e7abd375b286b0bd22d35faa
Author: Joao Goncalves <an...@gmail.com>
AuthorDate: Wed Apr 8 15:39:31 2026 -0500

    FOP-3307 Use parent content area IPD to scale image to cell size
---
 .../main/java/org/apache/fop/apps/FOUserAgent.java |  10 ++
 .../java/org/apache/fop/apps/FopConfParser.java    |   9 ++
 .../main/java/org/apache/fop/apps/FopFactory.java  |   4 +
 .../org/apache/fop/apps/FopFactoryBuilder.java     |  21 ++++
 .../java/org/apache/fop/apps/FopFactoryConfig.java |   7 ++
 .../java/org/apache/fop/fo/GraphicsProperties.java |   7 ++
 .../apache/fop/layoutmgr/inline/ImageLayout.java   |  21 ++++
 .../java/org/apache/fop/apps/MutableConfig.java    |   4 +
 .../org/apache/fop/intermediate/TestAssistant.java |  10 ++
 .../table_cell_image_scale_down_to_fit.xml         | 132 +++++++++++++++++++++
 .../table_cell_image_scale_to_fit.xml              | 132 +++++++++++++++++++++
 .../table_cell_image_scale_up_to_fit.xml           | 132 +++++++++++++++++++++
 12 files changed, 489 insertions(+)

diff --git a/fop-core/src/main/java/org/apache/fop/apps/FOUserAgent.java b/fop-core/src/main/java/org/apache/fop/apps/FOUserAgent.java
index 89c7d6d15..a864cf8f5 100644
--- a/fop-core/src/main/java/org/apache/fop/apps/FOUserAgent.java
+++ b/fop-core/src/main/java/org/apache/fop/apps/FOUserAgent.java
@@ -551,6 +551,16 @@ public class FOUserAgent {
         return factory.isLegacyInvalidBreakPosition();
     }
 
+    /**
+     *  Should we use the parent's layout manager for the content area IPD?
+     *
+     * @return if FOP should use the parent's layout manager for the content area IPD
+     * @see FopFactory#isUseParentIPDImageScaling()
+     */
+    public boolean isUseParentIPDImageScaling() {
+        return factory.isUseParentIPDImageScaling();
+    }
+
     /**
      * @return true if the indent inheritance should be broken when crossing reference area
      *         boundaries (for more info, see the javadoc for the relative member variable)
diff --git a/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java b/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java
index 6aa3d31b4..07e7f9faa 100644
--- a/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java
+++ b/fop-core/src/main/java/org/apache/fop/apps/FopConfParser.java
@@ -64,6 +64,7 @@ public class FopConfParser {
     private static final String LEGACY_LAST_PAGE_CHANGE_IPD = "legacy-last-page-change-ipd";
     private static final String LEGACY_FO_WRAPPER = "legacy-fo-wrapper";
     private static final String LEGACY_INVALID_BREAK_POSITION = "legacy-invalid-break-position";
+    private static final String USE_PARENT_IPD_IMAGE_SCALING = "use-parent-ipd-image-scaling";
 
     private static final Log LOG = LogFactory.getLog(FopConfParser.class);
     private static final String ACCESSIBILITY = "accessibility";
@@ -347,6 +348,14 @@ public class FopConfParser {
                 LogUtil.handleException(LOG, e, strict);
             }
         }
+        if (cfg.getChild(USE_PARENT_IPD_IMAGE_SCALING, false) != null) {
+            try {
+                fopFactoryBuilder.setUseParentIPDImageScaling(
+                        cfg.getChild(USE_PARENT_IPD_IMAGE_SCALING).getValueAsBoolean());
+            } catch (ConfigurationException e) {
+                LogUtil.handleException(LOG, e, strict);
+            }
+        }
 
         // configure font manager
         new FontManagerConfigurator(cfg, baseURI, fopFactoryBuilder.getBaseURI(), resourceResolver)
diff --git a/fop-core/src/main/java/org/apache/fop/apps/FopFactory.java b/fop-core/src/main/java/org/apache/fop/apps/FopFactory.java
index 565813d05..f10f67cfd 100644
--- a/fop-core/src/main/java/org/apache/fop/apps/FopFactory.java
+++ b/fop-core/src/main/java/org/apache/fop/apps/FopFactory.java
@@ -272,6 +272,10 @@ public final class FopFactory implements ImageContext {
         return config.isLegacyInvalidBreakPosition();
     }
 
+    public boolean isUseParentIPDImageScaling() {
+        return config.isUseParentIPDImageScaling();
+    }
+
     /**
      * Returns a new {@link Fop} instance. FOP will be configured with a default user agent
      * instance. Use this factory method if your output type requires an output stream.
diff --git a/fop-core/src/main/java/org/apache/fop/apps/FopFactoryBuilder.java b/fop-core/src/main/java/org/apache/fop/apps/FopFactoryBuilder.java
index 3b90b8df3..996b350ea 100644
--- a/fop-core/src/main/java/org/apache/fop/apps/FopFactoryBuilder.java
+++ b/fop-core/src/main/java/org/apache/fop/apps/FopFactoryBuilder.java
@@ -385,6 +385,11 @@ public final class FopFactoryBuilder {
         return this;
     }
 
+    public FopFactoryBuilder setUseParentIPDImageScaling(boolean value) {
+        fopFactoryConfigBuilder.setUseParentIPDImageScaling(value);
+        return this;
+    }
+
     public static class FopFactoryConfigImpl implements FopFactoryConfig {
 
         private final EnvironmentProfile enviro;
@@ -443,6 +448,8 @@ public final class FopFactoryBuilder {
 
         private boolean legacyInvalidBreakPosition = FopFactoryConfig.DEFAULT_LEGACY_INVALID_BREAK_POSITION;
 
+        private boolean useParentIPDImageScaling = FopFactoryConfig.DEFAULT_USE_PARENT_IPD_IMAGE_SCALING;
+
         private static final class ImageContextImpl implements ImageContext {
 
             private final FopFactoryConfig config;
@@ -595,6 +602,10 @@ public final class FopFactoryBuilder {
             return legacyInvalidBreakPosition;
         }
 
+        public boolean isUseParentIPDImageScaling() {
+            return useParentIPDImageScaling;
+        }
+
         public Map<String, String> getHyphenationPatternNames() {
             return hyphPatNames;
         }
@@ -626,6 +637,8 @@ public final class FopFactoryBuilder {
 
         void setLegacyInvalidBreakPosition(boolean invalidBreakPosition);
 
+        void setUseParentIPDImageScaling(boolean useParentContentAreaIPD);
+
         void setBreakIndentInheritanceOnReferenceAreaBoundary(boolean value);
 
         void setSourceResolution(float dpi);
@@ -711,6 +724,10 @@ public final class FopFactoryBuilder {
             throwIllegalStateException();
         }
 
+        public void setUseParentIPDImageScaling(boolean useParentContentAreaIPD) {
+            throwIllegalStateException();
+        }
+
         public void setBreakIndentInheritanceOnReferenceAreaBoundary(
                 boolean value) {
             throwIllegalStateException();
@@ -898,6 +915,10 @@ public final class FopFactoryBuilder {
         public void setLegacyInvalidBreakPosition(boolean legacyInvalidBreakPosition) {
             config.legacyInvalidBreakPosition = legacyInvalidBreakPosition;
         }
+
+        public void setUseParentIPDImageScaling(boolean useParentIPDImageScaling) {
+            config.useParentIPDImageScaling = useParentIPDImageScaling;
+        }
     }
 
 }
diff --git a/fop-core/src/main/java/org/apache/fop/apps/FopFactoryConfig.java b/fop-core/src/main/java/org/apache/fop/apps/FopFactoryConfig.java
index 359917dec..38812069e 100644
--- a/fop-core/src/main/java/org/apache/fop/apps/FopFactoryConfig.java
+++ b/fop-core/src/main/java/org/apache/fop/apps/FopFactoryConfig.java
@@ -66,6 +66,11 @@ public interface FopFactoryConfig {
     /** Defines the default target resolution (72dpi) for FOP */
     float DEFAULT_TARGET_RESOLUTION = 72.0f; //dpi
 
+    /**
+     * Defines if FOP should use the parent's layout manager for the content area IPD
+     */
+    boolean DEFAULT_USE_PARENT_IPD_IMAGE_SCALING = false;
+
     /**
      * Whether accessibility features are switched on.
      *
@@ -187,6 +192,8 @@ public interface FopFactoryConfig {
 
     boolean isLegacyInvalidBreakPosition();
 
+    boolean isUseParentIPDImageScaling();
+
     /** @return the hyphenation pattern names */
     Map<String, String> getHyphenationPatternNames();
 
diff --git a/fop-core/src/main/java/org/apache/fop/fo/GraphicsProperties.java b/fop-core/src/main/java/org/apache/fop/fo/GraphicsProperties.java
index a22d59c24..eaddf8937 100644
--- a/fop-core/src/main/java/org/apache/fop/fo/GraphicsProperties.java
+++ b/fop-core/src/main/java/org/apache/fop/fo/GraphicsProperties.java
@@ -19,6 +19,7 @@
 
 package org.apache.fop.fo;
 
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.properties.LengthRangeProperty;
 
@@ -78,4 +79,10 @@ public interface GraphicsProperties {
      */
     int getTextAlign();
 
+    /**
+     *
+     * @return user agent
+     */
+    FOUserAgent getUserAgent();
+
 }
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/ImageLayout.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
index 8a25dc62b..686629a2d 100644
--- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
+++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
@@ -30,6 +30,7 @@ import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.GraphicsProperties;
 import org.apache.fop.fo.properties.LengthRangeProperty;
+import org.apache.fop.layoutmgr.LayoutManager;
 
 /**
  * Helper class which calculates the size and position in the viewport of an image.
@@ -49,6 +50,8 @@ public class ImageLayout implements Constants {
     private Dimension viewportSize = new Dimension(-1, -1);
     private boolean clip;
 
+    private boolean useParentIPDImageScaling;
+
     /**
      * Main constructor
      * @param props the properties for the image
@@ -60,6 +63,7 @@ public class ImageLayout implements Constants {
         this.props = props;
         this.percentBaseContext = percentBaseContext;
         this.intrinsicSize = intrinsicSize;
+        this.useParentIPDImageScaling = props.getUserAgent().isUseParentIPDImageScaling();
 
         doLayout();
     }
@@ -92,6 +96,10 @@ public class ImageLayout implements Constants {
             ipd = len.getValue(percentBaseContext);
         }
 
+        if (useParentIPDImageScaling && percentBaseContext instanceof LayoutManager) {
+            ipd = getParentIPD((LayoutManager) percentBaseContext, ipd);
+        }
+
         // if auto then use the intrinsic size of the content scaled
         // to the content-height and content-width
         boolean constrainIntrinsicSize = false;
@@ -281,6 +289,19 @@ public class ImageLayout implements Constants {
         return dim;
     }
 
+    private int getParentIPD(LayoutManager layoutManager, int ipd) {
+        if (layoutManager == null || layoutManager.getParent() == null) {
+            return ipd;
+        }
+
+        try {
+            return layoutManager.getParent().getContentAreaIPD();
+        } catch (UnsupportedOperationException e) {
+            // some layout managers do not support getContentAreaIPD, so we continue searching up the hierarchy
+            return getParentIPD(layoutManager.getParent(), ipd);
+        }
+    }
+
     /**
      * Given the ipd and the content width calculates the
      * required x offset based on the text-align property
diff --git a/fop-core/src/test/java/org/apache/fop/apps/MutableConfig.java b/fop-core/src/test/java/org/apache/fop/apps/MutableConfig.java
index 251efea84..32da60fbf 100644
--- a/fop-core/src/test/java/org/apache/fop/apps/MutableConfig.java
+++ b/fop-core/src/test/java/org/apache/fop/apps/MutableConfig.java
@@ -89,6 +89,10 @@ public final class MutableConfig implements FopFactoryConfig {
         return delegate.isLegacyInvalidBreakPosition();
     }
 
+    public boolean isUseParentIPDImageScaling() {
+        return delegate.isUseParentIPDImageScaling();
+    }
+
     public boolean isBreakIndentInheritanceOnReferenceAreaBoundary() {
         return setBreakInheritance;
     }
diff --git a/fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java b/fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java
index 33d11ddc5..8e22c0538 100644
--- a/fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java
+++ b/fop-core/src/test/java/org/apache/fop/intermediate/TestAssistant.java
@@ -130,6 +130,7 @@ public class TestAssistant {
         builder.setLegacyLastPageChangeIPD(isLegacyLastPageChangeIPD(testDoc));
         builder.setLegacyFoWrapper(isLegacyFoWrapper(testDoc));
         builder.setLegacyInvalidBreakPosition(isLegacyInvalidBreakPosition(testDoc));
+        builder.setUseParentIPDImageScaling(isUseParentIPDImageScaling(testDoc));
         return builder.build();
     }
 
@@ -219,6 +220,15 @@ public class TestAssistant {
         }
     }
 
+    private boolean isUseParentIPDImageScaling(Document testDoc) {
+        try {
+            String s = eval(testDoc, "/testcase/cfg/use-parent-ipd-image-scaling");
+            return "true".equalsIgnoreCase(s);
+        } catch (XPathExpressionException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
     /**
      * Loads a test case into a DOM document.
      * @param testFile the test file
diff --git a/fop/test/layoutengine/standard-testcases/table_cell_image_scale_down_to_fit.xml b/fop/test/layoutengine/standard-testcases/table_cell_image_scale_down_to_fit.xml
new file mode 100644
index 000000000..cdaad5411
--- /dev/null
+++ b/fop/test/layoutengine/standard-testcases/table_cell_image_scale_down_to_fit.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks image's width when inside a table cell
+    </p>
+  </info>
+  <cfg>
+    <use-parent-ipd-image-scaling>true</use-parent-ipd-image-scaling>
+  </cfg>
+  <fo>
+      <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+          <fo:layout-master-set>
+              <fo:simple-page-master master-name="content" page-width="2cm">
+                  <fo:region-body/>
+              </fo:simple-page-master>
+          </fo:layout-master-set>
+          <fo:page-sequence master-reference="content">
+              <fo:flow flow-name="xsl-region-body">
+                  <fo:block>
+                      <fo:table table-layout="fixed" width="100%">
+                          <fo:table-column column-width="proportional-column-width(50)" column-number="1"/>
+                          <fo:table-column column-width="proportional-column-width(50)" column-number="2"/>
+                          <fo:table-body>
+                              <fo:table-row>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:external-graphic content-width="scale-down-to-fit" scaling="non-uniform" src="../resources/images/bgimg300dpi.jpg"/>
+                                      </fo:block>
+                                  </fo:table-cell>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:external-graphic content-width="scale-down-to-fit" scaling="non-uniform" src="../resources/images/bgimg300dpi.jpg"/>
+                                      </fo:block>
+                                  </fo:table-cell>
+                              </fo:table-row>
+                              <fo:table-row height="0.396874994039536cm">
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:external-graphic content-width="scale-down-to-fit" scaling="uniform" src="../resources/images/bgimg300dpi.jpg"/>
+                                      </fo:block>
+                                  </fo:table-cell>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:external-graphic content-width="scale-down-to-fit" scaling="uniform" src="../resources/images/bgimg300dpi.jpg"/>
+                                      </fo:block>
+                                  </fo:table-cell>
+                              </fo:table-row>
+                              <fo:table-row>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:instream-foreign-object background-color="yellow" content-width="scale-down-to-fit" scaling="non-uniform">
+                                              <svg:svg width="1.5cm" height="1.5cm" viewBox="0 0 30 30">
+                                                  <svg:circle cx="15" cy="15" r="14" fill="#0000ff" stroke="none"/>
+                                              </svg:svg>
+                                          </fo:instream-foreign-object>
+                                      </fo:block>
+                                  </fo:table-cell>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:instream-foreign-object background-color="yellow" content-width="scale-down-to-fit" scaling="non-uniform">
+                                              <svg:svg width="2cm" height="2cm" viewBox="0 0 30 30">
+                                                  <svg:circle cx="15" cy="15" r="14" fill="#0000ff" stroke="none"/>
+                                              </svg:svg>
+                                          </fo:instream-foreign-object>
+                                      </fo:block>
+                                  </fo:table-cell>
+                              </fo:table-row>
+                              <fo:table-row>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:instream-foreign-object background-color="yellow" content-width="scale-down-to-fit" scaling="uniform">
+                                              <svg:svg width="1.5cm" height="1.5cm" viewBox="0 0 30 30">
+                                                  <svg:circle cx="15" cy="15" r="14" fill="#0000ff" stroke="none"/>
+                                              </svg:svg>
+                                          </fo:instream-foreign-object>
+                                      </fo:block>
+                                  </fo:table-cell>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:instream-foreign-object background-color="yellow" content-width="scale-down-to-fit" scaling="uniform">
+                                              <svg:svg width="2cm" height="2cm" viewBox="0 0 30 30">
+                                                  <svg:circle cx="15" cy="15" r="14" fill="#0000ff" stroke="none"/>
+                                              </svg:svg>
+                                          </fo:instream-foreign-object>
+                                      </fo:block>
+                                  </fo:table-cell>
+                              </fo:table-row>
+                          </fo:table-body>
+                      </fo:table>
+                  </fo:block>
+              </fo:flow>
+          </fo:page-sequence>
+      </fo:root>
+  </fo>
+  <checks>
+    <!-- width of the first table -->
+    <eval expected="28300" xpath="//flow/block/block/block/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[2]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[2]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[3]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[3]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[4]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[4]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[5]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[5]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[6]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[6]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[7]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[7]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[8]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[8]/block/lineArea/viewport[1]/@bpd"/>
+  </checks>
+</testcase>
diff --git a/fop/test/layoutengine/standard-testcases/table_cell_image_scale_to_fit.xml b/fop/test/layoutengine/standard-testcases/table_cell_image_scale_to_fit.xml
new file mode 100644
index 000000000..b945d454a
--- /dev/null
+++ b/fop/test/layoutengine/standard-testcases/table_cell_image_scale_to_fit.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks image's width when inside a table cell
+    </p>
+  </info>
+  <cfg>
+    <use-parent-ipd-image-scaling>true</use-parent-ipd-image-scaling>
+  </cfg>
+  <fo>
+      <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+          <fo:layout-master-set>
+              <fo:simple-page-master master-name="content" page-width="2cm">
+                  <fo:region-body/>
+              </fo:simple-page-master>
+          </fo:layout-master-set>
+          <fo:page-sequence master-reference="content">
+              <fo:flow flow-name="xsl-region-body">
+                  <fo:block>
+                      <fo:table table-layout="fixed" width="100%">
+                          <fo:table-column column-width="proportional-column-width(50)" column-number="1"/>
+                          <fo:table-column column-width="proportional-column-width(50)" column-number="2"/>
+                          <fo:table-body>
+                              <fo:table-row>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:external-graphic content-width="scale-to-fit" scaling="non-uniform" src="../resources/images/bgimg300dpi.jpg"/>
+                                      </fo:block>
+                                  </fo:table-cell>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:external-graphic content-width="scale-to-fit" scaling="non-uniform" src="../resources/images/bgimg300dpi.jpg"/>
+                                      </fo:block>
+                                  </fo:table-cell>
+                              </fo:table-row>
+                              <fo:table-row height="0.396874994039536cm">
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:external-graphic content-width="scale-to-fit" scaling="uniform" src="../resources/images/bgimg300dpi.jpg"/>
+                                      </fo:block>
+                                  </fo:table-cell>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:external-graphic content-width="scale-to-fit" scaling="uniform" src="../resources/images/bgimg300dpi.jpg"/>
+                                      </fo:block>
+                                  </fo:table-cell>
+                              </fo:table-row>
+                              <fo:table-row>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:instream-foreign-object background-color="yellow" content-width="scale-to-fit" scaling="non-uniform">
+                                              <svg:svg width="2cm" height="2cm" viewBox="0 0 30 30">
+                                                  <svg:circle cx="15" cy="15" r="14" fill="#0000ff" stroke="none"/>
+                                              </svg:svg>
+                                          </fo:instream-foreign-object>
+                                      </fo:block>
+                                  </fo:table-cell>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:instream-foreign-object background-color="yellow" content-width="scale-to-fit" scaling="non-uniform">
+                                              <svg:svg width="2cm" height="2cm" viewBox="0 0 30 30">
+                                                  <svg:circle cx="15" cy="15" r="14" fill="#0000ff" stroke="none"/>
+                                              </svg:svg>
+                                          </fo:instream-foreign-object>
+                                      </fo:block>
+                                  </fo:table-cell>
+                              </fo:table-row>
+                              <fo:table-row>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:instream-foreign-object background-color="yellow" content-width="scale-to-fit" scaling="uniform">
+                                              <svg:svg width="2cm" height="2cm" viewBox="0 0 30 30">
+                                                  <svg:circle cx="15" cy="15" r="14" fill="#0000ff" stroke="none"/>
+                                              </svg:svg>
+                                          </fo:instream-foreign-object>
+                                      </fo:block>
+                                  </fo:table-cell>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:instream-foreign-object background-color="yellow" content-width="scale-to-fit" scaling="uniform">
+                                              <svg:svg width="2cm" height="2cm" viewBox="0 0 30 30">
+                                                  <svg:circle cx="15" cy="15" r="14" fill="#0000ff" stroke="none"/>
+                                              </svg:svg>
+                                          </fo:instream-foreign-object>
+                                      </fo:block>
+                                  </fo:table-cell>
+                              </fo:table-row>
+                          </fo:table-body>
+                      </fo:table>
+                  </fo:block>
+              </fo:flow>
+          </fo:page-sequence>
+      </fo:root>
+  </fo>
+  <checks>
+    <!-- width of the first table -->
+    <eval expected="28300" xpath="//flow/block/block/block/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[2]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[2]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[3]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[3]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[4]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[4]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[5]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[5]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[6]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[6]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[7]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[7]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[8]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[8]/block/lineArea/viewport[1]/@bpd"/>
+  </checks>
+</testcase>
diff --git a/fop/test/layoutengine/standard-testcases/table_cell_image_scale_up_to_fit.xml b/fop/test/layoutengine/standard-testcases/table_cell_image_scale_up_to_fit.xml
new file mode 100644
index 000000000..94690b824
--- /dev/null
+++ b/fop/test/layoutengine/standard-testcases/table_cell_image_scale_up_to_fit.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks image's width when inside a table cell
+    </p>
+  </info>
+  <cfg>
+    <use-parent-ipd-image-scaling>true</use-parent-ipd-image-scaling>
+  </cfg>
+  <fo>
+      <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+          <fo:layout-master-set>
+              <fo:simple-page-master master-name="content" page-width="2cm">
+                  <fo:region-body/>
+              </fo:simple-page-master>
+          </fo:layout-master-set>
+          <fo:page-sequence master-reference="content">
+              <fo:flow flow-name="xsl-region-body">
+                  <fo:block>
+                      <fo:table table-layout="fixed" width="100%">
+                          <fo:table-column column-width="proportional-column-width(50)" column-number="1"/>
+                          <fo:table-column column-width="proportional-column-width(50)" column-number="2"/>
+                          <fo:table-body>
+                              <fo:table-row>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:external-graphic content-width="scale-up-to-fit" scaling="non-uniform" src="../resources/images/bgimg300dpi.jpg"/>
+                                      </fo:block>
+                                  </fo:table-cell>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:external-graphic content-width="scale-up-to-fit" scaling="non-uniform" src="../resources/images/bgimg300dpi.jpg"/>
+                                      </fo:block>
+                                  </fo:table-cell>
+                              </fo:table-row>
+                              <fo:table-row height="0.396874994039536cm">
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:external-graphic content-width="scale-up-to-fit" scaling="uniform" src="../resources/images/bgimg300dpi.jpg"/>
+                                      </fo:block>
+                                  </fo:table-cell>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:external-graphic content-width="scale-up-to-fit" scaling="uniform" src="../resources/images/bgimg300dpi.jpg"/>
+                                      </fo:block>
+                                  </fo:table-cell>
+                              </fo:table-row>
+                              <fo:table-row>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:instream-foreign-object background-color="yellow" content-width="scale-up-to-fit" scaling="non-uniform">
+                                              <svg:svg width="2cm" height="2cm" viewBox="0 0 30 30">
+                                                  <svg:circle cx="15" cy="15" r="14" fill="#0000ff" stroke="none"/>
+                                              </svg:svg>
+                                          </fo:instream-foreign-object>
+                                      </fo:block>
+                                  </fo:table-cell>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:instream-foreign-object background-color="yellow" content-width="scale-up-to-fit" scaling="non-uniform">
+                                              <svg:svg width="2cm" height="2cm" viewBox="0 0 30 30">
+                                                  <svg:circle cx="15" cy="15" r="14" fill="#0000ff" stroke="none"/>
+                                              </svg:svg>
+                                          </fo:instream-foreign-object>
+                                      </fo:block>
+                                  </fo:table-cell>
+                              </fo:table-row>
+                              <fo:table-row>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:instream-foreign-object background-color="yellow" content-width="scale-up-to-fit" scaling="uniform">
+                                              <svg:svg width="2cm" height="2cm" viewBox="0 0 30 30">
+                                                  <svg:circle cx="15" cy="15" r="14" fill="#0000ff" stroke="none"/>
+                                              </svg:svg>
+                                          </fo:instream-foreign-object>
+                                      </fo:block>
+                                  </fo:table-cell>
+                                  <fo:table-cell>
+                                      <fo:block text-align="center">
+                                          <fo:instream-foreign-object background-color="yellow" content-width="scale-up-to-fit" scaling="uniform">
+                                              <svg:svg width="2cm" height="2cm" viewBox="0 0 30 30">
+                                                  <svg:circle cx="15" cy="15" r="14" fill="#0000ff" stroke="none"/>
+                                              </svg:svg>
+                                          </fo:instream-foreign-object>
+                                      </fo:block>
+                                  </fo:table-cell>
+                              </fo:table-row>
+                          </fo:table-body>
+                      </fo:table>
+                  </fo:block>
+              </fo:flow>
+          </fo:page-sequence>
+      </fo:root>
+  </fo>
+  <checks>
+    <!-- width of the first table -->
+    <eval expected="28300" xpath="//flow/block/block/block/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="46080" xpath="//flow/block/block/block/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[2]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="46080" xpath="//flow/block/block/block[2]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[3]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="46080" xpath="//flow/block/block/block[3]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[4]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="46080" xpath="//flow/block/block/block[4]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[5]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="56692" xpath="//flow/block/block/block[5]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[6]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="56692" xpath="//flow/block/block/block[6]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[7]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="56692" xpath="//flow/block/block/block[7]/block/lineArea/viewport[1]/@bpd"/>
+    <eval expected="28300" xpath="//flow/block/block/block[8]/block/lineArea/viewport[1]/@ipd"/>
+    <eval expected="56692" xpath="//flow/block/block/block[8]/block/lineArea/viewport[1]/@bpd"/>
+  </checks>
+</testcase>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org