From 74b2adc7ebb1c898d17bc5778de412522512d4c8 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 28 Jan 2008 10:32:46 +0000 Subject: [PATCH] Improve breaking for block-container and static-content so there are no more "breaking artifacts" (like additional border lines) in the overflowing part of the content anymore. This is done by removing all breaks from the result list prior to constructing the area tree. The presence of breaks simply indicates that there is an overflow. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@615845 13f79535-47bb-0310-9956-ffa450edef68 --- .../BlockContainerLayoutManager.java | 9 +-- .../fop/layoutmgr/PageBreakingAlgorithm.java | 14 +++++ .../layoutmgr/StaticContentLayoutManager.java | 10 ++- ...lock-container_content_size_percentage.xml | 4 +- .../block-container_overflow_2.xml | 53 ++++++++++++++++ .../static-content_overflow_1.xml | 62 +++++++++++++++++++ 6 files changed, 140 insertions(+), 12 deletions(-) create mode 100644 test/layoutengine/standard-testcases/block-container_overflow_2.xml create mode 100644 test/layoutengine/standard-testcases/static-content_overflow_1.xml diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index ab153090b..3d9076efd 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -355,10 +355,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager MinOptMax range = new MinOptMax(relDims.ipd); BlockContainerBreaker breaker = new BlockContainerBreaker(this, range); breaker.doLayout(relDims.bpd, autoHeight); - boolean contentOverflows = false; - if (!breaker.isEmpty()) { - contentOverflows = (breaker.deferredAlg.getPageBreaks().size() > 1); - } + boolean contentOverflows = breaker.isOverflow(); Position bcPosition = new BlockContainerPosition(this, breaker); returnList.add(new KnuthBox(vpContentBPD, notifyPos(bcPosition), false)); @@ -648,9 +645,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } //Rendering all parts (not just the first) at once for the case where the parts that //overflow should be visible. - //TODO Check if this has any unwanted side-effects. Feels a bit like a hack. + this.deferredAlg.removeAllPageBreaks(); this.addAreas(this.deferredAlg, - /*1*/ this.deferredAlg.getPageBreaks().size(), + this.deferredAlg.getPageBreaks().size(), this.deferredOriginalList, this.deferredEffectiveList); } diff --git a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java index 32c2b8d3b..57fc4600e 100644 --- a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java @@ -734,6 +734,20 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { pageBreaks.addFirst(pageBreak); } + /** + * Removes all page breaks from the result list. This is used by block-containers and + * static-content when it is only desired to know where there is an overflow but later the + * whole content should be painted as one part. + */ + public void removeAllPageBreaks() { + if (pageBreaks == null) { + return; + } + while (pageBreaks.size() > 1) { + pageBreaks.removeFirst(); + } + } + private int getPartCount() { if (pageBreaks == null) { return 0; diff --git a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java index 92437a452..c8b89e6af 100644 --- a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java @@ -25,9 +25,10 @@ import java.util.ListIterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.fop.area.RegionReference; + import org.apache.fop.area.Area; import org.apache.fop.area.Block; +import org.apache.fop.area.RegionReference; import org.apache.fop.fo.FONode; import org.apache.fop.fo.pagination.PageSequence; import org.apache.fop.fo.pagination.SideRegion; @@ -339,11 +340,14 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { protected void doPhase3(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { - //Directly add areas after finding the breaks - this.addAreas(alg, partCount, originalList, effectiveList); if (partCount > 1) { overflow = true; } + //Rendering all parts (not just the first) at once for the case where the parts that + //overflow should be visible. + alg.removeAllPageBreaks(); + //Directly add areas after finding the breaks + this.addAreas(alg, 1, originalList, effectiveList); } protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp) { diff --git a/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml b/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml index 14d09a5d6..c3b11805c 100644 --- a/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml +++ b/test/layoutengine/standard-testcases/block-container_content_size_percentage.xml @@ -78,9 +78,7 @@ - + - - diff --git a/test/layoutengine/standard-testcases/block-container_overflow_2.xml b/test/layoutengine/standard-testcases/block-container_overflow_2.xml new file mode 100644 index 000000000..5fe97e7c3 --- /dev/null +++ b/test/layoutengine/standard-testcases/block-container_overflow_2.xml @@ -0,0 +1,53 @@ + + + + + +

+ This test checks behaviour with overflowing content on block-containers. +

+

+ Visual check: If there's a red line between the second and third line, the + behaviour is wrong. +

+
+ + + + + + + + + + + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque hendrerit euismod velit. Nulla facilisi. Etiam et risus at neque ultrices facilisis. Donec lectus est, nonummy quis, rhoncus bibendum, porta at, nisl. + + + + + + + + + + + + + +
diff --git a/test/layoutengine/standard-testcases/static-content_overflow_1.xml b/test/layoutengine/standard-testcases/static-content_overflow_1.xml new file mode 100644 index 000000000..b620f018c --- /dev/null +++ b/test/layoutengine/standard-testcases/static-content_overflow_1.xml @@ -0,0 +1,62 @@ + + + + + +

+ This test checks behaviour with overflowing content on static-content. +

+

+ Visual check: If there's a red line between the second and third line, the + behaviour is wrong. +

+
+ + + + + + + + + + + + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque hendrerit euismod velit. Nulla facilisi. Etiam et risus at neque ultrices facilisis. Donec lectus est, nonummy quis, rhoncus bibendum, porta at, nisl. + + + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque hendrerit euismod velit. Nulla facilisi. Etiam et risus at neque ultrices facilisis. Donec lectus est, nonummy quis, rhoncus bibendum, porta at, nisl. + + + xsl-region-body + + + + + + + + + + + + + + + +
-- 2.39.5