]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Applied Luca Furini's patch from bugzilla entry 28021.
authorChris Bowditch <cbowditch@apache.org>
Fri, 2 Apr 2004 13:50:52 +0000 (13:50 +0000)
committerChris Bowditch <cbowditch@apache.org>
Fri, 2 Apr 2004 13:50:52 +0000 (13:50 +0000)
Corrections to behaviour of whitespace-treatment property

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197483 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/flow/Block.java

index 63f694b36827cbec7b2ec4dac010718760b02c70..159a67784141de63f397915c3f41bc4c6f88ce17 100644 (file)
@@ -256,7 +256,8 @@ public class Block extends FObjMixed {
             LFchecker lfCheck = new LFchecker(charIter);
 
             while (charIter.hasNext()) {
-                switch (CharUtilities.classOf(charIter.nextChar())) {
+                char currentChar = charIter.nextChar();
+                switch (CharUtilities.classOf(currentChar)) {
                     case CharUtilities.XMLWHITESPACE:
                         /* Some kind of whitespace character, except linefeed. */
                         boolean bIgnore = false;
@@ -275,8 +276,11 @@ public class Block extends FObjMixed {
                             case Constants.IGNORE_IF_AFTER_LINEFEED:
                                 bIgnore = bPrevWasLF;
                                 break;
+                            case Constants.PRESERVE:
+                                // nothing to do now, replacement takes place later
+                                break;
                         }
-                        // Handle ignore
+                        // Handle ignore and replacement
                         if (bIgnore) {
                             charIter.remove();
                         } else if (bWScollapse) {
@@ -290,8 +294,17 @@ public class Block extends FObjMixed {
                                 // encountered yet
                                 if (!bSeenNonWSYet) {
                                     charIter.remove();
+                                } else {
+                                    if (currentChar != '\u0020') {
+                                        charIter.replaceChar('\u0020');
+                                    }
                                 }
                             }
+                        } else {
+                            // !bWScollapse
+                            if (currentChar != '\u0020') {
+                                charIter.replaceChar('\u0020');
+                            }
                         }
                         break;