From d9d2ec28c23c9dc69dd87c1060ea506ad08beca8 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Mon, 8 Oct 2012 17:47:48 +0000 Subject: Bugzilla #53980: PDF accessibility: Store language information coming from fo:block or fo:character in the structure tree. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1395692 13f79535-47bb-0310-9956-ffa450edef68 --- .../fo/FO2StructureTreeConverterTestCase.java | 5 ++ .../fop/accessibility/fo/fo2StructureTree.xsl | 13 ++++- .../org/apache/fop/accessibility/fo/language.fo | 30 +++++++++++ .../fo/properties/CommonHyphenationTestCase.java | 58 ++++++++++++++++++++++ 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 test/java/org/apache/fop/accessibility/fo/language.fo create mode 100644 test/java/org/apache/fop/fo/properties/CommonHyphenationTestCase.java (limited to 'test/java') diff --git a/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java b/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java index 87b970576..a86b5b2b2 100644 --- a/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java +++ b/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java @@ -96,6 +96,11 @@ public class FO2StructureTreeConverterTestCase { testConverter("table-header_scope.fo"); } + @Test + public void testLanguage() throws Exception { + testConverter("language.fo"); + } + private static InputStream getResource(String name) { return FO2StructureTreeConverterTestCase.class.getResourceAsStream(name); } diff --git a/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl b/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl index 90d74a7c4..a9de38db1 100644 --- a/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl +++ b/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl @@ -150,11 +150,22 @@ - + + + + + + - + + + + + diff --git a/test/java/org/apache/fop/accessibility/fo/language.fo b/test/java/org/apache/fop/accessibility/fo/language.fo new file mode 100644 index 000000000..8dfb2694a --- /dev/null +++ b/test/java/org/apache/fop/accessibility/fo/language.fo @@ -0,0 +1,30 @@ + + + + + + + + + + This block of text is written in the default language of the page sequence, which is + British English. + Ce text est + écrit dans une autre langue, en l’occurence le français de France. + However, this block of French text encloses a block of American + English. + The structure element corresponding to this block should have no language + set as it is the same as on the parent block. + Maintenant on revient au français. + And now we are back to the English language, with a + rench + character. + + + diff --git a/test/java/org/apache/fop/fo/properties/CommonHyphenationTestCase.java b/test/java/org/apache/fop/fo/properties/CommonHyphenationTestCase.java new file mode 100644 index 000000000..029146413 --- /dev/null +++ b/test/java/org/apache/fop/fo/properties/CommonHyphenationTestCase.java @@ -0,0 +1,58 @@ +/* + * 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 java.util.Locale; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class CommonHyphenationTestCase { + + private final String lang = "en"; + + @Test + public void testToLocaleNull() { + Locale locale = CommonHyphenation.toLocale(null, null); + assertNull(locale); + locale = CommonHyphenation.toLocale("none", null); + assertNull(locale); + locale = CommonHyphenation.toLocale("NoNe", "US"); + assertNull(locale); + } + + @Test + public void testToLocaleWithJustLanguage() { + Locale locale = new Locale(lang); + assertEquals(locale, CommonHyphenation.toLocale(lang, null)); + assertEquals(locale, CommonHyphenation.toLocale(lang, "none")); + assertEquals(locale, CommonHyphenation.toLocale(lang, "NONE")); + } + + @Test + public void testToLocaleWithLanguageAndCountry() { + Locale locale = new Locale(lang, "US"); + assertEquals(locale, CommonHyphenation.toLocale(lang, "US")); + assertEquals(locale, CommonHyphenation.toLocale(lang, "us")); + } + +} -- cgit v1.2.3