]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixed problem with linefeed-treatment=preserve not being correctly handled for text...
authorManuel Mall <manuel@apache.org>
Fri, 23 Dec 2005 11:27:07 +0000 (11:27 +0000)
committerManuel Mall <manuel@apache.org>
Fri, 23 Dec 2005 11:27:07 +0000 (11:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@358792 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
test/layoutengine/disabled-testcases.xml
test/layoutengine/standard-testcases/block_linefeed-treatment_2.xml

index 8b0f54256a4c3a54f10a68942ffda414ce8e2a22..5650c3e8028e7430e95f72d9b159c269ad49ce2e 100755 (executable)
@@ -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;
index adad62799e0805d4df0d3697fc3316d4e7de371c..5c927b4700899fa0adc47197c0a7795eb07fcfae 100644 (file)
@@ -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 
index 6504e6962faa633499e84a04668d36d8d18ef81a..43c347998a43b784af5ba9b6d668b69f91e3ff96 100755 (executable)
     correctly. Zero width space characters are not handled
     correctly.</description>
   </testcase>
-  <testcase>
-    <name>linefeed treatment 2</name>
-    <file>block_linefeed-treatment_2.xml</file>
-    <description>This test checks linefeed preservation between and at
-    the start of fo:inline elements.</description>
-    <reference>http://marc.theaimsgroup.com/?t=113525808000001</reference>
-  </testcase>
   <testcase>
     <name>Empty blocks produce fences</name>
     <file>block_space-before_space-after_8.xml</file>
index 016c27b2b66fe0c74c7c6be114ffb53077b7eab7..bb9587ec516718dffd10c906bc98dcab8b48a67c 100644 (file)
@@ -36,19 +36,29 @@ of fo:inline elements.
       </fo:layout-master-set>
       <fo:page-sequence master-reference="master">
         <fo:flow flow-name="xsl-region-body">
-          <fo:block linefeed-treatment="preserve" text-align="center">
+          <fo:block background-color="silver"
+                    linefeed-treatment="preserve" text-align="center"
+                    margin-top="10pt" margin-bottom="10pt">
             <fo:inline font-weight="bold">Leasing a ...</fo:inline>
+
             <fo:inline>Contrat Nr.: W-113283...</fo:inline>
           </fo:block>
-          <fo:block linefeed-treatment="preserve" text-align="center">
+          <fo:block background-color="yellow"
+                    linefeed-treatment="preserve" text-align="center"
+                    margin-top="10pt" margin-bottom="10pt">
             <fo:inline font-weight="bold">Leasing a ...</fo:inline>
             <fo:inline>&#10;Contrat Nr.: W-113283...</fo:inline>
           </fo:block>
-          <fo:block linefeed-treatment="preserve">
+          <fo:block background-color="silver"
+                    linefeed-treatment="preserve"
+                    margin-top="10pt" margin-bottom="10pt">
             <fo:inline font-weight="bold">Leasing a ...</fo:inline>
+
             <fo:inline>Contrat Nr.: W-113283...</fo:inline>
           </fo:block>
-          <fo:block linefeed-treatment="preserve">
+          <fo:block background-color="yellow"
+                    linefeed-treatment="preserve"
+                    margin-top="10pt" margin-bottom="10pt">
             <fo:inline font-weight="bold">Leasing a ...</fo:inline>
             <fo:inline>&#10;Contrat Nr.: W-113283...</fo:inline>
           </fo:block>
@@ -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.
 -->
-    <eval expected="3" xpath="count(//flow/block[1]/lineArea)"/>
+    <eval expected="4" xpath="count(//flow/block[1]/lineArea)"/>
     <eval expected="4" xpath="count(//flow/block[2]/lineArea)"/>
-    <eval expected="3" xpath="count(//flow/block[3]/lineArea)"/>
+    <eval expected="4" xpath="count(//flow/block[3]/lineArea)"/>
     <eval expected="4" xpath="count(//flow/block[4]/lineArea)"/>
   </checks>
 </testcase>