]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added support for the white-space shorthand
authorAndreas L. Delmelle <adelmelle@apache.org>
Fri, 30 Dec 2005 00:25:28 +0000 (00:25 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Fri, 30 Dec 2005 00:25:28 +0000 (00:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@359945 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/compliance.ihtml
src/java/org/apache/fop/fo/FOPropertyMapping.java
src/java/org/apache/fop/fo/properties/WhiteSpaceShorthandParser.java [new file with mode: 0644]
status.xml
test/fotree/testcases/white-space_shorthand-expansion.fo [new file with mode: 0644]

index 2a67a4a6fd41bd8304edc97090e2fcf8f760eadd..d3b1336e3142d27edfdfda50c89540ab1d80fbd1 100644 (file)
       <td class="no">
         no
       </td>
-      <td class="no">
-        no
+      <td class="yes">
+        yes
       </td>
       <td align="center">
         &nbsp;
index 29eb28584a5edf420141ca310d2408c42ecac292..2b68035474b91ff258566209c021d8fa20486ad8 100644 (file)
@@ -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 (file)
index 0000000..afe88dc
--- /dev/null
@@ -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;
+    }
+
+}
index 84fa1e438bbab423d31e8ec142c84e4c08f1f2e1..09ae373863e9ed4d7a3e06d35dd83da10e83074c 100644 (file)
@@ -27,6 +27,9 @@
 
   <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>
diff --git a/test/fotree/testcases/white-space_shorthand-expansion.fo b/test/fotree/testcases/white-space_shorthand-expansion.fo
new file mode 100644 (file)
index 0000000..b7b0947
--- /dev/null
@@ -0,0 +1,50 @@
+<?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>
+