]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla 50988: Fixed a NullPointerException in case a fo:character was removed due...
authorAndreas L. Delmelle <adelmelle@apache.org>
Sun, 3 Apr 2011 10:10:46 +0000 (10:10 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Sun, 3 Apr 2011 10:10:46 +0000 (10:10 +0000)
Thanks to Matthias Reischenbacher.

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

src/java/org/apache/fop/fo/FObjMixed.java
test/layoutengine/standard-testcases/block_white-space_bug50988.xml [new file with mode: 0644]

index 5dc5dd49d9aa0d0a54490a9e6ebc0a2a5165b250..d4867fb4af1f27d844ea2a6745bd05bacf061290 100644 (file)
@@ -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 (file)
index 0000000..eb44e7b
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+  Licensed to the Apache Software Foundation (ASF) under one or more\r
+  contributor license agreements.  See the NOTICE file distributed with\r
+  this work for additional information regarding copyright ownership.\r
+  The ASF licenses this file to You under the Apache License, Version 2.0\r
+  (the "License"); you may not use this file except in compliance with\r
+  the License.  You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+  Unless required by applicable law or agreed to in writing, software\r
+  distributed under the License is distributed on an "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  See the License for the specific language governing permissions and\r
+  limitations under the License.\r
+-->\r
+<!-- $Id$ -->\r
+<testcase>\r
+  <info>\r
+    <p>\r
+      This test checks for a potential NullPointerException due to white-space removal.\r
+      See also: https://issues.apache.org/bugzilla/show_bug.cgi?id=50988\r
+    </p>\r
+  </info>\r
+  <fo>\r
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">\r
+      <fo:layout-master-set>\r
+        <fo:simple-page-master master-name="even" page-height="210mm" page-width="148mm">\r
+          <fo:region-body margin="20mm"/>\r
+        </fo:simple-page-master>\r
+      </fo:layout-master-set>\r
+      <fo:page-sequence master-reference="even">\r
+        <fo:flow flow-name="xsl-region-body">\r
+          <fo:block><fo:character character=" " hyphenate="false"/></fo:block>\r
+          <fo:block><fo:character character=" " hyphenate="false"/><fo:character character="A" hyphenate="false"/></fo:block>\r
+        </fo:flow>\r
+      </fo:page-sequence>\r
+    </fo:root>\r
+  </fo>\r
+  <!-- Default checks only; should just not throw a NPE -->\r
+  <checks />\r
+</testcase>
\ No newline at end of file