aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2005-12-30 00:25:28 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2005-12-30 00:25:28 +0000
commit575539d616a11fbb56114965502c0d7fb83f1bd1 (patch)
tree7e79e959561ef124d4eb8f39c6a4244faef7e490 /src/java/org/apache/fop
parent54d297afea37ddc051cc43d26b919e2a95fbc815 (diff)
downloadxmlgraphics-fop-575539d616a11fbb56114965502c0d7fb83f1bd1.tar.gz
xmlgraphics-fop-575539d616a11fbb56114965502c0d7fb83f1bd1.zip
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
Diffstat (limited to 'src/java/org/apache/fop')
-rw-r--r--src/java/org/apache/fop/fo/FOPropertyMapping.java15
-rw-r--r--src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java63
2 files changed, 78 insertions, 0 deletions
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;
+ }
+
+}