]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Removed the FO document pre-processing step that was adding ptr and creating a reduce...
authorVincent Hennebert <vhennebert@apache.org>
Mon, 24 Oct 2011 16:29:56 +0000 (16:29 +0000)
committerVincent Hennebert <vhennebert@apache.org>
Mon, 24 Oct 2011 16:29:56 +0000 (16:29 +0000)
* Removed addPtr.xsl and reduceFOTree.xsl
* Implemented Common Accessibility properties on objects that support them
* Added a special implementation of FOEventHandler to build the structure tree
* Added mockito library and its dependencies
* Added mocks for some FO nodes and properties
* Removed FOTreeUnitTester and converted it into a re-usable FODocumentParser class
* Re-worked table FO test cases accordingly

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ImproveAccessibility@1188205 13f79535-47bb-0310-9956-ffa450edef68

132 files changed:
build.xml
lib/build/hamcrest.core-1.1.0.LICENSE.txt [new file with mode: 0644]
lib/build/hamcrest.core-1.1.0.jar [new file with mode: 0644]
lib/build/mockito-core-1.8.5.LICENCE.txt [new file with mode: 0644]
lib/build/mockito-core-1.8.5.NOTICE.txt [new file with mode: 0644]
lib/build/mockito-core-1.8.5.jar [new file with mode: 0644]
lib/build/objenesis-1.0.0.LICENSE.txt [new file with mode: 0644]
lib/build/objenesis-1.0.0.jar [new file with mode: 0644]
src/java/org/apache/fop/accessibility/Accessibility.java
src/java/org/apache/fop/accessibility/AccessibilityPreprocessor.java [deleted file]
src/java/org/apache/fop/accessibility/StructureTree.java
src/java/org/apache/fop/accessibility/StructureTreeBuildingFOEventHandler.java [new file with mode: 0644]
src/java/org/apache/fop/accessibility/addPtr.xsl [deleted file]
src/java/org/apache/fop/accessibility/reduceFOTree.xsl [deleted file]
src/java/org/apache/fop/apps/Fop.java
src/java/org/apache/fop/fo/Constants.java
src/java/org/apache/fop/fo/DelegatingFOEventHandler.java [new file with mode: 0644]
src/java/org/apache/fop/fo/FOEventHandler.java
src/java/org/apache/fop/fo/FONode.java
src/java/org/apache/fop/fo/FOPropertyMapping.java
src/java/org/apache/fop/fo/FOTreeBuilder.java
src/java/org/apache/fop/fo/PropertyList.java
src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
src/java/org/apache/fop/fo/extensions/InternalElementMapping.java
src/java/org/apache/fop/fo/flow/AbstractGraphics.java
src/java/org/apache/fop/fo/flow/AbstractListItemPart.java
src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java
src/java/org/apache/fop/fo/flow/BasicLink.java
src/java/org/apache/fop/fo/flow/Block.java
src/java/org/apache/fop/fo/flow/Character.java
src/java/org/apache/fop/fo/flow/Footnote.java
src/java/org/apache/fop/fo/flow/FootnoteBody.java
src/java/org/apache/fop/fo/flow/InitialPropertySet.java
src/java/org/apache/fop/fo/flow/Inline.java
src/java/org/apache/fop/fo/flow/InlineLevel.java
src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
src/java/org/apache/fop/fo/flow/Leader.java
src/java/org/apache/fop/fo/flow/ListBlock.java
src/java/org/apache/fop/fo/flow/ListItem.java
src/java/org/apache/fop/fo/flow/ListItemBody.java
src/java/org/apache/fop/fo/flow/ListItemLabel.java
src/java/org/apache/fop/fo/flow/PageNumber.java
src/java/org/apache/fop/fo/flow/Wrapper.java
src/java/org/apache/fop/fo/flow/table/Table.java
src/java/org/apache/fop/fo/flow/table/TableAndCaption.java
src/java/org/apache/fop/fo/flow/table/TableCaption.java
src/java/org/apache/fop/fo/flow/table/TableCell.java
src/java/org/apache/fop/fo/flow/table/TableCellContainer.java
src/java/org/apache/fop/fo/flow/table/TableFObj.java
src/java/org/apache/fop/fo/pagination/Root.java
src/java/org/apache/fop/fo/pagination/StaticContent.java
src/java/org/apache/fop/fo/pagination/bookmarks/Bookmark.java
src/java/org/apache/fop/fo/pagination/bookmarks/BookmarkTitle.java
src/java/org/apache/fop/fo/properties/CommonAccessibility.java
src/java/org/apache/fop/fo/properties/CommonAccessibilityHolder.java [new file with mode: 0644]
src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java
src/java/org/apache/fop/render/rtf/RTFHandler.java
test/accessibility/README
test/accessibility/pdf/background-image_jpg_repeat.pdf [new file with mode: 0644]
test/accessibility/pdf/background-image_jpg_repeat_painter_orig.pdf [deleted file]
test/accessibility/pdf/background-image_jpg_repeat_renderer_orig.pdf [deleted file]
test/accessibility/pdf/background-image_jpg_single.pdf [new file with mode: 0644]
test/accessibility/pdf/background-image_jpg_single_painter_orig.pdf [deleted file]
test/accessibility/pdf/background-image_jpg_single_renderer_orig.pdf [deleted file]
test/accessibility/pdf/background-image_png_repeat.pdf [new file with mode: 0644]
test/accessibility/pdf/background-image_png_repeat_painter_orig.pdf [deleted file]
test/accessibility/pdf/background-image_png_repeat_renderer_orig.pdf [deleted file]
test/accessibility/pdf/background-image_png_single.pdf [new file with mode: 0644]
test/accessibility/pdf/background-image_png_single_painter_orig.pdf [deleted file]
test/accessibility/pdf/background-image_png_single_renderer_orig.pdf [deleted file]
test/accessibility/pdf/background-image_svg_repeat.pdf [new file with mode: 0644]
test/accessibility/pdf/background-image_svg_repeat_painter_orig.pdf [deleted file]
test/accessibility/pdf/background-image_svg_repeat_renderer_orig.pdf [deleted file]
test/accessibility/pdf/background-image_svg_single.pdf [new file with mode: 0644]
test/accessibility/pdf/background-image_svg_single_painter_orig.pdf [deleted file]
test/accessibility/pdf/background-image_svg_single_renderer_orig.pdf [deleted file]
test/accessibility/pdf/complete.pdf [new file with mode: 0644]
test/accessibility/pdf/complete_painter_orig.pdf [deleted file]
test/accessibility/pdf/complete_renderer_orig.pdf [deleted file]
test/accessibility/pdf/image_jpg.pdf [new file with mode: 0644]
test/accessibility/pdf/image_jpg_painter_orig.pdf [deleted file]
test/accessibility/pdf/image_jpg_renderer_orig.pdf [deleted file]
test/accessibility/pdf/image_png.pdf [new file with mode: 0644]
test/accessibility/pdf/image_png_painter_orig.pdf [deleted file]
test/accessibility/pdf/image_png_renderer_orig.pdf [deleted file]
test/accessibility/pdf/image_svg.pdf [new file with mode: 0644]
test/accessibility/pdf/image_svg_painter_orig.pdf [deleted file]
test/accessibility/pdf/image_svg_renderer_orig.pdf [deleted file]
test/accessibility/pdf/image_wmf.pdf [new file with mode: 0644]
test/accessibility/pdf/image_wmf_painter_orig.pdf [deleted file]
test/accessibility/pdf/image_wmf_renderer_orig.pdf [deleted file]
test/accessibility/pdf/leader.pdf [new file with mode: 0644]
test/accessibility/pdf/leader_painter_orig.pdf [deleted file]
test/accessibility/pdf/leader_renderer_orig.pdf [deleted file]
test/accessibility/pdf/links.pdf [new file with mode: 0644]
test/accessibility/pdf/links_painter_orig.pdf [deleted file]
test/accessibility/pdf/links_renderer_orig.pdf [deleted file]
test/accessibility/pdf/role.pdf [new file with mode: 0644]
test/accessibility/pdf/role_non-standard.pdf [new file with mode: 0644]
test/accessibility/pdf/role_non-standard_painter_orig.pdf [deleted file]
test/accessibility/pdf/role_non-standard_renderer_orig.pdf [deleted file]
test/accessibility/pdf/role_painter_orig.pdf [deleted file]
test/accessibility/pdf/role_renderer_orig.pdf [deleted file]
test/accessibility/pdf/text_1.pdf [new file with mode: 0644]
test/accessibility/pdf/text_1_painter_orig.pdf [deleted file]
test/accessibility/pdf/text_1_renderer_orig.pdf [deleted file]
test/accessibility/pdf/text_2.pdf [new file with mode: 0644]
test/accessibility/pdf/text_2_painter_orig.pdf [deleted file]
test/accessibility/pdf/text_2_renderer_orig.pdf [deleted file]
test/accessibility/pdf/text_font-embedding.pdf [new file with mode: 0644]
test/accessibility/pdf/text_font-embedding_painter_orig.pdf [deleted file]
test/accessibility/pdf/text_font-embedding_renderer_orig.pdf [deleted file]
test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.fo [new file with mode: 0644]
test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java [new file with mode: 0644]
test/java/org/apache/fop/fo/FODocumentParser.java [new file with mode: 0644]
test/java/org/apache/fop/fo/FONodeMocks.java [new file with mode: 0644]
test/java/org/apache/fop/fo/LoadingException.java [new file with mode: 0644]
test/java/org/apache/fop/fo/extract-events.xsl [new file with mode: 0644]
test/java/org/apache/fop/fo/flow/table/AbstractTableTestCase.java
test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java
test/java/org/apache/fop/fo/flow/table/ErrorCheckTestCase.java
test/java/org/apache/fop/fo/flow/table/IllegalRowSpanTestCase.java
test/java/org/apache/fop/fo/flow/table/RowGroupBuilderTestCase.java
test/java/org/apache/fop/fo/flow/table/TableColumnColumnNumberTestCase.java
test/java/org/apache/fop/fo/flow/table/TooManyColumnsTestCase.java
test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java [new file with mode: 0644]
test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java [new file with mode: 0644]
test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java [new file with mode: 0644]
test/java/org/apache/fop/fo/properties/PropertyListMocks.java [new file with mode: 0644]
test/java/org/apache/fop/fo/properties/PropertyMocks.java [new file with mode: 0644]
test/java/org/apache/fop/fotreetest/FOTreeTestSuite.java
test/java/org/apache/fop/fotreetest/FOTreeUnitTester.java [deleted file]

index 542ff25de1b669a3e0ab455ee529ae7f57d52aa4..dda6493aeb905ea5ff94eff30cc07f1ee110f15c 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -735,6 +735,7 @@ list of possible build targets.
         <include name="**/*.xml"/>
         <include name="**/*.fo"/>
         <include name="**/*.afp"/>
+        <include name="**/*.xsl"/>
       </fileset>
       <fileset dir="${build.dir}/test-gensrc">
         <include name="**/*.xml"/>
diff --git a/lib/build/hamcrest.core-1.1.0.LICENSE.txt b/lib/build/hamcrest.core-1.1.0.LICENSE.txt
new file mode 100644 (file)
index 0000000..e3d4feb
--- /dev/null
@@ -0,0 +1,27 @@
+BSD License
+
+Copyright (c) 2000-2006, www.hamcrest.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer. Redistributions in binary form must reproduce
+the above copyright notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the distribution.
+
+Neither the name of Hamcrest nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
\ No newline at end of file
diff --git a/lib/build/hamcrest.core-1.1.0.jar b/lib/build/hamcrest.core-1.1.0.jar
new file mode 100644 (file)
index 0000000..5b2b484
Binary files /dev/null and b/lib/build/hamcrest.core-1.1.0.jar differ
diff --git a/lib/build/mockito-core-1.8.5.LICENCE.txt b/lib/build/mockito-core-1.8.5.LICENCE.txt
new file mode 100644 (file)
index 0000000..e0840a4
--- /dev/null
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2007 Mockito contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/lib/build/mockito-core-1.8.5.NOTICE.txt b/lib/build/mockito-core-1.8.5.NOTICE.txt
new file mode 100644 (file)
index 0000000..0594174
--- /dev/null
@@ -0,0 +1,11 @@
+Mockito license - MIT.
+
+Libraries used:
+
+Cglib - Apache License 2.0
+ASM - BSD license
+
+Mockito all distribution:
+
+Objenesis - MIT license
+Hamcrest - BSD license
\ No newline at end of file
diff --git a/lib/build/mockito-core-1.8.5.jar b/lib/build/mockito-core-1.8.5.jar
new file mode 100644 (file)
index 0000000..e1f33b4
Binary files /dev/null and b/lib/build/mockito-core-1.8.5.jar differ
diff --git a/lib/build/objenesis-1.0.0.LICENSE.txt b/lib/build/objenesis-1.0.0.LICENSE.txt
new file mode 100644 (file)
index 0000000..74582ac
--- /dev/null
@@ -0,0 +1,18 @@
+Copyright (c) 2003-2008, Objenesis Team and all contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of 
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/lib/build/objenesis-1.0.0.jar b/lib/build/objenesis-1.0.0.jar
new file mode 100644 (file)
index 0000000..1f1b76d
Binary files /dev/null and b/lib/build/objenesis-1.0.0.jar differ
index d550b433a87a85f5ef3e476f3b19bc1de02cd443..c842cf43f6e1760865ba96d26d44929596f95cd0 100644 (file)
 
 package org.apache.fop.accessibility;
 
-import javax.xml.transform.Source;
-import javax.xml.transform.Templates;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamSource;
-
-import org.xml.sax.helpers.DefaultHandler;
-
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
 
 /**
  * Helper class for FOP's accessibility features.
@@ -40,48 +28,6 @@ public final class Accessibility {
     /** Constant string for the rendering options key to enable accessibility features. */
     public static final String ACCESSIBILITY = "accessibility";
 
-    // TODO what if the default factory is not a SAXTransformerFactory?
-    private static SAXTransformerFactory tfactory
-            = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
-
-    private static Templates addPtrTemplates;
-
-    private static Templates reduceFOTreeTemplates;
-
     private Accessibility() { }
 
-    /**
-     * Decorates the given handler so the structure tree used for accessibility
-     * features can be branched off the main content stream.
-     * @param handler the handler to decorate
-     * @param userAgent the user agent
-     * @return the decorated handler
-     * @throws FOPException if an error occurs setting up the decoration
-     */
-    public static DefaultHandler decorateDefaultHandler(DefaultHandler handler,
-            FOUserAgent userAgent) throws FOPException {
-        try {
-            setupTemplates();
-            TransformerHandler addPtr = tfactory.newTransformerHandler(addPtrTemplates);
-            Transformer reduceFOTree = reduceFOTreeTemplates.newTransformer();
-            return new AccessibilityPreprocessor(addPtr, reduceFOTree, userAgent, handler);
-        } catch (TransformerConfigurationException e) {
-            throw new FOPException(e);
-        }
-    }
-
-    private static synchronized void setupTemplates() throws TransformerConfigurationException {
-        if (addPtrTemplates == null) {
-            addPtrTemplates = loadTemplates("addPtr.xsl");
-        }
-        if (reduceFOTreeTemplates == null) {
-            reduceFOTreeTemplates = loadTemplates("reduceFOTree.xsl");
-        }
-    }
-
-    private static Templates loadTemplates(String source) throws TransformerConfigurationException {
-        Source src = new StreamSource(Accessibility.class.getResource(source).toExternalForm());
-        return tfactory.newTemplates(src);
-    }
-
 }
diff --git a/src/java/org/apache/fop/accessibility/AccessibilityPreprocessor.java b/src/java/org/apache/fop/accessibility/AccessibilityPreprocessor.java
deleted file mode 100644 (file)
index 1958b74..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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 java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-import org.apache.commons.io.output.ByteArrayOutputStream;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.util.TransformerDefaultHandler;
-
-/**
- * This class prepares an XSL-FO document for accessibility. It adds a unique
- * identifier to every applicable FO, then creates the structure tree, before
- * handing the document over to the regular handler.
- */
-class AccessibilityPreprocessor extends TransformerDefaultHandler {
-
-    private final ByteArrayOutputStream enrichedFOBuffer = new ByteArrayOutputStream();
-
-    private final Transformer reduceFOTree;
-
-    private final FOUserAgent userAgent;
-
-    private final DefaultHandler fopHandler;
-
-    public AccessibilityPreprocessor(TransformerHandler addPtr, Transformer reduceFOTree,
-            FOUserAgent userAgent, DefaultHandler fopHandler) {
-        super(addPtr);
-        this.reduceFOTree = reduceFOTree;
-        this.userAgent = userAgent;
-        this.fopHandler = fopHandler;
-        getTransformerHandler().setResult(new StreamResult(enrichedFOBuffer));
-    }
-
-    /** {@inheritDoc} */
-    public void endDocument() throws SAXException {
-        super.endDocument();
-        // do the second transform to struct
-        try {
-            //TODO this must be optimized, no buffering (ex. SAX-based tee-proxy)
-            byte[] enrichedFO = enrichedFOBuffer.toByteArray();
-            Source src = new StreamSource(new ByteArrayInputStream(enrichedFO));
-            DOMResult res = new DOMResult();
-            reduceFOTree.transform(src, res);
-            StructureTree structureTree = new StructureTree();
-            NodeList pageSequences = res.getNode().getFirstChild().getChildNodes();
-            for (int i = 0; i < pageSequences.getLength(); i++) {
-                structureTree.addPageSequenceStructure(pageSequences.item(i).getChildNodes());
-            }
-            userAgent.setStructureTree(structureTree);
-
-            SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
-            saxParserFactory.setNamespaceAware(true);
-            saxParserFactory.setValidating(false);
-            SAXParser saxParser = saxParserFactory.newSAXParser();
-            InputStream in = new ByteArrayInputStream(enrichedFO);
-            saxParser.parse(in, fopHandler);
-        } catch (Exception e) {
-            throw new SAXException(e);
-        }
-    }
-
-}
index a0fdaac21760cc0fc3500fc8cc65c799433d5f3f..a8afd4ef5c84dc892f5a1d074d4c2f870933e894 100644 (file)
@@ -44,7 +44,7 @@ public final class StructureTree {
     /**
      * Package-private default constructor.
      */
-    StructureTree() { }
+    public StructureTree() { }
 
     private static boolean flowOrStaticContentNodes(NodeList nodes) {
         for (int i = 0; i < nodes.getLength(); i++) {
diff --git a/src/java/org/apache/fop/accessibility/StructureTreeBuildingFOEventHandler.java b/src/java/org/apache/fop/accessibility/StructureTreeBuildingFOEventHandler.java
new file mode 100644 (file)
index 0000000..e3f9468
--- /dev/null
@@ -0,0 +1,840 @@
+/*
+ * 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 javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.DelegatingFOEventHandler;
+import org.apache.fop.fo.FOEventHandler;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.extensions.ExtensionElementMapping;
+import org.apache.fop.fo.extensions.ExternalDocument;
+import org.apache.fop.fo.extensions.InternalElementMapping;
+import org.apache.fop.fo.flow.AbstractGraphics;
+import org.apache.fop.fo.flow.BasicLink;
+import org.apache.fop.fo.flow.Block;
+import org.apache.fop.fo.flow.BlockContainer;
+import org.apache.fop.fo.flow.Character;
+import org.apache.fop.fo.flow.ExternalGraphic;
+import org.apache.fop.fo.flow.Footnote;
+import org.apache.fop.fo.flow.FootnoteBody;
+import org.apache.fop.fo.flow.Inline;
+import org.apache.fop.fo.flow.InstreamForeignObject;
+import org.apache.fop.fo.flow.Leader;
+import org.apache.fop.fo.flow.ListBlock;
+import org.apache.fop.fo.flow.ListItem;
+import org.apache.fop.fo.flow.ListItemBody;
+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.Wrapper;
+import org.apache.fop.fo.flow.table.Table;
+import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TableCell;
+import org.apache.fop.fo.flow.table.TableColumn;
+import org.apache.fop.fo.flow.table.TableFooter;
+import org.apache.fop.fo.flow.table.TableHeader;
+import org.apache.fop.fo.flow.table.TableRow;
+import org.apache.fop.fo.pagination.Flow;
+import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fo.pagination.StaticContent;
+import org.apache.fop.fo.properties.CommonAccessibilityHolder;
+import org.apache.fop.util.XMLUtil;
+
+/**
+ * A class that builds the document's structure tree.
+ */
+public class StructureTreeBuildingFOEventHandler extends DelegatingFOEventHandler {
+
+    private int idCounter;
+
+    private final StructureTree structureTree;
+
+    private TransformerHandler structureTreeDOMBuilder;
+
+    private DOMResult result;
+
+    /** Delegates to either {@link #actualStructureTreeBuilder} or {@link #eventSwallower}. */
+    private FOEventHandler structureTreeBuilder;
+
+    private FOEventHandler actualStructureTreeBuilder;
+
+    /** The descendants of some elements like fo:leader must be ignored. */
+    private final FOEventHandler eventSwallower;
+
+    private final class StructureTreeBuilder extends FOEventHandler {
+
+        public StructureTreeBuilder(FOUserAgent foUserAgent) {
+            super(foUserAgent);
+        }
+
+        @Override
+        public void startDocument() throws SAXException {
+        }
+
+        @Override
+        public void endDocument() throws SAXException {
+        }
+
+        @Override
+        public void startPageSequence(PageSequence pageSeq) {
+            SAXTransformerFactory transformerFactory =
+                    (SAXTransformerFactory) TransformerFactory.newInstance();
+            try {
+                structureTreeDOMBuilder = transformerFactory.newTransformerHandler();
+            } catch (TransformerConfigurationException e) {
+                throw new RuntimeException(e);
+            }
+            result = new DOMResult();
+            structureTreeDOMBuilder.setResult(result);
+            try {
+                structureTreeDOMBuilder.startDocument();
+            } catch (SAXException e) {
+                throw new RuntimeException(e);
+            }
+            startElement(pageSeq);
+        }
+
+        @Override
+        public void endPageSequence(PageSequence pageSeq) {
+            endElement(pageSeq);
+            try {
+                structureTreeDOMBuilder.endDocument();
+            } catch (SAXException e) {
+                throw new RuntimeException(e);
+            }
+            structureTree.addPageSequenceStructure(
+                    result.getNode().getFirstChild().getChildNodes());
+        }
+
+        @Override
+        public void startPageNumber(PageNumber pagenum) {
+            startElementWithID(pagenum);
+        }
+
+        @Override
+        public void endPageNumber(PageNumber pagenum) {
+            endElement(pagenum);
+        }
+
+        @Override
+        public void startPageNumberCitation(PageNumberCitation pageCite) {
+            startElementWithID(pageCite);
+        }
+
+        @Override
+        public void endPageNumberCitation(PageNumberCitation pageCite) {
+            endElement(pageCite);
+        }
+
+        @Override
+        public void startPageNumberCitationLast(PageNumberCitationLast pageLast) {
+            startElementWithID(pageLast);
+        }
+
+        @Override
+        public void endPageNumberCitationLast(PageNumberCitationLast pageLast) {
+            endElement(pageLast);
+        }
+
+        @Override
+        public void startFlow(Flow fl) {
+            startElement(fl);
+        }
+
+        @Override
+        public void endFlow(Flow fl) {
+            endElement(fl);
+        }
+
+        @Override
+        public void startBlock(Block bl) {
+            startElementWithID(bl);
+        }
+
+        @Override
+        public void endBlock(Block bl) {
+            endElement(bl);
+        }
+
+        @Override
+        public void startBlockContainer(BlockContainer blc) {
+            startElement(blc);
+        }
+
+        @Override
+        public void endBlockContainer(BlockContainer blc) {
+            endElement(blc);
+        }
+
+        @Override
+        public void startInline(Inline inl) {
+            startElementWithID(inl);
+        }
+
+        @Override
+        public void endInline(Inline inl) {
+            endElement(inl);
+        }
+
+        @Override
+        public void startTable(Table tbl) {
+            startElementWithID(tbl);
+        }
+
+        @Override
+        public void endTable(Table tbl) {
+            endElement(tbl);
+        }
+
+        @Override
+        public void startHeader(TableHeader header) {
+            startElementWithID(header);
+        }
+
+        @Override
+        public void endHeader(TableHeader header) {
+            endElement(header);
+        }
+
+        @Override
+        public void startFooter(TableFooter footer) {
+            startElementWithID(footer);
+        }
+
+        @Override
+        public void endFooter(TableFooter footer) {
+            endElement(footer);
+        }
+
+        @Override
+        public void startBody(TableBody body) {
+            startElementWithID(body);
+        }
+
+        @Override
+        public void endBody(TableBody body) {
+            endElement(body);
+        }
+
+        @Override
+        public void startRow(TableRow tr) {
+            startElementWithID(tr);
+        }
+
+        @Override
+        public void endRow(TableRow tr) {
+            endElement(tr);
+        }
+
+        @Override
+        public void startCell(TableCell tc) {
+            AttributesImpl attributes = new AttributesImpl();
+            int colSpan = tc.getNumberColumnsSpanned();
+            if (colSpan > 1) {
+                addNoNamespaceAttribute(attributes, "number-columns-spanned",
+                        Integer.toString(colSpan));
+            }
+            startElementWithID(tc, attributes);
+        }
+
+        @Override
+        public void endCell(TableCell tc) {
+            endElement(tc);
+        }
+
+        @Override
+        public void startList(ListBlock lb) {
+            startElement(lb);
+        }
+
+        @Override
+        public void endList(ListBlock lb) {
+            endElement(lb);
+        }
+
+        @Override
+        public void startListItem(ListItem li) {
+            startElement(li);
+        }
+
+        @Override
+        public void endListItem(ListItem li) {
+            endElement(li);
+        }
+
+        @Override
+        public void startListLabel(ListItemLabel listItemLabel) {
+            startElement(listItemLabel);
+        }
+
+        @Override
+        public void endListLabel(ListItemLabel listItemLabel) {
+            endElement(listItemLabel);
+        }
+
+        @Override
+        public void startListBody(ListItemBody listItemBody) {
+            startElement(listItemBody);
+        }
+
+        @Override
+        public void endListBody(ListItemBody listItemBody) {
+            endElement(listItemBody);
+        }
+
+        @Override
+        public void startStatic(StaticContent staticContent) {
+            startElement(staticContent);
+        }
+
+        @Override
+        public void endStatic(StaticContent statisContent) {
+            endElement(statisContent);
+        }
+
+        @Override
+        public void startLink(BasicLink basicLink) {
+            startElementWithID(basicLink);
+        }
+
+        @Override
+        public void endLink(BasicLink basicLink) {
+            endElement(basicLink);
+        }
+
+        @Override
+        public void image(ExternalGraphic eg) {
+            startElementWithIDAndAltText(eg);
+            endElement(eg);
+        }
+
+        @Override
+        public void startInstreamForeignObject(InstreamForeignObject ifo) {
+            startElementWithIDAndAltText(ifo);
+        }
+
+        @Override
+        public void endInstreamForeignObject(InstreamForeignObject ifo) {
+            endElement(ifo);
+        }
+
+        @Override
+        public void startFootnote(Footnote footnote) {
+            startElement(footnote);
+        }
+
+        @Override
+        public void endFootnote(Footnote footnote) {
+            endElement(footnote);
+        }
+
+        @Override
+        public void startFootnoteBody(FootnoteBody body) {
+            startElement(body);
+        }
+
+        @Override
+        public void endFootnoteBody(FootnoteBody body) {
+            endElement(body);
+        }
+
+        @Override
+        public void startWrapper(Wrapper wrapper) {
+            startElement(wrapper);
+        }
+
+        @Override
+        public void endWrapper(Wrapper wrapper) {
+            endElement(wrapper);
+        }
+
+        @Override
+        public void character(Character c) {
+            startElementWithID(c);
+            endElement(c);
+        }
+
+        private void startElement(FONode node) {
+            startElement(node, new AttributesImpl());
+        }
+
+        private void startElementWithID(FONode node) {
+            startElementWithID(node, new AttributesImpl());
+        }
+
+        private void startElementWithIDAndAltText(AbstractGraphics node) {
+            AttributesImpl attributes = new AttributesImpl();
+            addAttribute(attributes, ExtensionElementMapping.URI, "alt-text",
+                    ExtensionElementMapping.STANDARD_PREFIX, node.getAltText());
+            startElementWithID(node, attributes);
+        }
+
+        private void startElementWithID(FONode node, AttributesImpl attributes) {
+            String id = Integer.toHexString(idCounter++);
+            node.setPtr(id);
+            addAttribute(attributes,
+                    InternalElementMapping.URI, "ptr", InternalElementMapping.STANDARD_PREFIX, id);
+            startElement(node, attributes);
+        }
+
+        private void startElement(FONode node, AttributesImpl attributes) {
+            String localName = node.getLocalName();
+            if (node instanceof CommonAccessibilityHolder) {
+                addRole((CommonAccessibilityHolder) node, attributes);
+            }
+            try {
+                structureTreeDOMBuilder.startElement(node.getNamespaceURI(), localName,
+                        node.getNormalNamespacePrefix() + ":" + localName,
+                        attributes);
+            } catch (SAXException e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+        private void addNoNamespaceAttribute(AttributesImpl attributes, String name, String value) {
+            attributes.addAttribute("", name, name, XMLUtil.CDATA, value);
+        }
+
+        private void addAttribute(AttributesImpl attributes,
+                String namespace, String localName, String prefix, String value) {
+            assert namespace.length() > 0 && prefix.length() > 0;
+            String qualifiedName = prefix + ":" + localName;
+            attributes.addAttribute(namespace, localName, qualifiedName, XMLUtil.CDATA, value);
+        }
+
+        private void addRole(CommonAccessibilityHolder node, AttributesImpl attributes) {
+            String role = node.getCommonAccessibility().getRole();
+            if (role != null) {
+                addNoNamespaceAttribute(attributes, "role", role);
+            }
+        }
+
+        private void endElement(FONode node) {
+            String localName = node.getLocalName();
+            try {
+                structureTreeDOMBuilder.endElement(node.getNamespaceURI(), localName,
+                        node.getNormalNamespacePrefix() + ":" + localName);
+            } catch (SAXException e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+    }
+
+    /**
+     * Creates a new instance.
+     *
+     * @param structureTree the object that will hold the structure tree
+     * @param delegate the FO event handler that must be wrapped by this instance
+     */
+    public StructureTreeBuildingFOEventHandler(StructureTree structureTree,
+            FOEventHandler delegate) {
+        super(delegate);
+        this.structureTree = structureTree;
+        this.actualStructureTreeBuilder = new StructureTreeBuilder(foUserAgent);
+        this.structureTreeBuilder = actualStructureTreeBuilder;
+        this.eventSwallower = new FOEventHandler(foUserAgent) { };
+    }
+
+    @Override
+    public void startDocument() throws SAXException {
+        structureTreeBuilder.startDocument();
+        super.startDocument();
+    }
+
+    @Override
+    public void endDocument() throws SAXException {
+        structureTreeBuilder.endDocument();
+        super.endDocument();
+    }
+
+    @Override
+    public void startPageSequence(PageSequence pageSeq) {
+        structureTreeBuilder.startPageSequence(pageSeq);
+        super.startPageSequence(pageSeq);
+    }
+
+    @Override
+    public void endPageSequence(PageSequence pageSeq) {
+        structureTreeBuilder.endPageSequence(pageSeq);
+        super.endPageSequence(pageSeq);
+    }
+
+    @Override
+    public void startPageNumber(PageNumber pagenum) {
+        structureTreeBuilder.startPageNumber(pagenum);
+        super.startPageNumber(pagenum);
+    }
+
+    @Override
+    public void endPageNumber(PageNumber pagenum) {
+        structureTreeBuilder.endPageNumber(pagenum);
+        super.endPageNumber(pagenum);
+    }
+
+    @Override
+    public void startPageNumberCitation(PageNumberCitation pageCite) {
+        structureTreeBuilder.startPageNumberCitation(pageCite);
+        super.startPageNumberCitation(pageCite);
+    }
+
+    @Override
+    public void endPageNumberCitation(PageNumberCitation pageCite) {
+        structureTreeBuilder.endPageNumberCitation(pageCite);
+        super.endPageNumberCitation(pageCite);
+    }
+
+    @Override
+    public void startPageNumberCitationLast(PageNumberCitationLast pageLast) {
+        structureTreeBuilder.startPageNumberCitationLast(pageLast);
+        super.startPageNumberCitationLast(pageLast);
+    }
+
+    @Override
+    public void endPageNumberCitationLast(PageNumberCitationLast pageLast) {
+        structureTreeBuilder.endPageNumberCitationLast(pageLast);
+        super.endPageNumberCitationLast(pageLast);
+    }
+
+    @Override
+    public void startFlow(Flow fl) {
+        structureTreeBuilder.startFlow(fl);
+        super.startFlow(fl);
+    }
+
+    @Override
+    public void endFlow(Flow fl) {
+        structureTreeBuilder.endFlow(fl);
+        super.endFlow(fl);
+    }
+
+    @Override
+    public void startBlock(Block bl) {
+        structureTreeBuilder.startBlock(bl);
+        super.startBlock(bl);
+    }
+
+    @Override
+    public void endBlock(Block bl) {
+        structureTreeBuilder.endBlock(bl);
+        super.endBlock(bl);
+    }
+
+    @Override
+    public void startBlockContainer(BlockContainer blc) {
+        structureTreeBuilder.startBlockContainer(blc);
+        super.startBlockContainer(blc);
+    }
+
+    @Override
+    public void endBlockContainer(BlockContainer blc) {
+        structureTreeBuilder.endBlockContainer(blc);
+        super.endBlockContainer(blc);
+    }
+
+    @Override
+    public void startInline(Inline inl) {
+        structureTreeBuilder.startInline(inl);
+        super.startInline(inl);
+    }
+
+    @Override
+    public void endInline(Inline inl) {
+        structureTreeBuilder.endInline(inl);
+        super.endInline(inl);
+    }
+
+    @Override
+    public void startTable(Table tbl) {
+        structureTreeBuilder.startTable(tbl);
+        super.startTable(tbl);
+    }
+
+    @Override
+    public void endTable(Table tbl) {
+        structureTreeBuilder.endTable(tbl);
+        super.endTable(tbl);
+    }
+
+    @Override
+    public void startColumn(TableColumn tc) {
+        structureTreeBuilder.startColumn(tc);
+        super.startColumn(tc);
+    }
+
+    @Override
+    public void endColumn(TableColumn tc) {
+        structureTreeBuilder.endColumn(tc);
+        super.endColumn(tc);
+    }
+
+    @Override
+    public void startHeader(TableHeader header) {
+        structureTreeBuilder.startHeader(header);
+        super.startHeader(header);
+    }
+
+    @Override
+    public void endHeader(TableHeader header) {
+        structureTreeBuilder.endHeader(header);
+        super.endHeader(header);
+    }
+
+    @Override
+    public void startFooter(TableFooter footer) {
+        structureTreeBuilder.startFooter(footer);
+        super.startFooter(footer);
+    }
+
+    @Override
+    public void endFooter(TableFooter footer) {
+        structureTreeBuilder.endFooter(footer);
+        super.endFooter(footer);
+    }
+
+    @Override
+    public void startBody(TableBody body) {
+        structureTreeBuilder.startBody(body);
+        super.startBody(body);
+    }
+
+    @Override
+    public void endBody(TableBody body) {
+        structureTreeBuilder.endBody(body);
+        super.endBody(body);
+    }
+
+    @Override
+    public void startRow(TableRow tr) {
+        structureTreeBuilder.startRow(tr);
+        super.startRow(tr);
+    }
+
+    @Override
+    public void endRow(TableRow tr) {
+        structureTreeBuilder.endRow(tr);
+        super.endRow(tr);
+    }
+
+    @Override
+    public void startCell(TableCell tc) {
+        structureTreeBuilder.startCell(tc);
+        super.startCell(tc);
+    }
+
+    @Override
+    public void endCell(TableCell tc) {
+        structureTreeBuilder.endCell(tc);
+        super.endCell(tc);
+    }
+
+    @Override
+    public void startList(ListBlock lb) {
+        structureTreeBuilder.startList(lb);
+        super.startList(lb);
+    }
+
+    @Override
+    public void endList(ListBlock lb) {
+        structureTreeBuilder.endList(lb);
+        super.endList(lb);
+    }
+
+    @Override
+    public void startListItem(ListItem li) {
+        structureTreeBuilder.startListItem(li);
+        super.startListItem(li);
+    }
+
+    @Override
+    public void endListItem(ListItem li) {
+        structureTreeBuilder.endListItem(li);
+        super.endListItem(li);
+    }
+
+    @Override
+    public void startListLabel(ListItemLabel listItemLabel) {
+        structureTreeBuilder.startListLabel(listItemLabel);
+        super.startListLabel(listItemLabel);
+    }
+
+    @Override
+    public void endListLabel(ListItemLabel listItemLabel) {
+        structureTreeBuilder.endListLabel(listItemLabel);
+        super.endListLabel(listItemLabel);
+    }
+
+    @Override
+    public void startListBody(ListItemBody listItemBody) {
+        structureTreeBuilder.startListBody(listItemBody);
+        super.startListBody(listItemBody);
+    }
+
+    @Override
+    public void endListBody(ListItemBody listItemBody) {
+        structureTreeBuilder.endListBody(listItemBody);
+        super.endListBody(listItemBody);
+    }
+
+    @Override
+    public void startStatic(StaticContent staticContent) {
+        structureTreeBuilder.startStatic(staticContent);
+        super.startStatic(staticContent);
+    }
+
+    @Override
+    public void endStatic(StaticContent statisContent) {
+        structureTreeBuilder.endStatic(statisContent);
+        super.endStatic(statisContent);
+    }
+
+    @Override
+    public void startMarkup() {
+        structureTreeBuilder.startMarkup();
+        super.startMarkup();
+    }
+
+    @Override
+    public void endMarkup() {
+        structureTreeBuilder.endMarkup();
+        super.endMarkup();
+    }
+
+    @Override
+    public void startLink(BasicLink basicLink) {
+        structureTreeBuilder.startLink(basicLink);
+        super.startLink(basicLink);
+    }
+
+    @Override
+    public void endLink(BasicLink basicLink) {
+        structureTreeBuilder.endLink(basicLink);
+        super.endLink(basicLink);
+    }
+
+    @Override
+    public void image(ExternalGraphic eg) {
+        structureTreeBuilder.image(eg);
+        super.image(eg);
+    }
+
+    @Override
+    public void pageRef() {
+        structureTreeBuilder.pageRef();
+        super.pageRef();
+    }
+
+    @Override
+    public void startInstreamForeignObject(InstreamForeignObject ifo) {
+        structureTreeBuilder.startInstreamForeignObject(ifo);
+        super.startInstreamForeignObject(ifo);
+    }
+
+    @Override
+    public void endInstreamForeignObject(InstreamForeignObject ifo) {
+        structureTreeBuilder.endInstreamForeignObject(ifo);
+        super.endInstreamForeignObject(ifo);
+    }
+
+    @Override
+    public void startFootnote(Footnote footnote) {
+        structureTreeBuilder.startFootnote(footnote);
+        super.startFootnote(footnote);
+    }
+
+    @Override
+    public void endFootnote(Footnote footnote) {
+        structureTreeBuilder.endFootnote(footnote);
+        super.endFootnote(footnote);
+    }
+
+    @Override
+    public void startFootnoteBody(FootnoteBody body) {
+        structureTreeBuilder.startFootnoteBody(body);
+        super.startFootnoteBody(body);
+    }
+
+    @Override
+    public void endFootnoteBody(FootnoteBody body) {
+        structureTreeBuilder.endFootnoteBody(body);
+        super.endFootnoteBody(body);
+    }
+
+    @Override
+    public void startLeader(Leader l) {
+        structureTreeBuilder = eventSwallower;
+        structureTreeBuilder.startLeader(l);
+        super.startLeader(l);
+    }
+
+    @Override
+    public void endLeader(Leader l) {
+        structureTreeBuilder.endLeader(l);
+        structureTreeBuilder = actualStructureTreeBuilder;
+        super.endLeader(l);
+    }
+
+    @Override
+    public void startWrapper(Wrapper wrapper) {
+        structureTreeBuilder.startWrapper(wrapper);
+        super.startWrapper(wrapper);
+    }
+
+    @Override
+    public void endWrapper(Wrapper wrapper) {
+        structureTreeBuilder.endWrapper(wrapper);
+        super.endWrapper(wrapper);
+    }
+
+    @Override
+    public void character(Character c) {
+        structureTreeBuilder.character(c);
+        super.character(c);
+    }
+
+    @Override
+    public void characters(char[] data, int start, int length) {
+        structureTreeBuilder.characters(data, start, length);
+        super.characters(data, start, length);
+    }
+
+    @Override
+    public void startExternalDocument(ExternalDocument document) {
+        structureTreeBuilder.startExternalDocument(document);
+        super.startExternalDocument(document);
+    }
+
+    @Override
+    public void endExternalDocument(ExternalDocument document) {
+        structureTreeBuilder.endExternalDocument(document);
+        super.endExternalDocument(document);
+    }
+
+}
diff --git a/src/java/org/apache/fop/accessibility/addPtr.xsl b/src/java/org/apache/fop/accessibility/addPtr.xsl
deleted file mode 100644 (file)
index b3984d4..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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$ -->
-<xsl:stylesheet version="1.0"
-  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-  xmlns:fo="http://www.w3.org/1999/XSL/Format"
-  xmlns:foi="http://xmlgraphics.apache.org/fop/internal">
-
-  <xsl:template name="addPtr">
-    <xsl:copy>
-      <xsl:apply-templates select="@*"/>
-      <xsl:attribute name="foi:ptr">
-        <xsl:value-of select="generate-id()"/>
-      </xsl:attribute>
-      <xsl:apply-templates/>
-    </xsl:copy>
-  </xsl:template>
-
-  <!-- Block-level Formatting Objects -->
-  <xsl:template match="fo:block|fo:block-container">
-    <xsl:call-template name="addPtr"/>
-  </xsl:template>
-
-  <!-- Inline-level Formatting Objects -->
-  <xsl:template match="fo:character|fo:inline|fo:inline-container">
-    <xsl:call-template name="addPtr"/>
-  </xsl:template>
-
-  <xsl:template match="fo:external-graphic|fo:instream-foreign-object">
-    <xsl:call-template name="addPtr"/>
-  </xsl:template>
-
-  <xsl:template match="fo:page-number|fo:page-number-citation|fo:page-number-citation-last">
-    <xsl:call-template name="addPtr"/>
-  </xsl:template>
-
-  <!-- Formatting Objects for Tables -->
-  <xsl:template match="fo:table-and-caption|fo:table-caption|fo:table">
-    <xsl:call-template name="addPtr"/>
-  </xsl:template>
-
-  <xsl:template match="fo:table-header|fo:table-footer|fo:table-body|fo:table-row|fo:table-cell">
-    <xsl:call-template name="addPtr"/>
-  </xsl:template>
-
-  <!-- Formatting Objects for Lists -->
-  <xsl:template match="fo:list-block|fo:list-item|fo:list-item-label|fo:list-item-body">
-    <xsl:call-template name="addPtr"/>
-  </xsl:template>
-
-  <!-- Dynamic Effects: Link and Multi Formatting Objects -->
-  <xsl:template match="fo:basic-link">
-    <xsl:call-template name="addPtr"/>
-  </xsl:template>
-
-  <!-- Out-of-Line Formatting Objects -->
-  <xsl:template match="fo:float|fo:footnote|fo:footnote-body">
-    <xsl:call-template name="addPtr"/>
-  </xsl:template>
-
-  <!-- Other Formatting Objects -->
-  <xsl:template match="fo:wrapper|fo:marker">
-    <xsl:call-template name="addPtr"/>
-  </xsl:template>
-
-
-  <xsl:template match="@*|node()">
-    <xsl:copy>
-      <xsl:apply-templates select="@*|node()"/>
-    </xsl:copy>
-  </xsl:template>
-
-</xsl:stylesheet>
diff --git a/src/java/org/apache/fop/accessibility/reduceFOTree.xsl b/src/java/org/apache/fop/accessibility/reduceFOTree.xsl
deleted file mode 100644 (file)
index 0d93a25..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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$ -->
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-  xmlns:fo="http://www.w3.org/1999/XSL/Format"
-  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
-  xmlns:foi="http://xmlgraphics.apache.org/fop/internal">
-
-  <xsl:output method="xml" indent="no"/>
-
-  <xsl:template name="copy">
-    <xsl:copy>
-      <xsl:apply-templates select="@*|node()"/>
-    </xsl:copy>
-  </xsl:template>
-
-  <!-- Declarations and Pagination and Layout Formatting Objects -->
-  <xsl:template match="fo:root|fo:page-sequence|fo:static-content|fo:flow">
-    <xsl:call-template name="copy"/>
-  </xsl:template>
-
-  <!-- Block-level Formatting Objects -->
-  <xsl:template match="fo:block|fo:block-container">
-    <xsl:call-template name="copy"/>
-  </xsl:template>
-
-  <!-- Inline-level Formatting Objects -->
-  <xsl:template match="fo:character|fo:inline|fo:inline-container">
-    <xsl:call-template name="copy"/>
-  </xsl:template>
-
-  <xsl:template match="fo:external-graphic|fo:instream-foreign-object">
-    <xsl:call-template name="copy"/>
-  </xsl:template>
-
-  <xsl:template match="fo:page-number|fo:page-number-citation|fo:page-number-citation-last">
-    <xsl:call-template name="copy"/>
-  </xsl:template>
-
-  <!-- Formatting Objects for Tables -->
-  <xsl:template match="fo:table-and-caption|fo:table-caption|fo:table">
-    <xsl:call-template name="copy"/>
-  </xsl:template>
-
-  <xsl:template match="fo:table-header|fo:table-footer|fo:table-body|fo:table-row|fo:table-cell">
-    <xsl:call-template name="copy"/>
-  </xsl:template>
-
-  <!-- Formatting Objects for Lists -->
-  <xsl:template match="fo:list-block|fo:list-item|fo:list-item-label|fo:list-item-body">
-    <xsl:call-template name="copy"/>
-  </xsl:template>
-
-  <!-- Dynamic Effects: Link and Multi Formatting Objects -->
-  <xsl:template match="fo:basic-link">
-    <xsl:call-template name="copy"/>
-  </xsl:template>
-
-  <!-- Out-of-Line Formatting Objects -->
-  <xsl:template match="fo:float|fo:footnote|fo:footnote-body">
-    <xsl:call-template name="copy"/>
-  </xsl:template>
-
-  <!-- Other Formatting Objects -->
-  <xsl:template match="fo:wrapper|fo:marker">
-    <xsl:call-template name="copy"/>
-  </xsl:template>
-
-
-  <!-- Discard descendants of fo:leader -->
-  <xsl:template match="fo:leader"/>
-      
-
-  <!-- Keep foi:ptr, fox:alt-text and role attributes, discard everything else -->
-  <xsl:template match="@foi:ptr|@fox:alt-text|@role">
-    <xsl:copy-of select="."/>
-  </xsl:template>
-
-  <xsl:template match="@*"/>
-
-
-  <!-- Discard text -->
-  <xsl:template match="text()"/>
-
-</xsl:stylesheet>
index 07fd4c0a4838a2e325b9e13c08f8f0329a9b4a25..0527ea290bdcca5f9fff95abcdd8f3d2a70d2046 100644 (file)
@@ -24,7 +24,6 @@ import java.io.OutputStream;
 
 import org.xml.sax.helpers.DefaultHandler;
 
-import org.apache.fop.accessibility.Accessibility;
 import org.apache.fop.fo.FOTreeBuilder;
 
 /**
@@ -111,11 +110,7 @@ public class Fop {
         if (foTreeBuilder == null) {
             createDefaultHandler();
         }
-        if (this.foUserAgent.isAccessibilityEnabled()) {
-            return Accessibility.decorateDefaultHandler(this.foTreeBuilder, foUserAgent);
-        } else {
-            return this.foTreeBuilder;
-        }
+        return this.foTreeBuilder;
     }
 
     /**
index 726d4d89e7dcc460dae21ebd33e2d917fc172e8c..a2b98226931d7232eaa0c9260f4d244d4d4c8cbc 100644 (file)
@@ -771,18 +771,16 @@ public interface Constants {
      * multi-column layouts.
      */
     int PR_X_DISABLE_COLUMN_BALANCING = 273;
-    /** Property constant - FOP proprietary: FOP internal use for accessibility */
-    int PR_X_PTR = 274;
     /**
      * Property constant - FOP proprietary: alternative text for e-g and i-f-o.
      * Used for accessibility.
      */
-    int PR_X_ALT_TEXT = 275;
+    int PR_X_ALT_TEXT = 274;
     /** Property constant - FOP proprietary prototype (in XSL-FO 2.0 Requirements) */
-    int PR_X_XML_BASE = 276;
+    int PR_X_XML_BASE = 275;
 
     /** Number of property constants defined */
-    int PROPERTY_COUNT = 276;
+    int PROPERTY_COUNT = 275;
 
     // compound property constants
 
diff --git a/src/java/org/apache/fop/fo/DelegatingFOEventHandler.java b/src/java/org/apache/fop/fo/DelegatingFOEventHandler.java
new file mode 100644 (file)
index 0000000..cb4ded1
--- /dev/null
@@ -0,0 +1,393 @@
+/*
+ * 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.fo;
+
+import org.xml.sax.SAXException;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.extensions.ExternalDocument;
+import org.apache.fop.fo.flow.BasicLink;
+import org.apache.fop.fo.flow.Block;
+import org.apache.fop.fo.flow.BlockContainer;
+import org.apache.fop.fo.flow.Character;
+import org.apache.fop.fo.flow.ExternalGraphic;
+import org.apache.fop.fo.flow.Footnote;
+import org.apache.fop.fo.flow.FootnoteBody;
+import org.apache.fop.fo.flow.Inline;
+import org.apache.fop.fo.flow.InstreamForeignObject;
+import org.apache.fop.fo.flow.Leader;
+import org.apache.fop.fo.flow.ListBlock;
+import org.apache.fop.fo.flow.ListItem;
+import org.apache.fop.fo.flow.ListItemBody;
+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.Wrapper;
+import org.apache.fop.fo.flow.table.Table;
+import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TableCell;
+import org.apache.fop.fo.flow.table.TableColumn;
+import org.apache.fop.fo.flow.table.TableFooter;
+import org.apache.fop.fo.flow.table.TableHeader;
+import org.apache.fop.fo.flow.table.TableRow;
+import org.apache.fop.fo.pagination.Flow;
+import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fo.pagination.StaticContent;
+import org.apache.fop.fonts.FontInfo;
+
+/**
+ * This class delegates all FO events to another FOEventHandler instance.
+ */
+public abstract class DelegatingFOEventHandler extends FOEventHandler {
+
+    private final FOEventHandler delegate;
+
+    /**
+     * Creates a new instance that delegates events to the given object.
+     *
+     * @param delegate the object to which all FO events will be forwarded
+     */
+    public DelegatingFOEventHandler(FOEventHandler delegate) {
+        super(delegate.getUserAgent());
+        this.delegate = delegate;
+    }
+
+    @Override
+    public FOUserAgent getUserAgent() {
+        return delegate.getUserAgent();
+    }
+
+    @Override
+    public FontInfo getFontInfo() {
+        return delegate.getFontInfo();
+    }
+
+    @Override
+    public void startDocument() throws SAXException {
+        delegate.startDocument();
+    }
+
+    @Override
+    public void endDocument() throws SAXException {
+        delegate.endDocument();
+    }
+
+    @Override
+    public void startPageSequence(PageSequence pageSeq) {
+        delegate.startPageSequence(pageSeq);
+    }
+
+    @Override
+    public void endPageSequence(PageSequence pageSeq) {
+        delegate.endPageSequence(pageSeq);
+    }
+
+    @Override
+    public void startPageNumber(PageNumber pagenum) {
+        delegate.startPageNumber(pagenum);
+    }
+
+    @Override
+    public void endPageNumber(PageNumber pagenum) {
+        delegate.endPageNumber(pagenum);
+    }
+
+    @Override
+    public void startPageNumberCitation(PageNumberCitation pageCite) {
+        delegate.startPageNumberCitation(pageCite);
+    }
+
+    @Override
+    public void endPageNumberCitation(PageNumberCitation pageCite) {
+        delegate.endPageNumberCitation(pageCite);
+    }
+
+    @Override
+    public void startPageNumberCitationLast(PageNumberCitationLast pageLast) {
+        delegate.startPageNumberCitationLast(pageLast);
+    }
+
+    @Override
+    public void endPageNumberCitationLast(PageNumberCitationLast pageLast) {
+        delegate.endPageNumberCitationLast(pageLast);
+    }
+
+    @Override
+    public void startFlow(Flow fl) {
+        delegate.startFlow(fl);
+    }
+
+    @Override
+    public void endFlow(Flow fl) {
+        delegate.endFlow(fl);
+    }
+
+    @Override
+    public void startBlock(Block bl) {
+        delegate.startBlock(bl);
+    }
+
+    @Override
+    public void endBlock(Block bl) {
+        delegate.endBlock(bl);
+    }
+
+    @Override
+    public void startBlockContainer(BlockContainer blc) {
+        delegate.startBlockContainer(blc);
+    }
+
+    @Override
+    public void endBlockContainer(BlockContainer blc) {
+        delegate.endBlockContainer(blc);
+    }
+
+    @Override
+    public void startInline(Inline inl) {
+        delegate.startInline(inl);
+    }
+
+    @Override
+    public void endInline(Inline inl) {
+        delegate.endInline(inl);
+    }
+
+    @Override
+    public void startTable(Table tbl) {
+        delegate.startTable(tbl);
+    }
+
+    @Override
+    public void endTable(Table tbl) {
+        delegate.endTable(tbl);
+    }
+
+    @Override
+    public void startColumn(TableColumn tc) {
+        delegate.startColumn(tc);
+    }
+
+    @Override
+    public void endColumn(TableColumn tc) {
+        delegate.endColumn(tc);
+    }
+
+    @Override
+    public void startHeader(TableHeader header) {
+        delegate.startHeader(header);
+    }
+
+    @Override
+    public void endHeader(TableHeader header) {
+        delegate.endHeader(header);
+    }
+
+    @Override
+    public void startFooter(TableFooter footer) {
+        delegate.startFooter(footer);
+    }
+
+    @Override
+    public void endFooter(TableFooter footer) {
+        delegate.endFooter(footer);
+    }
+
+    @Override
+    public void startBody(TableBody body) {
+        delegate.startBody(body);
+    }
+
+    @Override
+    public void endBody(TableBody body) {
+        delegate.endBody(body);
+    }
+
+    @Override
+    public void startRow(TableRow tr) {
+        delegate.startRow(tr);
+    }
+
+    @Override
+    public void endRow(TableRow tr) {
+        delegate.endRow(tr);
+    }
+
+    @Override
+    public void startCell(TableCell tc) {
+        delegate.startCell(tc);
+    }
+
+    @Override
+    public void endCell(TableCell tc) {
+        delegate.endCell(tc);
+    }
+
+    @Override
+    public void startList(ListBlock lb) {
+        delegate.startList(lb);
+    }
+
+    @Override
+    public void endList(ListBlock lb) {
+        delegate.endList(lb);
+    }
+
+    @Override
+    public void startListItem(ListItem li) {
+        delegate.startListItem(li);
+    }
+
+    @Override
+    public void endListItem(ListItem li) {
+        delegate.endListItem(li);
+    }
+
+    @Override
+    public void startListLabel(ListItemLabel listItemLabel) {
+        delegate.startListLabel(listItemLabel);
+    }
+
+    @Override
+    public void endListLabel(ListItemLabel listItemLabel) {
+        delegate.endListLabel(listItemLabel);
+    }
+
+    @Override
+    public void startListBody(ListItemBody listItemBody) {
+        delegate.startListBody(listItemBody);
+    }
+
+    @Override
+    public void endListBody(ListItemBody listItemBody) {
+        delegate.endListBody(listItemBody);
+    }
+
+    @Override
+    public void startStatic(StaticContent staticContent) {
+        delegate.startStatic(staticContent);
+    }
+
+    @Override
+    public void endStatic(StaticContent statisContent) {
+        delegate.endStatic(statisContent);
+    }
+
+    @Override
+    public void startMarkup() {
+        delegate.startMarkup();
+    }
+
+    @Override
+    public void endMarkup() {
+        delegate.endMarkup();
+    }
+
+    @Override
+    public void startLink(BasicLink basicLink) {
+        delegate.startLink(basicLink);
+    }
+
+    @Override
+    public void endLink(BasicLink basicLink) {
+        delegate.endLink(basicLink);
+    }
+
+    @Override
+    public void image(ExternalGraphic eg) {
+        delegate.image(eg);
+    }
+
+    @Override
+    public void pageRef() {
+        delegate.pageRef();
+    }
+
+    @Override
+    public void startInstreamForeignObject(InstreamForeignObject ifo) {
+        delegate.startInstreamForeignObject(ifo);
+    }
+
+    @Override
+    public void endInstreamForeignObject(InstreamForeignObject ifo) {
+        delegate.endInstreamForeignObject(ifo);
+    }
+
+    @Override
+    public void startFootnote(Footnote footnote) {
+        delegate.startFootnote(footnote);
+    }
+
+    @Override
+    public void endFootnote(Footnote footnote) {
+        delegate.endFootnote(footnote);
+    }
+
+    @Override
+    public void startFootnoteBody(FootnoteBody body) {
+        delegate.startFootnoteBody(body);
+    }
+
+    @Override
+    public void endFootnoteBody(FootnoteBody body) {
+        delegate.endFootnoteBody(body);
+    }
+
+    @Override
+    public void startLeader(Leader l) {
+        delegate.startLeader(l);
+    }
+
+    @Override
+    public void endLeader(Leader l) {
+        delegate.endLeader(l);
+    }
+
+    @Override
+    public void startWrapper(Wrapper wrapper) {
+        delegate.startWrapper(wrapper);
+    }
+
+    @Override
+    public void endWrapper(Wrapper wrapper) {
+        delegate.endWrapper(wrapper);
+    }
+
+    @Override
+    public void character(Character c) {
+        delegate.character(c);
+    }
+
+    @Override
+    public void characters(char[] data, int start, int length) {
+        delegate.characters(data, start, length);
+    }
+
+    @Override
+    public void startExternalDocument(ExternalDocument document) {
+        delegate.startExternalDocument(document);
+    }
+
+    @Override
+    public void endExternalDocument(ExternalDocument document) {
+        delegate.endExternalDocument(document);
+    }
+
+}
index e280af2d7d8b0ebd4185f4a628a157c4ec8ff354..453edec351fe9a4d11590809a3ff7574691b0cfd 100644 (file)
@@ -35,9 +35,12 @@ import org.apache.fop.fo.flow.InstreamForeignObject;
 import org.apache.fop.fo.flow.Leader;
 import org.apache.fop.fo.flow.ListBlock;
 import org.apache.fop.fo.flow.ListItem;
+import org.apache.fop.fo.flow.ListItemBody;
+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.Wrapper;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableBody;
 import org.apache.fop.fo.flow.table.TableCell;
@@ -47,6 +50,7 @@ import org.apache.fop.fo.flow.table.TableHeader;
 import org.apache.fop.fo.flow.table.TableRow;
 import org.apache.fop.fo.pagination.Flow;
 import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fo.pagination.StaticContent;
 import org.apache.fop.fonts.FontEventAdapter;
 import org.apache.fop.fonts.FontInfo;
 
@@ -359,39 +363,45 @@ public abstract class FOEventHandler {
 
     /**
      * Process start of a ListLabel.
+     * @param listItemLabel ListItemLabel that is starting
      */
-    public void startListLabel() {
+    public void startListLabel(ListItemLabel listItemLabel) {
     }
 
     /**
      * Process end of a ListLabel.
+     * @param listItemLabel ListItemLabel that is ending
      */
-    public void endListLabel() {
+    public void endListLabel(ListItemLabel listItemLabel) {
     }
 
     /**
      * Process start of a ListBody.
+     * @param listItemBody ListItemBody that is starting
      */
-    public void startListBody() {
+    public void startListBody(ListItemBody listItemBody) {
     }
 
     /**
      * Process end of a ListBody.
+     * @param listItemBody ListItemBody that is ending
      */
-    public void endListBody() {
+    public void endListBody(ListItemBody listItemBody) {
     }
 
     // Static Regions
     /**
      * Process start of a Static.
+     * @param staticContent StaticContent that is starting
      */
-    public void startStatic() {
+    public void startStatic(StaticContent staticContent) {
     }
 
     /**
      * Process end of a Static.
+     * @param statisContent StaticContent that is ending
      */
-    public void endStatic() {
+    public void endStatic(StaticContent statisContent) {
     }
 
 
@@ -409,15 +419,16 @@ public abstract class FOEventHandler {
 
     /**
      * Process start of a Link.
-     * @param basicLink BasicLink that is ending
+     * @param basicLink BasicLink that is starting
      */
     public void startLink(BasicLink basicLink) {
     }
 
     /**
      * Process end of a Link.
+     * @param basicLink BasicLink that is ending
      */
-    public void endLink() {
+    public void endLink(BasicLink basicLink) {
     }
 
     /**
@@ -434,10 +445,17 @@ public abstract class FOEventHandler {
     }
 
     /**
-     * Process an InstreamForeignObject.
-     * @param ifo InstreamForeignObject to process.
+     * Process the start of an InstreamForeignObject.
+     * @param ifo InstreamForeignObject that is starting
+     */
+    public void startInstreamForeignObject(InstreamForeignObject ifo) {
+    }
+
+    /**
+     * Process the end of an InstreamForeignObject.
+     * @param ifo InstreamForeignObject that is ending
      */
-    public void foreignObject(InstreamForeignObject ifo) {
+    public void endInstreamForeignObject(InstreamForeignObject ifo) {
     }
 
     /**
@@ -469,10 +487,33 @@ public abstract class FOEventHandler {
     }
 
     /**
-     * Process a Leader.
-     * @param l Leader to process.
+     * Process the start of a Leader.
+     * @param l Leader that is starting
+     */
+    public void startLeader(Leader l) {
+    }
+
+    /**
+     * Process the end of a Leader.
+     * @param l Leader that is ending
+     */
+    public void endLeader(Leader l) {
+    }
+
+    /**
+     * Process the start of a wrapper.
+     *
+     * @param wrapper wrapper that is starting
+     */
+    public void startWrapper(Wrapper wrapper) {
+    }
+
+    /**
+     * Process the ending of a wrapper.
+     *
+     * @param wrapper wrapper that is ending
      */
-    public void leader(Leader l) {
+    public void endWrapper(Wrapper wrapper) {
     }
 
     /**
index c9c04aa4e25aefd8aba5804eeae772defd64cd43..4946f6d5c6239bc6eea9ac54a86ac6acb9e3ba40 100644 (file)
@@ -912,4 +912,8 @@ public abstract class FONode implements Cloneable {
 
     }
 
+    public void setPtr(String ptr) {
+        throw new UnsupportedOperationException();
+    }
+
 }
index cf4eef3a5b540c34e1e066f3f5785245283653d6..172aa53294fab9546b8013f658ea017cf9216f63 100644 (file)
@@ -2533,12 +2533,6 @@ public final class FOPropertyMapping implements Constants {
         m.setDefault("");
         addPropertyMaker("id", m);
 
-        // foi:ptr, used for accessibility
-        m = new StringProperty.Maker(PR_X_PTR);
-        m.setInherited(false);
-        m.setDefault("");
-        addPropertyMaker("foi:ptr", m);
-
         // fox:alt-text, used for accessibility
         m = new StringProperty.Maker(PR_X_ALT_TEXT);
         m.setInherited(false);
index 451481eb8e57377617ed25c42f7a629bf0889e8d..890138e5cda4f3746acaf244d28cf307945bcba6 100644 (file)
@@ -33,6 +33,8 @@ import org.apache.commons.logging.LogFactory;
 
 import org.apache.xmlgraphics.util.QName;
 
+import org.apache.fop.accessibility.StructureTree;
+import org.apache.fop.accessibility.StructureTreeBuildingFOEventHandler;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.FormattingResults;
@@ -104,6 +106,11 @@ public class FOTreeBuilder extends DefaultHandler {
         //one of the RTF-, MIF- etc. Handlers.
         foEventHandler = foUserAgent.getRendererFactory().createFOEventHandler(
                 foUserAgent, outputFormat, stream);
+        if (userAgent.isAccessibilityEnabled()) {
+            StructureTree structureTree = new StructureTree();
+            foEventHandler = new StructureTreeBuildingFOEventHandler(structureTree, foEventHandler);
+            userAgent.setStructureTree(structureTree);
+        }
         builderContext = new FOTreeBuilderContext();
         builderContext.setPropertyListMaker(new PropertyListMaker() {
             public PropertyList make(FObj fobj, PropertyList parentPropertyList) {
index a1634e86864e8fcfb57f0ce09c0b4106d10423ac..65ebd40a20c17033cc4469c9629587fea4e359e9 100644 (file)
@@ -30,7 +30,6 @@ import org.apache.xmlgraphics.util.QName;
 import org.apache.fop.apps.FopFactory;
 import org.apache.fop.fo.expr.PropertyException;
 import org.apache.fop.fo.properties.CommonAbsolutePosition;
-import org.apache.fop.fo.properties.CommonAccessibility;
 import org.apache.fop.fo.properties.CommonAural;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonFont;
@@ -600,15 +599,6 @@ public abstract class PropertyList {
         return new CommonMarginInline(this);
     }
 
-    /**
-     * Constructs a CommonAccessibility object.
-     * @return the CommonAccessibility object
-     * @throws PropertyException if there's a problem while processing the properties
-     */
-    public CommonAccessibility getAccessibilityProps() throws PropertyException {
-        return new CommonAccessibility(this);
-    }
-
     /**
      * Constructs a CommonAural object.
      * @return the CommonAural object
index 80a569c90f2519c57fcfd146fae0454434f8b53b..f0e03399f1a8a24443edb312d782118f3b0954f9 100644 (file)
@@ -37,6 +37,9 @@ public class ExtensionElementMapping extends ElementMapping {
     /** The FOP extension namespace URI */
     public static final String URI = "http://xmlgraphics.apache.org/fop/extensions";
 
+    /** The standard XML prefix for elements and attributes in this namespace. */
+    public static final String STANDARD_PREFIX = "fox";
+
     private static final Set<String> PROPERTY_ATTRIBUTES
         = new java.util.HashSet<String>();
 
@@ -85,7 +88,7 @@ public class ExtensionElementMapping extends ElementMapping {
 
     /** {@inheritDoc} */
     public String getStandardPrefix() {
-        return "fox";
+        return STANDARD_PREFIX;
     }
 
     /** {@inheritDoc} */
index 4798f550001454856faa3800a31401a51c031121..e939841e1448f64d11d6bf45622445c5c8f61ae2 100644 (file)
@@ -34,6 +34,9 @@ public class InternalElementMapping extends ElementMapping {
     /** The FOP extension namespace URI */
     public static final String URI = "http://xmlgraphics.apache.org/fop/internal";
 
+    /** The standard XML prefix for elements and attributes in this namespace. */
+    public static final String STANDARD_PREFIX = "foi";
+
     private static final Set<String> PROPERTY_ATTRIBUTES = new java.util.HashSet<String>();
 
     static {
@@ -59,7 +62,7 @@ public class InternalElementMapping extends ElementMapping {
 
     /** {@inheritDoc} */
     public String getStandardPrefix() {
-        return "foi";
+        return STANDARD_PREFIX;
     }
 
     /** {@inheritDoc} */
index eeb06c1dfc748347e31e35348bbb5295e7630893..67a33d0887dcb23628a3dd2dbec75a4d802584b6 100644 (file)
@@ -25,6 +25,8 @@ import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.GraphicsProperties;
 import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.properties.CommonAccessibility;
+import org.apache.fop.fo.properties.CommonAccessibilityHolder;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.KeepProperty;
 import org.apache.fop.fo.properties.LengthRangeProperty;
@@ -38,10 +40,11 @@ import org.apache.fop.fo.properties.StructurePointerPropertySet;
  * <code>fo:external-graphic</code></a> flow formatting objects.
  */
 public abstract class AbstractGraphics extends FObj
-        implements GraphicsProperties, StructurePointerPropertySet {
+        implements GraphicsProperties, StructurePointerPropertySet, CommonAccessibilityHolder {
 
     // The value of properties relevant for fo:instream-foreign-object
     // and external-graphics.
+    private CommonAccessibility commonAccessibility;
     private CommonBorderPaddingBackground commonBorderPaddingBackground;
     private Length alignmentAdjust;
     private int alignmentBaseline;
@@ -62,6 +65,7 @@ public abstract class AbstractGraphics extends FObj
     private int scaling;
     private int textAlign;
     private Length width;
+    private String altText;
     private String ptr;   // used for accessibility
     // Unused but valid items, commented out for performance:
     //     private CommonAccessibility commonAccessibility;
@@ -85,6 +89,7 @@ public abstract class AbstractGraphics extends FObj
 
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
         alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
         alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
@@ -97,7 +102,6 @@ public abstract class AbstractGraphics extends FObj
         dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
         height = pList.get(PR_HEIGHT).getLength();
         id = pList.get(PR_ID).getString();
-        ptr = pList.get(PR_X_PTR).getString();   // used for accessibility
         inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange();
         keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep();
         keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep();
@@ -107,13 +111,17 @@ public abstract class AbstractGraphics extends FObj
         textAlign = pList.get(PR_TEXT_ALIGN).getEnum();
         width = pList.get(PR_WIDTH).getLength();
         if (getUserAgent().isAccessibilityEnabled()) {
-            String altText = pList.get(PR_X_ALT_TEXT).getString();
+            altText = pList.get(PR_X_ALT_TEXT).getString();
             if (altText.equals("")) {
                 getFOValidationEventProducer().altTextMissing(this, getLocalName(), getLocator());
             }
         }
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /**
      * @return the "id" property.
      */
@@ -217,11 +225,20 @@ public abstract class AbstractGraphics extends FObj
         return keepWithPrevious;
     }
 
+    @Override
+    public void setPtr(String ptr) {
+        this.ptr = ptr;
+    }
+
     /** {@inheritDoc} */
     public String getPtr() {
         return ptr;
     }
 
+    public String getAltText() {
+        return altText;
+    }
+
     /** @return the graphic's intrinsic width in millipoints */
     public abstract int getIntrinsicWidth();
 
index b0e93e9c6b21fc139b4a5451a7085bbda9833854..3ee44ac4fd60aaa8676e474ecfd498ecdf8ebb8b 100644 (file)
@@ -26,6 +26,8 @@ import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 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;
 import org.apache.fop.fo.properties.KeepProperty;
 
 /**
@@ -33,8 +35,10 @@ import org.apache.fop.fo.properties.KeepProperty;
  * <code>fo:list-item-label</code></a> and <a href="http://www.w3.org/TR/xsl/#fo_list-item-body">
  * <code>fo:list-item-body</code></a>.
  */
-public abstract class AbstractListItemPart extends FObj {
-    // The value of properties relevant for fo:list-item-label and fo:list-item-body.
+public abstract class AbstractListItemPart extends FObj implements CommonAccessibilityHolder {
+
+    private CommonAccessibility commonAccessibility;
+
     private KeepProperty keepTogether;
     // Valid properties, commented out for performance:
     //   private CommonAccessibility commonAccessibility;
@@ -55,6 +59,7 @@ public abstract class AbstractListItemPart extends FObj {
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep();
     }
 
@@ -86,6 +91,10 @@ public abstract class AbstractListItemPart extends FObj {
         }
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /** @return the "keep-together" property.  */
     public KeepProperty getKeepTogether() {
         return keepTogether;
index 7bc0ff00ca734f20faa813d2ed68f890eb44c20c..bbb632b29b7cb5ea3915737d6c644554b35c2ad1 100644 (file)
@@ -31,6 +31,8 @@ import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 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;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonFont;
 import org.apache.fop.fo.properties.CommonTextDecoration;
@@ -44,9 +46,10 @@ import org.apache.fop.fo.properties.StructurePointerPropertySet;
  * <code>fo:page-number-citation-last</code></a> objects.
  */
 public abstract class AbstractPageNumberCitation extends FObj
-            implements StructurePointerPropertySet {
+        implements StructurePointerPropertySet, CommonAccessibilityHolder {
 
     // The value of properties relevant for fo:page-number-citation(-last).
+    private CommonAccessibility commonAccessibility;
     private CommonBorderPaddingBackground commonBorderPaddingBackground;
     private CommonFont commonFont;
     private Length alignmentAdjust;
@@ -61,7 +64,6 @@ public abstract class AbstractPageNumberCitation extends FObj
     private CommonTextDecoration textDecoration;
     // private ToBeImplementedProperty textShadow;
     // Unused but valid items, commented out for performance:
-    //     private CommonAccessibility commonAccessibility;
     //     private CommonAural commonAural;
     //     private CommonMarginInline commonMarginInline;
     //     private CommonRelativePosition commonRelativePosition;
@@ -91,6 +93,7 @@ public abstract class AbstractPageNumberCitation extends FObj
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
         commonFont = pList.getFontProps();
         alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
@@ -99,7 +102,6 @@ public abstract class AbstractPageNumberCitation extends FObj
         dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
         // letterSpacing = pList.get(PR_LETTER_SPACING);
         lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
-        ptr = pList.get(PR_X_PTR).getString();   // used for accessibility
         refId = pList.get(PR_REF_ID).getString();
         textDecoration = pList.getTextDecorationProps();
         // textShadow = pList.get(PR_TEXT_SHADOW);
@@ -129,6 +131,10 @@ public abstract class AbstractPageNumberCitation extends FObj
         }
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /** @return the {@link CommonFont} */
     public CommonFont getCommonFont() {
         return commonFont;
@@ -144,6 +150,11 @@ public abstract class AbstractPageNumberCitation extends FObj
         return textDecoration;
     }
 
+    @Override
+    public void setPtr(String ptr) {
+        this.ptr = ptr;
+    }
+
     /** {@inheritDoc} */
     public String getPtr() {
         return ptr;
index c3a735db6d8c6865be518f39166aace345dd0c97..7bff2d5212dbdef0f7fba536def8aea5ed606e2b 100644 (file)
@@ -76,7 +76,6 @@ public class BasicLink extends InlineLevel implements StructurePointerPropertySe
         alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
         baselineShift = pList.get(PR_BASELINE_SHIFT).getLength();
         dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
-        ptr = pList.get(PR_X_PTR).getString(); // used for accessibility
         // destinationPlacementOffset = pList.get(PR_DESTINATION_PLACEMENT_OFFSET);
         externalDestination = pList.get(PR_EXTERNAL_DESTINATION).getString();
         // indicateDestination = pList.get(PR_INDICATE_DESTINATION);
@@ -104,7 +103,7 @@ public class BasicLink extends InlineLevel implements StructurePointerPropertySe
     /** {@inheritDoc} */
     protected void endOfNode() throws FOPException {
         super.endOfNode();
-        getFOEventHandler().endLink();
+        getFOEventHandler().endLink(this);
     }
 
     /** {@inheritDoc} */
@@ -143,6 +142,11 @@ public class BasicLink extends InlineLevel implements StructurePointerPropertySe
         return dominantBaseline;
     }
 
+    @Override
+    public void setPtr(String ptr) {
+        this.ptr = ptr;
+    }
+
     /** {@inheritDoc} */
     public String getPtr() {
         return ptr;
index 66e06db83b2f4b2ea242bfc5e2e7d027adb64970..b1705288a60e8a0b60c64f862db19777aff6153f 100644 (file)
@@ -33,6 +33,8 @@ import org.apache.fop.fo.NullCharIterator;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
 import org.apache.fop.fo.properties.BreakPropertySet;
+import org.apache.fop.fo.properties.CommonAccessibility;
+import org.apache.fop.fo.properties.CommonAccessibilityHolder;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonFont;
 import org.apache.fop.fo.properties.CommonHyphenation;
@@ -46,13 +48,15 @@ import org.apache.fop.fo.properties.StructurePointerPropertySet;
   * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_block">
   * <code>fo:block object</code></a>.
   */
-public class Block extends FObjMixed implements BreakPropertySet, StructurePointerPropertySet {
+public class Block extends FObjMixed implements BreakPropertySet, StructurePointerPropertySet,
+        CommonAccessibilityHolder {
 
     // used for FO validation
     private boolean blockOrInlineItemFound = false;
     private boolean initialPropertySetFound = false;
 
     // The value of properties relevant for fo:block.
+    private CommonAccessibility commonAccessibility;
     private CommonBorderPaddingBackground commonBorderPaddingBackground;
     private CommonFont commonFont;
     private CommonHyphenation commonHyphenation;
@@ -104,6 +108,7 @@ public class Block extends FObjMixed implements BreakPropertySet, StructurePoint
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
         commonFont = pList.getFontProps();
         commonHyphenation = pList.getHyphenationProps();
@@ -125,7 +130,6 @@ public class Block extends FObjMixed implements BreakPropertySet, StructurePoint
         lineHeightShiftAdjustment = pList.get(PR_LINE_HEIGHT_SHIFT_ADJUSTMENT).getEnum();
         lineStackingStrategy = pList.get(PR_LINE_STACKING_STRATEGY).getEnum();
         orphans = pList.get(PR_ORPHANS).getNumeric();
-        ptr = pList.get(PR_X_PTR).getString();  //used for accessibility
         whiteSpaceTreatment = pList.get(PR_WHITE_SPACE_TREATMENT).getEnum();
         span = pList.get(PR_SPAN).getEnum();
         textAlign = pList.get(PR_TEXT_ALIGN).getEnum();
@@ -149,6 +153,10 @@ public class Block extends FObjMixed implements BreakPropertySet, StructurePoint
         getFOEventHandler().endBlock(this);
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /** @return the {@link CommonMarginBlock} */
     public CommonMarginBlock getCommonMarginBlock() {
         return commonMarginBlock;
@@ -175,6 +183,11 @@ public class Block extends FObjMixed implements BreakPropertySet, StructurePoint
         return breakAfter;
     }
 
+    @Override
+    public void setPtr(String ptr) {
+        this.ptr = ptr;
+    }
+
     /** {@inheritDoc} */
     public String getPtr() {
         return ptr;
index 7328b564405d554a01ff93585cdd6552474fd76b..a33bea53db7c94785528f3290d5c8cefa24a52ac 100644 (file)
@@ -110,7 +110,6 @@ public class Character extends FObj implements StructurePointerPropertySet {
         lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
         textDecoration = pList.getTextDecorationProps();
         wordSpacing = pList.get(PR_WORD_SPACING);
-        ptr = pList.get(PR_X_PTR).getString();  // used for accessibility
     }
 
     /** {@inheritDoc} */
@@ -210,6 +209,11 @@ public class Character extends FObj implements StructurePointerPropertySet {
         return keepWithPrevious;
     }
 
+    @Override
+    public void setPtr(String ptr) {
+        this.ptr = ptr;
+    }
+
     /** {@inheritDoc} */
     public String getPtr() {
         return ptr;
index 51d2581cda74ebe27eb90f91452da0aefd100a94..61149b0342a9c83e81a1f816b1a43d9ebbdffcbe 100644 (file)
@@ -26,15 +26,16 @@ import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 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_footnote">
  * <code>fo:footnote</code></a> object.
  */
-public class Footnote extends FObj {
-    // The value of properties relevant for fo:footnote (commented out for performance).
-    //     private CommonAccessibility commonAccessibility;
-    // End of property values
+public class Footnote extends FObj implements CommonAccessibilityHolder {
+
+    private CommonAccessibility commonAccessibility;
 
     private Inline footnoteCitation = null;
     private FootnoteBody footnoteBody;
@@ -51,7 +52,7 @@ public class Footnote extends FObj {
 
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
-        // No active properties -> do nothing.
+        commonAccessibility = CommonAccessibility.getInstance(pList);
     }
 
     /** {@inheritDoc} */
@@ -110,6 +111,10 @@ public class Footnote extends FObj {
         }
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /**
      * Public accessor for inline FO
      *
index eb26a200944c874dbda65ced2226159995c1aea7..24edaf5d272529c8f0cb2b8de1e8afc7e99a31ac 100644 (file)
@@ -27,15 +27,16 @@ import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 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_footnote-body">
  * <code>fo:footnote-body</code></a> object.
  */
-public class FootnoteBody extends FObj {
-    // The value of properties relevant for fo:footnote-body (commented out for perforance).
-    //     private CommonAccessibility commonAccessibility;
-    // End of property values
+public class FootnoteBody extends FObj implements CommonAccessibilityHolder {
+
+    private CommonAccessibility commonAccessibility;
 
     /**
      * Base constructor
@@ -48,6 +49,7 @@ public class FootnoteBody extends FObj {
 
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
+        commonAccessibility = CommonAccessibility.getInstance(pList);
     }
 
     /** {@inheritDoc} */
@@ -93,4 +95,9 @@ public class FootnoteBody extends FObj {
     public int getNameId() {
         return FO_FOOTNOTE_BODY;
     }
+
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
 }
index 0df7379f2d43d691e38675382ab8535f04aaf516..47ce749fe3f5eb4c466a7773d3f5f7c50c9d4104 100644 (file)
@@ -27,19 +27,22 @@ import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 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;
 import org.apache.fop.fo.properties.SpaceProperty;
 
 /**
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_initial-property-set">
  * <code>fo:initial-property-set</code></a> object.
  */
-public class InitialPropertySet extends FObj {
-    // The value of properties relevant for fo:initial-property-set.
+public class InitialPropertySet extends FObj implements CommonAccessibilityHolder {
+
+    private CommonAccessibility commonAccessibility;
+
     // private ToBeImplementedProperty letterSpacing;
     private SpaceProperty lineHeight;
     // private ToBeImplementedProperty textShadow;
     // Unused but valid items, commented out for performance:
-    //     private CommonAccessibility commonAccessibility;
     //     private CommonAural commonAural;
     //     private CommonBorderPaddingBackground commonBorderPaddingBackground;
     //     private CommonFont commonFont;
@@ -63,6 +66,7 @@ public class InitialPropertySet extends FObj {
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         // letterSpacing = pList.get(PR_LETTER_SPACING);
         lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
         // textShadow = pList.get(PR_TEXT_SHADOW);
@@ -96,4 +100,9 @@ public class InitialPropertySet extends FObj {
     public int getNameId() {
         return FO_INITIAL_PROPERTY_SET;
     }
+
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
 }
index d9ae63ec8a3389e08c4138cfa22bc705bc46ef51..e458184f47c5fbcd0654e96ff9e79ec81a0a1a8f 100644 (file)
@@ -68,7 +68,6 @@ public class Inline extends InlineLevel implements StructurePointerPropertySet {
         alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum();
         baselineShift = pList.get(PR_BASELINE_SHIFT).getLength();
         dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum();
-        ptr = pList.get(PR_X_PTR).getString(); // used for accessibility
     }
 
     /** {@inheritDoc} */
@@ -148,6 +147,11 @@ public class Inline extends InlineLevel implements StructurePointerPropertySet {
         return dominantBaseline;
     }
 
+    @Override
+    public void setPtr(String ptr) {
+        this.ptr = ptr;
+    }
+
     /** {@inheritDoc} */
     public String getPtr() {
         return ptr;
index 5410e1ca7ae0c9f0a7568feeaee23780845a5927..d23b775f0d6a48badbb36072f100678d7b4e5aae 100644 (file)
@@ -25,6 +25,8 @@ import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObjMixed;
 import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.properties.CommonAccessibility;
+import org.apache.fop.fo.properties.CommonAccessibilityHolder;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonFont;
 import org.apache.fop.fo.properties.CommonMarginInline;
@@ -35,9 +37,10 @@ import org.apache.fop.fo.properties.SpaceProperty;
  * Class modelling the commonalities of several inline-level
  * formatting objects.
  */
-public abstract class InlineLevel extends FObjMixed {
+public abstract class InlineLevel extends FObjMixed implements CommonAccessibilityHolder {
 
     // The value of properties relevant for inline-level FOs.
+    private CommonAccessibility commonAccessibility;
     private CommonBorderPaddingBackground commonBorderPaddingBackground;
     private CommonMarginInline commonMarginInline;
     private CommonFont commonFont;
@@ -59,6 +62,7 @@ public abstract class InlineLevel extends FObjMixed {
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
         commonMarginInline = pList.getMarginInlineProps();
         commonFont = pList.getFontProps();
@@ -68,6 +72,10 @@ public abstract class InlineLevel extends FObjMixed {
         lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /** @return the {@link CommonMarginInline} */
     public CommonMarginInline getCommonMarginInline() {
         return commonMarginInline;
index 02d25f8dd6c32b3a370b656a3dd555005ec1233b..33164188fde56f6dd2837533f9167c6c47491e70 100644 (file)
@@ -59,6 +59,12 @@ public class InstreamForeignObject extends AbstractGraphics {
         super(parent);
     }
 
+    @Override
+    protected void startOfNode() throws FOPException {
+        super.startOfNode();
+        getFOEventHandler().startInstreamForeignObject(this);
+    }
+
     /**
      * Make sure content model satisfied, if so then tell the
      * {@link org.apache.fop.fo.FOEventHandler} that we are at
@@ -69,7 +75,7 @@ public class InstreamForeignObject extends AbstractGraphics {
         if (firstChild == null) {
             missingChildElementError("one (1) non-XSL namespace child");
         }
-        getFOEventHandler().foreignObject(this);
+        getFOEventHandler().endInstreamForeignObject(this);
     }
 
     /**
index 54027514ce17d9f765646819274e6d92650ad8d8..f12930dde8a0b4d2c5b2394b608a21624ff14885 100644 (file)
@@ -158,4 +158,16 @@ public class Leader extends InlineLevel {
     public int getNameId() {
         return FO_LEADER;
     }
+
+    @Override
+    protected void startOfNode() throws FOPException {
+        super.startOfNode();
+        getFOEventHandler().startLeader(this);
+    }
+
+    @Override
+    protected void endOfNode() throws FOPException {
+        super.endOfNode();
+        getFOEventHandler().endLeader(this);
+    }
 }
index 8f72ded6716df2dcd3a967014ea1437a243fd592..390978c194fad00d7cb563a7c18538cc01258f95 100644 (file)
@@ -28,6 +28,8 @@ import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
 import org.apache.fop.fo.properties.BreakPropertySet;
+import org.apache.fop.fo.properties.CommonAccessibility;
+import org.apache.fop.fo.properties.CommonAccessibilityHolder;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonMarginBlock;
 import org.apache.fop.fo.properties.KeepProperty;
@@ -36,8 +38,9 @@ import org.apache.fop.fo.properties.KeepProperty;
  * Class modelling the <a href=http://www.w3.org/TR/xsl/#fo_list-block">
  * <code>fo:list-block</code></a> object.
  */
-public class ListBlock extends FObj implements BreakPropertySet {
+public class ListBlock extends FObj implements BreakPropertySet, CommonAccessibilityHolder {
     // The value of properties relevant for fo:list-block.
+    private CommonAccessibility commonAccessibility;
     private CommonBorderPaddingBackground commonBorderPaddingBackground;
     private CommonMarginBlock commonMarginBlock;
     private int breakAfter;
@@ -46,7 +49,6 @@ public class ListBlock extends FObj implements BreakPropertySet {
     private KeepProperty keepWithNext;
     private KeepProperty keepWithPrevious;
     // Unused but valid items, commented out for performance:
-    //     private CommonAccessibility commonAccessibility;
     //     private CommonAural commonAural;
     //     private CommonRelativePosition commonRelativePosition;
     //     private int intrusionDisplace;
@@ -73,6 +75,7 @@ public class ListBlock extends FObj implements BreakPropertySet {
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
         commonMarginBlock = pList.getMarginBlockProps();
         breakAfter = pList.get(PR_BREAK_AFTER).getEnum();
@@ -123,6 +126,10 @@ public class ListBlock extends FObj implements BreakPropertySet {
         }
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /** @return the {@link CommonMarginBlock} */
     public CommonMarginBlock getCommonMarginBlock() {
         return commonMarginBlock;
index c4a2aa64b7490ba14286a968d9ac81384fcec176..dfd74f9d172e9f05864c37b5cc80f13e9b29e005 100644 (file)
@@ -27,6 +27,8 @@ import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
 import org.apache.fop.fo.properties.BreakPropertySet;
+import org.apache.fop.fo.properties.CommonAccessibility;
+import org.apache.fop.fo.properties.CommonAccessibilityHolder;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonMarginBlock;
 import org.apache.fop.fo.properties.KeepProperty;
@@ -35,8 +37,9 @@ import org.apache.fop.fo.properties.KeepProperty;
  * Class modelling the <a href=http://www.w3.org/TR/xsl/#fo_list-item">
  * <code>fo:list-item</code></a> object.
  */
-public class ListItem extends FObj implements BreakPropertySet {
+public class ListItem extends FObj implements BreakPropertySet, CommonAccessibilityHolder {
     // The value of properties relevant for fo:list-item.
+    private CommonAccessibility commonAccessibility;
     private CommonBorderPaddingBackground commonBorderPaddingBackground;
     private CommonMarginBlock commonMarginBlock;
     private int breakAfter;
@@ -45,7 +48,6 @@ public class ListItem extends FObj implements BreakPropertySet {
     private KeepProperty keepWithNext;
     private KeepProperty keepWithPrevious;
     // Unused but valid items, commented out for performance:
-    //     private CommonAccessibility commonAccessibility;
     //     private CommonAural commonAural;
     //     private CommonRelativePosition commonRelativePosition;
     //     private int intrusionDisplace;
@@ -67,6 +69,7 @@ public class ListItem extends FObj implements BreakPropertySet {
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
         commonMarginBlock = pList.getMarginBlockProps();
         breakAfter = pList.get(PR_BREAK_AFTER).getEnum();
@@ -134,6 +137,10 @@ public class ListItem extends FObj implements BreakPropertySet {
         }
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /** @return the {@link CommonMarginBlock} */
     public CommonMarginBlock getCommonMarginBlock() {
         return commonMarginBlock;
index 853beb20b39caa824fab46c94bf1d0bca632c58f..3007f9ba3b8bd32fbc20b8191f930923bfb9cef5 100644 (file)
@@ -38,13 +38,13 @@ public class ListItemBody extends AbstractListItemPart {
     /** {@inheritDoc} */
     protected void startOfNode() throws FOPException {
         super.startOfNode();
-        getFOEventHandler().startListBody();
+        getFOEventHandler().startListBody(this);
     }
 
     /** {@inheritDoc} */
     protected void endOfNode() throws FOPException {
         super.endOfNode();
-        getFOEventHandler().endListBody();
+        getFOEventHandler().endListBody(this);
     }
 
     /** {@inheritDoc} */
index 1c757686c1a63735ae84577a9212fcde6dbdae9f..10436afa6398023ee34a6db27ddb3096f60af6b9 100644 (file)
@@ -40,13 +40,13 @@ public class ListItemLabel extends AbstractListItemPart {
     /** {@inheritDoc} */
     protected void startOfNode() throws FOPException {
         super.startOfNode();
-        getFOEventHandler().startListLabel();
+        getFOEventHandler().startListLabel(this);
     }
 
     /** {@inheritDoc} */
     protected void endOfNode() throws FOPException {
         super.endOfNode();
-        getFOEventHandler().endListLabel();
+        getFOEventHandler().endListLabel(this);
     }
 
     /** {@inheritDoc} */
index 34d267a641bcec257835dd72cf75a5d50bc0d9a6..c0373aa7fd6fd0e9113638fff49a65d29ba27b0f 100644 (file)
@@ -30,6 +30,8 @@ import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 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;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonFont;
 import org.apache.fop.fo.properties.CommonTextDecoration;
@@ -40,8 +42,10 @@ import org.apache.fop.fo.properties.StructurePointerPropertySet;
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_page-number">
  * <code>fo:page-number</code></a> object.
  */
-public class PageNumber extends FObj implements StructurePointerPropertySet {
+public class PageNumber extends FObj
+        implements StructurePointerPropertySet, CommonAccessibilityHolder {
     // The value of properties relevant for fo:page-number.
+    private CommonAccessibility commonAccessibility;
     private CommonBorderPaddingBackground commonBorderPaddingBackground;
     private CommonFont commonFont;
     private Length alignmentAdjust;
@@ -55,7 +59,6 @@ public class PageNumber extends FObj implements StructurePointerPropertySet {
     private CommonTextDecoration textDecoration;
     // private ToBeImplementedProperty textShadow;
     // Unused but valid items, commented out for performance:
-    //     private CommonAccessibility commonAccessibility;
     //     private CommonAural commonAural;
     //     private CommonMarginInline commonMarginInline;
     //     private CommonRelativePosition commonRelativePosition;
@@ -85,6 +88,7 @@ public class PageNumber extends FObj implements StructurePointerPropertySet {
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
         commonFont = pList.getFontProps();
         alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength();
@@ -94,7 +98,6 @@ public class PageNumber extends FObj implements StructurePointerPropertySet {
         // letterSpacing = pList.get(PR_LETTER_SPACING);
         lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
         textDecoration = pList.getTextDecorationProps();
-        ptr = pList.get(PR_X_PTR).getString(); // used for accessibility
         // textShadow = pList.get(PR_TEXT_SHADOW);
 
         // implicit properties
@@ -123,6 +126,10 @@ public class PageNumber extends FObj implements StructurePointerPropertySet {
         }
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /** @return the Common Font Properties. */
     public CommonFont getCommonFont() {
         return commonFont;
@@ -168,6 +175,11 @@ public class PageNumber extends FObj implements StructurePointerPropertySet {
         return lineHeight;
     }
 
+    @Override
+    public void setPtr(String ptr) {
+        this.ptr = ptr;
+    }
+
     /** {@inheritDoc} */
     public String getPtr() {
         return ptr;
index 7fb412521c1483a9bb71fe89d643f7c1ac12051c..6c56192528022967cd7715b32c5070bcfda39d3e 100644 (file)
@@ -51,6 +51,18 @@ public class Wrapper extends FObjMixed {
         super(parent);
     }
 
+    @Override
+    protected void startOfNode() throws FOPException {
+        super.startOfNode();
+        getFOEventHandler().startWrapper(this);
+    }
+
+    @Override
+    protected void endOfNode() throws FOPException {
+        super.endOfNode();
+        getFOEventHandler().endWrapper(this);
+    }
+
     /**
      * {@inheritDoc}
      * <br>XSL Content Model: marker* (#PCDATA|%inline;|%block;)*
index 86196cb29ef22788ea4fc19db1c6ebfbc0c7d8e3..ae7b8e4a1d67e9a6d1484deaa3e47c94e863615d 100644 (file)
@@ -32,6 +32,8 @@ import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.StaticPropertyList;
 import org.apache.fop.fo.ValidationException;
 import org.apache.fop.fo.properties.BreakPropertySet;
+import org.apache.fop.fo.properties.CommonAccessibility;
+import org.apache.fop.fo.properties.CommonAccessibilityHolder;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonMarginBlock;
 import org.apache.fop.fo.properties.KeepProperty;
@@ -43,9 +45,11 @@ import org.apache.fop.fo.properties.TableColLength;
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table">
  * <code>fo:table</code></a> object.
  */
-public class Table extends TableFObj implements ColumnNumberManagerHolder, BreakPropertySet {
+public class Table extends TableFObj implements ColumnNumberManagerHolder, BreakPropertySet,
+        CommonAccessibilityHolder {
 
     /** properties */
+    private CommonAccessibility commonAccessibility;
     private CommonBorderPaddingBackground commonBorderPaddingBackground;
     private CommonMarginBlock commonMarginBlock;
     private LengthRangeProperty blockProgressionDimension;
@@ -61,7 +65,6 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break
     private int tableOmitFooterAtBreak;
     private int tableOmitHeaderAtBreak;
     // Unused but valid items, commented out for performance:
-    //     private CommonAccessibility commonAccessibility;
     //     private CommonAural commonAural;
     //     private CommonRelativePosition commonRelativePosition;
     //     private int intrusionDisplace;
@@ -112,6 +115,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break
      */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
         commonMarginBlock = pList.getMarginBlockProps();
         blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange();
@@ -301,6 +305,10 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break
         }
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /** {@inheritDoc} */
     public Table getTable() {
         return this;
index 634460ec476c6cfddc9f5aa332731e9686da22b0..62acc579c08a01075db9d4dc28fcbde4879ef2e9 100644 (file)
@@ -25,17 +25,22 @@ import org.xml.sax.Locator;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
+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_table-and-caption">
  * <code>fo:table-and-caption</code></a> property.
  * TODO needs implementation
  */
-public class TableAndCaption extends FObj /*implements BreakPropertySet*/ {
+public class TableAndCaption extends FObj implements CommonAccessibilityHolder {
+
+    private CommonAccessibility commonAccessibility;
+
     // The value of properties relevant for fo:table-and-caption.
     // Unused but valid items, commented out for performance:
-    //     private CommonAccessibility commonAccessibility;
     //     private CommonAural commonAural;
     //     private CommonBorderPaddingBackground commonBorderPaddingBackground;
     //     private CommonMarginBlock commonMarginBlock;
@@ -50,7 +55,7 @@ public class TableAndCaption extends FObj /*implements BreakPropertySet*/ {
     //     private int textAlign;
     // End of property values
 
-    private static boolean notImplementedWarningGiven = false;
+    static boolean notImplementedWarningGiven = false; // CSOK: VisibilityModifier
 
     /** used for FO validation */
     private boolean tableCaptionFound = false;
@@ -71,6 +76,12 @@ public class TableAndCaption extends FObj /*implements BreakPropertySet*/ {
         }
     }
 
+    @Override
+    public void bind(PropertyList pList) throws FOPException {
+        super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
+    }
+
     /**
      * Make sure content model satisfied, if so then tell the
      * FOEventHandler that we are at the end of the flow.
@@ -128,5 +139,10 @@ public class TableAndCaption extends FObj /*implements BreakPropertySet*/ {
     public int getNameId() {
         return FO_TABLE_AND_CAPTION;
     }
+
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
 }
 
index fc5d3d5b76075edd3b1e8b9b547ca7df7ec7904a..127c09802f8334ec5936d1ed2653bd9d8d9102f3 100644 (file)
@@ -27,13 +27,18 @@ import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 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_table-caption">
  * <code>fo:table-caption</code></a> object.
  */
-public class TableCaption extends FObj {
+public class TableCaption extends FObj implements CommonAccessibilityHolder {
+
+    private CommonAccessibility commonAccessibility;
+
     // The value of properties relevant for fo:table-caption.
     // Unused but valid items, commented out for performance:
     //     private CommonAural commonAural;
@@ -49,7 +54,7 @@ public class TableCaption extends FObj {
     /** used for FO validation */
     private boolean blockItemFound = false;
 
-    private static boolean notImplementedWarningGiven = false;
+    static boolean notImplementedWarningGiven = false; // CSOK: VisibilityModifier
 
     /**
      * Create a TableCaption instance with the given {@link FONode}
@@ -69,6 +74,7 @@ public class TableCaption extends FObj {
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
     }
 
     /** {@inheritDoc} */
@@ -109,5 +115,10 @@ public class TableCaption extends FObj {
     public int getNameId() {
         return FO_TABLE_CAPTION;
     }
+
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
 }
 
index 637ee2a9af71087f608fb417aa73d3bf9d1e144f..549377ffd736e96d3f7b93a9e3003d68f38dd6a2 100644 (file)
@@ -26,6 +26,8 @@ import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.FONode;
 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;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.LengthRangeProperty;
 
@@ -33,8 +35,9 @@ import org.apache.fop.fo.properties.LengthRangeProperty;
  * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-cell">
  * <code>fo:table-cell</code></a> object.
  */
-public class TableCell extends TableFObj {
+public class TableCell extends TableFObj implements CommonAccessibilityHolder {
     // The value of properties relevant for fo:table-cell.
+    private CommonAccessibility commonAccessibility;
     private CommonBorderPaddingBackground commonBorderPaddingBackground;
     private LengthRangeProperty blockProgressionDimension;
     private int columnNumber;
@@ -46,7 +49,6 @@ public class TableCell extends TableFObj {
     private int startsRow;
     private Length width;
     // Unused but valid items, commented out for performance:
-    //     private CommonAccessibility commonAccessibility;
     //     private CommonAural commonAural;
     //     private CommonRelativePosition commonRelativePosition;
     //     private int relativeAlign;
@@ -74,6 +76,7 @@ public class TableCell extends TableFObj {
      */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
         blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange();
         displayAlign = pList.get(PR_DISPLAY_ALIGN).getEnum();
@@ -145,6 +148,10 @@ public class TableCell extends TableFObj {
         return true;
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /**
      * Get the {@link CommonBorderPaddingBackground} instance
      * attached to this TableCell.
index 41eab578f2a4a8f33bd01c0826dcf8a808e9d8c1..4b2a5101f26f80d41ff76bb808490bf339af47e0 100644 (file)
@@ -24,11 +24,17 @@ import java.util.List;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.properties.CommonAccessibility;
+import org.apache.fop.fo.properties.CommonAccessibilityHolder;
 
 /**
  * A common class for fo:table-body and fo:table-row which both can contain fo:table-cell.
  */
-public abstract class TableCellContainer extends TableFObj implements ColumnNumberManagerHolder {
+public abstract class TableCellContainer extends TableFObj
+        implements ColumnNumberManagerHolder, CommonAccessibilityHolder {
+
+    private CommonAccessibility commonAccessibility;
 
     /** list of pending spans */
     protected List pendingSpans;
@@ -44,6 +50,12 @@ public abstract class TableCellContainer extends TableFObj implements ColumnNumb
         super(parent);
     }
 
+    @Override
+    public void bind(PropertyList pList) throws FOPException {
+        super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
+    }
+
     /**
      * Add cell to current row.
      * @param cell a table cell to add
@@ -116,4 +128,8 @@ public abstract class TableCellContainer extends TableFObj implements ColumnNumb
         return columnNumberManager;
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
 }
index fce82dcff09c147478da1c7de15160f1b60037c9..0da7b94589d70cd92b9a9473181f92e0e312c3ee 100644 (file)
@@ -74,7 +74,6 @@ public abstract class TableFObj extends FObj implements StructurePointerProperty
         borderBeforePrecedence = pList.get(PR_BORDER_BEFORE_PRECEDENCE).getNumeric();
         borderEndPrecedence = pList.get(PR_BORDER_END_PRECEDENCE).getNumeric();
         borderStartPrecedence = pList.get(PR_BORDER_START_PRECEDENCE).getNumeric();
-        ptr = pList.get(PR_X_PTR).getString();
         if (getNameId() != FO_TABLE //Separate check for fo:table in Table.java
                 && getNameId() != FO_TABLE_CELL
                 && getCommonBorderPaddingBackground().hasPadding(
@@ -241,6 +240,11 @@ public abstract class TableFObj extends FObj implements StructurePointerProperty
         }
     }
 
+    @Override
+    public void setPtr(String ptr) {
+        this.ptr = ptr;
+    }
+
     /** {@inheritDoc} */
     public String getPtr() {
         return ptr;
index fb69dc2f13d20a5a284c09bf15fc6094b440b0cc..c670d6e4256ccf1154d20b722c5b844461cd811a 100644 (file)
@@ -33,16 +33,19 @@ import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
 import org.apache.fop.fo.extensions.destination.Destination;
 import org.apache.fop.fo.pagination.bookmarks.BookmarkTree;
+import org.apache.fop.fo.properties.CommonAccessibility;
+import org.apache.fop.fo.properties.CommonAccessibilityHolder;
 
 /**
  * Class modeling the <a href="http://www.w3.org/TR/xsl/#fo_root">
  * <code>fo:root</code></a> formatting object.
  * Contains page masters, page-sequences.
  */
-public class Root extends FObj {
-    // The value of properties relevant for fo:root.
+public class Root extends FObj implements CommonAccessibilityHolder {
+
+    private CommonAccessibility commonAccessibility;
+
     private int mediaUsage;
-    // End of property values
 
     private LayoutMasterSet layoutMasterSet;
     private Declarations declarations;
@@ -83,6 +86,7 @@ public class Root extends FObj {
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         mediaUsage = pList.get(PR_MEDIA_USAGE).getEnum();
     }
 
@@ -156,6 +160,10 @@ public class Root extends FObj {
         }
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /**
      * Sets the FOEventHandler object that this Root is attached to
      * @param foEventHandler the FOEventHandler object
index 4084a250a96d05eb055f88033d474fee67ea232b..e70c80c5de544e01d643bf59deaa11df9de916c1 100644 (file)
@@ -44,7 +44,7 @@ public class StaticContent extends Flow {
         if (getFlowName() == null || getFlowName().equals("")) {
             missingPropertyError("flow-name");
         }
-        getFOEventHandler().startFlow(this);
+        getFOEventHandler().startStatic(this);
     }
 
     /**
@@ -56,7 +56,7 @@ public class StaticContent extends Flow {
         if (firstChild == null && getUserAgent().validateStrictly()) {
             missingChildElementError("(%block;)+");
         }
-        getFOEventHandler().endFlow(this);
+        getFOEventHandler().endStatic(this);
     }
 
     /**
index 5969729d46ca7326b17ec5bc7f041fdb9c5052ef..5348e88e3fc0a2a9017104f57d7bf730bfe7e654 100644 (file)
@@ -22,11 +22,14 @@ package org.apache.fop.fo.pagination.bookmarks;
 import java.util.ArrayList;
 
 import org.xml.sax.Locator;
+
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FObj;
 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;
 
 
 /**
@@ -34,11 +37,12 @@ import org.apache.fop.fo.ValidationException;
  * <code>fo:bookmark</code></a> object, first introduced in the
  * XSL 1.1 WD.
  */
-public class Bookmark extends FObj {
+public class Bookmark extends FObj implements CommonAccessibilityHolder {
     private BookmarkTitle bookmarkTitle;
     private ArrayList childBookmarks = new ArrayList();
 
     // The value of properties relevant for this FO
+    private CommonAccessibility commonAccessibility;
     private String internalDestination;
     private String externalDestination;
     private boolean bShow = true; // from starting-state property
@@ -59,6 +63,7 @@ public class Bookmark extends FObj {
 
     /** {@inheritDoc} */
     public void bind(PropertyList pList) throws FOPException {
+        commonAccessibility = CommonAccessibility.getInstance(pList);
         externalDestination = pList.get(PR_EXTERNAL_DESTINATION).getString();
         internalDestination = pList.get(PR_INTERNAL_DESTINATION).getString();
         bShow = (pList.get(PR_STARTING_STATE).getEnum() == EN_SHOW);
@@ -112,6 +117,10 @@ public class Bookmark extends FObj {
         }
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /**
      * Get the bookmark title for this bookmark
      *
index 028cdc7dfaceb392c2eb80581692b8d71d9ce3ed..f4441934d0e05ddf2f16d68f7dfc306bb99faaf3 100644 (file)
@@ -21,17 +21,23 @@ package org.apache.fop.fo.pagination.bookmarks;
 
 import org.xml.sax.Locator;
 
+import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 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_bookmark-title">
  * <code>fo:bookmark-title</code></a> object, first introduced in the
  * XSL 1.1 WD.
  */
-public class BookmarkTitle extends FObj {
+public class BookmarkTitle extends FObj implements CommonAccessibilityHolder {
+
+    private CommonAccessibility commonAccessibility;
+
     private String title = "";
 
     /**
@@ -44,6 +50,12 @@ public class BookmarkTitle extends FObj {
         super(parent);
     }
 
+    @Override
+    public void bind(PropertyList pList) throws FOPException {
+        super.bind(pList);
+        commonAccessibility = CommonAccessibility.getInstance(pList);
+    }
+
     /**
      * Add the characters to this BookmarkTitle.
      * The text data inside the BookmarkTitle xml element
@@ -72,6 +84,10 @@ public class BookmarkTitle extends FObj {
         }
     }
 
+    public CommonAccessibility getCommonAccessibility() {
+        return commonAccessibility;
+    }
+
     /**
      * Get the title for this BookmarkTitle.
      *
index dc17228d231ea1f445abd98da574186cae5a0817..85183b01f357c4b7282e889e03fd7e41d6accaf5 100644 (file)
@@ -24,37 +24,62 @@ import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.PropertyException;
 
 /**
- * Store all common accessibility properties.
- * See Sec 7.4 of the XSL-FO Standard.
- * Public "structure" allows direct member access.
+ * The "role" and "source-document" properties, see Section 7.5 of the XSL-FO 1.1
+ * Recommendation.
  */
-public class CommonAccessibility {
-    /**
-     * The "source-doc" property.
-     */
-    public String sourceDoc = null;                             // CSOK: VisibilityModifier
+public final class CommonAccessibility {
 
-    /**
-     * The "role" property.
-     */
-    public String role = null;                                  // CSOK: VisibilityModifier
+    private static final CommonAccessibility DEFAULT_INSTANCE = new CommonAccessibility(null, null);
+
+    private final String sourceDocument;
+
+    private final String role;
+
+    private CommonAccessibility(String sourceDocument, String role) {
+        this.sourceDocument = sourceDocument;
+        this.role = role;
+    }
 
     /**
-     * Create a <code>CommonAccessibility</code> object.
-     * @param pList The PropertyList with propery values.
-     * @throws PropertyException if a property exception is raised
+     * Returns an instance that matches the values (if any) in the given property list.
+     *
+     * @param propertyList a list from which to retrieve the accessibility properties
+     * @return the corresponding instance
+     * @throws PropertyException if a problem occurs while retrieving the properties
      */
-    public CommonAccessibility(PropertyList pList) throws PropertyException {
-        sourceDoc = pList.get(Constants.PR_SOURCE_DOCUMENT).getString();
-        if ("none".equals(sourceDoc)) {
-            sourceDoc = null;
+    public static CommonAccessibility getInstance(PropertyList propertyList)
+            throws PropertyException {
+        String sourceDocument = propertyList.get(Constants.PR_SOURCE_DOCUMENT).getString();
+        if ("none".equals(sourceDocument)) {
+            sourceDocument = null;
         }
-        role = pList.get(Constants.PR_ROLE).getString();
+        String role = propertyList.get(Constants.PR_ROLE).getString();
         if ("none".equals(role)) {
             role = null;
         }
+        if (sourceDocument == null && role == null) {
+            return DEFAULT_INSTANCE;
+        } else {
+            return new CommonAccessibility(sourceDocument, role);
+        }
+    }
 
+    /**
+     * Returns the value of the source-document property.
+     *
+     * @return the source document, or null if the property was set to "none"
+     */
+    public String getSourceDocument() {
+        return sourceDocument;
     }
 
+    /**
+     * Returns the value of the role property.
+     *
+     * @return the role, or null if the property was set to "none"
+     */
+    public String getRole() {
+        return role;
+    }
 
 }
diff --git a/src/java/org/apache/fop/fo/properties/CommonAccessibilityHolder.java b/src/java/org/apache/fop/fo/properties/CommonAccessibilityHolder.java
new file mode 100644 (file)
index 0000000..745c0cf
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.fo.properties;
+
+/**
+ * Classes that implement this interface support the common accessibility properties.
+ *
+ * @see CommonAccessibility
+ */
+public interface CommonAccessibilityHolder {
+
+    /**
+     * Returns the accessibility properties.
+     *
+     * @return the accessibility properties
+     */
+    CommonAccessibility getCommonAccessibility();
+}
index 4fd66109a8a18939232a05137f888513b4e4952d..ce86f48496d9a4ff2c26ca64224c7ed99c5bfa17 100644 (file)
@@ -149,9 +149,6 @@ class PDFLogicalStructureHandler {
     }
 
     private void processNode(Node node, PDFStructElem parent, boolean addKid) {
-        Node attr = node.getAttributes().getNamedItemNS(InternalElementMapping.URI, "ptr");
-        assert attr != null;
-        String ptr = attr.getNodeValue();
         PDFStructElem structElem = pdfDoc.getFactory().makeStructureElement(
                 FOToPDFRoleMap.mapFormattingObject(node, parent, eventBroadcaster), parent);
         // TODO necessary? If a page-sequence is empty (e.g., contains a single
@@ -170,7 +167,11 @@ class PDFLogicalStructureHandler {
                 structElem.put("Alt", "No alternate text specified");
             }
         }
-        structTreeMap.put(ptr, structElem);
+        Node attr = node.getAttributes().getNamedItemNS(InternalElementMapping.URI, "ptr");
+        if (attr != null) {
+            String ptr = attr.getNodeValue();
+            structTreeMap.put(ptr, structElem);
+        }
         NodeList nodes = node.getChildNodes();
         for (int i = 0, n = nodes.getLength(); i < n; i++) {
             processNode(nodes.item(i), structElem, false);
index 56bc0287f53a8c7b19c2843e6775fab7144c04b3..8878b5d2437ced0a9df5a9815da7ba73ce52dc9b 100644 (file)
@@ -32,7 +32,6 @@ import java.util.Iterator;
 import java.util.Map;
 
 import org.w3c.dom.Document;
-
 import org.xml.sax.SAXException;
 
 import org.apache.commons.io.IOUtils;
@@ -938,10 +937,10 @@ public class RTFHandler extends FOEventHandler {
              */
             //TODO: do this only, if the labels content <> previous labels content
             if (list.getChildCount() > 0) {
-                this.endListBody();
+                this.endListBody(null);
                 this.endList((ListBlock) li.getParent());
                 this.startList((ListBlock) li.getParent());
-                this.startListBody();
+                this.startListBody(null);
 
                 list = (RtfList)builderContext.getContainer(
                         RtfList.class, true, this);
@@ -966,7 +965,7 @@ public class RTFHandler extends FOEventHandler {
     }
 
     /** {@inheritDoc} */
-    public void startListLabel() {
+    public void startListLabel(ListItemLabel listItemLabel) {
         if (bDefer) {
             return;
         }
@@ -986,7 +985,7 @@ public class RTFHandler extends FOEventHandler {
     }
 
     /** {@inheritDoc} */
-    public void endListLabel() {
+    public void endListLabel(ListItemLabel listItemLabel) {
         if (bDefer) {
             return;
         }
@@ -995,20 +994,20 @@ public class RTFHandler extends FOEventHandler {
     }
 
     /** {@inheritDoc} */
-    public void startListBody() {
+    public void startListBody(ListItemBody listItemBody) {
     }
 
     /** {@inheritDoc} */
-    public void endListBody() {
+    public void endListBody(ListItemBody listItemBody) {
     }
 
     // Static Regions
     /** {@inheritDoc} */
-    public void startStatic() {
+    public void startStatic(StaticContent staticContent) {
     }
 
     /** {@inheritDoc} */
-    public void endStatic() {
+    public void endStatic(StaticContent statisContent) {
     }
 
     /** {@inheritDoc} */
@@ -1051,7 +1050,7 @@ public class RTFHandler extends FOEventHandler {
     }
 
     /** {@inheritDoc} */
-    public void endLink() {
+    public void endLink(BasicLink basicLink) {
         if (bDefer) {
             return;
         }
@@ -1091,7 +1090,7 @@ public class RTFHandler extends FOEventHandler {
     }
 
     /** {@inheritDoc} */
-    public void foreignObject(InstreamForeignObject ifo) {
+    public void endInstreamForeignObject(InstreamForeignObject ifo) {
         if (bDefer) {
             return;
         }
@@ -1338,7 +1337,7 @@ public class RTFHandler extends FOEventHandler {
     }
 
     /** {@inheritDoc} */
-    public void leader(Leader l) {
+    public void startLeader(Leader l) {
         if (bDefer) {
             return;
         }
@@ -1519,9 +1518,9 @@ public class RTFHandler extends FOEventHandler {
             }
         } else if (foNode instanceof StaticContent) {
             if (bStart) {
-                startStatic();
+                startStatic(null);
             } else {
-                endStatic();
+                endStatic(null);
             }
         } else if (foNode instanceof ExternalGraphic) {
             if (bStart) {
@@ -1529,7 +1528,7 @@ public class RTFHandler extends FOEventHandler {
             }
         } else if (foNode instanceof InstreamForeignObject) {
             if (bStart) {
-                foreignObject( (InstreamForeignObject) foNode );
+                endInstreamForeignObject( (InstreamForeignObject) foNode );
             }
         } else if (foNode instanceof Block) {
             if (bStart) {
@@ -1548,7 +1547,7 @@ public class RTFHandler extends FOEventHandler {
             if (bStart) {
                 startLink( (BasicLink) foNode);
             } else {
-                endLink();
+                endLink(null);
             }
         } else if (foNode instanceof Inline) {
             if (bStart) {
@@ -1592,9 +1591,9 @@ public class RTFHandler extends FOEventHandler {
             }
         } else if (foNode instanceof ListItemBody) {
             if (bStart) {
-                startListBody();
+                startListBody(null);
             } else {
-                endListBody();
+                endListBody(null);
             }
         } else if (foNode instanceof ListItem) {
             if (bStart) {
@@ -1604,9 +1603,9 @@ public class RTFHandler extends FOEventHandler {
             }
         } else if (foNode instanceof ListItemLabel) {
             if (bStart) {
-                startListLabel();
+                startListLabel(null);
             } else {
-                endListLabel();
+                endListLabel(null);
             }
         } else if (foNode instanceof Table) {
             if (bStart) {
@@ -1652,7 +1651,7 @@ public class RTFHandler extends FOEventHandler {
             }
         } else if (foNode instanceof Leader) {
             if (bStart) {
-                leader((Leader) foNode);
+                startLeader((Leader) foNode);
             }
         } else if (foNode instanceof PageNumberCitation) {
             if (bStart) {
index 391d3905517a5975f41a7bcfb19b1380771e20b4..1d2e04361305cada72bcdff4e121b92c501c2f87 100644 (file)
@@ -1,11 +1,8 @@
 This directory contains sample FO files for testing the accessibility features
 of FOP.
 
-To every FO file in this directory correspond two PDF files in the pdf/ 
-sub-directory: one generated by the painter, one by the renderer. For example, 
-the text_1.fo file has been rendered into pdf/text_1_painter_orig.pdf and 
-pdf/text_1_renderer_orig.pdf. The configuration file config-painter.xconf (resp. 
-config-renderer.xconf) was used.
+Every FO file in this directory has a corresponding PDF file in the pdf/
+sub-directory. The fop.xconf configuration file was used.
 
 The PDF files have been checked with Adobe Acrobat Professional 9, using both 
 the full accessibility checker and the read-aloud feature. The checker reports 
@@ -22,7 +19,7 @@ problem yet part or all of the document cannot be read aloud.)
 
 The purpose of this infrastructure is to be able to quickly re-test the 
 accessibility processing chain when any change has been made to it. The 
-configuration files disable the compression of the PDF streams, so it is 
+configuration file disables the compression of the PDF streams, so it is 
 possible to compare a re-generated PDF with the original one by using a simple 
 diff tool. The files will not be identical because of the different creation 
 dates (and the ID key in the trailer), but apart from that there should be no 
@@ -32,21 +29,13 @@ The rationale is that using a diff tool is much quicker and less tedious than
 running Acrobat's accessibility checker and read-aloud feature every time.
 
 
-To re-generate the PDF files using the painter:
-    ../../fop -c config-painter.xconf text_1.fo pdf/text_1_painter.pdf
-    diff pdf/text_1_painter_orig.pdf pdf/text_1_painter.pdf
+To re-generate the PDF files:
+    ../../fop -c fop.xconf text_1.fo pdf/text_1.new.pdf
+    diff pdf/text_1_painter.pdf pdf/text_1.new.pdf
 Or, going through the intermediate format:
-    ../../fop -c config-painter.xconf text_1.fo -if application/pdf text_1_if.xml
-    ../../fop -c config-painter.xconf -ifin text_1_if.xml pdf/text_1_painter.pdf
-    diff pdf/text_1_painter_orig.pdf pdf/text_1_painter.pdf
-
-To re-generate the PDF files using the legacy renderer:
-    ../../fop -c config-renderer.xconf text_1.fo pdf/text_1_renderer.pdf
-    diff pdf/text_1_renderer_orig.pdf pdf/text_1_renderer.pdf
-Or, going through the intermediate format:
-    ../../fop -c config-renderer.xconf text_1.fo -at application/pdf text_1_at.xml
-    ../../fop -c config-renderer.xconf -atin text_1_at.xml pdf/text_1_renderer.pdf
-    diff pdf/text_1_renderer_orig.pdf pdf/text_1_renderer.pdf
+    ../../fop -c fop.xconf text_1.fo -if application/pdf text_1_if.xml
+    ../../fop -c fop.xconf -ifin text_1_if.xml pdf/text_1.new.pdf
+    diff pdf/text_1.pdf pdf/text_1.new.pdf
 
 
 $Id$
diff --git a/test/accessibility/pdf/background-image_jpg_repeat.pdf b/test/accessibility/pdf/background-image_jpg_repeat.pdf
new file mode 100644 (file)
index 0000000..c7c27f9
Binary files /dev/null and b/test/accessibility/pdf/background-image_jpg_repeat.pdf differ
diff --git a/test/accessibility/pdf/background-image_jpg_repeat_painter_orig.pdf b/test/accessibility/pdf/background-image_jpg_repeat_painter_orig.pdf
deleted file mode 100644 (file)
index c7c27f9..0000000
Binary files a/test/accessibility/pdf/background-image_jpg_repeat_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/background-image_jpg_repeat_renderer_orig.pdf b/test/accessibility/pdf/background-image_jpg_repeat_renderer_orig.pdf
deleted file mode 100644 (file)
index ee5d89d..0000000
Binary files a/test/accessibility/pdf/background-image_jpg_repeat_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/background-image_jpg_single.pdf b/test/accessibility/pdf/background-image_jpg_single.pdf
new file mode 100644 (file)
index 0000000..080f0b8
Binary files /dev/null and b/test/accessibility/pdf/background-image_jpg_single.pdf differ
diff --git a/test/accessibility/pdf/background-image_jpg_single_painter_orig.pdf b/test/accessibility/pdf/background-image_jpg_single_painter_orig.pdf
deleted file mode 100644 (file)
index 080f0b8..0000000
Binary files a/test/accessibility/pdf/background-image_jpg_single_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/background-image_jpg_single_renderer_orig.pdf b/test/accessibility/pdf/background-image_jpg_single_renderer_orig.pdf
deleted file mode 100644 (file)
index 4d04ca4..0000000
Binary files a/test/accessibility/pdf/background-image_jpg_single_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/background-image_png_repeat.pdf b/test/accessibility/pdf/background-image_png_repeat.pdf
new file mode 100644 (file)
index 0000000..a10e135
Binary files /dev/null and b/test/accessibility/pdf/background-image_png_repeat.pdf differ
diff --git a/test/accessibility/pdf/background-image_png_repeat_painter_orig.pdf b/test/accessibility/pdf/background-image_png_repeat_painter_orig.pdf
deleted file mode 100644 (file)
index a10e135..0000000
Binary files a/test/accessibility/pdf/background-image_png_repeat_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/background-image_png_repeat_renderer_orig.pdf b/test/accessibility/pdf/background-image_png_repeat_renderer_orig.pdf
deleted file mode 100644 (file)
index 982c50c..0000000
Binary files a/test/accessibility/pdf/background-image_png_repeat_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/background-image_png_single.pdf b/test/accessibility/pdf/background-image_png_single.pdf
new file mode 100644 (file)
index 0000000..1e9ff00
Binary files /dev/null and b/test/accessibility/pdf/background-image_png_single.pdf differ
diff --git a/test/accessibility/pdf/background-image_png_single_painter_orig.pdf b/test/accessibility/pdf/background-image_png_single_painter_orig.pdf
deleted file mode 100644 (file)
index 1e9ff00..0000000
Binary files a/test/accessibility/pdf/background-image_png_single_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/background-image_png_single_renderer_orig.pdf b/test/accessibility/pdf/background-image_png_single_renderer_orig.pdf
deleted file mode 100644 (file)
index 2c7084d..0000000
Binary files a/test/accessibility/pdf/background-image_png_single_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/background-image_svg_repeat.pdf b/test/accessibility/pdf/background-image_svg_repeat.pdf
new file mode 100644 (file)
index 0000000..c641fbb
Binary files /dev/null and b/test/accessibility/pdf/background-image_svg_repeat.pdf differ
diff --git a/test/accessibility/pdf/background-image_svg_repeat_painter_orig.pdf b/test/accessibility/pdf/background-image_svg_repeat_painter_orig.pdf
deleted file mode 100644 (file)
index c641fbb..0000000
Binary files a/test/accessibility/pdf/background-image_svg_repeat_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/background-image_svg_repeat_renderer_orig.pdf b/test/accessibility/pdf/background-image_svg_repeat_renderer_orig.pdf
deleted file mode 100644 (file)
index 65d7110..0000000
Binary files a/test/accessibility/pdf/background-image_svg_repeat_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/background-image_svg_single.pdf b/test/accessibility/pdf/background-image_svg_single.pdf
new file mode 100644 (file)
index 0000000..09a9ad8
Binary files /dev/null and b/test/accessibility/pdf/background-image_svg_single.pdf differ
diff --git a/test/accessibility/pdf/background-image_svg_single_painter_orig.pdf b/test/accessibility/pdf/background-image_svg_single_painter_orig.pdf
deleted file mode 100644 (file)
index 09a9ad8..0000000
Binary files a/test/accessibility/pdf/background-image_svg_single_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/background-image_svg_single_renderer_orig.pdf b/test/accessibility/pdf/background-image_svg_single_renderer_orig.pdf
deleted file mode 100644 (file)
index b7c5a71..0000000
Binary files a/test/accessibility/pdf/background-image_svg_single_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/complete.pdf b/test/accessibility/pdf/complete.pdf
new file mode 100644 (file)
index 0000000..caf7a41
Binary files /dev/null and b/test/accessibility/pdf/complete.pdf differ
diff --git a/test/accessibility/pdf/complete_painter_orig.pdf b/test/accessibility/pdf/complete_painter_orig.pdf
deleted file mode 100644 (file)
index caf7a41..0000000
Binary files a/test/accessibility/pdf/complete_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/complete_renderer_orig.pdf b/test/accessibility/pdf/complete_renderer_orig.pdf
deleted file mode 100644 (file)
index e7e4ed6..0000000
Binary files a/test/accessibility/pdf/complete_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/image_jpg.pdf b/test/accessibility/pdf/image_jpg.pdf
new file mode 100644 (file)
index 0000000..1336f99
Binary files /dev/null and b/test/accessibility/pdf/image_jpg.pdf differ
diff --git a/test/accessibility/pdf/image_jpg_painter_orig.pdf b/test/accessibility/pdf/image_jpg_painter_orig.pdf
deleted file mode 100644 (file)
index 1336f99..0000000
Binary files a/test/accessibility/pdf/image_jpg_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/image_jpg_renderer_orig.pdf b/test/accessibility/pdf/image_jpg_renderer_orig.pdf
deleted file mode 100644 (file)
index 62be9c1..0000000
Binary files a/test/accessibility/pdf/image_jpg_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/image_png.pdf b/test/accessibility/pdf/image_png.pdf
new file mode 100644 (file)
index 0000000..b22c157
Binary files /dev/null and b/test/accessibility/pdf/image_png.pdf differ
diff --git a/test/accessibility/pdf/image_png_painter_orig.pdf b/test/accessibility/pdf/image_png_painter_orig.pdf
deleted file mode 100644 (file)
index b22c157..0000000
Binary files a/test/accessibility/pdf/image_png_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/image_png_renderer_orig.pdf b/test/accessibility/pdf/image_png_renderer_orig.pdf
deleted file mode 100644 (file)
index efd5d2b..0000000
Binary files a/test/accessibility/pdf/image_png_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/image_svg.pdf b/test/accessibility/pdf/image_svg.pdf
new file mode 100644 (file)
index 0000000..1f5393c
Binary files /dev/null and b/test/accessibility/pdf/image_svg.pdf differ
diff --git a/test/accessibility/pdf/image_svg_painter_orig.pdf b/test/accessibility/pdf/image_svg_painter_orig.pdf
deleted file mode 100644 (file)
index 1f5393c..0000000
Binary files a/test/accessibility/pdf/image_svg_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/image_svg_renderer_orig.pdf b/test/accessibility/pdf/image_svg_renderer_orig.pdf
deleted file mode 100644 (file)
index 9c02070..0000000
Binary files a/test/accessibility/pdf/image_svg_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/image_wmf.pdf b/test/accessibility/pdf/image_wmf.pdf
new file mode 100644 (file)
index 0000000..599b4c5
Binary files /dev/null and b/test/accessibility/pdf/image_wmf.pdf differ
diff --git a/test/accessibility/pdf/image_wmf_painter_orig.pdf b/test/accessibility/pdf/image_wmf_painter_orig.pdf
deleted file mode 100644 (file)
index 599b4c5..0000000
Binary files a/test/accessibility/pdf/image_wmf_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/image_wmf_renderer_orig.pdf b/test/accessibility/pdf/image_wmf_renderer_orig.pdf
deleted file mode 100644 (file)
index c821349..0000000
Binary files a/test/accessibility/pdf/image_wmf_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/leader.pdf b/test/accessibility/pdf/leader.pdf
new file mode 100644 (file)
index 0000000..cf77a5c
Binary files /dev/null and b/test/accessibility/pdf/leader.pdf differ
diff --git a/test/accessibility/pdf/leader_painter_orig.pdf b/test/accessibility/pdf/leader_painter_orig.pdf
deleted file mode 100644 (file)
index cf77a5c..0000000
Binary files a/test/accessibility/pdf/leader_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/leader_renderer_orig.pdf b/test/accessibility/pdf/leader_renderer_orig.pdf
deleted file mode 100644 (file)
index 27c3afb..0000000
Binary files a/test/accessibility/pdf/leader_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/links.pdf b/test/accessibility/pdf/links.pdf
new file mode 100644 (file)
index 0000000..ee37c72
Binary files /dev/null and b/test/accessibility/pdf/links.pdf differ
diff --git a/test/accessibility/pdf/links_painter_orig.pdf b/test/accessibility/pdf/links_painter_orig.pdf
deleted file mode 100644 (file)
index ee37c72..0000000
Binary files a/test/accessibility/pdf/links_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/links_renderer_orig.pdf b/test/accessibility/pdf/links_renderer_orig.pdf
deleted file mode 100644 (file)
index 2bae650..0000000
Binary files a/test/accessibility/pdf/links_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/role.pdf b/test/accessibility/pdf/role.pdf
new file mode 100644 (file)
index 0000000..1eaaf1a
Binary files /dev/null and b/test/accessibility/pdf/role.pdf differ
diff --git a/test/accessibility/pdf/role_non-standard.pdf b/test/accessibility/pdf/role_non-standard.pdf
new file mode 100644 (file)
index 0000000..f8b1c9d
Binary files /dev/null and b/test/accessibility/pdf/role_non-standard.pdf differ
diff --git a/test/accessibility/pdf/role_non-standard_painter_orig.pdf b/test/accessibility/pdf/role_non-standard_painter_orig.pdf
deleted file mode 100644 (file)
index f8b1c9d..0000000
Binary files a/test/accessibility/pdf/role_non-standard_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/role_non-standard_renderer_orig.pdf b/test/accessibility/pdf/role_non-standard_renderer_orig.pdf
deleted file mode 100644 (file)
index 1700d7c..0000000
Binary files a/test/accessibility/pdf/role_non-standard_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/role_painter_orig.pdf b/test/accessibility/pdf/role_painter_orig.pdf
deleted file mode 100644 (file)
index 1eaaf1a..0000000
Binary files a/test/accessibility/pdf/role_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/role_renderer_orig.pdf b/test/accessibility/pdf/role_renderer_orig.pdf
deleted file mode 100644 (file)
index fc8e002..0000000
Binary files a/test/accessibility/pdf/role_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/text_1.pdf b/test/accessibility/pdf/text_1.pdf
new file mode 100644 (file)
index 0000000..2ad8a12
Binary files /dev/null and b/test/accessibility/pdf/text_1.pdf differ
diff --git a/test/accessibility/pdf/text_1_painter_orig.pdf b/test/accessibility/pdf/text_1_painter_orig.pdf
deleted file mode 100644 (file)
index 2ad8a12..0000000
Binary files a/test/accessibility/pdf/text_1_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/text_1_renderer_orig.pdf b/test/accessibility/pdf/text_1_renderer_orig.pdf
deleted file mode 100644 (file)
index 67d3989..0000000
Binary files a/test/accessibility/pdf/text_1_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/text_2.pdf b/test/accessibility/pdf/text_2.pdf
new file mode 100644 (file)
index 0000000..21ad6d0
Binary files /dev/null and b/test/accessibility/pdf/text_2.pdf differ
diff --git a/test/accessibility/pdf/text_2_painter_orig.pdf b/test/accessibility/pdf/text_2_painter_orig.pdf
deleted file mode 100644 (file)
index 21ad6d0..0000000
Binary files a/test/accessibility/pdf/text_2_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/text_2_renderer_orig.pdf b/test/accessibility/pdf/text_2_renderer_orig.pdf
deleted file mode 100644 (file)
index 6a5956c..0000000
Binary files a/test/accessibility/pdf/text_2_renderer_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/text_font-embedding.pdf b/test/accessibility/pdf/text_font-embedding.pdf
new file mode 100644 (file)
index 0000000..d5c61c0
Binary files /dev/null and b/test/accessibility/pdf/text_font-embedding.pdf differ
diff --git a/test/accessibility/pdf/text_font-embedding_painter_orig.pdf b/test/accessibility/pdf/text_font-embedding_painter_orig.pdf
deleted file mode 100644 (file)
index d5c61c0..0000000
Binary files a/test/accessibility/pdf/text_font-embedding_painter_orig.pdf and /dev/null differ
diff --git a/test/accessibility/pdf/text_font-embedding_renderer_orig.pdf b/test/accessibility/pdf/text_font-embedding_renderer_orig.pdf
deleted file mode 100644 (file)
index f8669cb..0000000
Binary files a/test/accessibility/pdf/text_font-embedding_renderer_orig.pdf and /dev/null differ
diff --git a/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.fo b/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.fo
new file mode 100644 (file)
index 0000000..74afd6c
--- /dev/null
@@ -0,0 +1,175 @@
+<?xml version="1.0" standalone="no"?>
+<!--
+  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$ -->
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
+  xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
+
+  <fo:layout-master-set>
+    <fo:simple-page-master master-name="page"
+      page-height="400pt" page-width="300pt" margin="20pt" margin-top="10pt">
+      <fo:region-body margin-top="20pt"/>
+      <fo:region-before extent="15pt"/>
+    </fo:simple-page-master>
+  </fo:layout-master-set>
+
+  <fo:page-sequence master-reference="page">
+    <fo:static-content flow-name="xsl-region-before">
+      <fo:block id="1" font-size="7pt" text-align-last="justify" padding-bottom="2pt" 
+        border-bottom="0.25pt solid black">This is the page header<fo:leader/>Page <fo:page-number 
+          id="2"/></fo:block>
+    </fo:static-content>
+    <fo:static-content flow-name="xsl-footnote-separator">
+      <fo:block id="3"><fo:leader leader-length="100pt" leader-pattern="rule"/></fo:block>
+    </fo:static-content>
+    <fo:flow flow-name="xsl-region-body">
+      <fo:block id="4">This is a link to the <fo:wrapper id="5" color="blue"><fo:basic-link id="6" 
+            internal-destination="second-start">next page-sequence</fo:basic-link></fo:wrapper> 
+        (which starts on page <fo:page-number-citation id="7" ref-id="second-start"/> and ends on 
+        page <fo:page-number-citation-last id="8" ref-id="second-end"/>).</fo:block>
+      <fo:block id="9" font-family="sans-serif" font-weight="bold" space-before="1em" 
+        space-after="0.2em" role="H1"><fo:block id="10">A Title Block</fo:block></fo:block>
+      <fo:block id="11">This block of text contains a footnote<fo:footnote id="12"><fo:inline id="13" 
+            baseline-shift="super" font-size="70%">1</fo:inline><fo:footnote-body id="14"><fo:block 
+              id="15">A footnote with a link to the  <fo:wrapper id="16" color="blue"><fo:basic-link 
+                  id="17" external-destination="http://xmlgraphics.apache.org/fop/">FOP 
+                  website</fo:basic-link></fo:wrapper></fo:block></fo:footnote-body></fo:footnote> 
+        call.</fo:block>
+      <fo:table id="18" space-before="1em" width="100%" table-layout="fixed">
+        <fo:table-column id="19" column-width="proportional-column-width(1)"/>
+        <fo:table-column id="20" column-width="proportional-column-width(2)"/>
+        <fo:table-header id="21">
+          <fo:table-row id="22">
+            <fo:table-cell id="23" border="2pt solid black" padding="2pt 2pt 0">
+              <fo:block id="24">Header 1.1</fo:block>
+            </fo:table-cell>
+            <fo:table-cell id="25" border="2pt solid black" padding="2pt 2pt 0">
+              <fo:block id="26">Header 1.2</fo:block>
+            </fo:table-cell>
+          </fo:table-row>
+        </fo:table-header>
+        <fo:table-footer id="27">
+          <fo:table-row id="28">
+            <fo:table-cell id="29" border="2pt solid black" padding="2pt 2pt 0">
+              <fo:block id="30">Footer 1.1</fo:block>
+            </fo:table-cell>
+            <fo:table-cell id="31" border="2pt solid black" padding="2pt 2pt 0">
+              <fo:block id="32">Footer 1.2</fo:block>
+            </fo:table-cell>
+          </fo:table-row>
+        </fo:table-footer>
+        <fo:table-body id="33">
+          <fo:table-row id="34">
+            <fo:table-cell id="35" border="1pt solid black" padding="2pt 2pt 0">
+              <fo:block id="36">Cell 1.1</fo:block>
+            </fo:table-cell>
+            <fo:table-cell id="37" border="1pt solid black" padding="2pt 2pt 0">
+              <fo:block id="38">Cell 1.2</fo:block>
+            </fo:table-cell>
+          </fo:table-row>
+          <fo:table-row id="39">
+            <fo:table-cell id="40" border="1pt solid black" padding="2pt 2pt 0">
+              <fo:block id="41">Cell 2.1</fo:block>
+            </fo:table-cell>
+            <fo:table-cell id="42" border="1pt solid black" padding="2pt 2pt 0">
+              <fo:block id="43">Cell 2.2</fo:block>
+            </fo:table-cell>
+          </fo:table-row>
+        </fo:table-body>
+      </fo:table>
+      <fo:block-container id="44" space-before="1.2em">
+        <fo:block-container id="45" absolute-position="absolute" top="6pt" right="2.5pt" 
+          inline-progression-dimension="37%" padding="3pt 1pt 2pt 3pt" border="1.5pt solid 
+          darkblue">
+          <fo:block id="46" color="darkblue" font-size="80%">This is an absolutely positioned 
+            block-container. Nullam interdum mattis ipsum sit amet molestie.</fo:block>
+        </fo:block-container>
+        <fo:block id="47" end-indent="37% + 15pt">Lorem ipsum dolor sit amet, consectetur adipiscing 
+          elit. Integer vel lacinia diam. Etiam venenatis magna vel libero imperdiet 
+          rhoncus.</fo:block>
+      </fo:block-container>
+    </fo:flow>
+  </fo:page-sequence>
+
+  <fo:page-sequence master-reference="page">
+    <fo:static-content id="48" flow-name="xsl-region-before">
+      <fo:block id="49" font-size="7pt" text-align-last="justify" padding-bottom="2pt" 
+        border-bottom="0.25pt solid black">This is the page header<fo:leader id="50"/>Page 
+        <fo:page-number id="51"/></fo:block>
+    </fo:static-content>
+    <fo:flow flow-name="xsl-region-body" text-align="justify" space-before.minimum="8pt" 
+      space-before.optimum="10pt" space-before.maximum="12pt">
+      <fo:block id="second-start">Starting a new page-sequence.</fo:block>
+      <fo:block id="52" text-align="center">The <fo:external-graphic id="53"
+          src="test/resources/images/fop-logo-color-24bit.png" 
+          inline-progression-dimension.maximum="50%" content-width="scale-to-fit" 
+          alignment-adjust="-46%" alignment-baseline="middle" fox:alt-text="FOP Logo"/> 
+        logo.</fo:block>
+      <fo:list-block id="54" provisional-distance-between-starts="15pt" 
+        provisional-label-separation="0" space-before="inherit">
+        <fo:list-item id="55">
+          <fo:list-item-label id="56" end-indent="label-end()">
+            <fo:block id="57">1.</fo:block>
+          </fo:list-item-label>
+          <fo:list-item-body id="58" start-indent="body-start()">
+            <fo:block id="59">First item of a list</fo:block>
+          </fo:list-item-body>
+        </fo:list-item>
+        <fo:list-item id="60">
+          <fo:list-item-label id="61" end-indent="label-end()">
+            <fo:block id="62">2.</fo:block>
+          </fo:list-item-label>
+          <fo:list-item-body id="63" start-indent="body-start()">
+            <fo:block id="64">Second item of a list</fo:block>
+          </fo:list-item-body>
+        </fo:list-item>
+        <fo:list-item id="65">
+          <fo:list-item-label id="66" end-indent="label-end()">
+            <fo:block id="67">3.</fo:block>
+          </fo:list-item-label>
+          <fo:list-item-body id="68" start-indent="body-start()">
+            <fo:block id="69">Third item of a list</fo:block>
+          </fo:list-item-body>
+        </fo:list-item>
+      </fo:list-block>
+      <fo:block id="70" text-align="center"><fo:instream-foreign-object id="71" 
+          inline-progression-dimension.maximum="50%" content-width="scale-to-fit">
+          <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:block id="72" space-before="inherit">A block containing an <fo:inline id="73" 
+          border="0.5pt solid black" padding="2pt" padding-bottom="0">inline</fo:inline> 
+        element.</fo:block>
+      <fo:block id="74" space-before="inherit">A block containing a fancy <fo:character id="75" 
+          border="1pt solid black" padding="0 2pt 1pt 2pt" font-family="Symbol" character="♦"/> 
+        character.</fo:block>
+      <fo:block id="76" space-before="inherit" text-align-last="justify">A leader with special 
+        content: <fo:leader id="77" leader-pattern="use-content"><fo:inline id="78"><fo:character 
+              id="79" character=" "/><fo:inline id="80" border="0.5pt solid black" 
+              padding-left="2pt" padding-right="2pt"><fo:character id="81" baseline-shift="-10%" 
+                character="•"/></fo:inline></fo:inline></fo:leader>.</fo:block>
+      <fo:block id="second-end" space-before="inherit">Ending the page-sequence.</fo:block>
+    </fo:flow>
+  </fo:page-sequence>
+
+</fo:root>
diff --git a/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java b/test/java/org/apache/fop/fo/DelegatingFOEventHandlerTestCase.java
new file mode 100644 (file)
index 0000000..faa88e3
--- /dev/null
@@ -0,0 +1,522 @@
+/*
+ * 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.fo;
+
+import static org.junit.Assert.assertArrayEquals;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory;
+import org.apache.fop.fo.flow.BasicLink;
+import org.apache.fop.fo.flow.Block;
+import org.apache.fop.fo.flow.BlockContainer;
+import org.apache.fop.fo.flow.Character;
+import org.apache.fop.fo.flow.ExternalGraphic;
+import org.apache.fop.fo.flow.Footnote;
+import org.apache.fop.fo.flow.FootnoteBody;
+import org.apache.fop.fo.flow.Inline;
+import org.apache.fop.fo.flow.InstreamForeignObject;
+import org.apache.fop.fo.flow.Leader;
+import org.apache.fop.fo.flow.ListBlock;
+import org.apache.fop.fo.flow.ListItem;
+import org.apache.fop.fo.flow.ListItemBody;
+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.Wrapper;
+import org.apache.fop.fo.flow.table.Table;
+import org.apache.fop.fo.flow.table.TableBody;
+import org.apache.fop.fo.flow.table.TableCell;
+import org.apache.fop.fo.flow.table.TableColumn;
+import org.apache.fop.fo.flow.table.TableFooter;
+import org.apache.fop.fo.flow.table.TableHeader;
+import org.apache.fop.fo.flow.table.TableRow;
+import org.apache.fop.fo.pagination.Flow;
+import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fo.pagination.StaticContent;
+
+/**
+ * Tests that {@link DelegatingFOEventHandler} does forward every event to its delegate
+ * event handler.
+ */
+public class DelegatingFOEventHandlerTestCase {
+
+    private InputStream document;
+
+    private List<String> expectedEvents;
+
+    private List<String> actualEvents;
+
+    private FODocumentParser documentParser;
+
+    private class DelegatingFOEventHandlerTester extends FOEventHandler {
+
+        DelegatingFOEventHandlerTester(FOUserAgent foUserAgent) {
+            super(foUserAgent);
+        }
+
+        private final StringBuilder eventBuilder = new StringBuilder();
+
+        @Override
+        public void startDocument() throws SAXException {
+            actualEvents.add("start root");
+        }
+
+        @Override
+        public void endDocument() throws SAXException {
+            actualEvents.add("end   root");
+        }
+
+        @Override
+        public void startPageSequence(PageSequence pageSeq) {
+            startElement(pageSeq);
+        }
+
+        @Override
+        public void endPageSequence(PageSequence pageSeq) {
+            endElement(pageSeq);
+        }
+
+        @Override
+        public void startPageNumber(PageNumber pagenum) {
+            startElement(pagenum);
+        }
+
+        @Override
+        public void endPageNumber(PageNumber pagenum) {
+            endElement(pagenum);
+        }
+
+        @Override
+        public void startPageNumberCitation(PageNumberCitation pageCite) {
+            startElement(pageCite);
+        }
+
+        @Override
+        public void endPageNumberCitation(PageNumberCitation pageCite) {
+            endElement(pageCite);
+        }
+
+        @Override
+        public void startPageNumberCitationLast(PageNumberCitationLast pageLast) {
+            startElement(pageLast);
+        }
+
+        @Override
+        public void endPageNumberCitationLast(PageNumberCitationLast pageLast) {
+            endElement(pageLast);
+        }
+
+        @Override
+        public void startFlow(Flow fl) {
+            startElement(fl);
+        }
+
+        @Override
+        public void endFlow(Flow fl) {
+            endElement(fl);
+        }
+
+        @Override
+        public void startBlock(Block bl) {
+            startElement(bl);
+        }
+
+        @Override
+        public void endBlock(Block bl) {
+            endElement(bl);
+        }
+
+        @Override
+        public void startBlockContainer(BlockContainer blc) {
+            startElement(blc);
+        }
+
+        @Override
+        public void endBlockContainer(BlockContainer blc) {
+            endElement(blc);
+        }
+
+        @Override
+        public void startInline(Inline inl) {
+            startElement(inl);
+        }
+
+        @Override
+        public void endInline(Inline inl) {
+            endElement(inl);
+        }
+
+        @Override
+        public void startTable(Table tbl) {
+            startElement(tbl);
+        }
+
+        @Override
+        public void endTable(Table tbl) {
+            endElement(tbl);
+        }
+
+        @Override
+        public void startColumn(TableColumn tc) {
+            startElement(tc);
+        }
+
+        @Override
+        public void endColumn(TableColumn tc) {
+            endElement(tc);
+        }
+
+        @Override
+        public void startHeader(TableHeader header) {
+            startElement(header);
+        }
+
+        @Override
+        public void endHeader(TableHeader header) {
+            endElement(header);
+        }
+
+        @Override
+        public void startFooter(TableFooter footer) {
+            startElement(footer);
+        }
+
+        @Override
+        public void endFooter(TableFooter footer) {
+            endElement(footer);
+        }
+
+        @Override
+        public void startBody(TableBody body) {
+            startElement(body);
+        }
+
+        @Override
+        public void endBody(TableBody body) {
+            endElement(body);
+        }
+
+        @Override
+        public void startRow(TableRow tr) {
+            startElement(tr);
+        }
+
+        @Override
+        public void endRow(TableRow tr) {
+            endElement(tr);
+        }
+
+        @Override
+        public void startCell(TableCell tc) {
+            startElement(tc);
+        }
+
+        @Override
+        public void endCell(TableCell tc) {
+            endElement(tc);
+        }
+
+        @Override
+        public void startList(ListBlock lb) {
+            startElement(lb);
+        }
+
+        @Override
+        public void endList(ListBlock lb) {
+            endElement(lb);
+        }
+
+        @Override
+        public void startListItem(ListItem li) {
+            startElement(li);
+        }
+
+        @Override
+        public void endListItem(ListItem li) {
+            endElement(li);
+        }
+
+        @Override
+        public void startListLabel(ListItemLabel listItemLabel) {
+            startElement(listItemLabel);
+        }
+
+        @Override
+        public void endListLabel(ListItemLabel listItemLabel) {
+            endElement(listItemLabel);
+        }
+
+        @Override
+        public void startListBody(ListItemBody listItemBody) {
+            startElement(listItemBody);
+        }
+
+        @Override
+        public void endListBody(ListItemBody listItemBody) {
+            endElement(listItemBody);
+        }
+
+        @Override
+        public void startStatic(StaticContent staticContent) {
+            startElement(staticContent);
+        }
+
+        @Override
+        public void endStatic(StaticContent statisContent) {
+            endElement(statisContent);
+        }
+
+        @Override
+        public void startLink(BasicLink basicLink) {
+            startElement(basicLink);
+        }
+
+        @Override
+        public void endLink(BasicLink basicLink) {
+            endElement(basicLink);
+        }
+
+        @Override
+        public void image(ExternalGraphic eg) {
+            startElement(eg);
+            endElement(eg);
+        }
+
+        @Override
+        public void startInstreamForeignObject(InstreamForeignObject ifo) {
+            startElement(ifo);
+        }
+
+        @Override
+        public void endInstreamForeignObject(InstreamForeignObject ifo) {
+            endElement(ifo);
+        }
+
+        @Override
+        public void startFootnote(Footnote footnote) {
+            startElement(footnote);
+        }
+
+        @Override
+        public void endFootnote(Footnote footnote) {
+            endElement(footnote);
+        }
+
+        @Override
+        public void startFootnoteBody(FootnoteBody body) {
+            startElement(body);
+        }
+
+        @Override
+        public void endFootnoteBody(FootnoteBody body) {
+            endElement(body);
+        }
+
+        @Override
+        public void startLeader(Leader l) {
+            startElement(l);
+        }
+
+        @Override
+        public void endLeader(Leader l) {
+            endElement(l);
+        }
+
+        @Override
+        public void startWrapper(Wrapper wrapper) {
+            startElement(wrapper);
+        }
+
+        @Override
+        public void endWrapper(Wrapper wrapper) {
+            endElement(wrapper);
+        }
+
+        @Override
+        public void character(Character c) {
+            startElement(c);
+            endElement(c);
+        }
+
+        private void startElement(FObj node) {
+            addEvent("start ", node);
+        }
+
+        private void endElement(FObj node) {
+            addEvent("end   ", node);
+        }
+
+        private void addEvent(String event, FObj node) {
+            eventBuilder.append(event);
+            eventBuilder.append(node.getLocalName());
+            addID(node);
+            actualEvents.add(eventBuilder.toString());
+            eventBuilder.setLength(0);
+        }
+
+        private void addID(FObj node) {
+            String id = node.getId();
+            if (id != null && id.length() > 0) {
+                eventBuilder.append(" id=\"");
+                eventBuilder.append(id);
+                eventBuilder.append("\"");
+            }
+        }
+    }
+
+    @Before
+    public void setUp() throws IOException {
+        setUpEvents();
+        loadDocument();
+        createDocumentParser();
+    }
+
+    private void setUpEvents() throws IOException {
+        loadDocument();
+        loadExpectedEvents();
+        actualEvents = new ArrayList<String>(expectedEvents.size());
+    }
+
+    private void loadDocument() {
+        Class<?> clazz = getClass();
+        String documentName = clazz.getSimpleName() + ".fo";
+        document = clazz.getResourceAsStream(documentName);
+    }
+
+    private void loadExpectedEvents() throws IOException {
+        expectedEvents = new ArrayList<String>();
+        InputStream xslt = getClass().getResourceAsStream("extract-events.xsl");
+        try {
+            runXSLT(xslt);
+        } finally {
+            closeStream(xslt);
+            closeStream(document);
+        }
+    }
+
+    private void runXSLT(InputStream xslt) {
+        Transformer transformer = createTransformer(xslt);
+        Source fo = new StreamSource(document);
+        Result result = createTransformOutputHandler();
+        try {
+            transformer.transform(fo, result);
+        } catch (TransformerException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private Transformer createTransformer(InputStream xslt) {
+        TransformerFactory transformerFactory = TransformerFactory.newInstance();
+        try {
+            return transformerFactory.newTransformer(new StreamSource(xslt));
+        } catch (TransformerConfigurationException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private Result createTransformOutputHandler() {
+        return new SAXResult(new DefaultHandler() {
+
+            private final StringBuilder event = new StringBuilder();
+
+            @Override
+            public void startElement(String uri, String localName, String qName,
+                    Attributes attributes) throws SAXException {
+                event.setLength(0);
+            }
+
+            @Override
+            public void characters(char[] ch, int start, int length) throws SAXException {
+                event.append(ch, start, length);
+            }
+
+            @Override
+            public void endElement(String uri, String localName, String qName) throws SAXException {
+                expectedEvents.add(event.toString());
+            }
+
+        });
+    }
+
+    private void closeStream(InputStream stream) {
+        try {
+            stream.close();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private void createDocumentParser() {
+        documentParser = FODocumentParser.newInstance(new FOEventHandlerFactory() {
+
+            public FOEventHandler newFOEventHandler(FOUserAgent foUserAgent) {
+                return new DelegatingFOEventHandler(
+                        new DelegatingFOEventHandlerTester(foUserAgent)) {
+                };
+            }
+        });
+    }
+
+    @Test
+    public void testFOEventHandler() throws Exception {
+        documentParser.parse(document);
+        assertArrayEquals(expectedEvents.toArray(), actualEvents.toArray());
+    }
+
+    @After
+    public void unloadDocument() throws IOException {
+        document.close();
+    }
+
+    /**
+     * Prints the given list to {@code System.out}, each element on a new line. For
+     * debugging purpose.
+     *
+     * @param list a list
+     */
+    public void printList(List<?> list) {
+        for (Object element : list) {
+            System.out.println(element);
+        }
+    }
+
+}
diff --git a/test/java/org/apache/fop/fo/FODocumentParser.java b/test/java/org/apache/fop/fo/FODocumentParser.java
new file mode 100644 (file)
index 0000000..4706866
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * 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.fo;
+
+import java.io.InputStream;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.Fop;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.events.EventListener;
+
+/**
+ * Parse an FO document and run the corresponding FO events through a given
+ * {@link FOEventHandler} instance. That instance is created using the helper
+ * {@link FOEventHandlerFactory}.
+ *
+ * <p>An instance of this class may not be used in multiple threads concurrently.<p>
+ *
+ * <p>An instance of this class may be used multiple times if the given
+ * {@link FOEventHandler} implementation can be used multiple times.
+ */
+public final class FODocumentParser {
+
+    private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
+
+    private static final FopFactory FOP_FACTORY = FopFactory.newInstance();
+
+    private final FOEventHandlerFactory foEventHandlerFactory;
+
+    private Fop fop;
+
+    private Transformer transformer;
+
+    private EventListener eventListener;
+
+    /**
+     * A factory to create custom instances of {@link FOEventHandler}.
+     */
+    public static interface FOEventHandlerFactory {
+
+        /**
+         * Creates a new {@code FOEventHandler} instance parameterized with the given FO user agent.
+         *
+         * @param foUserAgent an FO user agent
+         * @return a new {@code FOEventHandler} instance
+         */
+        FOEventHandler newFOEventHandler(FOUserAgent foUserAgent);
+    }
+
+    private FODocumentParser(FOEventHandlerFactory foeEventHandlerFactory) {
+        this.foEventHandlerFactory = foeEventHandlerFactory;
+    }
+
+    /**
+     * Creates and returns a new FO document parser. The given factory will be used to
+     * customize the handler that will receive FO events, using the
+     * {@link FOUserAgent#setFOEventHandlerOverride(FOEventHandler)} method.
+     *
+     * @param foEventHandlerFactory the factory to be used to create {@code
+     * FOEventHandler} instances
+     * @return a new parser
+     */
+    public static FODocumentParser newInstance(FOEventHandlerFactory foEventHandlerFactory) {
+        return new FODocumentParser(foEventHandlerFactory);
+    }
+
+    /**
+     * Sets the event listener to be used if events occurs when parsing the document.
+     *
+     * @param eventListener an event listener
+     */
+    public void setEventListener(EventListener eventListener) {
+        this.eventListener = eventListener;
+    }
+
+    /**
+     * Runs FOP on the given document.
+     *
+     * @param document XSL-FO document to parse
+     * @throws FOPException if an error occurs when initializing FOP
+     * @throws LoadingException if an error occurs when parsing the document
+     */
+    public void parse(InputStream document) throws FOPException, LoadingException {
+        FOUserAgent foUserAgent = createFOUserAgent();
+        fop = FOP_FACTORY.newFop(foUserAgent);
+        createTransformer();
+        runTransformer(document);
+    }
+
+    private FOUserAgent createFOUserAgent() {
+        FOUserAgent userAgent = FOP_FACTORY.newFOUserAgent();
+        FOEventHandler foEventHandler = foEventHandlerFactory.newFOEventHandler(userAgent);
+        userAgent.setFOEventHandlerOverride(foEventHandler);
+        if (eventListener != null) {
+            userAgent.getEventBroadcaster().addEventListener(eventListener);
+        }
+        return userAgent;
+    }
+
+    private void createTransformer() {
+        try {
+            transformer = TRANSFORMER_FACTORY.newTransformer();
+        } catch (TransformerConfigurationException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private void runTransformer(InputStream input) throws LoadingException, FOPException {
+        Source source = new StreamSource(input);
+        Result result = new SAXResult(fop.getDefaultHandler());
+        try {
+            transformer.transform(source, result);
+        } catch (TransformerException e) {
+            Throwable cause = e.getCause();
+            throw new LoadingException(cause == null ? e : cause);
+        }
+    }
+}
diff --git a/test/java/org/apache/fop/fo/FONodeMocks.java b/test/java/org/apache/fop/fo/FONodeMocks.java
new file mode 100644 (file)
index 0000000..1310d4a
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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.fo;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+
+import org.apache.xmlgraphics.image.loader.ImageException;
+import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FopFactory;
+
+/**
+ * A helper class for creating mocks of {@link FONode} and its descendants.
+ */
+public final class FONodeMocks {
+
+    private FONodeMocks() { }
+
+    /**
+     * Creates and returns a mock {@link FONode} configured with a mock
+     * {@link FOEventHandler}. The FO event handler returns a mock {@link FOUserAgent},
+     * which in turn returns a mock {@link FopFactory}, which returns a mock
+     * {@link ImageManager}.
+     *
+     * @return a mock FO node
+     */
+    public static FONode mockFONode() {
+        FONode mockFONode = mock(FONode.class);
+        mockGetFOEventHandler(mockFONode);
+        return mockFONode;
+    }
+
+    private static void mockGetFOEventHandler(FONode mockFONode) {
+        FOEventHandler mockFOEventHandler = mock(FOEventHandler.class);
+        mockGetUserAgent(mockFOEventHandler);
+        when(mockFONode.getFOEventHandler()).thenReturn(mockFOEventHandler);
+    }
+
+    private static void mockGetUserAgent(FOEventHandler mockFOEventHandler) {
+        FOUserAgent mockFOUserAgent = mock(FOUserAgent.class);
+        mockGetFactory(mockFOUserAgent);
+        when(mockFOEventHandler.getUserAgent()).thenReturn(mockFOUserAgent);
+    }
+
+    private static void mockGetFactory(FOUserAgent mockFOUserAgent) {
+        FopFactory mockFopFactory = mock(FopFactory.class);
+        mockGetImageManager(mockFopFactory);
+        when(mockFOUserAgent.getFactory()).thenReturn(mockFopFactory);
+    }
+
+    private static void mockGetImageManager(FopFactory mockFopFactory) {
+        try {
+            ImageManager mockImageManager = mock(ImageManager.class);
+            when(mockImageManager.getImageInfo(anyString(), any(ImageSessionContext.class)))
+                    .thenReturn(null);
+            when(mockFopFactory.getImageManager()).thenReturn(mockImageManager);
+        } catch (ImageException e) {
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+}
diff --git a/test/java/org/apache/fop/fo/LoadingException.java b/test/java/org/apache/fop/fo/LoadingException.java
new file mode 100644 (file)
index 0000000..a5d5092
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.fo;
+
+/**
+ * This class specifies an exceptional condition that occurred while an XSL-FO document
+ * was being parsed.
+ */
+public class LoadingException extends Exception {
+
+    private static final long serialVersionUID = 7529029475875542916L;
+
+    LoadingException(Throwable cause) {
+        super(cause);
+    }
+
+}
diff --git a/test/java/org/apache/fop/fo/extract-events.xsl b/test/java/org/apache/fop/fo/extract-events.xsl
new file mode 100644 (file)
index 0000000..8edc0ee
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:fo="http://www.w3.org/1999/XSL/Format"
+  exclude-result-prefixes="fo">
+
+  <xsl:output indent="yes" omit-xml-declaration="yes"/>
+
+  <xsl:template match="fo:root">
+    <event>
+      <xsl:text>start root</xsl:text>
+    </event>
+    <xsl:apply-templates select="fo:page-sequence"/>
+    <event>
+      <xsl:text>end   root</xsl:text>
+    </event>
+  </xsl:template>
+
+  <xsl:template match="fo:*">
+    <xsl:call-template name="process.node">
+      <xsl:with-param name="id">
+        <xsl:apply-templates select="@id"/>
+      </xsl:with-param>
+    </xsl:call-template>
+  </xsl:template>
+
+  <!-- Those elements do not retrieve the id property.
+    This will have to be fixed at some point. -->
+  <xsl:template match="fo:footnote|fo:footnote-body">
+    <xsl:call-template name="process.node"/>
+  </xsl:template>
+
+  <xsl:template name="process.node">
+    <xsl:param name="id" select="''"/>
+    <event>
+      <xsl:text>start </xsl:text>
+      <xsl:value-of select="local-name()"/>
+      <xsl:value-of select="$id"/>
+    </event>
+    <xsl:apply-templates/>
+    <event>
+      <xsl:text>end   </xsl:text>
+      <xsl:value-of select="local-name()"/>
+      <xsl:value-of select="$id"/>
+    </event>
+  </xsl:template>
+
+  <xsl:template match="@id">
+    <xsl:text> id="</xsl:text>
+    <xsl:value-of select="."/>
+    <xsl:text>"</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="text()"/>
+
+</xsl:stylesheet>
index 90d89d702e6223f0d340a78d0ccbb8c40dfcf9fb..01e20166aa5b7605fb4c78cafc45046eee15f7f7 100644 (file)
 
 package org.apache.fop.fo.flow.table;
 
+import java.io.FileInputStream;
 import java.util.Iterator;
 
 import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.FODocumentParser;
 import org.apache.fop.fo.FOEventHandler;
-import org.apache.fop.fotreetest.FOTreeUnitTester;
+import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory;
+import org.apache.fop.util.ConsoleEventListenerForTests;
 
 /**
  * Superclass for testcases related to tables, factoring the common stuff.
  */
-abstract class AbstractTableTestCase extends FOTreeUnitTester {
+abstract class AbstractTableTestCase {
 
-    private FOTreeUnitTester.FOEventHandlerFactory tableHandlerFactory;
+    private FODocumentParser documentParser;
 
     private TableHandler tableHandler;
 
-    public AbstractTableTestCase() throws Exception {
-        super();
-        tableHandlerFactory = new FOEventHandlerFactory() {
-            public FOEventHandler createFOEventHandler(FOUserAgent foUserAgent) {
+    protected void setUp(String filename) throws Exception {
+        createDocumentParser();
+        documentParser.setEventListener(new ConsoleEventListenerForTests(filename));
+        documentParser.parse(new FileInputStream("test/fotree/unittests/" + filename));
+    }
+
+    private void createDocumentParser() {
+        documentParser = FODocumentParser.newInstance(new FOEventHandlerFactory() {
+            public FOEventHandler newFOEventHandler(FOUserAgent foUserAgent) {
                 tableHandler = new TableHandler(foUserAgent);
                 return tableHandler;
             }
-        };
-    }
-
-    protected void setUp(String filename) throws Exception {
-        setUp(filename, tableHandlerFactory);
+        });
     }
 
     protected TableHandler getTableHandler() {
index 7501c1b9a893e81e1c7a620be46a0c30fff7f0d3..d046537e3ccb2dcda7138a9011e4b4ad11e41bb7 100644 (file)
@@ -25,10 +25,11 @@ import java.awt.Color;
 import java.util.Iterator;
 import java.util.List;
 
+import org.junit.Test;
+
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode.FONodeIterator;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
-import org.junit.Test;
 
 /**
  * A testcase for the resolution of collapsed borders in the FO tree, taking
@@ -107,10 +108,6 @@ public class CollapsedConditionalBorderTestCase extends AbstractTableTestCase {
 {{border8pt, Color.black}, {border6pt, Color.blue}, {border8pt, Color.black}, {border6pt, Color.blue}, {border4pt, Color.black}, {border4pt, Color.black}, {border4pt, Color.red}, {border8pt, Color.black}, {border8pt, Color.black}, {border8pt, Color.black}, {border8pt, Color.black}, {border4pt, Color.blue}, {border4pt, Color.red}, {border6pt, Color.magenta}, {border6pt, Color.magenta}, {border6pt, Color.magenta}}
     };
 
-    public CollapsedConditionalBorderTestCase() throws Exception {
-        super();
-    }
-
     private static GridUnit getGridUnit(TablePart part) {
         return (GridUnit) ((List) ((List) part.getRowGroups().get(0)).get(0)).get(0);
     }
index a3a6b9e71b57f9152edbf0e12b4ae693c6ade124..68c7d9f30c3acebeb0f2d6e84f615b80675886fd 100644 (file)
 
 package org.apache.fop.fo.flow.table;
 
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import org.apache.fop.fo.LoadingException;
 import org.apache.fop.fo.ValidationException;
 
 /**
@@ -28,16 +30,13 @@ import org.apache.fop.fo.ValidationException;
  */
 abstract class ErrorCheckTestCase extends AbstractTableTestCase {
 
-    public ErrorCheckTestCase() throws Exception {
-        super();
-    }
-
     protected void launchTest(String filename) throws Exception {
         try {
             setUp(filename);
-            fail();
-        } catch (ValidationException e) {
+            fail("Expected ValidationException to be thrown");
+        } catch (LoadingException e) {
             // TODO check location
+            assertTrue(e.getCause() instanceof ValidationException);
         }
     }
 
index 5473f098a854c14f041536cf3b8645ce28087f9a..4018f957cb561e82bb9e34e945b374e169c299ff 100644 (file)
@@ -27,10 +27,6 @@ import org.junit.Test;
  */
 public class IllegalRowSpanTestCase extends ErrorCheckTestCase {
 
-    public IllegalRowSpanTestCase() throws Exception {
-        super();
-    }
-
     @Test
     public void testBody1() throws Exception {
         launchTest("table/illegal-row-span_body_1.fo");
index 48c25faca9848dac6c07db4b33cc704e6df8aa75..1af3083ecb798157aca564dc1fd4566f03650bd8 100644 (file)
@@ -35,10 +35,6 @@ import org.junit.Test;
  */
 public class RowGroupBuilderTestCase extends AbstractTableTestCase {
 
-    public RowGroupBuilderTestCase() throws Exception {
-        super();
-    }
-
     /**
      * Checks that the given table-body(header,footer) will return row groups as expected.
      * More precisely, checks that the number of row groups corresponds to the size of the
index 0f24ae68ce1e573ac3a829bcc0c9564e643140e6..c6a93a65cc04b2171d59fe38efe7224ac2898da9 100644 (file)
@@ -23,9 +23,10 @@ import static org.junit.Assert.assertEquals;
 
 import java.util.Iterator;
 
+import org.junit.Test;
+
 import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.FObj;
-import org.junit.Test;
 
 
 public class TableColumnColumnNumberTestCase extends AbstractTableTestCase {
@@ -50,10 +51,6 @@ public class TableColumnColumnNumberTestCase extends AbstractTableTestCase {
 
     private TablePercentBaseContext percentBaseContext = new TablePercentBaseContext();
 
-    public TableColumnColumnNumberTestCase() throws Exception {
-        super();
-    }
-
     private void checkColumn(Table t, int number, boolean isImplicit, int spans, int repeated, int width) {
         TableColumn c = t.getColumn(number - 1);
         // TODO a repeated column has a correct number only for its first occurrence
index 665a88759ba704cf7732630e883b1635a4ab3a4e..7a9af100e889ec2af157695ec6e5e3a3a7804be1 100644 (file)
@@ -23,10 +23,6 @@ import org.junit.Test;
 
 public class TooManyColumnsTestCase extends ErrorCheckTestCase {
 
-    public TooManyColumnsTestCase() throws Exception {
-        super();
-    }
-
     @Test
     public void testBody1() throws Exception {
         launchTest("table/too-many-columns_body_1.fo");
diff --git a/test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java b/test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java
new file mode 100644 (file)
index 0000000..1a5e382
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.fo.flow.table;
+
+/**
+ * This class aims at easing testing, by preventing the event notification system from
+ * getting in the way just to issue an Unimplemented Feature warning.
+ */
+public final class UnimplementedWarningNeutralizer {
+
+    private UnimplementedWarningNeutralizer() { }
+
+    /**
+     * Neutralizes Unimplemented Feature events from the {@link TableAndCaption} and
+     * {@link TableCaption} classes.
+     */
+    public static void neutralizeUnimplementedWarning() {
+        TableAndCaption.notImplementedWarningGiven = true;
+        TableCaption.notImplementedWarningGiven = true;
+    }
+}
diff --git a/test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java b/test/java/org/apache/fop/fo/properties/AltTextHolderTestCase.java
new file mode 100644 (file)
index 0000000..cd5d545
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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.fo.properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.junit.Test;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FONodeMocks;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.flow.AbstractGraphics;
+import org.apache.fop.fo.flow.ExternalGraphic;
+import org.apache.fop.fo.flow.InstreamForeignObject;
+
+
+/**
+ * Tests that the fox:alt-text property is correctly set on objects that support it.
+ */
+public class AltTextHolderTestCase {
+
+    private final String altText = "alternative text";
+
+    @Test
+    public void externalGraphicHasAltText() throws FOPException {
+        testAltTextGetter(new ExternalGraphic(mockFONode()));
+    }
+
+    @Test
+    public void instreamForeignObjectHasAltText() throws FOPException {
+        testAltTextGetter(new InstreamForeignObject(mockFONode()));
+    }
+
+    private FONode mockFONode() {
+        FONode mockFONode = FONodeMocks.mockFONode();
+        FOUserAgent mockFOUserAgent = mockFONode.getFOEventHandler().getUserAgent();
+        when(mockFOUserAgent.isAccessibilityEnabled()).thenReturn(true);
+        return mockFONode;
+    }
+
+    private void testAltTextGetter(AbstractGraphics g) throws FOPException {
+        g.bind(mockPropertyList());
+        assertEquals(altText, g.getAltText());
+    }
+
+    private PropertyList mockPropertyList() throws PropertyException {
+        PropertyList mockPropertyList = PropertyListMocks.mockPropertyList();
+        Property mockAltText = mock(Property.class);
+        when(mockAltText.getString()).thenReturn(altText);
+        when(mockPropertyList.get(Constants.PR_X_ALT_TEXT)).thenReturn(mockAltText);
+        return mockPropertyList;
+    }
+
+}
diff --git a/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java b/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java
new file mode 100644 (file)
index 0000000..45f6a61
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * 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.fo.properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FONodeMocks;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * This tests that all the FONodes that implement CommonAccessibilityHolder correctly configure
+ * the CommonAccessibility property.
+ */
+public class CommonAccessibilityHolderTestCase {
+
+    private static final List<Class<? extends CommonAccessibilityHolder>> IMPLEMENTATIONS
+            = new ArrayList<Class<? extends CommonAccessibilityHolder>>();
+
+    private final String role = "role";
+
+    private final String sourceDocument = "source document";
+
+    static {
+        /* This triggers 'unimplemented feature' FO validation events so that the event system is
+         * not triggered when testing, avoiding extra convoluted dependency stubbing. */
+//        UnimplementedWarningNeutralizer.neutralizeUnimplementedWarning();
+
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.BasicLink.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.Block.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.pagination.bookmarks.Bookmark.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.pagination.bookmarks.BookmarkTitle.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.ExternalGraphic.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.Footnote.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.FootnoteBody.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.InitialPropertySet.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.Inline.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.InstreamForeignObject.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.Leader.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.ListBlock.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.ListItem.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.ListItemBody.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.ListItemLabel.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.PageNumber.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.PageNumberCitation.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.PageNumberCitationLast.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.pagination.Root.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.Table.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableAndCaption.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableBody.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableCaption.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableCell.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableFooter.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableHeader.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.flow.table.TableRow.class);
+        IMPLEMENTATIONS.add(org.apache.fop.fo.pagination.Title.class);
+    }
+
+    /**
+     * Bind should be overridden to correctly configure the CommonAccessibility property
+     * @throws Exception -
+     */
+    @Test
+    public void bindMustSetRoleAndSourceDoc() throws Exception {
+        final PropertyList mockPList = mockPropertyList();
+        final FONode parent = FONodeMocks.mockFONode();
+        for (Class<? extends CommonAccessibilityHolder> clazz : IMPLEMENTATIONS) {
+            Constructor<? extends CommonAccessibilityHolder> constructor
+                    = clazz.getConstructor(FONode.class);
+            CommonAccessibilityHolder sut = constructor.newInstance(parent);
+            ((FONode)sut).bind(mockPList);
+            String errorMessage = "Test failed for " + clazz + ": ";
+            assertEquals(errorMessage, role, sut.getCommonAccessibility().getRole());
+            assertEquals(errorMessage, sourceDocument,
+                    sut.getCommonAccessibility().getSourceDocument());
+        }
+    }
+
+    private PropertyList mockPropertyList() throws PropertyException {
+        final PropertyList mockPList = PropertyListMocks.mockPropertyList();
+        PropertyListMocks.mockTableProperties(mockPList);
+        PropertyListMocks.mockCommonBorderPaddingBackgroundProps(mockPList);
+        mockRoleProperty(mockPList);
+        mockSourceDocProperty(mockPList);
+        return mockPList;
+    }
+
+    private void mockRoleProperty(PropertyList mockPList) throws PropertyException {
+        final Property mockRoleProperty = mock(Property.class);
+        when(mockRoleProperty.getString()).thenReturn(role);
+        when(mockPList.get(Constants.PR_ROLE)).thenReturn(mockRoleProperty);
+    }
+
+    private void mockSourceDocProperty(PropertyList mockPList) throws PropertyException {
+        final Property mockSourceDocProperty = mock(Property.class);
+        when(mockSourceDocProperty.getString()).thenReturn(sourceDocument);
+        when(mockPList.get(Constants.PR_SOURCE_DOCUMENT)).thenReturn(mockSourceDocProperty);
+    }
+
+}
diff --git a/test/java/org/apache/fop/fo/properties/PropertyListMocks.java b/test/java/org/apache/fop/fo/properties/PropertyListMocks.java
new file mode 100644 (file)
index 0000000..380f6e5
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * 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.fo.properties;
+
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * A helper class for mocking a property list.
+ */
+public final class PropertyListMocks {
+
+    private PropertyListMocks() { }
+
+    /**
+     * Creates and returns a mock property list returning a generic default for the
+     * {@link PropertyList#get(int)} method.
+     *
+     * @return a mock property list
+     */
+    public static PropertyList mockPropertyList() {
+        try {
+            final PropertyList mockPList = mock(PropertyList.class);
+            final Property mockGenericProperty = PropertyMocks.mockGenericProperty();
+            when(mockPList.get(anyInt())).thenReturn(mockGenericProperty);
+            return mockPList;
+        } catch (PropertyException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Overrides with working mock properties the values returned by
+     * {@link PropertyList#get(int)} for {@link Constants#PR_COLUMN_NUMBER},
+     * {@link Constants#PR_NUMBER_COLUMNS_SPANNED},
+     * {@link Constants#PR_NUMBER_ROWS_SPANNED} and {@link Constants#PR_BORDER_COLLAPSE}.
+     *
+     * @param mockPList a mock property list
+     */
+    public static void mockTableProperties(PropertyList mockPList) {
+        try {
+            final Property mockNumberProperty = PropertyMocks.mockNumberProperty();
+            when(mockPList.get(Constants.PR_COLUMN_NUMBER)).thenReturn(mockNumberProperty);
+            when(mockPList.get(Constants.PR_NUMBER_COLUMNS_SPANNED)).thenReturn(mockNumberProperty);
+            when(mockPList.get(Constants.PR_NUMBER_ROWS_SPANNED)).thenReturn(mockNumberProperty);
+
+            final Property borderCollapseProperty = mock(Property.class);
+            when(borderCollapseProperty.getEnum()).thenReturn(Constants.EN_SEPARATE);
+            when(mockPList.get(Constants.PR_BORDER_COLLAPSE)).thenReturn(borderCollapseProperty);
+        } catch (PropertyException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Overrides with a working mock property the value returned by
+     * {@link PropertyList#getBorderPaddingBackgroundProps()}.
+     *
+     * @param mockPList a mock property list
+     */
+    public static void mockCommonBorderPaddingBackgroundProps(PropertyList mockPList) {
+        try {
+            final CommonBorderPaddingBackground mockCommonBorderPaddingBackground
+                    = mock(CommonBorderPaddingBackground.class);
+            when(mockPList.getBorderPaddingBackgroundProps())
+                    .thenReturn(mockCommonBorderPaddingBackground);
+        } catch (PropertyException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+}
diff --git a/test/java/org/apache/fop/fo/properties/PropertyMocks.java b/test/java/org/apache/fop/fo/properties/PropertyMocks.java
new file mode 100644 (file)
index 0000000..40c9232
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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.fo.properties;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.datatypes.PercentBaseContext;
+import org.apache.fop.fo.Constants;
+
+/**
+ * Helper class to create mocks of various kinds of properties.
+ */
+public final class PropertyMocks {
+
+    private PropertyMocks() { }
+
+    /**
+     * Creates and returns a generic mock property returning decent defaults for the
+     * {@link Property#getString()}, {@link Property#getEnum()} and
+     * {@link Property#getLengthRange()} methods.
+     *
+     * @return a mock all-purpose property
+     */
+    public static Property mockGenericProperty() {
+        final Property mockGenericProperty = mock(Property.class);
+        when(mockGenericProperty.getString()).thenReturn("A non-empty string");
+        when(mockGenericProperty.getEnum()).thenReturn(Constants.EN_SPACE);
+        LengthRangeProperty lengthRangeProperty = mockLengthRangeProperty();
+        when(mockGenericProperty.getLengthRange()).thenReturn(lengthRangeProperty);
+        return mockGenericProperty;
+    }
+
+    private static LengthRangeProperty mockLengthRangeProperty() {
+        final LengthRangeProperty mockLengthRangeProperty = mock(LengthRangeProperty.class);
+        final Property optimum = mockOptimumProperty();
+        when(mockLengthRangeProperty.getOptimum(any(PercentBaseContext.class)))
+                .thenReturn(optimum);
+        return mockLengthRangeProperty;
+    }
+
+    /**
+     * Creates and returns a mock property returning a decent default for the
+     * {@link Property#getNumeric()} method.
+     *
+     * @return a mock number property
+     */
+    public static Property mockNumberProperty() {
+        final Property mockNumberProperty = mock(Property.class);
+        final Numeric mockNumeric = mock(Numeric.class);
+        when(mockNumberProperty.getNumeric()).thenReturn(mockNumeric);
+        return mockNumberProperty;
+    }
+
+    private static Property mockOptimumProperty() {
+        final Property optimum = mock(Property.class);
+        when(optimum.isAuto()).thenReturn(true);
+        return optimum;
+    }
+
+}
index 6e6f62b929fae88b579a3338085863a44459a2b0..b435769015565e6da10c7ab0688f8e2db2f842ef 100644 (file)
 
 package org.apache.fop.fotreetest;
 
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+import org.apache.fop.fo.DelegatingFOEventHandlerTestCase;
 import org.apache.fop.fo.flow.table.CollapsedConditionalBorderTestCase;
 import org.apache.fop.fo.flow.table.IllegalRowSpanTestCase;
 import org.apache.fop.fo.flow.table.RowGroupBuilderTestCase;
 import org.apache.fop.fo.flow.table.TableColumnColumnNumberTestCase;
 import org.apache.fop.fo.flow.table.TooManyColumnsTestCase;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
 
 /**
  * JUnit test suit for running layout engine test under JUnit control.
  */
 @RunWith(Suite.class)
-@Suite.SuiteClasses({ TooManyColumnsTestCase.class, IllegalRowSpanTestCase.class,
-        RowGroupBuilderTestCase.class, TableColumnColumnNumberTestCase.class,
-        CollapsedConditionalBorderTestCase.class, FOTreeTester.class })
+@Suite.SuiteClasses({
+    TooManyColumnsTestCase.class,
+    IllegalRowSpanTestCase.class,
+    RowGroupBuilderTestCase.class,
+    TableColumnColumnNumberTestCase.class,
+    CollapsedConditionalBorderTestCase.class,
+    FOTreeTester.class,
+    org.apache.fop.fo.properties.CommonAccessibilityHolderTestCase.class,
+    DelegatingFOEventHandlerTestCase.class
+})
 public final class FOTreeTestSuite {
 }
diff --git a/test/java/org/apache/fop/fotreetest/FOTreeUnitTester.java b/test/java/org/apache/fop/fotreetest/FOTreeUnitTester.java
deleted file mode 100644 (file)
index 0906c26..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.fotreetest;
-
-import java.io.File;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.Fop;
-import org.apache.fop.apps.FopFactory;
-import org.apache.fop.fo.FOEventHandler;
-import org.apache.fop.util.ConsoleEventListenerForTests;
-import org.xml.sax.XMLReader;
-
-
-/**
- * Base class for unit-testing the FO tree building code. It performs the necessary setup
- * to parse an FO file and register a proper {@link FOEventHandler}. That handler will be
- * the entry point to test classes from the FObj hierarchy.
- */
-public abstract class FOTreeUnitTester {
-
-    private XMLReader foReader;
-
-    private FopFactory fopFactory;
-
-    /**
-     * Should be implemented by children testcases for properly setting up the custom
-     * FOEventHandler needed to test FObj classes.
-     */
-    public abstract static class FOEventHandlerFactory {
-
-        /**
-         * This method is called by FOTreeUnitTester when creating a {@link Fop} instance.
-         * That lets pass to the custom FOEventHandler the proper user agent that will be
-         * used by this instance.
-         *
-         * @param foUserAgent the user agent needed by the Fop instance that will be used
-         * to create the FO tree
-         * @return the appropriate FOEventHandler for performing the tests
-         */
-        public abstract FOEventHandler createFOEventHandler(FOUserAgent foUserAgent);
-    }
-
-    public FOTreeUnitTester() throws Exception {
-        // Stuff that needs to be set up only once and will be re-used for each test
-        SAXParserFactory spf = SAXParserFactory.newInstance();
-        spf.setNamespaceAware(true);
-        spf.setValidating(false);
-        SAXParser parser;
-        parser = spf.newSAXParser();
-        foReader = parser.getXMLReader();
-        fopFactory = FopFactory.newInstance();
-    }
-
-    /**
-     * Launches FOP on the given FO file.
-     *
-     * @param filename path to the test FO file
-     * @param factory to create the appropriate FOEventHandler for performing tests
-     */
-    public void setUp(String filename, FOEventHandlerFactory factory) throws Exception {
-        FOUserAgent ua = fopFactory.newFOUserAgent();
-        ua.setFOEventHandlerOverride(factory.createFOEventHandler(ua));
-        ua.getEventBroadcaster().addEventListener(
-                new ConsoleEventListenerForTests(filename));
-
-        Fop fop = fopFactory.newFop(ua);
-
-        foReader.setContentHandler(fop.getDefaultHandler());
-        foReader.setDTDHandler(fop.getDefaultHandler());
-        foReader.setErrorHandler(fop.getDefaultHandler());
-        foReader.setEntityResolver(fop.getDefaultHandler());
-
-        foReader.parse(new File("test/fotree/unittests/" + filename).toURI().toURL().toExternalForm());
-    }
-}