Преглед изворни кода

Added very basic parsing for the xml:lang shorthand.

No validation of the specified value, but the language and country
properties now do take the shorthand into account to determine their
value.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@617976 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_95beta
Andreas L. Delmelle пре 16 година
родитељ
комит
bc75831436

+ 4
- 4
src/documentation/content/xdocs/compliance.ihtml Прегледај датотеку

@@ -1223,7 +1223,7 @@
yes </td>
<td class="yes">
yes </td>
<td align="center">&nbsp; </td>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td>
@@ -5612,9 +5612,9 @@
<td class="no"> no </td>
<td class="no">
no </td>
<td class="no">
no </td>
<td align="center">&nbsp; </td>
<td class="yes">
yes </td>
<td align="center">[dev] Very basic parsing; no validation of the specified value.</td>
</tr>
</table>
<h1><a name="fo-function-core-library-section">XSL-FO Core Function Library Support Table</a> (<a href="http://www.w3.org/TR/2001/REC-xsl-20011015/slice5.html#section-N8434-Core-Function-Library">&sect;5.10</a>)</h1>

+ 5
- 1
src/java/org/apache/fop/fo/FOPropertyMapping.java Прегледај датотеку

@@ -66,6 +66,7 @@ import org.apache.fop.fo.properties.TextDecorationProperty;
import org.apache.fop.fo.properties.ToBeImplementedProperty;
import org.apache.fop.fo.properties.VerticalAlignShorthandParser;
import org.apache.fop.fo.properties.WhiteSpaceShorthandParser;
import org.apache.fop.fo.properties.XMLLangShorthandParser;

/**
* This class creates and returns an array of Property.Maker instances
@@ -1060,12 +1061,14 @@ public final class FOPropertyMapping implements Constants {
m = new StringProperty.Maker(PR_COUNTRY);
m.setInherited(true);
m.setDefault("none");
m.addShorthand(s_generics[PR_XML_LANG]);
addPropertyMaker("country", m);

// language
m = new StringProperty.Maker(PR_LANGUAGE);
m.setInherited(true);
m.setDefault("none");
m.addShorthand(s_generics[PR_XML_LANG]);
addPropertyMaker("language", m);

// script
@@ -2722,9 +2725,10 @@ public final class FOPropertyMapping implements Constants {
addPropertyMaker("white-space", m);
// xml:lang
m = new ToBeImplementedProperty.Maker(PR_XML_LANG);
m = new StringProperty.Maker(PR_XML_LANG);
m.setInherited(true);
m.setDefault("");
m.setDatatypeParser(new XMLLangShorthandParser());
addPropertyMaker("xml:lang", m);

}

+ 4
- 2
src/java/org/apache/fop/fo/PropertyList.java Прегледај датотеку

@@ -310,11 +310,13 @@ public abstract class PropertyList {
String attributeNS;
FopFactory factory = getFObj().getUserAgent().getFactory();
for (int i = 0; i < attributes.getLength(); i++) {
/* convert all attributes with the same namespace as the fo element for this fObj */
/* convert all attributes with the same namespace as the fo element
* the "xml:lang" property is a special case */
attributeNS = attributes.getURI(i);
attributeName = attributes.getQName(i);
attributeValue = attributes.getValue(i);
if (attributeNS == null || attributeNS.length() == 0) {
if (attributeNS == null || attributeNS.length() == 0
|| "xml:lang".equals(attributeName)) {
convertAttributeToProperty(attributes, attributeName, attributeValue);
} else if (!factory.isNamespaceIgnored(attributeNS)) {
ElementMapping mapping = factory.getElementMappingRegistry().getElementMapping(

+ 61
- 0
src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java Прегледај датотеку

@@ -0,0 +1,61 @@
/*
* 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 org.apache.fop.fo.Constants;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;

public class XMLLangShorthandParser extends GenericShorthandParser {

private static final char HYPHEN_MINUS = '-';
/** {@inheritDoc} */
public Property getValueForProperty(int propId,
Property property,
PropertyMaker maker,
PropertyList propertyList)
throws PropertyException {
String shorthandValue = property.getString();
int hyphenIndex = shorthandValue.indexOf(HYPHEN_MINUS);
if (propId == Constants.PR_LANGUAGE) {
if (hyphenIndex == -1) {
/* only language specified; use the whole property */
return property;
} else {
/* use only the primary tag */
return StringProperty.getInstance(
shorthandValue.substring(0, hyphenIndex));
}
} else if (propId == Constants.PR_COUNTRY) {
if (hyphenIndex != -1) {
int nextHyphenIndex = shorthandValue.indexOf(HYPHEN_MINUS, hyphenIndex + 1);
if (nextHyphenIndex != -1) {
return StringProperty.getInstance(
shorthandValue.substring(hyphenIndex + 1, nextHyphenIndex));
} else {
return StringProperty.getInstance(
shorthandValue.substring(hyphenIndex + 1));
}
}
}
return null;
}
}

+ 3
- 0
status.xml Прегледај датотеку

@@ -28,6 +28,9 @@

<changes>
<release version="FOP Trunk">
<action context="Code" dev="AD" type="add">
Added very basic parsing for the xml:lang shorthand.
</action>
<action context="Code" dev="AD" type="fix" fixes-bug="44343">
Fixed a bug when using relative font-size (smaller/larger) in combination
with percentages.

+ 35
- 0
test/fotree/testcases/xml-lang_shorthand-expansion.fo Прегледај датотеку

@@ -0,0 +1,35 @@
<?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$ -->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:test="http://xmlgraphics.apache.org/fop/test">
<fo:layout-master-set>
<fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="normal" xml:lang="en-US">
<fo:flow flow-name="xsl-region-body">
<fo:block white-space="normal">
<test:assert property="language" expected="en" />
<test:assert property="country" expected="US" />
Block 1
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>


Loading…
Откажи
Сачувај