You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Andreas L Delmelle <a_...@pandora.be> on 2006/12/24 10:56:33 UTC
Columns from first row (continued)
(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;
}
/**
Re: Columns from first row (continued)
Posted by Andreas L Delmelle <a_...@pandora.be>.
On Dec 25, 2006, at 10:08, Simon Pepping wrote:
> If I am correct, your only patch to the release 0.93 branch concerns
> the replacement of a hash map with a weak has map. That is OK.
OK, sorry.
That one I only committed since Jeremias' remark was very right, and
it influences behaviour in production environments.
I'll commit other patches only to the trunk for now.
Cheers,
Andreas
Re: Columns from first row (continued)
Posted by Simon Pepping <sp...@leverkruid.eu>.
Andreas,
If I am correct, your only patch to the release 0.93 branch concerns
the replacement of a hash map with a weak has map. That is OK.
Please, do not commit any other patches to the release branch. If you
are really uncertain that this state of the code is fit to be part of
a production release, please revert it to an earlier _known_ stable
state.
I have checked that the current code passes all tests.
Regards, Simon
On Mon, Dec 25, 2006 at 12:54:31AM +0100, Andreas L Delmelle wrote:
> On Dec 24, 2006, at 10:56, Andreas L Delmelle wrote:
>
> >In the meantime, I've locally patched FOP to correctly deal with this.
>
> Forget it. Too simplistic. After running a few thorough tests,
> percentages are still not correctly distributed... :(
>
> Works nicely for FixedLength though.
>
> I'll still work out the percentage bit, and try to get it out of the
> way before the release.
>
> Stay tuned.
>
> Cheers,
>
> Andreas
>
--
Simon Pepping
home page: http://www.leverkruid.eu
Re: Columns from first row (continued)
Posted by Andreas L Delmelle <a_...@pandora.be>.
On Dec 24, 2006, at 10:56, Andreas L Delmelle wrote:
> In the meantime, I've locally patched FOP to correctly deal with this.
Forget it. Too simplistic. After running a few thorough tests,
percentages are still not correctly distributed... :(
Works nicely for FixedLength though.
I'll still work out the percentage bit, and try to get it out of the
way before the release.
Stay tuned.
Cheers,
Andreas