From 26df5d3099cf61227665a120fd55c4d5461265c7 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 8 Dec 2005 10:15:33 +0000 Subject: [PATCH] Looks like the 2-column situation has to be handled differently than the 3-column approach. The 4-column example shows that my current approach is not good enough and needs to be revisited. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@355063 13f79535-47bb-0310-9956-ffa450edef68 --- .../BalancingColumnBreakingAlgorithm.java | 14 ++- test/layoutengine/disabled-testcases.xml | 6 ++ .../region-body_column-count_balance_2col.xml | 71 +++++++++++++++ .../region-body_column-count_balance_4col.xml | 86 +++++++++++++++++++ 4 files changed, 173 insertions(+), 4 deletions(-) create mode 100644 test/layoutengine/standard-testcases/region-body_column-count_balance_2col.xml create mode 100644 test/layoutengine/standard-testcases/region-body_column-count_balance_4col.xml diff --git a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java index b3a887f34..77c8b43c4 100644 --- a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java @@ -76,12 +76,18 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm { log.trace("balance=" + balance); } double absBalance = Math.abs(balance); + dem = absBalance; //Step 1: This does the rough balancing - if (balance <= 0) { - dem = absBalance; + if (columnCount > 2) { + if (balance > 0) { + //shorter parts are less desired than longer ones + dem = dem * 1.2f; + } } else { - //shorter parts are less desired than longer ones - dem = absBalance * 1.2f; + if (balance < 0) { + //shorter parts are less desired than longer ones + dem = dem * 1.2f; + } } //Step 2: This helps keep the trailing parts shorter than the previous ones dem += (avgRestLen) / 1000f; diff --git a/test/layoutengine/disabled-testcases.xml b/test/layoutengine/disabled-testcases.xml index a4b3d64e6..0fe5c0c14 100755 --- a/test/layoutengine/disabled-testcases.xml +++ b/test/layoutengine/disabled-testcases.xml @@ -232,6 +232,12 @@ Footnotes may overlap with text of the region-body in multi-column documents. + + Column Balancing problems + region-body_column-count_balance_4col.xml + Situation in a 4-column document where the column balancing doesn't work and even causes some + content to disappear. + No background-images on table-body table-body_background-image.xml diff --git a/test/layoutengine/standard-testcases/region-body_column-count_balance_2col.xml b/test/layoutengine/standard-testcases/region-body_column-count_balance_2col.xml new file mode 100644 index 000000000..aacb350e4 --- /dev/null +++ b/test/layoutengine/standard-testcases/region-body_column-count_balance_2col.xml @@ -0,0 +1,71 @@ + + + + + +

+ This test checks multi-column documents. Checks column balancing with 2 columns. +

+
+ + + + + + + + + + + This line is spanned over all columns. + + + line1 + line2 + line3 + line4 + line5 + line6 + line7 + line8 + line9 + line10 + line11 + line12 + line13 + + + This line is spanned over all columns. + + + + + + + + + + + + + + + + + + +
diff --git a/test/layoutengine/standard-testcases/region-body_column-count_balance_4col.xml b/test/layoutengine/standard-testcases/region-body_column-count_balance_4col.xml new file mode 100644 index 000000000..5e131b1b1 --- /dev/null +++ b/test/layoutengine/standard-testcases/region-body_column-count_balance_4col.xml @@ -0,0 +1,86 @@ + + + + + +

+ This test checks multi-column documents. Checks column balancing with 4 columns. +

+
+ + + + + + + + + + + This line is spanned over all columns. + + + line1 + line2 + line3 + line4 + line5 + line6 + line7 + line8 + line9 + line10 + line11 + line12 + line13 + line14 + line15 + line16 + line17 + line18 + line19 + line20 + line21 + line22 + line23 + + + This line is spanned over all columns. + + + + + + + + + + + + + + + + + + + + + + + +
-- 2.39.5