<td class="no">
no
</td>
- <td class="no">
- no
+ <td class="yes">
+ yes
</td>
<td align="center">
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
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
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.
m.useGeneric(genericBoolean);
m.setInherited(true);
m.setDefault("true");
+ m.addShorthand(s_generics[PR_WHITE_SPACE]);
addPropertyMaker("white-space-collapse", m);
// wrap-option
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);
}
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);
--- /dev/null
+/*
+ * 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;
+ }
+
+}
<changes>
<release version="FOP Trunk">
+ <action context="Code" dev="AD" type="enhancement">
+ Added feature: support for white-space shorthand
+ </action>
<action context="Code" dev="AD" type="enhancement">
Added feature: support for page-break-* shorthands
</action>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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$ -->
+ <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">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block white-space="normal">
+ <test:assert property="linefeed-treatment" expected="TREAT_AS_SPACE" />
+ <test:assert property="white-space-treatment" expected="IGNORE_IF_SURROUNDING_LINEFEED" />
+ <test:assert property="white-space-collapse" expected="TRUE" />
+ <test:assert property="wrap-option" expected="WRAP" />
+ Block 1: testing white-space="normal"
+ </fo:block>
+ <fo:block white-space="pre">
+ <test:assert property="linefeed-treatment" expected="PRESERVE" />
+ <test:assert property="white-space-treatment" expected="PRESERVE" />
+ <test:assert property="white-space-collapse" expected="FALSE" />
+ <test:assert property="wrap-option" expected="NO_WRAP" />
+ Block 2: testing white-space="pre"
+ </fo:block>
+ <fo:block white-space="no-wrap">
+ <test:assert property="linefeed-treatment" expected="TREAT_AS_SPACE" />
+ <test:assert property="white-space-treatment" expected="IGNORE_IF_SURROUNDING_LINEFEED" />
+ <test:assert property="white-space-collapse" expected="TRUE" />
+ <test:assert property="wrap-option" expected="NO_WRAP" />
+ Block 3: testing white-space="no-wrap"
+ </fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+