From: Manuel Mall Date: Fri, 23 Dec 2005 11:27:07 +0000 (+0000) Subject: Fixed problem with linefeed-treatment=preserve not being correctly handled for text... X-Git-Tag: fop-0_92-beta~267 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=40cf61859f22923df0877a930a55627cb4af2066;p=xmlgraphics-fop.git Fixed problem with linefeed-treatment=preserve not being correctly handled for text-align=center git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@358792 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java index 8b0f54256..5650c3e80 100755 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java @@ -362,7 +362,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { LayoutManager lastLM = null; // last child LM in this iterator while (parentIter.hasNext()) { pos = (NonLeafPosition) parentIter.next(); - if (pos.getPosition() != null) { + if (pos != null && pos.getPosition() != null) { positionList.add(pos.getPosition()); lastLM = pos.getPosition().getLM(); lastPos = pos; diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index adad62799..5c927b470 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -338,7 +338,19 @@ public class LineLayoutManager extends InlineStackingLayoutManager inlineLM.removeWordSpace(removedElements); } } - + + /** + * @return true if the sequence contains a box + */ + public boolean containsBox() { + for (int i = 0; i < this.size(); i++) { + KnuthElement el = (KnuthElement)this.get(i); + if (el.isBox()) { + return true; + } + } + return false; + } } private class LineBreakingAlgorithm extends BreakingAlgorithm { @@ -756,9 +768,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager == -KnuthPenalty.INFINITE) { // a penalty item whose value is -inf // represents a preserved linefeed, - // wich forces a line break + // which forces a line break lastPar.removeLast(); - if (lastPar.size() == 0) { + if (!lastPar.containsBox()) { //only a forced linefeed on this line //-> compensate with a zero width box lastPar.add(new KnuthInlineBox(0, null, null, false)); @@ -798,7 +810,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager } log.trace(trace); } - + /** * Find a set of breaking points. * This method is called only once by getNextBreakPoss, and it diff --git a/test/layoutengine/disabled-testcases.xml b/test/layoutengine/disabled-testcases.xml index 6504e6962..43c347998 100755 --- a/test/layoutengine/disabled-testcases.xml +++ b/test/layoutengine/disabled-testcases.xml @@ -55,13 +55,6 @@ correctly. Zero width space characters are not handled correctly. - - linefeed treatment 2 - block_linefeed-treatment_2.xml - This test checks linefeed preservation between and at - the start of fo:inline elements. - http://marc.theaimsgroup.com/?t=113525808000001 - Empty blocks produce fences block_space-before_space-after_8.xml diff --git a/test/layoutengine/standard-testcases/block_linefeed-treatment_2.xml b/test/layoutengine/standard-testcases/block_linefeed-treatment_2.xml index 016c27b2b..bb9587ec5 100644 --- a/test/layoutengine/standard-testcases/block_linefeed-treatment_2.xml +++ b/test/layoutengine/standard-testcases/block_linefeed-treatment_2.xml @@ -36,19 +36,29 @@ of fo:inline elements. - + Leasing a ... + Contrat Nr.: W-113283... - + Leasing a ... Contrat Nr.: W-113283... - + Leasing a ... + Contrat Nr.: W-113283... - + Leasing a ... Contrat Nr.: W-113283... @@ -61,12 +71,15 @@ of fo:inline elements. The result: Leasing a ... + Contract Nr.: W-... Leasing a ... + Contract Nr.: W-... Leasing a ... + Contract Nr.: W-... Leasing a ... @@ -77,9 +90,9 @@ The result for the second case is lacking the linefeed at the start of the fo:inline. The results for the first and second cases are lacking the linefeed before the first line. --> - + - +