From 575539d616a11fbb56114965502c0d7fb83f1bd1 Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Fri, 30 Dec 2005 00:25:28 +0000 Subject: [PATCH] Added support for the white-space shorthand git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@359945 13f79535-47bb-0310-9956-ffa450edef68 --- .../content/xdocs/compliance.ihtml | 4 +- .../org/apache/fop/fo/FOPropertyMapping.java | 15 +++++ .../properties/WhiteSpaceShorthandParser.java | 63 +++++++++++++++++++ status.xml | 3 + .../white-space_shorthand-expansion.fo | 50 +++++++++++++++ 5 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java create mode 100644 test/fotree/testcases/white-space_shorthand-expansion.fo diff --git a/src/documentation/content/xdocs/compliance.ihtml b/src/documentation/content/xdocs/compliance.ihtml index 2a67a4a6f..d3b1336e3 100644 --- a/src/documentation/content/xdocs/compliance.ihtml +++ b/src/documentation/content/xdocs/compliance.ihtml @@ -6821,8 +6821,8 @@ no - - no + + yes   diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index 29eb28584..2b6803547 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -59,6 +59,7 @@ import org.apache.fop.fo.properties.TableBorderPrecedence; 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; /** * This class creates and returns an array of Property.Maker instances @@ -1643,6 +1644,7 @@ public class FOPropertyMapping implements Constants { m.addEnum("treat-as-space", getEnumProperty(EN_TREAT_AS_SPACE, "TREAT_AS_SPACE")); m.addEnum("treat-as-zero-width-space", getEnumProperty(EN_TREAT_AS_ZERO_WIDTH_SPACE, "TREAT_AS_ZERO_WIDTH_SPACE")); m.setDefault("treat-as-space"); + m.addShorthand(s_generics[PR_WHITE_SPACE]); addPropertyMaker("linefeed-treatment", m); // white-space-treatment @@ -1654,6 +1656,7 @@ public class FOPropertyMapping implements Constants { m.addEnum("ignore-if-after-linefeed", getEnumProperty(EN_IGNORE_IF_AFTER_LINEFEED, "IGNORE_IF_AFTER_LINEFEED")); m.addEnum("ignore-if-surrounding-linefeed", getEnumProperty(EN_IGNORE_IF_SURROUNDING_LINEFEED, "IGNORE_IF_SURROUNDING_LINEFEED")); m.setDefault("ignore-if-surrounding-linefeed"); + m.addShorthand(s_generics[PR_WHITE_SPACE]); addPropertyMaker("white-space-treatment", m); // text-align TODO: make it a StringProperty with enums. @@ -1713,6 +1716,7 @@ public class FOPropertyMapping implements Constants { m.useGeneric(genericBoolean); m.setInherited(true); m.setDefault("true"); + m.addShorthand(s_generics[PR_WHITE_SPACE]); addPropertyMaker("white-space-collapse", m); // wrap-option @@ -1721,6 +1725,7 @@ public class FOPropertyMapping implements Constants { m.addEnum("wrap", getEnumProperty(EN_WRAP, "WRAP")); m.addEnum("no-wrap", getEnumProperty(EN_NO_WRAP, "NO_WRAP")); m.setDefault("wrap"); + m.addShorthand(s_generics[PR_WHITE_SPACE]); addPropertyMaker("wrap-option", m); } @@ -2763,6 +2768,16 @@ public class FOPropertyMapping implements Constants { m.setDefault("baseline"); addPropertyMaker("vertical-align", m); + // white-space + m = new EnumProperty.Maker(PR_WHITE_SPACE); + m.setInherited(true); + m.addEnum("normal", getEnumProperty(EN_NORMAL, "NORMAL")); + m.addEnum("pre", getEnumProperty(EN_PRE, "PRE")); + m.addEnum("no-wrap", getEnumProperty(EN_NO_WRAP, "NO_WRAP")); + m.setDefault("normal"); + m.setDatatypeParser(new WhiteSpaceShorthandParser()); + addPropertyMaker("white-space", m); + // xml:lang m = new ToBeImplementedProperty.Maker(PR_XML_LANG); m.setInherited(true); diff --git a/src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java b/src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java new file mode 100644 index 000000000..afe88dc5b --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java @@ -0,0 +1,63 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed 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; + +/** + * Shorthand parser for the white-space property; + * Sets the values for white-space-treament, linefeed-treatment, + * white-space-collapse and wrap-option + * + */ +public class WhiteSpaceShorthandParser implements ShorthandParser { + + /** + * @see org.apache.fop.fo.properties.ShorthandParser#getValueForProperty() + */ + public Property getValueForProperty(int propId, Property property, + PropertyMaker maker, PropertyList propertyList) + throws PropertyException { + switch (property.getEnum()) { + case Constants.EN_PRE: + switch (propId) { + case Constants.PR_LINEFEED_TREATMENT: + case Constants.PR_WHITE_SPACE_TREATMENT: + return new EnumProperty(Constants.EN_PRESERVE, "PRESERVE"); + case Constants.PR_WHITE_SPACE_COLLAPSE: + return new EnumProperty(Constants.EN_FALSE, "FALSE"); + case Constants.PR_WRAP_OPTION: + return new EnumProperty(Constants.EN_NO_WRAP, "NO_WRAP"); + default: + //nop + } + case Constants.EN_NO_WRAP: + if (propId == Constants.PR_WRAP_OPTION) { + return new EnumProperty(Constants.EN_NO_WRAP, "NO_WRAP"); + } + case Constants.EN_NORMAL: + default: + //nop + } + return null; + } + +} diff --git a/status.xml b/status.xml index 84fa1e438..09ae37386 100644 --- a/status.xml +++ b/status.xml @@ -27,6 +27,9 @@ + + Added feature: support for white-space shorthand + Added feature: support for page-break-* shorthands diff --git a/test/fotree/testcases/white-space_shorthand-expansion.fo b/test/fotree/testcases/white-space_shorthand-expansion.fo new file mode 100644 index 000000000..b7b094738 --- /dev/null +++ b/test/fotree/testcases/white-space_shorthand-expansion.fo @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + Block 1: testing white-space="normal" + + + + + + + Block 2: testing white-space="pre" + + + + + + + Block 3: testing white-space="no-wrap" + + + + + -- 2.39.5