git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1465599 13f79535-47bb-0310-9956-ffa450edef68tags/fop-2_0
@@ -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; | |||
} | |||
@@ -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); | |||
} | |||
} |
@@ -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. |
@@ -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<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. | |||
* | |||
@@ -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<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); |
@@ -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<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; | |||
@@ -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<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()); | |||
@@ -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) { |
@@ -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); |
@@ -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. | |||
* <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. |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} |
@@ -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(); | |||
} | |||
@@ -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); | |||
} |
@@ -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) { |
@@ -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(); | |||
} |
@@ -61,7 +61,7 @@ public class Destination extends FONode { | |||
/** | |||
* {@inheritDoc} | |||
*/ | |||
protected void endOfNode() throws FOPException { | |||
public void endOfNode() throws FOPException { | |||
root.addDestination(this); | |||
} | |||
@@ -234,7 +234,7 @@ public abstract class AbstractGraphics extends FObj | |||
this.structureTreeElement = structureTreeElement; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public StructureTreeElement getStructureTreeElement() { | |||
return structureTreeElement; | |||
} |
@@ -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(), |
@@ -160,7 +160,7 @@ public abstract class AbstractPageNumberCitation extends FObj | |||
this.structureTreeElement = structureTreeElement; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public StructureTreeElement getStructureTreeElement() { | |||
return structureTreeElement; | |||
} |
@@ -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 <code>retrieve-class-name</code> | |||
* property |
@@ -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; | |||
} |
@@ -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); | |||
} |
@@ -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;)+"); | |||
} |
@@ -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; | |||
} |
@@ -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); | |||
} |
@@ -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;)+"); | |||
} |
@@ -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)"); |
@@ -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;)+"); | |||
} |
@@ -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); | |||
} |
@@ -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;)+"); | |||
} |
@@ -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"); | |||
} |
@@ -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); | |||
} |
@@ -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)+"); | |||
} |
@@ -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)"); | |||
} |
@@ -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); | |||
} |
@@ -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); | |||
} |
@@ -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); |
@@ -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)"); | |||
} |
@@ -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+)"); | |||
} |
@@ -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; | |||
} |
@@ -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); | |||
} |
@@ -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); | |||
} |
@@ -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 <code>retrieve-position</code> | |||
* property | |||
@@ -108,4 +120,10 @@ public class RetrieveMarker extends AbstractRetrieveMarker { | |||
public int getNameId() { | |||
return FO_RETRIEVE_MARKER; | |||
} | |||
@Override | |||
protected void restoreFOEventHandlerState() { | |||
getFOEventHandler().restoreState(this); | |||
} | |||
} |
@@ -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 <code>retrieve-position-within-table</code> | |||
* property | |||
@@ -113,4 +125,9 @@ public class RetrieveTableMarker extends AbstractRetrieveMarker { | |||
this.lastFOTextProcessed = null; | |||
} | |||
@Override | |||
protected void restoreFOEventHandlerState() { | |||
getFOEventHandler().restoreState(this); | |||
} | |||
} |
@@ -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); | |||
} |
@@ -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); | |||
} |
@@ -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"); | |||
} |
@@ -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); | |||
} |
@@ -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;)"); | |||
} |
@@ -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); | |||
} |
@@ -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); | |||
} |
@@ -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); | |||
} |
@@ -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); | |||
} |
@@ -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); |
@@ -72,7 +72,7 @@ public class ConditionalPageMasterReference extends FObj { | |||
} | |||
/** {@inheritDoc} */ | |||
protected void startOfNode() throws FOPException { | |||
public void startOfNode() throws FOPException { | |||
getConcreteParent().addConditionalPageMasterReference(this); | |||
} | |||
@@ -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(); |
@@ -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;)+"); | |||
} |
@@ -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<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)+"); | |||
} |
@@ -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<String, FONode>(); | |||
@@ -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)"); | |||
} |
@@ -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<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)+"); |
@@ -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<ConditionalPageMasterReference>(); | |||
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+)"); | |||
} |
@@ -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) { |
@@ -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)+)"); |
@@ -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?)"); |
@@ -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); | |||
} |
@@ -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;)+"); | |||
} |
@@ -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*)"); | |||
} |
@@ -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+)"); | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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(), |
@@ -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) { |
@@ -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 |
@@ -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 |
@@ -86,7 +86,7 @@ public abstract class AbstractAFPExtensionObject extends FONode { | |||
} | |||
/** {@inheritDoc} */ | |||
protected void endOfNode() throws FOPException { | |||
public void endOfNode() throws FOPException { | |||
super.endOfNode(); | |||
} | |||
@@ -163,25 +163,15 @@ public class IFParser implements IFConstants { | |||
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 | |||
@@ -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; | |||
} | |||
} | |||
@@ -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); | |||
} |
@@ -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<SAXEventRecorder> pageSequenceEventRecorders | |||
= new ArrayList<SAXEventRecorder>(); | |||
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); | |||
} | |||
@@ -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; |
@@ -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); | |||
} | |||
} |
@@ -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(), |
@@ -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(), |
@@ -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) { |
@@ -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) { |
@@ -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(), |
@@ -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)) ) { |
@@ -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(), |
@@ -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); |
@@ -0,0 +1,169 @@ | |||
<?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> |