Author: vhennebert
Date: Thu Oct 22 15:30:13 2009
New Revision: 828747

URL: http://svn.apache.org/viewvc?rev=828747&view=rev
Log:
Issue an error when attempting to render an intermediate XML file in 
accessibility mode, but that file wasn't generated with accessibility (i.e., 
does not contain the structure tree)

Added:
    
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java
   (with props)
    
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml
   (with props)
Modified:
    
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/area/AreaTreeParser.java
    
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java

Added: 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java?rev=828747&view=auto
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java
 (added)
+++ 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java
 Thu Oct 22 15:30:13 2009
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.accessibility;
+
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+
+/**
+ * Event producer for accessibility-related events.
+ */
+public interface AccessibilityEventProducer extends EventProducer {
+
+    /** Provider class for the event producer. */
+    public final class Provider {
+
+        private Provider() { }
+
+        /**
+         * Returns an event producer.
+         *
+         * @param broadcaster the event broadcaster to use
+         * @return the event producer
+         */
+        public static AccessibilityEventProducer get(EventBroadcaster 
broadcaster) {
+            return (AccessibilityEventProducer) 
broadcaster.getEventProducerFor(
+                    AccessibilityEventProducer.class);
+        }
+    }
+
+    /**
+     * The structure tree is missing in the XML file.
+     *
+     * @param source the event source
+     * @event.severity FATAL
+     */
+    void noStructureTreeInXML(Object source);
+}

Propchange: 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Added: 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml?rev=828747&view=auto
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml
 (added)
+++ 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml
 Thu Oct 22 15:30:13 2009
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<catalogue xml:lang="en">
+  <message 
key="org.apache.fop.accessibility.AccessibilityEventProducer.noStructureTreeInXML">Accessibility
 is enabled but structure tree is missing in XML file. Please disable 
accessibility, or re-generate XML file in accessibility mode.</message>
+</catalogue>

Propchange: 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/accessibility/AccessibilityEventProducer.xml
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Modified: 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/area/AreaTreeParser.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/area/AreaTreeParser.java?rev=828747&r1=828746&r2=828747&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/area/AreaTreeParser.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/area/AreaTreeParser.java
 Thu Oct 22 15:30:13 2009
@@ -57,6 +57,7 @@
 import org.apache.xmlgraphics.image.loader.ImageSessionContext;
 import org.apache.xmlgraphics.util.QName;
 
+import org.apache.fop.accessibility.AccessibilityEventProducer;
 import org.apache.fop.accessibility.StructureTreeBuilder;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.Trait.Background;
@@ -164,19 +165,19 @@
 
         private ContentHandler structureTreeBuilderWrapper;
 
-        private final class StructureTreeBuilderWrapper extends 
DelegatingContentHandler {
+        private Attributes pageSequenceAttributes;
 
-            private Attributes pageSequenceAttributes;
+        private final class StructureTreeBuilderWrapper extends 
DelegatingContentHandler {
 
-            private StructureTreeBuilderWrapper(Attributes 
pageSequenceAttributes)
+            private StructureTreeBuilderWrapper()
                     throws SAXException {
                 super(structureTreeBuilder.getHandlerForNextPageSequence());
-                this.pageSequenceAttributes = new 
AttributesImpl(pageSequenceAttributes);
             }
 
             public void endDocument() throws SAXException {
                 super.endDocument();
                 startAreaTreeElement("pageSequence", pageSequenceAttributes);
+                pageSequenceAttributes = null;
             }
         }
 
@@ -297,7 +298,8 @@
                 boolean handled = true;
                 if ("".equals(uri)) {
                     if (localName.equals("pageSequence") && 
userAgent.isAccessibilityEnabled()) {
-                        structureTreeBuilderWrapper = new 
StructureTreeBuilderWrapper(attributes);
+                        structureTreeBuilderWrapper = new 
StructureTreeBuilderWrapper();
+                        pageSequenceAttributes = new 
AttributesImpl(attributes);
                     } else if (localName.equals("structureTree")) {
                         if (userAgent.isAccessibilityEnabled()) {
                             delegate = structureTreeBuilderWrapper;
@@ -309,6 +311,18 @@
                         delegate.startDocument();
                         delegate.startElement(uri, localName, qName, 
attributes);
                     } else {
+                        if (pageSequenceAttributes != null) {
+                            /*
+                             * This means that no structure-element tag was
+                             * found in the XML, otherwise a
+                             * StructureTreeBuilderWrapper object would have
+                             * been created, which would have reset the
+                             * pageSequenceAttributes field.
+                             */
+                            AccessibilityEventProducer.Provider
+                                    .get(userAgent.getEventBroadcaster())
+                                    .noStructureTreeInXML(this);
+                        }
                         handled = startAreaTreeElement(localName, attributes);
                     }
                 } else {

Modified: 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java?rev=828747&r1=828746&r2=828747&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/render/intermediate/IFParser.java
 Thu Oct 22 15:30:13 2009
@@ -46,6 +46,7 @@
 
 import org.apache.xmlgraphics.util.QName;
 
+import org.apache.fop.accessibility.AccessibilityEventProducer;
 import org.apache.fop.accessibility.StructureTreeBuilder;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fo.ElementMapping;
@@ -155,19 +156,19 @@
 
         private ContentHandler structureTreeBuilderWrapper;
 
-        private final class StructureTreeBuilderWrapper extends 
DelegatingContentHandler {
+        private Attributes pageSequenceAttributes;
 
-            private Attributes pageSequenceAttributes;
+        private final class StructureTreeBuilderWrapper extends 
DelegatingContentHandler {
 
-            private StructureTreeBuilderWrapper(Attributes 
pageSequenceAttributes)
+            private StructureTreeBuilderWrapper()
                     throws SAXException {
                 super(structureTreeBuilder.getHandlerForNextPageSequence());
-                this.pageSequenceAttributes = new 
AttributesImpl(pageSequenceAttributes);
             }
 
             public void endDocument() throws SAXException {
                 super.endDocument();
                 startIFElement(EL_PAGE_SEQUENCE, pageSequenceAttributes);
+                pageSequenceAttributes = null;
             }
         }
 
@@ -227,7 +228,8 @@
                 boolean handled = true;
                 if (NAMESPACE.equals(uri)) {
                     if (localName.equals(EL_PAGE_SEQUENCE) && 
userAgent.isAccessibilityEnabled()) {
-                        structureTreeBuilderWrapper = new 
StructureTreeBuilderWrapper(attributes);
+                        pageSequenceAttributes = new 
AttributesImpl(attributes);
+                        structureTreeBuilderWrapper = new 
StructureTreeBuilderWrapper();
                     } else if (localName.equals(EL_STRUCTURE_TREE)) {
                         if (userAgent.isAccessibilityEnabled()) {
                             delegate = structureTreeBuilderWrapper;
@@ -239,6 +241,18 @@
                         delegate.startDocument();
                         delegate.startElement(uri, localName, qName, 
attributes);
                     } else {
+                        if (pageSequenceAttributes != null) {
+                            /*
+                             * This means that no structure-element tag was
+                             * found in the XML, otherwise a
+                             * StructureTreeBuilderWrapper object would have
+                             * been created, which would have reset the
+                             * pageSequenceAttributes field.
+                             */
+                            AccessibilityEventProducer.Provider
+                                    .get(userAgent.getEventBroadcaster())
+                                    .noStructureTreeInXML(this);
+                        }
                         handled = startIFElement(localName, attributes);
                     }
                 } else if 
(DocumentNavigationExtensionConstants.NAMESPACE.equals(uri)) {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to