From ce39d4c2fb899be5d8d705fe72e0153fde21e592 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Mon, 8 Apr 2013 11:51:52 +0000 Subject: [PATCH] FOP #2234: NPE when rendering a document with markers and accessibility is enabled git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1465599 13f79535-47bb-0310-9956-ffa450edef68 --- .../DummyStructureTreeEventHandler.java | 6 +- .../StructureTree2SAXEventAdapter.java | 10 +- .../StructureTreeEventHandler.java | 12 +- .../fo/FO2StructureTreeConverter.java | 76 +++++++- .../fo/StructureTreeEventTrigger.java | 87 ++++++++- .../fop/fo/DelegatingFOEventHandler.java | 32 ++++ .../org/apache/fop/fo/FOEventHandler.java | 52 ++++++ src/java/org/apache/fop/fo/FONode.java | 13 +- src/java/org/apache/fop/fo/FOText.java | 4 +- src/java/org/apache/fop/fo/FOTreeBuilder.java | 6 +- src/java/org/apache/fop/fo/FObj.java | 2 +- src/java/org/apache/fop/fo/FObjMixed.java | 12 +- .../fop/fo/extensions/ExternalDocument.java | 4 +- .../extensions/destination/Destination.java | 2 +- .../apache/fop/fo/flow/AbstractGraphics.java | 2 +- .../fop/fo/flow/AbstractListItemPart.java | 2 +- .../fo/flow/AbstractPageNumberCitation.java | 2 +- .../fop/fo/flow/AbstractRetrieveMarker.java | 30 +++- .../org/apache/fop/fo/flow/BasicLink.java | 6 +- src/java/org/apache/fop/fo/flow/Block.java | 4 +- .../apache/fop/fo/flow/BlockContainer.java | 4 +- .../org/apache/fop/fo/flow/Character.java | 4 +- .../apache/fop/fo/flow/ExternalGraphic.java | 2 +- src/java/org/apache/fop/fo/flow/Float.java | 2 +- src/java/org/apache/fop/fo/flow/Footnote.java | 4 +- .../org/apache/fop/fo/flow/FootnoteBody.java | 4 +- src/java/org/apache/fop/fo/flow/Inline.java | 4 +- .../apache/fop/fo/flow/InlineContainer.java | 2 +- .../fop/fo/flow/InstreamForeignObject.java | 4 +- src/java/org/apache/fop/fo/flow/Leader.java | 4 +- .../org/apache/fop/fo/flow/ListBlock.java | 4 +- src/java/org/apache/fop/fo/flow/ListItem.java | 4 +- .../org/apache/fop/fo/flow/ListItemBody.java | 4 +- .../org/apache/fop/fo/flow/ListItemLabel.java | 4 +- src/java/org/apache/fop/fo/flow/Marker.java | 4 +- .../apache/fop/fo/flow/MultiProperties.java | 2 +- .../org/apache/fop/fo/flow/MultiSwitch.java | 2 +- .../org/apache/fop/fo/flow/PageNumber.java | 6 +- .../fop/fo/flow/PageNumberCitation.java | 4 +- .../fop/fo/flow/PageNumberCitationLast.java | 4 +- .../apache/fop/fo/flow/RetrieveMarker.java | 18 ++ .../fop/fo/flow/RetrieveTableMarker.java | 17 ++ src/java/org/apache/fop/fo/flow/Wrapper.java | 4 +- .../org/apache/fop/fo/flow/table/Table.java | 4 +- .../fop/fo/flow/table/TableAndCaption.java | 2 +- .../apache/fop/fo/flow/table/TableBody.java | 4 +- .../fop/fo/flow/table/TableCaption.java | 2 +- .../apache/fop/fo/flow/table/TableCell.java | 4 +- .../apache/fop/fo/flow/table/TableFooter.java | 4 +- .../apache/fop/fo/flow/table/TableHeader.java | 4 +- .../apache/fop/fo/flow/table/TableRow.java | 4 +- .../fo/pagination/AbstractPageSequence.java | 2 +- .../ConditionalPageMasterReference.java | 2 +- .../fop/fo/pagination/Declarations.java | 2 +- .../org/apache/fop/fo/pagination/Flow.java | 4 +- .../fop/fo/pagination/LayoutMasterSet.java | 4 +- .../fop/fo/pagination/PageSequence.java | 4 +- .../fop/fo/pagination/PageSequenceMaster.java | 4 +- .../RepeatablePageMasterAlternatives.java | 4 +- .../RepeatablePageMasterReference.java | 2 +- .../org/apache/fop/fo/pagination/Root.java | 4 +- .../fop/fo/pagination/SimplePageMaster.java | 4 +- .../pagination/SinglePageMasterReference.java | 2 +- .../fop/fo/pagination/StaticContent.java | 4 +- .../fop/fo/pagination/bookmarks/Bookmark.java | 2 +- .../fo/pagination/bookmarks/BookmarkTree.java | 2 +- .../org/apache/fop/pdf/PDFStructElem.java | 5 +- .../extensions/AFPIncludeFormMapElement.java | 2 +- .../extensions/AFPInvokeMediumMapElement.java | 2 +- .../afp/extensions/AFPPageOverlayElement.java | 2 +- .../afp/extensions/AFPPageSetupElement.java | 2 +- .../AbstractAFPExtensionObject.java | 2 +- .../fop/render/intermediate/IFParser.java | 63 ++++--- .../fop/render/intermediate/IFSerializer.java | 3 + .../intermediate/IFStructureTreeBuilder.java | 48 ++++- .../pdf/PDFLogicalStructureHandler.java | 7 +- .../render/pdf/PDFStructureTreeBuilder.java | 17 +- .../extensions/PDFEmbeddedFileElement.java | 2 +- .../extensions/AbstractPSCommentElement.java | 2 +- .../AbstractPSExtensionElement.java | 2 +- .../extensions/AbstractPSExtensionObject.java | 2 +- .../ps/extensions/PSPageSetupCodeElement.java | 2 +- .../ps/extensions/PSSetPageDeviceElement.java | 2 +- .../ps/extensions/PSSetupCodeElement.java | 2 +- .../IFStructureTreeBuilderTestCase.java | 2 +- test/pdf/accessibility/markers.fo | 169 ++++++++++++++++++ test/pdf/accessibility/pdf/markers.pdf | Bin 0 -> 34636 bytes 87 files changed, 717 insertions(+), 170 deletions(-) create mode 100644 test/pdf/accessibility/markers.fo create mode 100644 test/pdf/accessibility/pdf/markers.pdf diff --git a/src/java/org/apache/fop/accessibility/DummyStructureTreeEventHandler.java b/src/java/org/apache/fop/accessibility/DummyStructureTreeEventHandler.java index c63c721e5..be1177635 100644 --- a/src/java/org/apache/fop/accessibility/DummyStructureTreeEventHandler.java +++ b/src/java/org/apache/fop/accessibility/DummyStructureTreeEventHandler.java @@ -42,7 +42,7 @@ public final class DummyStructureTreeEventHandler implements StructureTreeEventH } /** {@inheritDoc} */ - public StructureTreeElement startNode(String name, Attributes attributes) { + public StructureTreeElement startNode(String name, Attributes attributes, StructureTreeElement parent) { return null; } @@ -51,12 +51,12 @@ public final class DummyStructureTreeEventHandler implements StructureTreeEventH } /** {@inheritDoc} */ - public StructureTreeElement startImageNode(String name, Attributes attributes) { + public StructureTreeElement startImageNode(String name, Attributes attributes, StructureTreeElement parent) { return null; } /** {@inheritDoc} */ - public StructureTreeElement startReferencedNode(String name, Attributes attributes) { + public StructureTreeElement startReferencedNode(String name, Attributes attributes, StructureTreeElement parent) { return null; } diff --git a/src/java/org/apache/fop/accessibility/StructureTree2SAXEventAdapter.java b/src/java/org/apache/fop/accessibility/StructureTree2SAXEventAdapter.java index 7a375ef20..0b8073e57 100644 --- a/src/java/org/apache/fop/accessibility/StructureTree2SAXEventAdapter.java +++ b/src/java/org/apache/fop/accessibility/StructureTree2SAXEventAdapter.java @@ -87,7 +87,7 @@ public final class StructureTree2SAXEventAdapter implements StructureTreeEventHa } /** {@inheritDoc} */ - public StructureTreeElement startNode(String name, Attributes attributes) { + public StructureTreeElement startNode(String name, Attributes attributes, StructureTreeElement parent) { try { if (name.equals("#PCDATA")) { name = "marked-content"; @@ -115,13 +115,13 @@ public final class StructureTree2SAXEventAdapter implements StructureTreeEventHa } /** {@inheritDoc} */ - public StructureTreeElement startImageNode(String name, Attributes attributes) { - return startNode(name, attributes); + public StructureTreeElement startImageNode(String name, Attributes attributes, StructureTreeElement parent) { + return startNode(name, attributes, null); } /** {@inheritDoc} */ - public StructureTreeElement startReferencedNode(String name, Attributes attributes) { - return startNode(name, attributes); + public StructureTreeElement startReferencedNode(String name, Attributes attributes, StructureTreeElement parent) { + return startNode(name, attributes, null); } } diff --git a/src/java/org/apache/fop/accessibility/StructureTreeEventHandler.java b/src/java/org/apache/fop/accessibility/StructureTreeEventHandler.java index 46b724626..53c27130c 100644 --- a/src/java/org/apache/fop/accessibility/StructureTreeEventHandler.java +++ b/src/java/org/apache/fop/accessibility/StructureTreeEventHandler.java @@ -43,9 +43,11 @@ public interface StructureTreeEventHandler { * * @param name the name of the structure tree node * @param attributes the node properties + * @param parent the parent of the node. May be null, in which case the parent node is + * the node corresponding to the previous call to this method * @return the corresponding structure tree element */ - StructureTreeElement startNode(String name, Attributes attributes); + StructureTreeElement startNode(String name, Attributes attributes, StructureTreeElement parent); /** * Ends a structure tree node. @@ -59,9 +61,11 @@ public interface StructureTreeEventHandler { * * @param name the name of the structure tree node * @param attributes the node properties + * @param parent the parent of the node. May be null, in which case the parent node is + * the node corresponding to the previous call to this method * @return the corresponding structure tree element */ - StructureTreeElement startImageNode(String name, Attributes attributes); + StructureTreeElement startImageNode(String name, Attributes attributes, StructureTreeElement parent); /** * Starts a node that can be referenced by other nodes. This is usually a @@ -69,9 +73,11 @@ public interface StructureTreeEventHandler { * * @param name the name of the structure tree node * @param attributes the node properties + * @param parent the parent of the node. May be null, in which case the parent node is + * the node corresponding to the previous call to this method * @return the corresponding structure tree element */ - StructureTreeElement startReferencedNode(String name, Attributes attributes); + StructureTreeElement startReferencedNode(String name, Attributes attributes, StructureTreeElement parent); /** * Ends a page sequence structure tree node. diff --git a/src/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java b/src/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java index aaf112cb5..4614a7005 100644 --- a/src/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java +++ b/src/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java @@ -19,6 +19,8 @@ package org.apache.fop.accessibility.fo; +import java.util.HashMap; +import java.util.Map; import java.util.Stack; import org.xml.sax.SAXException; @@ -29,6 +31,7 @@ import org.apache.fop.fo.DelegatingFOEventHandler; import org.apache.fop.fo.FOEventHandler; import org.apache.fop.fo.FOText; import org.apache.fop.fo.extensions.ExternalDocument; +import org.apache.fop.fo.flow.AbstractRetrieveMarker; import org.apache.fop.fo.flow.BasicLink; import org.apache.fop.fo.flow.Block; import org.apache.fop.fo.flow.BlockContainer; @@ -46,6 +49,8 @@ import org.apache.fop.fo.flow.ListItemLabel; import org.apache.fop.fo.flow.PageNumber; import org.apache.fop.fo.flow.PageNumberCitation; import org.apache.fop.fo.flow.PageNumberCitationLast; +import org.apache.fop.fo.flow.RetrieveMarker; +import org.apache.fop.fo.flow.RetrieveTableMarker; import org.apache.fop.fo.flow.Wrapper; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; @@ -70,14 +75,30 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler { /** The top of the {@link converters} stack. */ private FOEventHandler converter; - private final Stack converters = new Stack(); + private Stack converters = new Stack(); - private final FOEventHandler structureTreeEventTrigger; + private final StructureTreeEventTrigger structureTreeEventTrigger; /** The descendants of some elements like fo:leader must be ignored. */ private final FOEventHandler eventSwallower = new FOEventHandler() { }; + private final Map states = new HashMap(); + + private static final class State { + + private final FOEventHandler converter; + + private final Stack converters; + + @SuppressWarnings("unchecked") + State(FO2StructureTreeConverter o) { + this.converter = o.converter; + this.converters = (Stack) o.converters.clone(); + } + + } + /** * Creates a new instance. * @@ -458,6 +479,57 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler { super.endWrapper(wrapper); } + @Override + public void startRetrieveMarker(RetrieveMarker retrieveMarker) { + converter.startRetrieveMarker(retrieveMarker); + saveState(retrieveMarker); + super.startRetrieveMarker(retrieveMarker); + } + + private void saveState(AbstractRetrieveMarker retrieveMarker) { + states.put(retrieveMarker, new State(this)); + } + + @Override + public void endRetrieveMarker(RetrieveMarker retrieveMarker) { + converter.endRetrieveMarker(retrieveMarker); + super.endRetrieveMarker(retrieveMarker); + } + + @Override + public void restoreState(RetrieveMarker retrieveMarker) { + restoreRetrieveMarkerState(retrieveMarker); + converter.restoreState(retrieveMarker); + super.restoreState(retrieveMarker); + } + + @SuppressWarnings("unchecked") + private void restoreRetrieveMarkerState(AbstractRetrieveMarker retrieveMarker) { + State state = states.get(retrieveMarker); + this.converter = state.converter; + this.converters = (Stack) state.converters.clone(); + } + + @Override + public void startRetrieveTableMarker(RetrieveTableMarker retrieveTableMarker) { + converter.startRetrieveTableMarker(retrieveTableMarker); + saveState(retrieveTableMarker); + super.startRetrieveTableMarker(retrieveTableMarker); + } + + @Override + public void endRetrieveTableMarker(RetrieveTableMarker retrieveTableMarker) { + converter.endRetrieveTableMarker(retrieveTableMarker); + super.endRetrieveTableMarker(retrieveTableMarker); + } + + @Override + public void restoreState(RetrieveTableMarker retrieveTableMarker) { + restoreRetrieveMarkerState(retrieveTableMarker); + converter.restoreState(retrieveTableMarker); + super.restoreState(retrieveTableMarker); + } + @Override public void character(Character c) { converter.character(c); diff --git a/src/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java b/src/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java index 6a763a6f6..1a59bebfb 100644 --- a/src/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java +++ b/src/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java @@ -19,7 +19,9 @@ package org.apache.fop.accessibility.fo; +import java.util.HashMap; import java.util.Locale; +import java.util.Map; import java.util.Stack; import javax.xml.XMLConstants; @@ -34,6 +36,7 @@ import org.apache.fop.fo.FOText; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fo.extensions.InternalElementMapping; import org.apache.fop.fo.flow.AbstractGraphics; +import org.apache.fop.fo.flow.AbstractRetrieveMarker; import org.apache.fop.fo.flow.BasicLink; import org.apache.fop.fo.flow.Block; import org.apache.fop.fo.flow.BlockContainer; @@ -50,6 +53,8 @@ import org.apache.fop.fo.flow.ListItemLabel; import org.apache.fop.fo.flow.PageNumber; import org.apache.fop.fo.flow.PageNumberCitation; import org.apache.fop.fo.flow.PageNumberCitationLast; +import org.apache.fop.fo.flow.RetrieveMarker; +import org.apache.fop.fo.flow.RetrieveTableMarker; import org.apache.fop.fo.flow.Wrapper; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; @@ -76,11 +81,30 @@ class StructureTreeEventTrigger extends FOEventHandler { private LayoutMasterSet layoutMasterSet; - private final Stack tables = new Stack
(); + private Stack
tables = new Stack
(); - private final Stack inTableHeader = new Stack(); + private Stack inTableHeader = new Stack(); - private final Stack locales = new Stack(); + private Stack locales = new Stack(); + + private final Map states = new HashMap(); + + private static final class State { + + private final Stack
tables; + + private final Stack inTableHeader; + + private final Stack locales; + + @SuppressWarnings("unchecked") + State(StructureTreeEventTrigger o) { + this.tables = (Stack
) o.tables.clone(); + this.inTableHeader = (Stack) o.inTableHeader.clone(); + this.locales = (Stack) o.locales.clone(); + } + + } public StructureTreeEventTrigger(StructureTreeEventHandler structureTreeEventHandler) { this.structureTreeEventHandler = structureTreeEventHandler; @@ -414,6 +438,50 @@ class StructureTreeEventTrigger extends FOEventHandler { endElement(wrapper); } + @Override + public void startRetrieveMarker(RetrieveMarker retrieveMarker) { + startElementWithID(retrieveMarker); + saveState(retrieveMarker); + } + + void saveState(AbstractRetrieveMarker retrieveMarker) { + states.put(retrieveMarker, new State(this)); + } + + @Override + public void endRetrieveMarker(RetrieveMarker retrieveMarker) { + endElement(retrieveMarker); + } + + @Override + public void restoreState(RetrieveMarker retrieveMarker) { + restoreRetrieveMarkerState(retrieveMarker); + } + + @SuppressWarnings("unchecked") + private void restoreRetrieveMarkerState(AbstractRetrieveMarker retrieveMarker) { + State state = states.get(retrieveMarker); + tables = (Stack
) state.tables.clone(); + inTableHeader = (Stack) state.inTableHeader.clone(); + locales = (Stack) state.locales.clone(); + } + + @Override + public void startRetrieveTableMarker(RetrieveTableMarker retrieveTableMarker) { + startElementWithID(retrieveTableMarker); + saveState(retrieveTableMarker); + } + + @Override + public void endRetrieveTableMarker(RetrieveTableMarker retrieveTableMarker) { + endElement(retrieveTableMarker); + } + + @Override + public void restoreState(RetrieveTableMarker retrieveTableMarker) { + restoreRetrieveMarkerState(retrieveTableMarker); + } + @Override public void character(Character c) { AttributesImpl attributes = createLangAttribute(c.getCommonHyphenation()); @@ -429,8 +497,8 @@ class StructureTreeEventTrigger extends FOEventHandler { } - private void startElement(FONode node) { - startElement(node, new AttributesImpl()); + private StructureTreeElement startElement(FONode node) { + return startElement(node, new AttributesImpl()); } private void startElementWithID(FONode node) { @@ -443,7 +511,8 @@ class StructureTreeEventTrigger extends FOEventHandler { addRole((CommonAccessibilityHolder) node, attributes); } node.setStructureTreeElement( - structureTreeEventHandler.startReferencedNode(localName, attributes)); + structureTreeEventHandler.startReferencedNode(localName, attributes, + node.getParent().getStructureTreeElement())); } private void startElementWithIDAndAltText(AbstractGraphics node) { @@ -453,7 +522,8 @@ class StructureTreeEventTrigger extends FOEventHandler { addAttribute(attributes, ExtensionElementMapping.URI, "alt-text", ExtensionElementMapping.STANDARD_PREFIX, node.getAltText()); node.setStructureTreeElement( - structureTreeEventHandler.startImageNode(localName, attributes)); + structureTreeEventHandler.startImageNode(localName, attributes, + node.getParent().getStructureTreeElement())); } private StructureTreeElement startElement(FONode node, AttributesImpl attributes) { @@ -461,7 +531,8 @@ class StructureTreeEventTrigger extends FOEventHandler { if (node instanceof CommonAccessibilityHolder) { addRole((CommonAccessibilityHolder) node, attributes); } - return structureTreeEventHandler.startNode(localName, attributes); + return structureTreeEventHandler.startNode(localName, attributes, + node.getParent().getStructureTreeElement()); } private void addNoNamespaceAttribute(AttributesImpl attributes, String name, String value) { diff --git a/src/java/org/apache/fop/fo/DelegatingFOEventHandler.java b/src/java/org/apache/fop/fo/DelegatingFOEventHandler.java index bb0a1ba75..4cf6ddd15 100644 --- a/src/java/org/apache/fop/fo/DelegatingFOEventHandler.java +++ b/src/java/org/apache/fop/fo/DelegatingFOEventHandler.java @@ -41,6 +41,8 @@ import org.apache.fop.fo.flow.ListItemLabel; import org.apache.fop.fo.flow.PageNumber; import org.apache.fop.fo.flow.PageNumberCitation; import org.apache.fop.fo.flow.PageNumberCitationLast; +import org.apache.fop.fo.flow.RetrieveMarker; +import org.apache.fop.fo.flow.RetrieveTableMarker; import org.apache.fop.fo.flow.Wrapper; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; @@ -382,6 +384,36 @@ public abstract class DelegatingFOEventHandler extends FOEventHandler { delegate.endWrapper(wrapper); } + @Override + public void startRetrieveMarker(RetrieveMarker retrieveMarker) { + delegate.startRetrieveMarker(retrieveMarker); + } + + @Override + public void endRetrieveMarker(RetrieveMarker retrieveMarker) { + delegate.endRetrieveMarker(retrieveMarker); + } + + @Override + public void restoreState(RetrieveMarker retrieveMarker) { + delegate.restoreState(retrieveMarker); + } + + @Override + public void startRetrieveTableMarker(RetrieveTableMarker retrieveTableMarker) { + delegate.startRetrieveTableMarker(retrieveTableMarker); + } + + @Override + public void endRetrieveTableMarker(RetrieveTableMarker retrieveTableMarker) { + delegate.endRetrieveTableMarker(retrieveTableMarker); + } + + @Override + public void restoreState(RetrieveTableMarker retrieveTableMarker) { + delegate.restoreState(retrieveTableMarker); + } + @Override public void character(Character c) { delegate.character(c); diff --git a/src/java/org/apache/fop/fo/FOEventHandler.java b/src/java/org/apache/fop/fo/FOEventHandler.java index ad647e42a..0be90dd04 100644 --- a/src/java/org/apache/fop/fo/FOEventHandler.java +++ b/src/java/org/apache/fop/fo/FOEventHandler.java @@ -41,6 +41,8 @@ import org.apache.fop.fo.flow.ListItemLabel; import org.apache.fop.fo.flow.PageNumber; import org.apache.fop.fo.flow.PageNumberCitation; import org.apache.fop.fo.flow.PageNumberCitationLast; +import org.apache.fop.fo.flow.RetrieveMarker; +import org.apache.fop.fo.flow.RetrieveTableMarker; import org.apache.fop.fo.flow.Wrapper; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; @@ -534,6 +536,56 @@ public abstract class FOEventHandler { public void endWrapper(Wrapper wrapper) { } + /** + * Process the start of a retrieve-marker. + * + * @param retrieveMarker the retrieve-marker that is starting + */ + public void startRetrieveMarker(RetrieveMarker retrieveMarker) { + } + + + /** + * Process the ending of a retrieve-marker. + * + * @param retrieveMarker the retrieve-marker that is ending + */ + public void endRetrieveMarker(RetrieveMarker retrieveMarker) { + } + + /** + * Restore the state of this event handler as it was when the given fo:retrieve-marker + * element was processed. This method is called at marker retrieval time, so that + * events for the marker descendants are fired within the proper context. + *

The default implementation of this method does nothing.

+ * + * @param retrieveMarker the fo:retrieve-marker element that is retrieving markers + */ + public void restoreState(RetrieveMarker retrieveMarker) { + } + + /** + * Process the start of a retrieve-table-marker. + * + * @param retrieveTableMarker the retrieve-table-marker that is starting + */ + public void startRetrieveTableMarker(RetrieveTableMarker retrieveTableMarker) { + } + + /** + * Process the ending of a retrieve-table-marker. + * + * @param retrieveTableMarker the retrieve-table-marker that is ending + */ + public void endRetrieveTableMarker(RetrieveTableMarker retrieveTableMarker) { + } + + /** + * See {@link #restoreState(RetrieveMarker)}. + */ + public void restoreState(RetrieveTableMarker retrieveTableMarker) { + } + /** * Process a Character. * @param c Character to process. diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index 2fae054fe..c9fd7e59a 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -311,7 +311,7 @@ public abstract class FONode implements Cloneable { * * @throws FOPException if there's a problem during processing */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { // do nothing by default } @@ -327,7 +327,7 @@ public abstract class FONode implements Cloneable { * * @throws FOPException if there's a problem during processing */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { this.finalizeNode(); } @@ -1093,4 +1093,13 @@ public abstract class FONode implements Cloneable { throw new UnsupportedOperationException(); } + /** + * Returns the structure tree element associated to this object. + * + * @return the structure tree element + */ + public StructureTreeElement getStructureTreeElement() { + return null; + } + } diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java index 5dfe0766b..6806d752d 100644 --- a/src/java/org/apache/fop/fo/FOText.java +++ b/src/java/org/apache/fop/fo/FOText.java @@ -193,7 +193,7 @@ public class FOText extends FONode implements CharSequence { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if ( charBuffer != null ) { charBuffer.rewind(); } @@ -726,7 +726,7 @@ public class FOText extends FONode implements CharSequence { this.structureTreeElement = structureTreeElement; } - /** @return the structure tree element. */ + @Override public StructureTreeElement getStructureTreeElement() { return structureTreeElement; } diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 9040c464a..84d03db83 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -321,7 +321,8 @@ public class FOTreeBuilder extends DefaultHandler { // fo:characters can potentially be removed during // white-space handling. // Do not notify the FOEventHandler. - if (currentFObj.getNameId() != Constants.FO_CHARACTER) { + if (currentFObj.getNameId() != Constants.FO_CHARACTER + && (!builderContext.inMarker() || currentFObj.getNameId() == Constants.FO_MARKER)) { currentFObj.startOfNode(); } } @@ -343,7 +344,8 @@ public class FOTreeBuilder extends DefaultHandler { // fo:characters can potentially be removed during // white-space handling. // Do not notify the FOEventHandler. - if (currentFObj.getNameId() != Constants.FO_CHARACTER) { + if (currentFObj.getNameId() != Constants.FO_CHARACTER + && (!builderContext.inMarker() || currentFObj.getNameId() == Constants.FO_MARKER)) { currentFObj.endOfNode(); } diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index a316a2260..e7b4fc2e9 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -179,7 +179,7 @@ public abstract class FObj extends FONode implements Constants { * {@inheritDoc} * @throws FOPException FOP Exception */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { if (id != null) { checkId(id); } diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java index e582e8689..f0a4e2695 100644 --- a/src/java/org/apache/fop/fo/FObjMixed.java +++ b/src/java/org/apache/fop/fo/FObjMixed.java @@ -49,6 +49,16 @@ public abstract class FObjMixed extends FObj { super(parent); } + @Override + public FONode clone(FONode parent, boolean removeChildren) throws FOPException { + flushText(); + FObjMixed clone = (FObjMixed) super.clone(parent, removeChildren); + if (removeChildren) { + clone.currentTextNode = null; + } + return clone; + } + /** {@inheritDoc} */ @Override protected void characters(char[] data, int start, int length, @@ -66,7 +76,7 @@ public abstract class FObjMixed extends FObj { /** {@inheritDoc} */ @Override - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); if (!inMarker() || getNameId() == FO_MARKER) { diff --git a/src/java/org/apache/fop/fo/extensions/ExternalDocument.java b/src/java/org/apache/fop/fo/extensions/ExternalDocument.java index a6f5e7680..b450c21ce 100644 --- a/src/java/org/apache/fop/fo/extensions/ExternalDocument.java +++ b/src/java/org/apache/fop/fo/extensions/ExternalDocument.java @@ -86,7 +86,7 @@ public class ExternalDocument extends AbstractPageSequence implements GraphicsPr * @throws FOPException in case of processing exception * @see org.apache.fop.fo.FONode#startOfNode() */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startExternalDocument(this); } @@ -95,7 +95,7 @@ public class ExternalDocument extends AbstractPageSequence implements GraphicsPr * @throws FOPException in case of processing exception * @see org.apache.fop.fo.FONode#endOfNode() */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { getFOEventHandler().endExternalDocument(this); super.endOfNode(); } diff --git a/src/java/org/apache/fop/fo/extensions/destination/Destination.java b/src/java/org/apache/fop/fo/extensions/destination/Destination.java index 98114bb23..95ae64c7d 100644 --- a/src/java/org/apache/fop/fo/extensions/destination/Destination.java +++ b/src/java/org/apache/fop/fo/extensions/destination/Destination.java @@ -61,7 +61,7 @@ public class Destination extends FONode { /** * {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { root.addDestination(this); } diff --git a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java b/src/java/org/apache/fop/fo/flow/AbstractGraphics.java index 3d93eaa8f..2bf0061b0 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java +++ b/src/java/org/apache/fop/fo/flow/AbstractGraphics.java @@ -234,7 +234,7 @@ public abstract class AbstractGraphics extends FObj this.structureTreeElement = structureTreeElement; } - /** {@inheritDoc} */ + @Override public StructureTreeElement getStructureTreeElement() { return structureTreeElement; } diff --git a/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java b/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java index 0e99bfe96..c8e8fc620 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java +++ b/src/java/org/apache/fop/fo/flow/AbstractListItemPart.java @@ -83,7 +83,7 @@ public abstract class AbstractListItemPart extends FObj implements CommonAccessi } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (!this.blockItemFound) { String contentModel = "marker* (%block;)+"; getFOValidationEventProducer().missingChildElement(this, getName(), diff --git a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java index ec3891632..68582a430 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java @@ -160,7 +160,7 @@ public abstract class AbstractPageNumberCitation extends FObj this.structureTreeElement = structureTreeElement; } - /** {@inheritDoc} */ + @Override public StructureTreeElement getStructureTreeElement() { return structureTreeElement; } diff --git a/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java b/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java index 636bc04df..018f6bb73 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java +++ b/src/java/org/apache/fop/fo/flow/AbstractRetrieveMarker.java @@ -23,6 +23,7 @@ import java.util.Iterator; import org.xml.sax.Locator; +import org.apache.fop.accessibility.StructureTreeElement; import org.apache.fop.apps.FOPException; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOText; @@ -51,6 +52,8 @@ public abstract class AbstractRetrieveMarker extends FObjMixed { private int boundary; private String boundaryLabel; + private StructureTreeElement structureTreeElement; + /** * Create a new AbstractRetrieveMarker instance that * is a child of the given {@link FONode} @@ -86,6 +89,16 @@ public abstract class AbstractRetrieveMarker extends FObjMixed { this.propertyList = pList.getParentPropertyList(); } + @Override + public void setStructureTreeElement(StructureTreeElement structureTreeElement) { + this.structureTreeElement = structureTreeElement; + } + + @Override + public StructureTreeElement getStructureTreeElement() { + return structureTreeElement; + } + private PropertyList createPropertyListFor(FObj fo, PropertyList parent) { return getBuilderContext().getPropertyListMaker().make(fo, parent); } @@ -108,6 +121,7 @@ public abstract class AbstractRetrieveMarker extends FObjMixed { pList, newPropertyList); addChildTo(newChild, newParent); + newChild.startOfNode(); switch ( newChild.getNameId() ) { case FO_TABLE: Table t = (Table) child; @@ -132,17 +146,22 @@ public abstract class AbstractRetrieveMarker extends FObjMixed { newChild, marker, newPropertyList); break; } + newChild.endOfNode(); } else if (child instanceof FOText) { FOText ft = (FOText) newChild; ft.bind(parentPropertyList); addChildTo(newChild, newParent); + if (newParent instanceof AbstractRetrieveMarker) { + /* + * Otherwise the parent of newChild is a cloned FObjMixed that will + * call this FOText's endOfNode when its own endOfNode method is + * called. + */ + newChild.endOfNode(); + } } else if (child instanceof XMLObj) { addChildTo(newChild, newParent); } - - // trigger end-of-node white-space handling - // and finalization for table-FOs - newChild.finalizeNode(); } } @@ -191,6 +210,7 @@ public abstract class AbstractRetrieveMarker extends FObjMixed { } if (marker.getChildNodes() != null) { try { + restoreFOEventHandlerState(); cloneFromMarker(marker); } catch (FOPException exc) { getFOValidationEventProducer().markerCloningFailed(this, @@ -201,6 +221,8 @@ public abstract class AbstractRetrieveMarker extends FObjMixed { } } + protected abstract void restoreFOEventHandlerState(); + /** * Return the value for the retrieve-class-name * property diff --git a/src/java/org/apache/fop/fo/flow/BasicLink.java b/src/java/org/apache/fop/fo/flow/BasicLink.java index 0d6d5d9b4..3394842fb 100644 --- a/src/java/org/apache/fop/fo/flow/BasicLink.java +++ b/src/java/org/apache/fop/fo/flow/BasicLink.java @@ -96,13 +96,13 @@ public class BasicLink extends InlineLevel implements StructureTreeElementHolder } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startLink(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endLink(this); } @@ -148,7 +148,7 @@ public class BasicLink extends InlineLevel implements StructureTreeElementHolder this.structureTreeElement = structureTreeElement; } - /** {@inheritDoc} */ + @Override public StructureTreeElement getStructureTreeElement() { return structureTreeElement; } diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index d93821ca6..13b218b55 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -140,13 +140,13 @@ public class Block extends FObjMixed implements BreakPropertySet, } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startBlock(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endBlock(this); } diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java index cdeb99081..005f9289a 100644 --- a/src/java/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java @@ -103,7 +103,7 @@ public class BlockContainer extends FObj implements BreakPropertySet, WritingMod } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startBlockContainer(this); } @@ -138,7 +138,7 @@ public class BlockContainer extends FObj implements BreakPropertySet, WritingMod } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (!blockItemFound) { missingChildElementError("marker* (%block;)+"); } diff --git a/src/java/org/apache/fop/fo/flow/Character.java b/src/java/org/apache/fop/fo/flow/Character.java index f48ff289e..2d0814301 100644 --- a/src/java/org/apache/fop/fo/flow/Character.java +++ b/src/java/org/apache/fop/fo/flow/Character.java @@ -116,7 +116,7 @@ public class Character extends FObj implements StructureTreeElementHolder { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().character(this); } @@ -217,7 +217,7 @@ public class Character extends FObj implements StructureTreeElementHolder { this.structureTreeElement = structureTreeElement; } - /** {@inheritDoc} */ + @Override public StructureTreeElement getStructureTreeElement() { return structureTreeElement; } diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java index dc8584abc..b564526b4 100644 --- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java @@ -104,7 +104,7 @@ public class ExternalGraphic extends AbstractGraphics { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().image(this); } diff --git a/src/java/org/apache/fop/fo/flow/Float.java b/src/java/org/apache/fop/fo/flow/Float.java index 5d8fcdc2c..c12998144 100644 --- a/src/java/org/apache/fop/fo/flow/Float.java +++ b/src/java/org/apache/fop/fo/flow/Float.java @@ -74,7 +74,7 @@ public class Float extends FObj { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (firstChild == null) { missingChildElementError("(%block;)+"); } diff --git a/src/java/org/apache/fop/fo/flow/Footnote.java b/src/java/org/apache/fop/fo/flow/Footnote.java index 5953363ed..3aa2097a2 100644 --- a/src/java/org/apache/fop/fo/flow/Footnote.java +++ b/src/java/org/apache/fop/fo/flow/Footnote.java @@ -56,7 +56,7 @@ public class Footnote extends FObj implements CommonAccessibilityHolder { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { getFOEventHandler().startFootnote(this); } @@ -66,7 +66,7 @@ public class Footnote extends FObj implements CommonAccessibilityHolder { * * {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); if (footnoteCitation == null || footnoteBody == null) { missingChildElementError("(inline,footnote-body)"); diff --git a/src/java/org/apache/fop/fo/flow/FootnoteBody.java b/src/java/org/apache/fop/fo/flow/FootnoteBody.java index 1c103b6b5..af2bc2bcf 100644 --- a/src/java/org/apache/fop/fo/flow/FootnoteBody.java +++ b/src/java/org/apache/fop/fo/flow/FootnoteBody.java @@ -54,7 +54,7 @@ public class FootnoteBody extends FObj implements CommonAccessibilityHolder { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { getFOEventHandler().startFootnoteBody(this); } @@ -64,7 +64,7 @@ public class FootnoteBody extends FObj implements CommonAccessibilityHolder { * end of the footnote-body. * {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (firstChild == null) { missingChildElementError("(%block;)+"); } diff --git a/src/java/org/apache/fop/fo/flow/Inline.java b/src/java/org/apache/fop/fo/flow/Inline.java index 941850cdd..d115f469a 100644 --- a/src/java/org/apache/fop/fo/flow/Inline.java +++ b/src/java/org/apache/fop/fo/flow/Inline.java @@ -69,7 +69,7 @@ public class Inline extends InlineLevel { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); /* Check to see if this node can have block-level children. @@ -94,7 +94,7 @@ public class Inline extends InlineLevel { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endInline(this); } diff --git a/src/java/org/apache/fop/fo/flow/InlineContainer.java b/src/java/org/apache/fop/fo/flow/InlineContainer.java index b79d66bb0..b8e9fd09a 100644 --- a/src/java/org/apache/fop/fo/flow/InlineContainer.java +++ b/src/java/org/apache/fop/fo/flow/InlineContainer.java @@ -119,7 +119,7 @@ public class InlineContainer extends FObj { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (!blockItemFound) { missingChildElementError("marker* (%block;)+"); } diff --git a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java index 33164188f..9f88b9478 100644 --- a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java @@ -60,7 +60,7 @@ public class InstreamForeignObject extends AbstractGraphics { } @Override - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startInstreamForeignObject(this); } @@ -71,7 +71,7 @@ public class InstreamForeignObject extends AbstractGraphics { * the end of the instream-foreign-object. * {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (firstChild == null) { missingChildElementError("one (1) non-XSL namespace child"); } diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java index 4062d6562..c1fd98002 100644 --- a/src/java/org/apache/fop/fo/flow/Leader.java +++ b/src/java/org/apache/fop/fo/flow/Leader.java @@ -191,13 +191,13 @@ public class Leader extends InlineLevel { } @Override - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startLeader(this); } @Override - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endLeader(this); } diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java index 35288ec80..647891131 100644 --- a/src/java/org/apache/fop/fo/flow/ListBlock.java +++ b/src/java/org/apache/fop/fo/flow/ListBlock.java @@ -89,7 +89,7 @@ public class ListBlock extends FObj implements BreakPropertySet, CommonAccessibi } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startList(this); } @@ -100,7 +100,7 @@ public class ListBlock extends FObj implements BreakPropertySet, CommonAccessibi * of the list-block. * {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (!hasListItem) { missingChildElementError("marker* (list-item)+"); } diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java index f61254874..bfd512f4d 100644 --- a/src/java/org/apache/fop/fo/flow/ListItem.java +++ b/src/java/org/apache/fop/fo/flow/ListItem.java @@ -83,13 +83,13 @@ public class ListItem extends FObj implements BreakPropertySet, CommonAccessibil } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startListItem(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (label == null || body == null) { missingChildElementError("marker* (list-item-label,list-item-body)"); } diff --git a/src/java/org/apache/fop/fo/flow/ListItemBody.java b/src/java/org/apache/fop/fo/flow/ListItemBody.java index 3007f9ba3..5b121f53c 100644 --- a/src/java/org/apache/fop/fo/flow/ListItemBody.java +++ b/src/java/org/apache/fop/fo/flow/ListItemBody.java @@ -36,13 +36,13 @@ public class ListItemBody extends AbstractListItemPart { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startListBody(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endListBody(this); } diff --git a/src/java/org/apache/fop/fo/flow/ListItemLabel.java b/src/java/org/apache/fop/fo/flow/ListItemLabel.java index 10436afa6..53dfab84e 100644 --- a/src/java/org/apache/fop/fo/flow/ListItemLabel.java +++ b/src/java/org/apache/fop/fo/flow/ListItemLabel.java @@ -38,13 +38,13 @@ public class ListItemLabel extends AbstractListItemPart { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startListLabel(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endListLabel(this); } diff --git a/src/java/org/apache/fop/fo/flow/Marker.java b/src/java/org/apache/fop/fo/flow/Marker.java index de806e986..5d525ee8c 100644 --- a/src/java/org/apache/fop/fo/flow/Marker.java +++ b/src/java/org/apache/fop/fo/flow/Marker.java @@ -83,7 +83,7 @@ public class Marker extends FObjMixed { } /** {@inheritDoc} */ - protected void startOfNode() { + public void startOfNode() { FOTreeBuilderContext builderContext = getBuilderContext(); // Push a new property list maker which will make MarkerPropertyLists. savePropertyListMaker = builderContext.getPropertyListMaker(); @@ -97,7 +97,7 @@ public class Marker extends FObjMixed { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); // Pop the MarkerPropertyList maker. getBuilderContext().setPropertyListMaker(savePropertyListMaker); diff --git a/src/java/org/apache/fop/fo/flow/MultiProperties.java b/src/java/org/apache/fop/fo/flow/MultiProperties.java index 3e2e57d97..ff8192006 100644 --- a/src/java/org/apache/fop/fo/flow/MultiProperties.java +++ b/src/java/org/apache/fop/fo/flow/MultiProperties.java @@ -59,7 +59,7 @@ public class MultiProperties extends FObj { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (!hasMultiPropertySet || !hasWrapper) { missingChildElementError("(multi-property-set+, wrapper)"); } diff --git a/src/java/org/apache/fop/fo/flow/MultiSwitch.java b/src/java/org/apache/fop/fo/flow/MultiSwitch.java index aa18d6cdf..d8ebee4cb 100644 --- a/src/java/org/apache/fop/fo/flow/MultiSwitch.java +++ b/src/java/org/apache/fop/fo/flow/MultiSwitch.java @@ -64,7 +64,7 @@ public class MultiSwitch extends FObj { /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (firstChild == null) { missingChildElementError("(multi-case+)"); } diff --git a/src/java/org/apache/fop/fo/flow/PageNumber.java b/src/java/org/apache/fop/fo/flow/PageNumber.java index fe3e80a75..33b34e2d5 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumber.java +++ b/src/java/org/apache/fop/fo/flow/PageNumber.java @@ -106,13 +106,13 @@ public class PageNumber extends FObj } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startPageNumber(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { getFOEventHandler().endPageNumber(this); } @@ -182,7 +182,7 @@ public class PageNumber extends FObj this.structureTreeElement = structureTreeElement; } - /** {@inheritDoc} */ + @Override public StructureTreeElement getStructureTreeElement() { return structureTreeElement; } diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java index 0ebb6eb3d..ee7b59a15 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java @@ -41,13 +41,13 @@ public class PageNumberCitation extends AbstractPageNumberCitation { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startPageNumberCitation(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endPageNumberCitation(this); } diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitationLast.java b/src/java/org/apache/fop/fo/flow/PageNumberCitationLast.java index 6a08568b1..b6e209202 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumberCitationLast.java +++ b/src/java/org/apache/fop/fo/flow/PageNumberCitationLast.java @@ -42,13 +42,13 @@ public class PageNumberCitationLast extends AbstractPageNumberCitation { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startPageNumberCitationLast(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endPageNumberCitationLast(this); } diff --git a/src/java/org/apache/fop/fo/flow/RetrieveMarker.java b/src/java/org/apache/fop/fo/flow/RetrieveMarker.java index b001a41ee..2f2b7e5a4 100644 --- a/src/java/org/apache/fop/fo/flow/RetrieveMarker.java +++ b/src/java/org/apache/fop/fo/flow/RetrieveMarker.java @@ -71,6 +71,18 @@ public class RetrieveMarker extends AbstractRetrieveMarker { setBoundaryLabel((String) pList.get(PR_RETRIEVE_BOUNDARY).getObject()); } + @Override + public void startOfNode() throws FOPException { + super.startOfNode(); + getFOEventHandler().startRetrieveMarker(this); + } + + @Override + public void endOfNode() throws FOPException { + super.endOfNode(); + getFOEventHandler().endRetrieveMarker(this); + } + /** * Return the value for the retrieve-position * property @@ -108,4 +120,10 @@ public class RetrieveMarker extends AbstractRetrieveMarker { public int getNameId() { return FO_RETRIEVE_MARKER; } + + @Override + protected void restoreFOEventHandlerState() { + getFOEventHandler().restoreState(this); + } + } diff --git a/src/java/org/apache/fop/fo/flow/RetrieveTableMarker.java b/src/java/org/apache/fop/fo/flow/RetrieveTableMarker.java index efacba864..d4bc7c687 100644 --- a/src/java/org/apache/fop/fo/flow/RetrieveTableMarker.java +++ b/src/java/org/apache/fop/fo/flow/RetrieveTableMarker.java @@ -68,6 +68,18 @@ public class RetrieveTableMarker extends AbstractRetrieveMarker { setBoundaryLabel((String) pList.get(PR_RETRIEVE_BOUNDARY_WITHIN_TABLE).getObject()); } + @Override + public void startOfNode() throws FOPException { + super.startOfNode(); + getFOEventHandler().startRetrieveTableMarker(this); + } + + @Override + public void endOfNode() throws FOPException { + super.endOfNode(); + getFOEventHandler().endRetrieveTableMarker(this); + } + /** * Return the value for the retrieve-position-within-table * property @@ -113,4 +125,9 @@ public class RetrieveTableMarker extends AbstractRetrieveMarker { this.lastFOTextProcessed = null; } + @Override + protected void restoreFOEventHandlerState() { + getFOEventHandler().restoreState(this); + } + } diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java index 0aec7ce16..dd15187f2 100644 --- a/src/java/org/apache/fop/fo/flow/Wrapper.java +++ b/src/java/org/apache/fop/fo/flow/Wrapper.java @@ -61,13 +61,13 @@ public class Wrapper extends FObjMixed implements CommonAccessibilityHolder { } @Override - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startWrapper(this); } @Override - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endWrapper(this); } diff --git a/src/java/org/apache/fop/fo/flow/table/Table.java b/src/java/org/apache/fop/fo/flow/table/Table.java index a574723b1..f23ac1cc4 100644 --- a/src/java/org/apache/fop/fo/flow/table/Table.java +++ b/src/java/org/apache/fop/fo/flow/table/Table.java @@ -179,7 +179,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startTable(this); } @@ -238,7 +238,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endTable(this); } diff --git a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java index 51db27e4e..667138e00 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java +++ b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java @@ -87,7 +87,7 @@ public class TableAndCaption extends FObj implements CommonAccessibilityHolder { * FOEventHandler that we are at the end of the flow. * {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (!tableFound) { missingChildElementError("marker* table-caption? table"); } diff --git a/src/java/org/apache/fop/fo/flow/table/TableBody.java b/src/java/org/apache/fop/fo/flow/table/TableBody.java index d69081e48..63e927952 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableBody.java +++ b/src/java/org/apache/fop/fo/flow/table/TableBody.java @@ -38,13 +38,13 @@ public class TableBody extends TablePart { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startBody(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endBody(this); } diff --git a/src/java/org/apache/fop/fo/flow/table/TableCaption.java b/src/java/org/apache/fop/fo/flow/table/TableCaption.java index 380b27f34..def1c1093 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableCaption.java +++ b/src/java/org/apache/fop/fo/flow/table/TableCaption.java @@ -78,7 +78,7 @@ public class TableCaption extends FObj implements CommonAccessibilityHolder { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (firstChild == null) { missingChildElementError("marker* (%block;)"); } diff --git a/src/java/org/apache/fop/fo/flow/table/TableCell.java b/src/java/org/apache/fop/fo/flow/table/TableCell.java index f198f3aad..20a80d135 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableCell.java +++ b/src/java/org/apache/fop/fo/flow/table/TableCell.java @@ -96,7 +96,7 @@ public class TableCell extends TableFObj implements CommonAccessibilityHolder { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startCell(this); } @@ -106,7 +106,7 @@ public class TableCell extends TableFObj implements CommonAccessibilityHolder { * FOEventHandler that we are at the end of the table-cell. * {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endCell(this); } diff --git a/src/java/org/apache/fop/fo/flow/table/TableFooter.java b/src/java/org/apache/fop/fo/flow/table/TableFooter.java index cfd0136dc..e12b75c5c 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableFooter.java +++ b/src/java/org/apache/fop/fo/flow/table/TableFooter.java @@ -41,13 +41,13 @@ public class TableFooter extends TablePart { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startFooter(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endFooter(this); } diff --git a/src/java/org/apache/fop/fo/flow/table/TableHeader.java b/src/java/org/apache/fop/fo/flow/table/TableHeader.java index a0ad40798..73b43f301 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableHeader.java +++ b/src/java/org/apache/fop/fo/flow/table/TableHeader.java @@ -40,13 +40,13 @@ public class TableHeader extends TablePart { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startHeader(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endHeader(this); } diff --git a/src/java/org/apache/fop/fo/flow/table/TableRow.java b/src/java/org/apache/fop/fo/flow/table/TableRow.java index dd9f7c6d4..2beaf2f99 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableRow.java +++ b/src/java/org/apache/fop/fo/flow/table/TableRow.java @@ -98,13 +98,13 @@ public class TableRow extends TableCellContainer implements BreakPropertySet { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startRow(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endRow(this); } diff --git a/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java b/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java index d1ccf7273..c74be7d7e 100644 --- a/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java @@ -82,7 +82,7 @@ public abstract class AbstractPageSequence extends FObj implements CommonAccessi } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { this.pageNumberGenerator = new PageNumberGenerator( format, groupingSeparator, groupingSize, letterValue, numberConversionFeatures, language, country); diff --git a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java index da92c7439..b83a72a11 100644 --- a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java @@ -72,7 +72,7 @@ public class ConditionalPageMasterReference extends FObj { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { getConcreteParent().addConditionalPageMasterReference(this); } diff --git a/src/java/org/apache/fop/fo/pagination/Declarations.java b/src/java/org/apache/fop/fo/pagination/Declarations.java index 9c68043ff..12d95c131 100644 --- a/src/java/org/apache/fop/fo/pagination/Declarations.java +++ b/src/java/org/apache/fop/fo/pagination/Declarations.java @@ -75,7 +75,7 @@ public class Declarations extends FObj { * a hashmap of color profiles and a list of extension attachments. * @throws FOPException if there's a problem during processing */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (firstChild != null) { for (FONodeIterator iter = getChildNodes(); iter.hasNext();) { FONode node = iter.nextNode(); diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java index 45c8f7804..8a52b9a9e 100644 --- a/src/java/org/apache/fop/fo/pagination/Flow.java +++ b/src/java/org/apache/fop/fo/pagination/Flow.java @@ -62,7 +62,7 @@ public class Flow extends FObj implements CommonAccessibilityHolder { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { if (flowName == null || flowName.equals("")) { missingPropertyError(FLOW_NAME); } @@ -88,7 +88,7 @@ public class Flow extends FObj implements CommonAccessibilityHolder { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (!blockItemFound) { missingChildElementError("marker* (%block;)+"); } diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java index 8b109dd0e..905291b35 100644 --- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java +++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java @@ -62,14 +62,14 @@ public class LayoutMasterSet extends FObj { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { getRoot().setLayoutMasterSet(this); simplePageMasters = new java.util.HashMap(); pageSequenceMasters = new java.util.HashMap(); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (firstChild == null) { missingChildElementError("(simple-page-master|page-sequence-master)+"); } diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index 6039dafeb..6b1ee2ef4 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -103,7 +103,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); flowMap = new java.util.HashMap(); @@ -121,7 +121,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (mainFlow == null) { missingChildElementError("(title?,static-content*,flow)"); } diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java index 080d663d7..6fa9b4261 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java @@ -79,14 +79,14 @@ public class PageSequenceMaster extends FObj { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { subSequenceSpecifiers = new java.util.ArrayList(); layoutMasterSet = parent.getRoot().getLayoutMasterSet(); layoutMasterSet.addPageSequenceMaster(masterName, this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (firstChild == null) { missingChildElementError("(single-page-master-reference|" + "repeatable-page-master-reference|repeatable-page-master-alternatives)+"); diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java index 8ade4d34a..439ed2859 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java @@ -68,7 +68,7 @@ public class RepeatablePageMasterAlternatives extends FObj } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { conditionalPageMasterRefs = new java.util.ArrayList(); assert parent.getName().equals("fo:page-sequence-master"); //Validation by the parent @@ -77,7 +77,7 @@ public class RepeatablePageMasterAlternatives extends FObj } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (firstChild == null) { missingChildElementError("(conditional-page-master-reference+)"); } diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java index c3f2368ea..9ea1ab50a 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java @@ -70,7 +70,7 @@ public class RepeatablePageMasterReference extends FObj } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent; if (masterReference == null) { diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java index 6db8d6db1..64a6b039d 100644 --- a/src/java/org/apache/fop/fo/pagination/Root.java +++ b/src/java/org/apache/fop/fo/pagination/Root.java @@ -97,12 +97,12 @@ public class Root extends FObj implements CommonAccessibilityHolder { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { foEventHandler.startRoot(this); } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (!pageSequenceFound || layoutMasterSet == null) { missingChildElementError("(layout-master-set, declarations?, " + "bookmark-tree?, (page-sequence|fox:external-document)+)"); diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java index 79c8c3358..637289cde 100644 --- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -89,7 +89,7 @@ public class SimplePageMaster extends FObj { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { LayoutMasterSet layoutMasterSet = (LayoutMasterSet) parent; if (masterName == null) { @@ -103,7 +103,7 @@ public class SimplePageMaster extends FObj { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (!hasRegionBody) { missingChildElementError( "(region-body, region-before?, region-after?, region-start?, region-end?)"); diff --git a/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java index 38b56af19..ed0c041dd 100644 --- a/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java +++ b/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java @@ -71,7 +71,7 @@ public class SinglePageMasterReference extends FObj } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent; pageSequenceMaster.addSubsequenceSpecifier(this); } diff --git a/src/java/org/apache/fop/fo/pagination/StaticContent.java b/src/java/org/apache/fop/fo/pagination/StaticContent.java index 412cdbcca..d85ab5f30 100644 --- a/src/java/org/apache/fop/fo/pagination/StaticContent.java +++ b/src/java/org/apache/fop/fo/pagination/StaticContent.java @@ -40,7 +40,7 @@ public class StaticContent extends Flow { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { if (getFlowName() == null || getFlowName().equals("")) { missingPropertyError(FLOW_NAME); } @@ -52,7 +52,7 @@ public class StaticContent extends Flow { * FOEventHandler that we are at the end of the flow. * {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (firstChild == null && getUserAgent().validateStrictly()) { missingChildElementError("(%block;)+"); } diff --git a/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java b/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java index 9e7d80cea..9cefe85b4 100644 --- a/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java +++ b/src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java @@ -102,7 +102,7 @@ public class Bookmark extends FObj implements CommonAccessibilityHolder { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (bookmarkTitle == null) { missingChildElementError("(bookmark-title, bookmark*)"); } diff --git a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java index 22bf0769b..c5594bff0 100644 --- a/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java +++ b/src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTree.java @@ -56,7 +56,7 @@ public class BookmarkTree extends FObj { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { if (bookmarks == null) { missingChildElementError("(fo:bookmark+)"); } diff --git a/src/java/org/apache/fop/pdf/PDFStructElem.java b/src/java/org/apache/fop/pdf/PDFStructElem.java index 8250318d7..badf53060 100644 --- a/src/java/org/apache/fop/pdf/PDFStructElem.java +++ b/src/java/org/apache/fop/pdf/PDFStructElem.java @@ -37,7 +37,7 @@ public class PDFStructElem extends StructureHierarchyMember private StructureType structureType; - private PDFStructElem parentElement; + protected PDFStructElem parentElement; /** * Elements to be added to the kids array. @@ -231,6 +231,9 @@ public class PDFStructElem extends StructureHierarchyMember textBuffer.append(' '); } Object obj = kids.get(i); + if (obj instanceof PDFStructElem) { + ((PDFStructElem) obj).setParent(parentElement); + } formatObject(obj, out, textBuffer); } } diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPIncludeFormMapElement.java b/src/java/org/apache/fop/render/afp/extensions/AFPIncludeFormMapElement.java index c5079b2bd..71765bb7d 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPIncludeFormMapElement.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPIncludeFormMapElement.java @@ -54,7 +54,7 @@ public class AFPIncludeFormMapElement extends AbstractAFPExtensionObject { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); if (parent.getNameId() != Constants.FO_DECLARATIONS) { invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java b/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java index 813cf6ddd..e40d3da34 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java @@ -40,7 +40,7 @@ public class AFPInvokeMediumMapElement extends AbstractAFPExtensionObject { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); if (parent.getNameId() != Constants.FO_PAGE_SEQUENCE && parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) { diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java b/src/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java index 0b9645236..59df1529e 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPPageOverlayElement.java @@ -57,7 +57,7 @@ public class AFPPageOverlayElement extends AbstractAFPExtensionObject { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); if (AFPElementMapping.INCLUDE_PAGE_OVERLAY.equals(getLocalName())) { if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java b/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java index 9b325c5cd..e3aa3ca57 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java @@ -54,7 +54,7 @@ public class AFPPageSetupElement extends AbstractAFPExtensionObject { /** {@inheritDoc} */ @Override - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(getLocalName())) { if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER diff --git a/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java b/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java index e35a13ec6..388ea3f44 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java +++ b/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java @@ -86,7 +86,7 @@ public abstract class AbstractAFPExtensionObject extends FONode { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); } diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java index 5753dad01..484e8d559 100644 --- a/src/java/org/apache/fop/render/intermediate/IFParser.java +++ b/src/java/org/apache/fop/render/intermediate/IFParser.java @@ -163,25 +163,15 @@ public class IFParser implements IFConstants { private Map structureTreeElements = new HashMap(); - private final class StructureTreeHandler extends DefaultHandler { + private class StructureTreeHandler extends DefaultHandler { - private final Locale pageSequenceLanguage; - - private final StructureTreeEventHandler structureTreeEventHandler; + protected final StructureTreeEventHandler structureTreeEventHandler; - private StructureTreeHandler(StructureTreeEventHandler structureTreeEventHandler, - Locale pageSequenceLanguage) throws SAXException { - this.pageSequenceLanguage = pageSequenceLanguage; + StructureTreeHandler(StructureTreeEventHandler structureTreeEventHandler) { this.structureTreeEventHandler = structureTreeEventHandler; } void startStructureTree(String type) { - structureTreeEventHandler.startPageSequence(pageSequenceLanguage, type); - } - - public void endDocument() throws SAXException { - startIFElement(EL_PAGE_SEQUENCE, pageSequenceAttributes); - pageSequenceAttributes = null; } @Override @@ -191,18 +181,19 @@ public class IFParser implements IFConstants { if (localName.equals("marked-content")) { localName = "#PCDATA"; } + StructureTreeElement parent = getStructureTreeElement(attributes); String structID = attributes.getValue(InternalElementMapping.URI, InternalElementMapping.STRUCT_ID); if (structID == null) { - structureTreeEventHandler.startNode(localName, attributes); + structureTreeEventHandler.startNode(localName, attributes, parent); } else if (localName.equals("external-graphic") || localName.equals("instream-foreign-object")) { StructureTreeElement structureTreeElement - = structureTreeEventHandler.startImageNode(localName, attributes); + = structureTreeEventHandler.startImageNode(localName, attributes, parent); structureTreeElements.put(structID, structureTreeElement); } else { StructureTreeElement structureTreeElement = structureTreeEventHandler - .startReferencedNode(localName, attributes); + .startReferencedNode(localName, attributes, parent); structureTreeElements.put(structID, structureTreeElement); } } @@ -217,6 +208,28 @@ public class IFParser implements IFConstants { } } + private class MainStructureTreeHandler extends StructureTreeHandler { + + private final Locale pageSequenceLanguage; + + MainStructureTreeHandler(StructureTreeEventHandler structureTreeEventHandler, + Locale pageSequenceLanguage) throws SAXException { + super(structureTreeEventHandler); + this.pageSequenceLanguage = pageSequenceLanguage; + } + + @Override + void startStructureTree(String type) { + structureTreeEventHandler.startPageSequence(pageSequenceLanguage, type); + } + + public void endDocument() throws SAXException { + startIFElement(EL_PAGE_SEQUENCE, pageSequenceAttributes); + pageSequenceAttributes = null; + } + + } + public Handler(IFDocumentHandler documentHandler, FOUserAgent userAgent, ElementMappingRegistry elementMappingRegistry) { this.documentHandler = documentHandler; @@ -264,7 +277,7 @@ public class IFParser implements IFConstants { if (localName.equals(EL_PAGE_SEQUENCE) && userAgent.isAccessibilityEnabled()) { pageSequenceAttributes = new AttributesImpl(attributes); Locale language = getLanguage(attributes); - structureTreeHandler = new StructureTreeHandler( + structureTreeHandler = new MainStructureTreeHandler( userAgent.getStructureTreeEventHandler(), language); } else if (localName.equals(EL_STRUCTURE_TREE)) { @@ -520,6 +533,7 @@ public class IFParser implements IFConstants { public void startElement(Attributes attributes) throws IFException { documentHandler.startPageHeader(); + structureTreeHandler = new StructureTreeHandler(userAgent.getStructureTreeEventHandler()); } public void endElement() throws IFException { @@ -842,12 +856,19 @@ public class IFParser implements IFConstants { } private void establishStructureTreeElement(Attributes attributes) { - String structRef = attributes.getValue(InternalElementMapping.URI, - InternalElementMapping.STRUCT_REF); + StructureTreeElement element = getStructureTreeElement(attributes); + if (element != null) { + documentHandler.getContext().setStructureTreeElement(element); + } + } + + private StructureTreeElement getStructureTreeElement(Attributes attributes) { + String structRef = attributes.getValue(InternalElementMapping.URI, InternalElementMapping.STRUCT_REF); if (structRef != null && structRef.length() > 0) { assert structureTreeElements.containsKey(structRef); - StructureTreeElement structureTreeElement = structureTreeElements.get(structRef); - documentHandler.getContext().setStructureTreeElement(structureTreeElement); + return structureTreeElements.get(structRef); + } else { + return null; } } diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java index ff3f761bf..bba8c744d 100644 --- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -314,6 +314,9 @@ implements IFConstants, IFPainter, IFDocumentNavigationHandler { public void startPageHeader() throws IFException { try { handler.startElement(EL_PAGE_HEADER); + if (this.getUserAgent().isAccessibilityEnabled()) { + structureTreeBuilder.replayEventsForRetrievedMarkers(handler); + } } catch (SAXException e) { throw new IFException("SAX error in startPageHeader()", e); } diff --git a/src/java/org/apache/fop/render/intermediate/IFStructureTreeBuilder.java b/src/java/org/apache/fop/render/intermediate/IFStructureTreeBuilder.java index 9ba9afd81..f7049997e 100644 --- a/src/java/org/apache/fop/render/intermediate/IFStructureTreeBuilder.java +++ b/src/java/org/apache/fop/render/intermediate/IFStructureTreeBuilder.java @@ -33,6 +33,7 @@ import org.apache.fop.accessibility.StructureTree2SAXEventAdapter; import org.apache.fop.accessibility.StructureTreeElement; import org.apache.fop.accessibility.StructureTreeEventHandler; import org.apache.fop.fo.extensions.InternalElementMapping; +import org.apache.fop.util.XMLConstants; import org.apache.fop.util.XMLUtil; /** @@ -176,6 +177,8 @@ final class IFStructureTreeBuilder implements StructureTreeEventHandler { private final List pageSequenceEventRecorders = new ArrayList(); + private SAXEventRecorder retrievedMarkersEventRecorder; + private int idCounter; /** @@ -189,6 +192,16 @@ final class IFStructureTreeBuilder implements StructureTreeEventHandler { pageSequenceEventRecorders.get(pageSequenceIndex).replay(handler); } + public void replayEventsForRetrievedMarkers(ContentHandler handler) throws SAXException { + if (!retrievedMarkersEventRecorder.events.isEmpty()) { + delegate = StructureTree2SAXEventAdapter.newInstance(handler); + delegate.startPageSequence(null, null); + retrievedMarkersEventRecorder.replay(handler); + delegate.endPageSequence(); + prepareRetrievedMarkersEventRecorder(); + } + } + public void startPageSequence(Locale locale, String role) { SAXEventRecorder eventRecorder = new SAXEventRecorder(); pageSequenceEventRecorders.add(eventRecorder); @@ -198,28 +211,51 @@ final class IFStructureTreeBuilder implements StructureTreeEventHandler { public void endPageSequence() { delegate.endPageSequence(); + prepareRetrievedMarkersEventRecorder(); + } + + private void prepareRetrievedMarkersEventRecorder() { + SAXEventRecorder eventRecorder = new SAXEventRecorder(); + retrievedMarkersEventRecorder = eventRecorder; + delegate = StructureTree2SAXEventAdapter.newInstance(eventRecorder); } - public StructureTreeElement startNode(String name, Attributes attributes) { - delegate.startNode(name, attributes); + public StructureTreeElement startNode(String name, Attributes attributes, StructureTreeElement parent) { + if (parent != null) { + attributes = addParentAttribute(new AttributesImpl(attributes), parent); + } + delegate.startNode(name, attributes, null); return new IFStructureTreeElement(); } + private AttributesImpl addParentAttribute(AttributesImpl attributes, StructureTreeElement parent) { + if (parent != null) { + attributes.addAttribute(InternalElementMapping.URI, + InternalElementMapping.STRUCT_REF, + InternalElementMapping.STANDARD_PREFIX + ":" + InternalElementMapping.STRUCT_REF, + XMLConstants.CDATA, + ((IFStructureTreeElement) parent).getId()); + } + return attributes; + } + public void endNode(String name) { delegate.endNode(name); } - public StructureTreeElement startImageNode(String name, Attributes attributes) { + public StructureTreeElement startImageNode(String name, Attributes attributes, StructureTreeElement parent) { String id = getNextID(); AttributesImpl atts = addIDAttribute(attributes, id); - delegate.startImageNode(name, atts); + addParentAttribute(atts, parent); + delegate.startImageNode(name, atts, null); return new IFStructureTreeElement(id); } - public StructureTreeElement startReferencedNode(String name, Attributes attributes) { + public StructureTreeElement startReferencedNode(String name, Attributes attributes, StructureTreeElement parent) { String id = getNextID(); AttributesImpl atts = addIDAttribute(attributes, id); - delegate.startReferencedNode(name, atts); + addParentAttribute(atts, parent); + delegate.startReferencedNode(name, atts, null); return new IFStructureTreeElement(id); } diff --git a/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java b/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java index c532a05a4..2eb5bc8aa 100644 --- a/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java @@ -128,9 +128,10 @@ class PDFLogicalStructureHandler { } private MarkedContentInfo addToParentTree(PDFStructElem structureTreeElement) { - PDFStructElem parent = (structureTreeElement instanceof PDFStructElem.Placeholder) - ? structureTreeElement.getParentStructElem() - : structureTreeElement; + PDFStructElem parent = structureTreeElement; + while (parent instanceof PDFStructElem.Placeholder) { + parent = parent.getParentStructElem(); + } pageParentTreeArray.add(parent); String type = parent.getStructureType().getName().toString(); int mcid = pageParentTreeArray.length() - 1; diff --git a/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java b/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java index 08aad08f6..4d34b8be4 100644 --- a/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java +++ b/src/java/org/apache/fop/render/pdf/PDFStructureTreeBuilder.java @@ -96,8 +96,11 @@ class PDFStructureTreeBuilder implements StructureTreeEventHandler { addBuilder("float", StandardStructureTypes.Grouping.DIV); addBuilder("footnote", StandardStructureTypes.InlineLevelStructure.NOTE); addBuilder("footnote-body", StandardStructureTypes.Grouping.SECT); + // Other Formatting Objects addBuilder("wrapper", StandardStructureTypes.InlineLevelStructure.SPAN); addBuilder("marker", StandardStructureTypes.Grouping.PRIVATE); + addBuilder("retrieve-marker", new PlaceholderBuilder()); + addBuilder("retrieve-table-marker", new PlaceholderBuilder()); addBuilder("#PCDATA", new PlaceholderBuilder()); } @@ -354,9 +357,9 @@ class PDFStructureTreeBuilder implements StructureTreeEventHandler { public void endPageSequence() { } - public StructureTreeElement startNode(String name, Attributes attributes) { - PDFStructElem parent = ancestors.getFirst(); - PDFStructElem structElem = createStructureElement(name, parent, attributes, + public StructureTreeElement startNode(String name, Attributes attributes, StructureTreeElement parent) { + PDFStructElem parentElem = parent == null ? ancestors.getFirst() : (PDFStructElem) parent; + PDFStructElem structElem = createStructureElement(name, parentElem, attributes, pdfFactory, eventBroadcaster); ancestors.addFirst(structElem); return structElem; @@ -366,12 +369,12 @@ class PDFStructureTreeBuilder implements StructureTreeEventHandler { ancestors.removeFirst(); } - public StructureTreeElement startImageNode(String name, Attributes attributes) { - return startNode(name, attributes); + public StructureTreeElement startImageNode(String name, Attributes attributes, StructureTreeElement parent) { + return startNode(name, attributes, parent); } - public StructureTreeElement startReferencedNode(String name, Attributes attributes) { - return startNode(name, attributes); + public StructureTreeElement startReferencedNode(String name, Attributes attributes, StructureTreeElement parent) { + return startNode(name, attributes, parent); } } diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileElement.java b/src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileElement.java index b2d85dd10..36d7c18d2 100644 --- a/src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileElement.java +++ b/src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileElement.java @@ -49,7 +49,7 @@ public class PDFEmbeddedFileElement extends AbstractPDFExtensionElement { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); if (parent.getNameId() != Constants.FO_DECLARATIONS) { invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java index a8bab26b6..11b2e5f7b 100644 --- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java @@ -42,7 +42,7 @@ public abstract class AbstractPSCommentElement extends AbstractPSExtensionElemen * @throws FOPException if there's a problem during processing * @see org.apache.fop.fo.FONode#startOfNode() */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { if (parent.getNameId() != Constants.FO_DECLARATIONS && parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) { invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java index 3f534af7e..c79d31613 100644 --- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java @@ -97,7 +97,7 @@ public abstract class AbstractPSExtensionElement extends FONode { * @see org.apache.fop.fo.FONode#endOfNode() * @throws FOPException if there's a problem during processing */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); String s = ((PSExtensionAttachment)getExtensionAttachment()).getContent(); if (s == null || s.length() == 0) { diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java index d097e7b5e..1ee48d9d6 100644 --- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java +++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionObject.java @@ -86,7 +86,7 @@ public abstract class AbstractPSExtensionObject extends FONode { } /** {@inheritDoc} */ - protected void endOfNode() throws FOPException { + public void endOfNode() throws FOPException { super.endOfNode(); String s = setupCode.getContent(); if (s == null || s.length() == 0) { diff --git a/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java index 686667c3d..cf2ea9444 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSPageSetupCodeElement.java @@ -40,7 +40,7 @@ public class PSPageSetupCodeElement extends AbstractPSExtensionObject { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) { invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java index 6cdd1c60c..ebae5baaf 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java @@ -49,7 +49,7 @@ public class PSSetPageDeviceElement extends AbstractPSExtensionElement { * @throws FOPException if there's a problem during processing * @see org.apache.fop.fo.FONode#startOfNode() */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); if ( !((parent.getNameId() == Constants.FO_DECLARATIONS) || (parent.getNameId() == Constants.FO_SIMPLE_PAGE_MASTER)) ) { diff --git a/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java index 4ac0af2b7..365275455 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSSetupCodeElement.java @@ -40,7 +40,7 @@ public class PSSetupCodeElement extends AbstractPSExtensionObject { } /** {@inheritDoc} */ - protected void startOfNode() throws FOPException { + public void startOfNode() throws FOPException { super.startOfNode(); if (parent.getNameId() != Constants.FO_DECLARATIONS) { invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(), diff --git a/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java b/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java index 6819fed79..4df3fe278 100644 --- a/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java +++ b/test/java/org/apache/fop/render/intermediate/IFStructureTreeBuilderTestCase.java @@ -90,7 +90,7 @@ public class IFStructureTreeBuilderTestCase { final ContentHandler handler = mock(ContentHandler.class); sut.startPageSequence(null, null); - sut.startNode(nodeName, createSimpleAttributes(attributes)); + sut.startNode(nodeName, createSimpleAttributes(attributes), null); sut.endPageSequence(); sut.replayEventsForPageSequence(handler, 0); diff --git a/test/pdf/accessibility/markers.fo b/test/pdf/accessibility/markers.fo new file mode 100644 index 000000000..67dbfc3d4 --- /dev/null +++ b/test/pdf/accessibility/markers.fo @@ -0,0 +1,169 @@ + + + + + + + + + + + Retrieving the marker: + + Marker retrieved. + + + + + + + + + Inside a block-container. + + + + A character: . + + + + + + + + + + + + + + Leader. + Page . + + Absolute. + + + + + + + + 1.1 + + + 1.2 + + + 1.3 + + + 1.4 + + + + + 2.1 + + + 2.2 + + + 2.3 + + + 2.4 + + + + Text in the region-body. + + + + + + This whole page footer should neither appear in the structure tree nor be read out + loud. + Retrieving the marker: + + Marker retrieved. + + + + + + + + + Inside a block-container. + + + + A character: . + + + + + + + + + + + + + + Leader. + Page . + + Absolute. + + + + + + + + 1.1 + + + 1.2 + + + 1.3 + + + 1.4 + + + + + 2.1 + + + 2.2 + + + 2.3 + + + 2.4 + + + + Text in the region-body. + + + diff --git a/test/pdf/accessibility/pdf/markers.pdf b/test/pdf/accessibility/pdf/markers.pdf new file mode 100644 index 0000000000000000000000000000000000000000..752fbd10df4c9773409bb9926d8c5f82a6c84d3f GIT binary patch literal 34636 zcmeG_31Cyjwm0cUL(A5JfGk7V!6tXfTG~QaTA)zc%8rsIw{0LxNm5#HS40J$C@Lbj zB2NVreEI~$9Z_6(DDL|M`G}}b@hNWj^q-k~lia0Cx~Qm)(#$=XIdf*_%$ak}Ju@@B zG`}#N(HnKcw`{%dew`7~$XB^gmzk+EDej07Q+&bJ47G%7!Xr5TPk(pH8snN7B_G&_=}M~>EIXX|*c z6H{RdQ-cgs5r+&@cyD#E2AOQ|Lm7gMfglj+(NR=V(G-{0r|m&e9&gZJHZd2?nmq?4 z9H6vRA{9?D6lHe=YD>xsD=7FB7v!M;WWwpl=i4_a4Ssqpy{HtS2t2A(Pe-jkNKu+n z$jv$VfCJLYA?>aY)?)YxNT*gV!f9i7Q zK{}J7x+GOg(v^~QkZ%AwDJsubyVUQht_h-1j?sv**{rCDuXppoV0x+DvB>UsqCB6c z*6v+OQ9_$>DXJIlTLhhKW^872I;)574}Y5dF`TRU1Rh%<$Jf)zm}&a#kH8{jBQW1a zin5-BzPUC6tGt<_c3w_Vecz41hTTC?-Ir6;j+Z6v>4W*DCK#;EFc|9V>-8?)p~oE> z{A2@)%j5XrX-Kjl}y~`f)cVMbevVjSMh${ z3subkE^~RSVYt0cR}hN;m$#`AZeuYC4LB+AH6&6t{Y<5vtEYOroJz&~XFnC2(v^yt zcN_eo36I;9#2FNxc{2we6Zjs|@H_b{`=ebAkJ^B%8ewo=Sp{;``Iq1{%nAG_j?z)x zsZ^>THHaEYjiS;ima8Ba28LkC+({9w>r`@4_TKkgr4ecTA zX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