(Sorry for sending this as a new post, but seems my reply didn't come through again ... *sigh*)


In the meantime, I've locally patched FOP to correctly deal with this.

Patch consists of a few changes in TableBody, TableRow and PercentLength. The latter only because I needed to have some way to be able to get the percentage value of the cell-width, divide it by the number of columns spanned, and construct a new PercentLength with the percentage distributed over the number of columns.

Full patch below.

If no one objects, I'll commit this to the trunk and the release branch, together with a few testcases, so this issue is out of the way.

Cheers,

Andreas

Index: src/java/org/apache/fop/fo/flow/TableBody.java
===================================================================
--- src/java/org/apache/fop/fo/flow/TableBody.java (revision 489884)
+++ src/java/org/apache/fop/fo/flow/TableBody.java      (working copy)
@@ -40,6 +40,9 @@
import org.apache.fop.fo.properties.CommonAural;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.CommonRelativePosition;
+import org.apache.fop.fo.properties.FixedLength;
+import org.apache.fop.fo.properties.LengthProperty;
+import org.apache.fop.fo.properties.PercentLength;
/**
  * Class modelling the fo:table-body object.
@@ -201,9 +204,16 @@
                     int colSpan = cell.getNumberColumnsSpanned();
                     Length colWidth = null;
-                    if (cell.getWidth().getEnum() != EN_AUTO
-                            && colSpan == 1) {
-                        colWidth = cell.getWidth();
+                    if (cell.getWidth().getEnum() != EN_AUTO) {
+ LengthProperty p = (LengthProperty) cell.getWidth();
+                        if (p instanceof FixedLength) {
+ colWidth = new FixedLength(p.getValue () / colSpan);
+                        } else if (p instanceof PercentLength) {
+ PercentLength pctLength = (PercentLength) p; + double factor = pctLength.getPercentage () / 100; + colWidth = new PercentLength(factor / colSpan,
+                                            pctLength.getBaseLength());
+                        }
                     }

                     for (int i = colNr; i < colNr + colSpan; ++i) {
Index: src/java/org/apache/fop/fo/flow/TableRow.java
===================================================================
--- src/java/org/apache/fop/fo/flow/TableRow.java (revision 489884)
+++ src/java/org/apache/fop/fo/flow/TableRow.java       (working copy)
@@ -34,8 +34,11 @@
import org.apache.fop.fo.properties.CommonAural;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.CommonRelativePosition;
+import org.apache.fop.fo.properties.FixedLength;
import org.apache.fop.fo.properties.KeepProperty;
+import org.apache.fop.fo.properties.LengthProperty;
import org.apache.fop.fo.properties.LengthRangeProperty;
+import org.apache.fop.fo.properties.PercentLength;
/**
  * Class modelling the fo:table-row object.
@@ -133,9 +136,16 @@
                 int colSpan = cell.getNumberColumnsSpanned();
                 Length colWidth = null;
-                if (cell.getWidth().getEnum() != EN_AUTO
-                        && colSpan == 1) {
-                    colWidth = cell.getWidth();
+                if (cell.getWidth().getEnum() != EN_AUTO) {
+ LengthProperty p = (LengthProperty) cell.getWidth ();
+                    if (p instanceof FixedLength) {
+ colWidth = new FixedLength(p.getValue() / colSpan);
+                    } else if (p instanceof PercentLength) {
+                        PercentLength pctLength = (PercentLength) p;
+ double factor = pctLength.getPercentage() / 100;
+                        colWidth = new PercentLength(factor / colSpan,
+                                        pctLength.getBaseLength());
+                    }
                 }

                 for (int i = colNr; i < colNr + colSpan; ++i) {
Index: src/java/org/apache/fop/fo/properties/PercentLength.java
===================================================================
--- src/java/org/apache/fop/fo/properties/PercentLength.java (revision 489884) +++ src/java/org/apache/fop/fo/properties/PercentLength.java (working copy)
@@ -68,8 +68,8 @@
      *
      * @return the percentage value
      */
-    protected double getPercentage() {
-        return factor * 100;
+    public double getPercentage() {
+        return factor * 100.0;
     }
     /**

Reply via email to