From: Andreas L. Delmelle Date: Sun, 3 Apr 2011 10:10:46 +0000 (+0000) Subject: Bugzilla 50988: Fixed a NullPointerException in case a fo:character was removed due... X-Git-Tag: fop-1_1rc1old~245 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d13c4630adcca0c40704c063db2b3f93b6cfc3d7;p=xmlgraphics-fop.git Bugzilla 50988: Fixed a NullPointerException in case a fo:character was removed due to white-space handling. Thanks to Matthias Reischenbacher. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1088242 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java index 5dc5dd49d..d4867fb4a 100644 --- a/src/java/org/apache/fop/fo/FObjMixed.java +++ b/src/java/org/apache/fop/fo/FObjMixed.java @@ -50,6 +50,7 @@ public abstract class FObjMixed extends FObj { } /** {@inheritDoc} */ + @Override protected void characters(char[] data, int start, int length, PropertyList pList, Locator locator) throws FOPException { @@ -64,6 +65,7 @@ public abstract class FObjMixed extends FObj { } /** {@inheritDoc} */ + @Override protected void endOfNode() throws FOPException { super.endOfNode(); @@ -150,6 +152,7 @@ public abstract class FObjMixed extends FObj { } /** {@inheritDoc} */ + @Override protected void addChildNode(FONode child) throws FOPException { flushText(); @@ -169,6 +172,17 @@ public abstract class FObjMixed extends FObj { } /** {@inheritDoc} */ + @Override + public void removeChild(FONode child) { + super.removeChild(child); + if (child == this.currentTextNode) { + // reset to following sibling + this.currentTextNode = child.siblings != null ? child.siblings[1] : null; + } + } + + /** {@inheritDoc} */ + @Override public void finalizeNode() throws FOPException { flushText(); @@ -183,6 +197,7 @@ public abstract class FObjMixed extends FObj { * * @return iterator for this object */ + @Override public CharIterator charIterator() { return new RecursiveCharIterator(this); } diff --git a/test/layoutengine/standard-testcases/block_white-space_bug50988.xml b/test/layoutengine/standard-testcases/block_white-space_bug50988.xml new file mode 100644 index 000000000..eb44e7be7 --- /dev/null +++ b/test/layoutengine/standard-testcases/block_white-space_bug50988.xml @@ -0,0 +1,43 @@ + + + + + +

+ This test checks for a potential NullPointerException due to white-space removal. + See also: https://issues.apache.org/bugzilla/show_bug.cgi?id=50988 +

+
+ + + + + + + + + + + + + + + + + +
\ No newline at end of file