aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/accessibility/Accessibility.java6
-rw-r--r--src/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java25
-rw-r--r--src/java/org/apache/fop/fo/flow/Wrapper.java19
3 files changed, 47 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/accessibility/Accessibility.java b/src/java/org/apache/fop/accessibility/Accessibility.java
index c842cf43f..88ec6dbdd 100644
--- a/src/java/org/apache/fop/accessibility/Accessibility.java
+++ b/src/java/org/apache/fop/accessibility/Accessibility.java
@@ -28,6 +28,12 @@ public final class Accessibility {
/** Constant string for the rendering options key to enable accessibility features. */
public static final String ACCESSIBILITY = "accessibility";
+ /**
+ * The value to be set on the 'role' property for the element and its descendants to
+ * be considered as artifacts.
+ */
+ public static final String ROLE_ARTIFACT = "artifact";
+
private Accessibility() { }
}
diff --git a/src/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java b/src/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java
index 47c227e9a..27469d6e0 100644
--- a/src/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java
+++ b/src/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java
@@ -23,6 +23,7 @@ import java.util.Stack;
import org.xml.sax.SAXException;
+import org.apache.fop.accessibility.Accessibility;
import org.apache.fop.accessibility.StructureTreeEventHandler;
import org.apache.fop.fo.DelegatingFOEventHandler;
import org.apache.fop.fo.FOEventHandler;
@@ -57,6 +58,8 @@ import org.apache.fop.fo.pagination.Flow;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.Root;
import org.apache.fop.fo.pagination.StaticContent;
+import org.apache.fop.fo.properties.CommonAccessibility;
+import org.apache.fop.fo.properties.CommonAccessibilityHolder;
/**
* Allows to create the structure tree of an FO document, by converting FO
@@ -355,6 +358,7 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler {
@Override
public void startStatic(StaticContent staticContent) {
+ handleStartArtifact(staticContent);
converter.startStatic(staticContent);
super.startStatic(staticContent);
}
@@ -362,6 +366,7 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler {
@Override
public void endStatic(StaticContent statisContent) {
converter.endStatic(statisContent);
+ handleEndArtifact(statisContent);
super.endStatic(statisContent);
}
@@ -454,6 +459,7 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler {
@Override
public void startWrapper(Wrapper wrapper) {
+ handleStartArtifact(wrapper);
converter.startWrapper(wrapper);
super.startWrapper(wrapper);
}
@@ -461,6 +467,7 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler {
@Override
public void endWrapper(Wrapper wrapper) {
converter.endWrapper(wrapper);
+ handleEndArtifact(wrapper);
super.endWrapper(wrapper);
}
@@ -488,4 +495,22 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler {
super.endExternalDocument(document);
}
+ private void handleStartArtifact(CommonAccessibilityHolder fobj) {
+ if (isArtifact(fobj)) {
+ converters.push(converter);
+ converter = eventSwallower;
+ }
+ }
+
+ private void handleEndArtifact(CommonAccessibilityHolder fobj) {
+ if (isArtifact(fobj)) {
+ converter = converters.pop();
+ }
+ }
+
+ private boolean isArtifact(CommonAccessibilityHolder fobj) {
+ CommonAccessibility accessibility = fobj.getCommonAccessibility();
+ return Accessibility.ROLE_ARTIFACT.equalsIgnoreCase(accessibility.getRole());
+ }
+
}
diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java
index 1302e3134..0aec7ce16 100644
--- a/src/java/org/apache/fop/fo/flow/Wrapper.java
+++ b/src/java/org/apache/fop/fo/flow/Wrapper.java
@@ -26,7 +26,10 @@ import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FOText;
import org.apache.fop.fo.FObjMixed;
+import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.properties.CommonAccessibility;
+import org.apache.fop.fo.properties.CommonAccessibilityHolder;
/**
* Class modelling the <a href=http://www.w3.org/TR/xsl/#fo_wrapper">
@@ -34,13 +37,13 @@ import org.apache.fop.fo.ValidationException;
* The <code>fo:wrapper</code> object serves as a property holder for
* its child node objects.
*/
-public class Wrapper extends FObjMixed {
- // The value of properties relevant for fo:wrapper.
- // End of property values
+public class Wrapper extends FObjMixed implements CommonAccessibilityHolder {
// used for FO validation
private boolean blockOrInlineItemFound = false;
+ private CommonAccessibility commonAccessibility;
+
/**
* Create a Wrapper instance that is a child of the
* given {@link FONode}
@@ -52,6 +55,12 @@ public class Wrapper extends FObjMixed {
}
@Override
+ public void bind(PropertyList pList) throws FOPException {
+ super.bind(pList);
+ commonAccessibility = CommonAccessibility.getInstance(pList);
+ }
+
+ @Override
protected void startOfNode() throws FOPException {
super.startOfNode();
getFOEventHandler().startWrapper(this);
@@ -136,6 +145,10 @@ public class Wrapper extends FObjMixed {
return FO_WRAPPER;
}
+ public CommonAccessibility getCommonAccessibility() {
+ return commonAccessibility;
+ }
+
@Override
public boolean isDelimitedTextRangeBoundary ( int boundary ) {
return false;