aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Lease <klease@apache.org>2002-02-25 21:28:28 +0000
committerKaren Lease <klease@apache.org>2002-02-25 21:28:28 +0000
commit6149a1b0be49d64f31d27c26c11f542fc642d246 (patch)
tree36aeedf42575cc8dae121fb7f93dd147ebad0a9a
parent8771aa888b2cbf704042dd6ff207e7c854f5a422 (diff)
downloadxmlgraphics-fop-6149a1b0be49d64f31d27c26c11f542fc642d246.tar.gz
xmlgraphics-fop-6149a1b0be49d64f31d27c26c11f542fc642d246.zip
Use CharUtilities instead of CharClass
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194673 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/org/apache/fop/fo/FONode.java3
-rw-r--r--src/org/apache/fop/fo/InlineCharIterator.java5
-rw-r--r--src/org/apache/fop/fo/flow/Block.java16
-rw-r--r--src/org/apache/fop/util/CharUtilities.java56
4 files changed, 55 insertions, 25 deletions
diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java
index 9f2d5aae5..55fde4fee 100644
--- a/src/org/apache/fop/fo/FONode.java
+++ b/src/org/apache/fop/fo/FONode.java
@@ -11,6 +11,7 @@ package org.apache.fop.fo;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.StreamRenderer;
import org.apache.fop.layout.Area;
+import org.apache.fop.util.CharUtilities;
import org.apache.log.Logger;
@@ -121,7 +122,7 @@ abstract public class FONode {
}
public CharIterator charIterator() {
- return new OneCharIterator(CharClass.CODE_EOT);
+ return new OneCharIterator(CharUtilities.CODE_EOT);
}
}
diff --git a/src/org/apache/fop/fo/InlineCharIterator.java b/src/org/apache/fop/fo/InlineCharIterator.java
index f8d048814..fe2a8eeda 100644
--- a/src/org/apache/fop/fo/InlineCharIterator.java
+++ b/src/org/apache/fop/fo/InlineCharIterator.java
@@ -1,6 +1,7 @@
package org.apache.fop.fo;
import org.apache.fop.layout.BorderAndPadding;
+import org.apache.fop.util.CharUtilities;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.NoSuchElementException;
@@ -36,7 +37,7 @@ public class InlineCharIterator extends RecursiveCharIterator {
public char nextChar() throws NoSuchElementException {
if (bStartBoundary) {
bStartBoundary=false;
- return CharClass.CODE_EOT;
+ return CharUtilities.CODE_EOT;
}
try {
return super.nextChar();
@@ -46,7 +47,7 @@ public class InlineCharIterator extends RecursiveCharIterator {
// Check end boundary char
if (bEndBoundary) {
bEndBoundary=false;
- return CharClass.CODE_EOT;
+ return CharUtilities.CODE_EOT;
}
else throw e;
}
diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java
index ba1b22ec4..3dc075b97 100644
--- a/src/org/apache/fop/fo/flow/Block.java
+++ b/src/org/apache/fop/fo/flow/Block.java
@@ -15,6 +15,7 @@ import org.apache.fop.datatypes.*;
import org.apache.fop.apps.FOPException;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.BlockLayoutManager;
+import org.apache.fop.util.CharUtilities;
import org.xml.sax.Attributes;
@@ -406,8 +407,8 @@ public class Block extends FObjMixed {
LFchecker lfCheck = new LFchecker(charIter);
while (charIter.hasNext()) {
- switch (CharClass.classOf(charIter.nextChar())) {
- case CharClass.XMLWHITESPACE:
+ switch (CharUtilities.classOf(charIter.nextChar())) {
+ case CharUtilities.XMLWHITESPACE:
/* Some kind of whitespace character, except linefeed. */
boolean bIgnore=false;
@@ -440,7 +441,7 @@ public class Block extends FObjMixed {
}
break;
- case CharClass.LINEFEED:
+ case CharUtilities.LINEFEED:
/* A linefeed */
lfCheck.reset();
bPrevWasLF=true; // for following whitespace
@@ -468,14 +469,14 @@ public class Block extends FObjMixed {
}
break;
- case CharClass.EOT:
+ case CharUtilities.EOT:
// A "boundary" objects such as non-character inline
// or nested block object was encountered.
// If any whitespace run in progress, finish it.
// FALL THROUGH
- case CharClass.UCWHITESPACE: // Non XML-whitespace
- case CharClass.NONWHITESPACE:
+ case CharUtilities.UCWHITESPACE: // Non XML-whitespace
+ case CharUtilities.NONWHITESPACE:
/* Any other character */
bInWS = bPrevWasLF=false;
lfCheck.reset();
@@ -503,7 +504,8 @@ public class Block extends FObjMixed {
bNextIsLF=true;
break;
}
- else if (CharClass.classOf(c)!=CharClass.XMLWHITESPACE) {
+ else if (CharUtilities.classOf(c) !=
+ CharUtilities.XMLWHITESPACE) {
break;
}
}
diff --git a/src/org/apache/fop/util/CharUtilities.java b/src/org/apache/fop/util/CharUtilities.java
index f8bcc7edc..14187a5ea 100644
--- a/src/org/apache/fop/util/CharUtilities.java
+++ b/src/org/apache/fop/util/CharUtilities.java
@@ -10,9 +10,36 @@ package org.apache.fop.util;
import org.apache.fop.layout.FontState;
/**
+ * This class provides utilities to distinguish various kinds of Unicode
+ * whitespace and to get character widths in a given FontState.
*/
public class CharUtilities {
+ /** Character code used to signal a character boundary in
+ * inline content, such as an inline with borders and padding
+ * or a nested block object.
+ */
+ public static final char CODE_EOT=0;
+
+ public static final int UCWHITESPACE=0; // unicode white space
+ public static final int LINEFEED=1;
+ public static final int EOT=2; // Boundary beteween text runs
+ public static final int NONWHITESPACE=3;
+ public static final int XMLWHITESPACE=4;
+
+
+ /**
+ * Return the appropriate CharClass constant for the type
+ * of the passed character.
+ */
+ public static int classOf(char c) {
+ if (c == CODE_EOT) return EOT;
+ if (c == '\n') return LINEFEED;
+ if ( c==' '|| c == '\r' || c=='\t' ) return XMLWHITESPACE;
+ if (isAnySpace(c)) return UCWHITESPACE;
+ return NONWHITESPACE;
+ }
+
/**
* Helper method for getting the width of a unicode char
* from the current fontstate.
@@ -76,21 +103,20 @@ public class CharUtilities {
* it's not non-breaking
*/
public static boolean isSpace(char c) {
- if (c == ' ' || c == '\u2000' || // en quad
- c == '\u2001' || // em quad
- c == '\u2002' || // en space
- c == '\u2003' || // em space
- c == '\u2004' || // three-per-em space
- c == '\u2005' || // four--per-em space
- c == '\u2006' || // six-per-em space
- c == '\u2007' || // figure space
- c == '\u2008' || // punctuation space
- c == '\u2009' || // thin space
- c == '\u200A' || // hair space
- c == '\u200B') // zero width space
- return true;
- else
- return false;
+ return (c == ' ' ||
+ (c >= '\u2000' && c <= '\u200B'));
+// c == '\u2000' // en quad
+// c == '\u2001' // em quad
+// c == '\u2002' // en space
+// c == '\u2003' // em space
+// c == '\u2004' // three-per-em space
+// c == '\u2005' // four--per-em space
+// c == '\u2006' // six-per-em space
+// c == '\u2007' // figure space
+// c == '\u2008' // punctuation space
+// c == '\u2009' // thin space
+// c == '\u200A' // hair space
+// c == '\u200B' // zero width space
}
/**