From b0ece6c49dde5f2ddc6c38338e51a1e8d9131264 Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Thu, 20 Aug 2009 21:15:52 +0000 Subject: [PATCH] Bugzilla 47710: White-space handling in retrieved markers throws a NullPointerException in some cases. 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 | 8 +- .../apache/fop/fo/XMLWhiteSpaceHandler.java | 12 +++ status.xml | 6 +- .../marker_white-space_npe.xml | 77 +++++++++++++++++++ 4 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 test/layoutengine/standard-testcases/marker_white-space_npe.xml diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 7c77f0697..b1fe3bc13 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -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); } diff --git a/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java b/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java index cad9fb729..51e84551c 100644 --- a/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java +++ b/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java @@ -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) diff --git a/status.xml b/status.xml index 17787f883..57ea52204 100644 --- a/status.xml +++ b/status.xml @@ -58,8 +58,12 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + White-space handling in markers with inline-content throws a NullPointerException + in some cases. + - Dithered Background Shading can produce illegal AFP if objects are very small + Dithered Background Shading can produce illegal AFP if objects are very small 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 index 000000000..f9f8e0313 --- /dev/null +++ b/test/layoutengine/standard-testcases/marker_white-space_npe.xml @@ -0,0 +1,77 @@ + + + + + +

+ This test checks for a potential NPE after white-space handling + for retrieved markers with only inline content. +

+
+ + + + + + + + + + + + page 1 + + + + + + + + + + + + + + Test Marker + + + + + + + + + + + + + + + + + + + + last page + + + + + +
-- 2.39.5