]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Merged in Temp_ImproveAccessibility
authorPeter Hancock <phancock@apache.org>
Fri, 10 Feb 2012 16:51:08 +0000 (16:51 +0000)
committerPeter Hancock <phancock@apache.org>
Fri, 10 Feb 2012 16:51:08 +0000 (16:51 +0000)
revs 118723411882051205935123671812383131240963

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

22 files changed:
1  2 
build.xml
findbugs-exclude.xml
src/java/org/apache/fop/fo/FOElementMapping.java
src/java/org/apache/fop/fo/FOTreeBuilder.java
src/java/org/apache/fop/pdf/PDFDocument.java
src/java/org/apache/fop/pdf/PDFStructElem.java
src/java/org/apache/fop/render/AbstractRenderer.java
src/java/org/apache/fop/render/Renderer.java
src/java/org/apache/fop/render/intermediate/IFRenderer.java
src/java/org/apache/fop/render/rtf/RTFHandler.java
src/java/org/apache/fop/render/xml/XMLRenderer.java
status.xml
test/java/org/apache/fop/StandardTestSuite.java
test/java/org/apache/fop/fo/flow/table/AbstractTableTest.java
test/java/org/apache/fop/fo/flow/table/CollapsedConditionalBorderTestCase.java
test/java/org/apache/fop/fo/flow/table/ErrorCheckTest.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/fotreetest/FOTreeTestSuite.java
test/java/org/apache/fop/intermediate/IFParserTestCase.java

diff --cc build.xml
Simple merge
Simple merge
index 4fb8cbcd50877ac3248f2fce9421ad159a9d3efc,d2b3be6aae04119c474bf3b428c705a742d010d7..160d553846fd140326c60e3f29fa1b52c235e98a
@@@ -154,6 -141,71 +141,71 @@@ public class PDFStructElem extends PDFD
       * @return the value of the Lang entry (<code>null</code> if no language was specified)
       */
      public String getLanguage() {
-         return (String)get("Lang");
+         return (String) get("Lang");
+     }
+     @Override
 -    protected void writeDictionary(OutputStream out, Writer writer) throws IOException {
++    protected void writeDictionary(OutputStream out, StringBuilder textBuffer) throws IOException {
+         attachKids();
 -        super.writeDictionary(out, writer);
++        super.writeDictionary(out, textBuffer);
      }
 -        public void outputInline(OutputStream out, Writer writer) throws IOException {
+     /**
+      * Attaches all valid kids to the kids array.
+      *
+      * @return true iff 1+ kids were added to the kids array
+      */
+     protected boolean attachKids() {
+         List<PDFObject> validKids = new ArrayList<PDFObject>();
+         if (kids != null) {
+             for (PDFObject kid : kids) {
+                 if (kid instanceof Placeholder)  {
+                     if (((Placeholder) kid).attachKids()) {
+                         validKids.add(kid);
+                     }
+                 } else {
+                     validKids.add(kid);
+                 }
+             }
+         }
+         boolean kidsAttached = !validKids.isEmpty();
+         if (kidsAttached) {
+             PDFArray array = new PDFArray();
+             for (PDFObject ob : validKids) {
+                 array.add(ob);
+             }
+             put("K", array);
+         }
+         return kidsAttached;
+     }
+     /**
+      * Class representing a placeholder for a PDF Structure Element.
+      */
+     public static class Placeholder extends PDFStructElem {
+         @Override
 -                        writer.write(' ');
++        public void outputInline(OutputStream out, StringBuilder textBuffer) throws IOException {
+             if (kids != null) {
+                 assert kids.size() > 0;
+                 for (int i = 0; i < kids.size(); i++) {
+                     if (i > 0) {
 -                    formatObject(obj, out, writer);
++                        textBuffer.append(' ');
+                     }
+                     Object obj = kids.get(i);
++                    formatObject(obj, out, textBuffer);
+                 }
+             }
+         }
+         /**
+          * Constructor
+          * @param parent -
+          * @param name -
+          */
+         public Placeholder(PDFObject parent, String name) {
+             super(parent, new PDFName(name));
+         }
+     }
  }
index d2cd55abe99705cc4e27a17f45fcbde6880ab201,5029346c07442f14676866f69c1fd744b129777b..504133c095b0a4dc078c0406da94c12ce0ae01a8
@@@ -110,14 -105,20 +105,12 @@@ public class XMLRenderer extends Abstra
      /** If not null, the XMLRenderer will mimic another renderer by using its font setup. */
      protected Renderer mimic;
  
-     private int pageSequenceIndex;
      /**
 -     * Creates a new XML renderer.
 +     * @param userAgent the user agent that contains configuration details. This cannot be null.
       */
 -    public XMLRenderer() {
 +    public XMLRenderer(FOUserAgent userAgent) {
 +        super(userAgent);
          context = new RendererContext(this, XML_MIME_TYPE);
 -    }
 -
 -    /**
 -     * {@inheritDoc}
 -     */
 -    @Override
 -    public void setUserAgent(FOUserAgent agent) {
 -        super.setUserAgent(agent);
 -
          XMLHandler xmlHandler = new XMLXMLHandler();
          userAgent.getXMLHandlerRegistry().addXMLHandler(xmlHandler);
          Boolean b = (Boolean)userAgent.getRendererOptions().get("compact-format");
diff --cc status.xml
index b395abe1e326556da4c5c52b3b484774f12082b6,118887d69b8ce2d32d5394e026b56c259ac6dd58..a5d800c61c2e2b0f847e5fe39e9d6386f47bacdd
        documents. Example: the fix of marks layering will be such a case when it's done.
      -->
      <release version="FOP Trunk" date="TBD">
++      <action context="Code" dev="PH" type="add" due-to="VH and PH">
++        Improvements of the Accessibility feature
++      </action>
 +      <action context="Code" dev="CB" type="add" fixes-bug="52416" due-to="Luis Bernardo">
 +        Suppress unnecessary "font not found warnings" when generating AFP with raster fonts 
 +      </action>
 +      <action context="Code" dev="CB" type="add" fixes-bug="51209" due-to="Luis Bernardo">
 +        SVG text in AFP creates miscoded GOCA text
 +      </action>
 +      <action context="Code" dev="CB" type="add" fixes-bug="50391" due-to="Peter Hancock">
 +        Add support for different flow-name of fo:region-body in FOP
 +      </action>
 +      <action context="Code" dev="CB" type="add" fixes-bug="51664" due-to="Mehdi Houshmand">
 +        Tagged PDF performance improvement plus tests
 +      </action>       
 +      <action context="Code" dev="MH" type="add" fixes-bug="52197">
 +        Improved AdobeStandardEncoding support in AFM files for type1 fonts
 +      </action>
 +      <action context="Code" dev="VH" type="add" fixes-bug="52151" due-to="Mehdi Houshmand">
 +        Added ant script to get JaCoCo code coverage.
 +      </action>
 +      <action context="Code" dev="VH" type="add" fixes-bug="52136" due-to="Mehdi Houshmand">
 +        Added to build file JUnit target that uses a regex to run all of the test cases. This 
 +        reduces the risk that some of them are omitted when building FOP.
 +      </action>
 +      <action context="Code" dev="PH" type="add" fixes-bug="52089" due-to="JM, Mehdi Houshmand">
 +        Allow JPEG images to be embedded in an AFP document as is, without being decoded and 
 +        encoded.
 +      </action>
        <action context="Code" dev="PH" type="add" fixes-bug="52010" due-to="Mehdi Houshmand">
          Simplification of the build: Reduced code duplication and layout engine tests.
        </action>
index bb59c8605a21cf0d7e9d563cfd045b91f3f32e2f,840b04917c7a5f5a89ad0743f50f75d9344094a9..808542306d9988a59554411ab190c18e32f6ea02
@@@ -51,32 -47,29 +51,33 @@@ import org.apache.fop.pdf.PDFLibraryTes
   */
  @RunWith(Suite.class)
  @SuiteClasses({
 -    BasicDriverTestSuite.class,
 -    UtilityCodeTestSuite.class,
 -    PDFAConformanceTestCase.class,
 -    PDFEncodingTestCase.class,
 -    PDFCMapTestCase.class,
 -    PDFsRGBSettingsTestCase.class,
 -    DejaVuLGCSerifTest.class,
 -    RichTextFormatTestSuite.class,
 -    ImageLoaderTestCase.class,
 -    ImagePreloaderTestCase.class,
 -    IFMimickingTestCase.class,
 -    PageBoundariesTest.class,
 -    PageScaleTest.class,
 -    org.apache.fop.afp.AFPTestSuite.class,
 -    GlyfTableTestCase.class,
 -    ViewportTestSuite.class,
 -    RenderPDFTestSuite.class,
 -    MODCAParserTestCase.class,
 -    CharactersetEncoderTest.class,
 -    org.apache.fop.render.afp.AFPTestSuite.class,
 -    PSTestSuite.class,
 -    MinOptMaxTest.class,
 -    org.apache.fop.render.intermediate.IFStructureTreeBuilderTestCase.class
 +        BasicDriverTestSuite.class,
 +        UtilityCodeTestSuite.class,
 +        PDFAConformanceTestCase.class,
 +        PDFEncodingTestCase.class,
 +        PDFCMapTestCase.class,
 +        PDFsRGBSettingsTestCase.class,
 +        DejaVuLGCSerifTestCase.class,
 +        RichTextFormatTestSuite.class,
 +        ImageLoaderTestCase.class,
 +        ImagePreloaderTestCase.class,
 +        IFMimickingTestCase.class,
 +        PageBoundariesTestCase.class,
 +        PageScaleTestCase.class,
 +        org.apache.fop.afp.AFPTestSuite.class,
 +        GlyfTableTestCase.class,
 +        ViewportTestSuite.class,
 +        RenderPDFTestSuite.class,
 +        MODCAParserTestCase.class,
 +        CharactersetEncoderTestCase.class,
 +        org.apache.fop.render.afp.AFPTestSuite.class,
 +        PDFLibraryTestSuite.class,
 +        PSTestSuite.class,
 +        MinOptMaxTestCase.class,
 +        AdobeStandardEncodingTestCase.class,
 +        AFMParserTestCase.class,
-         FontEventProcessingTestCase.class
++        FontEventProcessingTestCase.class,
++        org.apache.fop.render.intermediate.IFStructureTreeBuilderTestCase.class
  })
  public class StandardTestSuite {
  }
index 69bbc8d8c6389f9eb6d426ed25c5572ba99a6dd1,0000000000000000000000000000000000000000..fb6ec6a250f3cbc1e48c97b76c892a6638b49966
mode 100644,000000..100644
--- /dev/null
@@@ -1,58 -1,0 +1,62 @@@
- import org.apache.fop.fotreetest.FOTreeUnitTester;
 +/*
 + * 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;
 +
++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;
- abstract class AbstractTableTest extends FOTreeUnitTester {
++import org.apache.fop.fo.FODocumentParser.FOEventHandlerFactory;
++import org.apache.fop.util.ConsoleEventListenerForTests;
 +
 +/**
 + * Superclass for testcases related to tables, factoring the common stuff.
 + */
-     private FOTreeUnitTester.FOEventHandlerFactory tableHandlerFactory;
++abstract class AbstractTableTest {
 +
-     public AbstractTableTest() throws Exception {
-         super();
-         tableHandlerFactory = new FOEventHandlerFactory() {
-             public FOEventHandler createFOEventHandler(FOUserAgent foUserAgent) {
++    private FODocumentParser documentParser;
 +
 +    private TableHandler tableHandler;
 +
-         };
-     }
-     protected void setUp(String filename) throws Exception {
-         setUp(filename, tableHandlerFactory);
++    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 TableHandler getTableHandler() {
 +        return tableHandler;
 +    }
 +
 +    protected Iterator getTableIterator() {
 +        return tableHandler.getTables().iterator();
 +    }
 +}
index 724259a753a6411ccf82b2fcbcd1f71bc93717d6,0000000000000000000000000000000000000000..b30c64c078087b0a374e0d1e1fd85974a370b4cb
mode 100644,000000..100644
--- /dev/null
@@@ -1,44 -1,0 +1,43 @@@
-     public ErrorCheckTest() throws Exception {
-         super();
-     }
 +/*
 + * 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;
 +
++import static org.junit.Assert.assertTrue;
 +import static org.junit.Assert.fail;
 +
++import org.apache.fop.fo.LoadingException;
 +import org.apache.fop.fo.ValidationException;
 +
 +/**
 + * Abstract class for testing erroneous files, checking that a ValidationException is thrown.
 + */
 +abstract class ErrorCheckTest extends AbstractTableTest {
 +
-             fail();
-         } catch (ValidationException e) {
 +    protected void launchTest(String filename) throws Exception {
 +        try {
 +            setUp(filename);
++            fail("Expected ValidationException to be thrown");
++        } catch (LoadingException e) {
 +            // TODO check location
++            assertTrue(e.getCause() instanceof ValidationException);
 +        }
 +    }
 +
 +}
index 024e15c2e6e365d5518e719f4c5e37fb7f94db66,4018f957cb561e82bb9e34e945b374e169c299ff..b2e7a2c9d0f91fc9aba7e4d69cccfb70436e0ddb
@@@ -25,12 -25,8 +25,8 @@@ import org.junit.Test
   * Testcase checking that cells spanning further than their parent element aren't
   * accepted.
   */
 -public class IllegalRowSpanTestCase extends ErrorCheckTestCase {
 +public class IllegalRowSpanTestCase extends ErrorCheckTest {
  
-     public IllegalRowSpanTestCase() throws Exception {
-         super();
-     }
      @Test
      public void testBody1() throws Exception {
          launchTest("table/illegal-row-span_body_1.fo");
index 3df0338abdd6df2ed3702eefc5cbda66cf8b8e34,1af3083ecb798157aca564dc1fd4566f03650bd8..361517a66cb4a4f85a7d1c24960837b3744673bf
@@@ -33,12 -33,8 +33,8 @@@ import org.junit.Test
   * Tests that RowGroupBuilder returns, for each part of a table, the expected number of
   * row-groups with the expected number or rows in each.
   */
 -public class RowGroupBuilderTestCase extends AbstractTableTestCase {
 +public class RowGroupBuilderTestCase extends AbstractTableTest {
  
-     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 4f7d9e0548d5fc060e25a70e57e7a36be0f20156,c6a93a65cc04b2171d59fe38efe7224ac2898da9..a21806559f9bd843989e1d6a8a36b197527b56dc
@@@ -23,12 -23,13 +23,13 @@@ import static org.junit.Assert.assertEq
  
  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 {
 +public class TableColumnColumnNumberTestCase extends AbstractTableTest {
  
      /**
       * A percentBaseContext that mimics the behaviour of TableLM for computing the widths
index 284fd1d2f6d17eddf362091c2690e6a2294ce27c,7a9af100e889ec2af157695ec6e5e3a3a7804be1..76a5d196dbed7cf78d6694b4e726b25f70d5ffa6
@@@ -21,12 -21,8 +21,8 @@@ package org.apache.fop.fo.flow.table
  
  import org.junit.Test;
  
 -public class TooManyColumnsTestCase extends ErrorCheckTestCase {
 +public class TooManyColumnsTestCase extends ErrorCheckTest {
  
-     public TooManyColumnsTestCase() throws Exception {
-         super();
-     }
      @Test
      public void testBody1() throws Exception {
          launchTest("table/too-many-columns_body_1.fo");
index 4a77ca000f16c9dcc0a45a1562d74e6d0ec5a79b,b435769015565e6da10c7ab0688f8e2db2f842ef..b74afefc507caae9d2113b164d3e58e186943487
@@@ -27,9 -34,14 +27,11 @@@ import org.junit.runners.Suite
   */
  @RunWith(Suite.class)
  @Suite.SuiteClasses({
 -    TooManyColumnsTestCase.class,
 -    IllegalRowSpanTestCase.class,
 -    RowGroupBuilderTestCase.class,
 -    TableColumnColumnNumberTestCase.class,
 -    CollapsedConditionalBorderTestCase.class,
 -    FOTreeTester.class,
 -    org.apache.fop.fo.properties.CommonAccessibilityHolderTestCase.class,
 -    DelegatingFOEventHandlerTestCase.class
 +        org.apache.fop.fo.flow.table.AllTests.class,
 +        org.apache.fop.fo.pagination.AllTests.class,
-         FOTreeTestCase.class })
++        org.apache.fop.fotreetest.FOTreeTestCase.class,
++        org.apache.fop.fo.properties.CommonAccessibilityHolderTestCase.class,
++        org.apache.fop.fo.DelegatingFOEventHandlerTestCase.class
+ })
  public final class FOTreeTestSuite {
  }
index c37897dc1c103ea519bec82c1d91040db72ded26,6ac20c5565e24e8fdfa07375bbc37ed3d2e50630..7d4fb7ad876c72d673553d2b4d462f9c20a55f44
@@@ -46,8 -46,11 +46,11 @@@ import org.apache.fop.render.intermedia
   * Tests the intermediate format parser.
   */
  @RunWith(Parameterized.class)
 -public class IFParserTestCase extends AbstractIFTestCase {
 +public class IFParserTestCase extends AbstractIFTest {
  
+     /** Set this to true to get the correspondence between test number and test file. */
+     private static final boolean DEBUG = false;
      /**
       * Gets the parameters for this test
       *