}
/** {@inheritDoc} */
- public StructureTreeElement startNode(String name, Attributes attributes) {
+ public StructureTreeElement startNode(String name, Attributes attributes, StructureTreeElement parent) {
return null;
}
}
/** {@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;
}
}
/** {@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";
}
/** {@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);
}
}
*
* @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.
*
* @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
*
* @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.
package org.apache.fop.accessibility.fo;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Stack;
import org.xml.sax.SAXException;
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;
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;
/** The top of the {@link converters} stack. */
private FOEventHandler converter;
- private final Stack<FOEventHandler> converters = new Stack<FOEventHandler>();
+ private Stack<FOEventHandler> converters = new Stack<FOEventHandler>();
- 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<AbstractRetrieveMarker, State> states = new HashMap<AbstractRetrieveMarker, State>();
+
+ private static final class State {
+
+ private final FOEventHandler converter;
+
+ private final Stack<FOEventHandler> converters;
+
+ @SuppressWarnings("unchecked")
+ State(FO2StructureTreeConverter o) {
+ this.converter = o.converter;
+ this.converters = (Stack<FOEventHandler>) o.converters.clone();
+ }
+
+ }
+
/**
* Creates a new instance.
*
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<FOEventHandler>) 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);
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;
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;
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;
private LayoutMasterSet layoutMasterSet;
- private final Stack<Table> tables = new Stack<Table>();
+ private Stack<Table> tables = new Stack<Table>();
- private final Stack<Boolean> inTableHeader = new Stack<Boolean>();
+ private Stack<Boolean> inTableHeader = new Stack<Boolean>();
- private final Stack<Locale> locales = new Stack<Locale>();
+ private Stack<Locale> locales = new Stack<Locale>();
+
+ private final Map<AbstractRetrieveMarker, State> states = new HashMap<AbstractRetrieveMarker, State>();
+
+ private static final class State {
+
+ private final Stack<Table> tables;
+
+ private final Stack<Boolean> inTableHeader;
+
+ private final Stack<Locale> locales;
+
+ @SuppressWarnings("unchecked")
+ State(StructureTreeEventTrigger o) {
+ this.tables = (Stack<Table>) o.tables.clone();
+ this.inTableHeader = (Stack<Boolean>) o.inTableHeader.clone();
+ this.locales = (Stack<Locale>) o.locales.clone();
+ }
+
+ }
public StructureTreeEventTrigger(StructureTreeEventHandler structureTreeEventHandler) {
this.structureTreeEventHandler = structureTreeEventHandler;
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<Table>) state.tables.clone();
+ inTableHeader = (Stack<Boolean>) state.inTableHeader.clone();
+ locales = (Stack<Locale>) 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());
}
- private void startElement(FONode node) {
- startElement(node, new AttributesImpl());
+ private StructureTreeElement startElement(FONode node) {
+ return startElement(node, new AttributesImpl());
}
private void startElementWithID(FONode node) {
addRole((CommonAccessibilityHolder) node, attributes);
}
node.setStructureTreeElement(
- structureTreeEventHandler.startReferencedNode(localName, attributes));
+ structureTreeEventHandler.startReferencedNode(localName, attributes,
+ node.getParent().getStructureTreeElement()));
}
private void startElementWithIDAndAltText(AbstractGraphics node) {
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) {
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) {
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;
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);
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;
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.
+ * <p>The default implementation of this method does nothing.</p>
+ *
+ * @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.
*
* @throws FOPException if there's a problem during processing
*/
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
// do nothing by default
}
*
* @throws FOPException if there's a problem during processing
*/
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
this.finalizeNode();
}
throw new UnsupportedOperationException();
}
+ /**
+ * Returns the structure tree element associated to this object.
+ *
+ * @return the structure tree element
+ */
+ public StructureTreeElement getStructureTreeElement() {
+ return null;
+ }
+
}
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if ( charBuffer != null ) {
charBuffer.rewind();
}
this.structureTreeElement = structureTreeElement;
}
- /** @return the structure tree element. */
+ @Override
public StructureTreeElement getStructureTreeElement() {
return structureTreeElement;
}
// 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();
}
}
// 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();
}
* {@inheritDoc}
* @throws FOPException FOP Exception
*/
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
if (id != null) {
checkId(id);
}
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,
/** {@inheritDoc} */
@Override
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
super.endOfNode();
if (!inMarker() || getNameId() == FO_MARKER) {
* @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);
}
* @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();
}
/**
* {@inheritDoc}
*/
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
root.addDestination(this);
}
this.structureTreeElement = structureTreeElement;
}
- /** {@inheritDoc} */
+ @Override
public StructureTreeElement getStructureTreeElement() {
return structureTreeElement;
}
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (!this.blockItemFound) {
String contentModel = "marker* (%block;)+";
getFOValidationEventProducer().missingChildElement(this, getName(),
this.structureTreeElement = structureTreeElement;
}
- /** {@inheritDoc} */
+ @Override
public StructureTreeElement getStructureTreeElement() {
return structureTreeElement;
}
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;
private int boundary;
private String boundaryLabel;
+ private StructureTreeElement structureTreeElement;
+
/**
* Create a new AbstractRetrieveMarker instance that
* is a child of the given {@link FONode}
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);
}
pList,
newPropertyList);
addChildTo(newChild, newParent);
+ newChild.startOfNode();
switch ( newChild.getNameId() ) {
case FO_TABLE:
Table t = (Table) child;
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();
}
}
}
if (marker.getChildNodes() != null) {
try {
+ restoreFOEventHandlerState();
cloneFromMarker(marker);
} catch (FOPException exc) {
getFOValidationEventProducer().markerCloningFailed(this,
}
}
+ protected abstract void restoreFOEventHandlerState();
+
/**
* Return the value for the <code>retrieve-class-name</code>
* property
}
/** {@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);
}
this.structureTreeElement = structureTreeElement;
}
- /** {@inheritDoc} */
+ @Override
public StructureTreeElement getStructureTreeElement() {
return structureTreeElement;
}
}
/** {@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);
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
super.startOfNode();
getFOEventHandler().startBlockContainer(this);
}
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (!blockItemFound) {
missingChildElementError("marker* (%block;)+");
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
super.startOfNode();
getFOEventHandler().character(this);
}
this.structureTreeElement = structureTreeElement;
}
- /** {@inheritDoc} */
+ @Override
public StructureTreeElement getStructureTreeElement() {
return structureTreeElement;
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
super.startOfNode();
getFOEventHandler().image(this);
}
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (firstChild == null) {
missingChildElementError("(%block;)+");
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
getFOEventHandler().startFootnote(this);
}
*
* {@inheritDoc}
*/
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
super.endOfNode();
if (footnoteCitation == null || footnoteBody == null) {
missingChildElementError("(inline,footnote-body)");
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
getFOEventHandler().startFootnoteBody(this);
}
* end of the footnote-body.
* {@inheritDoc}
*/
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (firstChild == null) {
missingChildElementError("(%block;)+");
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
super.startOfNode();
/* Check to see if this node can have block-level children.
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
super.endOfNode();
getFOEventHandler().endInline(this);
}
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (!blockItemFound) {
missingChildElementError("marker* (%block;)+");
}
}
@Override
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
super.startOfNode();
getFOEventHandler().startInstreamForeignObject(this);
}
* 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");
}
}
@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);
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
super.startOfNode();
getFOEventHandler().startList(this);
}
* of the list-block.
* {@inheritDoc}
*/
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (!hasListItem) {
missingChildElementError("marker* (list-item)+");
}
}
/** {@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)");
}
}
/** {@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);
}
}
/** {@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);
}
}
/** {@inheritDoc} */
- protected void startOfNode() {
+ public void startOfNode() {
FOTreeBuilderContext builderContext = getBuilderContext();
// Push a new property list maker which will make MarkerPropertyLists.
savePropertyListMaker = builderContext.getPropertyListMaker();
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
super.endOfNode();
// Pop the MarkerPropertyList maker.
getBuilderContext().setPropertyListMaker(savePropertyListMaker);
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (!hasMultiPropertySet || !hasWrapper) {
missingChildElementError("(multi-property-set+, wrapper)");
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (firstChild == null) {
missingChildElementError("(multi-case+)");
}
}
/** {@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);
}
this.structureTreeElement = structureTreeElement;
}
- /** {@inheritDoc} */
+ @Override
public StructureTreeElement getStructureTreeElement() {
return structureTreeElement;
}
}
/** {@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);
}
}
/** {@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);
}
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 <code>retrieve-position</code>
* property
public int getNameId() {
return FO_RETRIEVE_MARKER;
}
+
+ @Override
+ protected void restoreFOEventHandlerState() {
+ getFOEventHandler().restoreState(this);
+ }
+
}
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 <code>retrieve-position-within-table</code>
* property
this.lastFOTextProcessed = null;
}
+ @Override
+ protected void restoreFOEventHandlerState() {
+ getFOEventHandler().restoreState(this);
+ }
+
}
}
@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);
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
super.startOfNode();
getFOEventHandler().startTable(this);
}
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
super.endOfNode();
getFOEventHandler().endTable(this);
}
* 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");
}
}
/** {@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);
}
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (firstChild == null) {
missingChildElementError("marker* (%block;)");
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
super.startOfNode();
getFOEventHandler().startCell(this);
}
* 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);
}
}
/** {@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);
}
}
/** {@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);
}
}
/** {@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);
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
this.pageNumberGenerator = new PageNumberGenerator(
format, groupingSeparator, groupingSize, letterValue,
numberConversionFeatures, language, country);
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
getConcreteParent().addConditionalPageMasterReference(this);
}
* 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();
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
if (flowName == null || flowName.equals("")) {
missingPropertyError(FLOW_NAME);
}
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (!blockItemFound) {
missingChildElementError("marker* (%block;)+");
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
getRoot().setLayoutMasterSet(this);
simplePageMasters = new java.util.HashMap<String, SimplePageMaster>();
pageSequenceMasters = new java.util.HashMap<String, PageSequenceMaster>();
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (firstChild == null) {
missingChildElementError("(simple-page-master|page-sequence-master)+");
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
super.startOfNode();
flowMap = new java.util.HashMap<String, FONode>();
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (mainFlow == null) {
missingChildElementError("(title?,static-content*,flow)");
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
subSequenceSpecifiers = new java.util.ArrayList<SubSequenceSpecifier>();
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)+");
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
conditionalPageMasterRefs = new java.util.ArrayList<ConditionalPageMasterReference>();
assert parent.getName().equals("fo:page-sequence-master"); //Validation by the parent
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (firstChild == null) {
missingChildElementError("(conditional-page-master-reference+)");
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent;
if (masterReference == null) {
}
/** {@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)+)");
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
LayoutMasterSet layoutMasterSet = (LayoutMasterSet) parent;
if (masterName == null) {
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (!hasRegionBody) {
missingChildElementError(
"(region-body, region-before?, region-after?, region-start?, region-end?)");
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent;
pageSequenceMaster.addSubsequenceSpecifier(this);
}
}
/** {@inheritDoc} */
- protected void startOfNode() throws FOPException {
+ public void startOfNode() throws FOPException {
if (getFlowName() == null || getFlowName().equals("")) {
missingPropertyError(FLOW_NAME);
}
* 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;)+");
}
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (bookmarkTitle == null) {
missingChildElementError("(bookmark-title, bookmark*)");
}
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
if (bookmarks == null) {
missingChildElementError("(fo:bookmark+)");
}
private StructureType structureType;
- private PDFStructElem parentElement;
+ protected PDFStructElem parentElement;
/**
* Elements to be added to the kids array.
textBuffer.append(' ');
}
Object obj = kids.get(i);
+ if (obj instanceof PDFStructElem) {
+ ((PDFStructElem) obj).setParent(parentElement);
+ }
formatObject(obj, out, textBuffer);
}
}
}
/** {@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(),
}
/** {@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) {
}
/** {@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
/** {@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
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
super.endOfNode();
}
private Map<String, StructureTreeElement> structureTreeElements
= new HashMap<String, StructureTreeElement>();
- 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
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);
}
}
}
}
+ 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;
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)) {
public void startElement(Attributes attributes) throws IFException {
documentHandler.startPageHeader();
+ structureTreeHandler = new StructureTreeHandler(userAgent.getStructureTreeEventHandler());
}
public void endElement() throws IFException {
}
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;
}
}
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);
}
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;
/**
private final List<SAXEventRecorder> pageSequenceEventRecorders
= new ArrayList<SAXEventRecorder>();
+ private SAXEventRecorder retrievedMarkersEventRecorder;
+
private int idCounter;
/**
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);
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);
}
}
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;
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());
}
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;
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);
}
}
}
/** {@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(),
* @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(),
* @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) {
}
/** {@inheritDoc} */
- protected void endOfNode() throws FOPException {
+ public void endOfNode() throws FOPException {
super.endOfNode();
String s = setupCode.getContent();
if (s == null || s.length() == 0) {
}
/** {@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(),
* @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)) ) {
}
/** {@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(),
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);
--- /dev/null
+<?xml version="1.0" standalone="no"?>
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" xml:lang="en-GB">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page"
+ page-height="200pt" page-width="280pt" margin="10pt">
+ <fo:region-body/>
+ <fo:region-after extent="100pt" display-align="after"/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="page">
+ <fo:static-content flow-name="xsl-region-after" line-height="10pt" font-size="8pt">
+ <fo:block>Retrieving the marker:</fo:block>
+ <fo:retrieve-marker retrieve-class-name="marker"/>
+ <fo:block>Marker retrieved.</fo:block>
+ </fo:static-content>
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block><fo:marker marker-class-name="marker">
+ <fo:table width="100%" table-layout="fixed">
+ <fo:table-header>
+ <fo:table-row>
+ <fo:table-cell border="1pt solid black">
+ <fo:block-container>
+ <fo:block>Inside a block-container.</fo:block>
+ </fo:block-container>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>A character: <fo:character character="c" color="blue"/>.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block text-align="center"><fo:instream-foreign-object fox:alt-text="Nice
+ circles." width="30pt" overflow="hidden" display-align="center"
+ content-width="30pt">
+ <svg xmlns="http://www.w3.org/2000/svg" width="319" height="286.6">
+ <g style="fill-opacity:0.7; stroke:black; stroke-width:3"
+ transform="translate(0, 286.6) scale(1, -1) translate(100, 100)">
+ <circle cx="50" cy="86.6" r="80" style="fill:red;"/>
+ <circle cx="0" cy="0" r="80" style="fill:green;"/>
+ <circle cx="100" cy="0" r="80" style="fill:blue;"/>
+ </g>
+ </svg>
+ </fo:instream-foreign-object></fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block text-align-last="justify">Lead<fo:leader leader-pattern="dots"
+ leader-length.minimum="0" leader-length.optimum="100%"/>er.</fo:block>
+ <fo:block>Page <fo:page-number/>.</fo:block>
+ <fo:block-container absolute-position="absolute" width="35pt" height="10pt" top="20pt"
+ right="2pt" color="purple" text-align="right">
+ <fo:block>Absolute.</fo:block>
+ </fo:block-container>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-header>
+ <fo:table-body>
+ <fo:table-row>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>1.1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>1.2</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>1.3</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>1.4</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>2.1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>2.2</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>2.3</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>2.4</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table></fo:marker>Text in the region-body.</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+
+ <fo:page-sequence master-reference="page">
+ <fo:static-content flow-name="xsl-region-after" line-height="10pt" font-size="8pt"
+ role="artifact">
+ <fo:block>This whole page footer should neither appear in the structure tree nor be read out
+ loud.</fo:block>
+ <fo:block>Retrieving the marker:</fo:block>
+ <fo:retrieve-marker retrieve-class-name="marker"/>
+ <fo:block>Marker retrieved.</fo:block>
+ </fo:static-content>
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block><fo:marker marker-class-name="marker">
+ <fo:table width="100%" table-layout="fixed">
+ <fo:table-header>
+ <fo:table-row>
+ <fo:table-cell border="1pt solid black">
+ <fo:block-container>
+ <fo:block>Inside a block-container.</fo:block>
+ </fo:block-container>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>A character: <fo:character character="c" color="blue"/>.</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block text-align="center"><fo:instream-foreign-object fox:alt-text="Nice
+ circles." width="30pt" overflow="hidden" display-align="center"
+ content-width="30pt">
+ <svg xmlns="http://www.w3.org/2000/svg" width="319" height="286.6">
+ <g style="fill-opacity:0.7; stroke:black; stroke-width:3"
+ transform="translate(0, 286.6) scale(1, -1) translate(100, 100)">
+ <circle cx="50" cy="86.6" r="80" style="fill:red;"/>
+ <circle cx="0" cy="0" r="80" style="fill:green;"/>
+ <circle cx="100" cy="0" r="80" style="fill:blue;"/>
+ </g>
+ </svg>
+ </fo:instream-foreign-object></fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block text-align-last="justify">Lead<fo:leader leader-pattern="dots"
+ leader-length.minimum="0" leader-length.optimum="100%"/>er.</fo:block>
+ <fo:block>Page <fo:page-number/>.</fo:block>
+ <fo:block-container absolute-position="absolute" width="35pt" height="10pt" top="20pt"
+ right="2pt" color="purple" text-align="right">
+ <fo:block>Absolute.</fo:block>
+ </fo:block-container>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-header>
+ <fo:table-body>
+ <fo:table-row>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>1.1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>1.2</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>1.3</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>1.4</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>2.1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>2.2</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>2.3</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black">
+ <fo:block>2.4</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table></fo:marker>Text in the region-body.</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+</fo:root>