]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla 47710: White-space handling in retrieved markers throws a NullPointerExcepti...
authorAndreas L. Delmelle <adelmelle@apache.org>
Thu, 20 Aug 2009 21:15:52 +0000 (21:15 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Thu, 20 Aug 2009 21:15:52 +0000 (21:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@806361 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/FOTreeBuilder.java
src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java
status.xml
test/layoutengine/standard-testcases/marker_white-space_npe.xml [new file with mode: 0644]

index 7c77f06975b67a68d42d8ff8b86e78ff5f9be36d..b1fe3bc13e6b24df6ad2c186a2648a8d5433200a 100644 (file)
@@ -39,6 +39,7 @@ import org.apache.fop.apps.FormattingResults;
 import org.apache.fop.area.AreaTreeHandler;
 import org.apache.fop.fo.ElementMapping.Maker;
 import org.apache.fop.fo.extensions.ExtensionElementMapping;
+import org.apache.fop.fo.extensions.pdf.PDFExtensionElementMapping;
 import org.apache.fop.fo.pagination.Root;
 import org.apache.fop.util.ContentHandlerFactory;
 import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
@@ -263,7 +264,8 @@ public class FOTreeBuilder extends DefaultHandler {
                 }
             } else { // check that incoming node is valid for currentFObj
                 if (currentFObj.getNamespaceURI().equals(FOElementMapping.URI)
-                    || currentFObj.getNamespaceURI().equals(ExtensionElementMapping.URI)) {
+                    || currentFObj.getNamespaceURI().equals(ExtensionElementMapping.URI)
+                    || currentFObj.getNamespaceURI().equals(PDFExtensionElementMapping.URI)) {
                     currentFObj.validateChildNode(locator, namespaceURI, localName);
                 }
             }
@@ -277,6 +279,7 @@ public class FOTreeBuilder extends DefaultHandler {
                     rootFObj.setBuilderContext(builderContext);
                     rootFObj.setFOEventHandler(foEventHandler);
                 }
+                builderContext.foIndex++;
                 propertyList = foNode.createPropertyList(
                                     currentPropertyList, foEventHandler);
                 foNode.processNode(localName, getEffectiveLocator(),
@@ -288,6 +291,9 @@ public class FOTreeBuilder extends DefaultHandler {
                         builderContext.switchMarkerContext(true);
                     }
                 }
+                if (foNode.getNameId() == Constants.FO_PAGE_SEQUENCE) {
+                    builderContext.getXMLWhiteSpaceHandler().reset();
+                }
             } catch (IllegalArgumentException e) {
                 throw new SAXException(e);
             }
index cad9fb729ae8800a83ace344e01ba6c6746d55ad..51e84551ce09781c85abf0c989eaddec3296d3e4 100644 (file)
@@ -233,6 +233,18 @@ public class XMLWhiteSpaceHandler {
         }
     }
 
+    /**
+     * Reset the handler, release all references
+     */
+    protected final void reset() {
+        if (pendingInlines != null) {
+            pendingInlines.clear();
+        }
+        nestedBlockStack.clear();
+        charIter = null;
+        firstWhiteSpaceInSeq = null;
+    }
+
     /**
      * Handle white-space for the fo that is passed in, starting at
      * firstTextNode (when a nested FO is encountered)
index 17787f88396e84bf6df00f29434ea946d9dfbe6b..57ea52204e2b41af1dae88c4094c0816a48f0074 100644 (file)
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Code" dev="AD" type="fix" fixes-bug="47710">
+        White-space handling in markers with inline-content throws a NullPointerException
+        in some cases.
+      </action>
       <action context="Renderers" dev="CB" type="fix" fixes-bug="47694">
-        Dithered Background Shading can produce illegal AFP if objects are very small 
+        Dithered Background Shading can produce illegal AFP if objects are very small
       </action>
       <action context="Renderers" dev="CB" type="add">
         AFP Output: Added support for IMM Extension on fo:simple-page-master.
diff --git a/test/layoutengine/standard-testcases/marker_white-space_npe.xml b/test/layoutengine/standard-testcases/marker_white-space_npe.xml
new file mode 100644 (file)
index 0000000..f9f8e03
--- /dev/null
@@ -0,0 +1,77 @@
+<?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 NPE after white-space handling\r
+      for retrieved markers with only inline content.\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 margin-right="6mm" margin-left="7mm" margin-bottom="4mm" margin-top="5mm" page-width="210mm" page-height="297mm" master-name="letterPageFront">\r
+          <fo:region-body margin-right="59mm" margin-left="8mm" margin-top="53mm" margin-bottom="57mm" region-name="letterPageBody"/>\r
+          <fo:region-after precedence="false" extent="52mm" region-name="letterPageFooter"/>\r
+          <fo:region-end precedence="true" extent="49mm" region-name="letterPageSidebar"/>\r
+        </fo:simple-page-master>\r
+      </fo:layout-master-set>\r
+      <fo:page-sequence initial-page-number="1" page-break-before="right" master-reference="letterPageFront">\r
+        <fo:flow flow-name="letterPageBody">\r
+          <fo:block>page 1</fo:block>\r
+        </fo:flow>\r
+      </fo:page-sequence>\r
+      <fo:page-sequence master-reference="letterPageFront">\r
+        <fo:static-content flow-name="letterPageFooter">\r
+          <fo:block text-align="right" margin-right="1cm" margin-left="8mm">\r
+            <fo:retrieve-marker retrieve-position="last-ending-within-page" retrieve-boundary="page-sequence" retrieve-class-name="statementFooterMarker"/>\r
+          </fo:block>\r
+        </fo:static-content>\r
+        <fo:flow flow-name="letterPageBody">\r
+          <fo:block>\r
+            <fo:block font="bold 16pt Arial">\r
+              <fo:block>\r
+                <fo:marker marker-class-name="statementFooterMarker">\r
+                  <fo:inline font-family="HelveticaNeue-LightCond" font-size="11pt" line-height="13pt" text-align="right">Test Marker</fo:inline>\r
+                </fo:marker>\r
+              </fo:block>\r
+            </fo:block>\r
+            <fo:block break-before="page">\r
+              <fo:block>\r
+                <fo:marker marker-class-name="statementFooterMarker"/>\r
+              </fo:block>\r
+            </fo:block>\r
+          </fo:block>\r
+          <fo:block id="TH_LastPage"/>\r
+        </fo:flow>\r
+      </fo:page-sequence>\r
+      <fo:page-sequence master-reference="letterPageFront">\r
+        <fo:static-content flow-name="letterPageSidebar">\r
+          <fo:block-container height="284mm">\r
+            <fo:block> </fo:block>\r
+          </fo:block-container>\r
+        </fo:static-content>\r
+        <fo:flow break-before="odd-page" flow-name="letterPageBody">\r
+          <fo:block>last page</fo:block>\r
+        </fo:flow>\r
+      </fo:page-sequence>\r
+    </fo:root>\r
+  </fo>\r
+  <checks /><!-- none except the default; simply check for non-occurrence of NPE -->\r
+</testcase>\r