You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ad...@apache.org on 2008/02/10 14:42:42 UTC

svn commit: r620285 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/fo/expr/PPColWidthFunction.java status.xml test/layoutengine/standard-testcases/table-column_column-width_proportional-column-width.xml

Author: adelmelle
Date: Sun Feb 10 05:42:39 2008
New Revision: 620285

URL: http://svn.apache.org/viewvc?rev=620285&view=rev
Log:
Bugzilla 41631: Percentage resolution for arguments to proportional-column-width()


Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java
    xmlgraphics/fop/trunk/status.xml
    xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-column_column-width_proportional-column-width.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java?rev=620285&r1=620284&r2=620285&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/expr/PPColWidthFunction.java Sun Feb 10 05:42:39 2008
@@ -19,6 +19,8 @@
 
 package org.apache.fop.fo.expr;
 
+import org.apache.fop.datatypes.PercentBase;
+import org.apache.fop.datatypes.PercentBaseContext;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.properties.Property;
@@ -38,6 +40,13 @@
         return 1;
     }
 
+    /** 
+     * @return the {@link PercentBase} for the proportional-column-width() 
+     *         function
+     */
+    public PercentBase getPercentBase() {
+        return new PPColWidthPercentBase();
+    }
     /**
      *
      * @param args array of arguments for this function
@@ -69,4 +78,24 @@
         return new TableColLength(d.doubleValue(), pInfo.getFO());
     }
 
+    private static class PPColWidthPercentBase implements PercentBase {
+
+        /** {@inheritDoc} */
+        public int getBaseLength(PercentBaseContext context) throws PropertyException {
+            return 0;
+        }
+
+        /** {@inheritDoc} */
+        public double getBaseValue() {
+            //make sure percentage-arguments are interpreted
+            //as numerics (1% = 1 * 0.01)
+            return 1;
+        }
+
+        /** {@inheritDoc} */
+        public int getDimension() {
+            return 0;
+        }
+        
+    }
 }

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=620285&r1=620284&r2=620285&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Sun Feb 10 05:42:39 2008
@@ -28,6 +28,9 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="AD" type="fix" fixes-bug="41631">
+        Added correct percentage resolution for arguments to the proportional-column-width() function.
+      </action>
       <action context="Fonts" dev="JM" type="fix">
         Bugfix for date formatting with negative time zones in the PDF's Info object.
         This affected PDF/A compliance.

Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-column_column-width_proportional-column-width.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-column_column-width_proportional-column-width.xml?rev=620285&r1=620284&r2=620285&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-column_column-width_proportional-column-width.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-column_column-width_proportional-column-width.xml Sun Feb 10 05:42:39 2008
@@ -67,6 +67,24 @@
               </fo:table-row>
             </fo:table-body>
           </fo:table>
+          <fo:table table-layout="fixed">
+            <fo:table-column column-width="proportional-column-width(25%)"/>
+            <fo:table-column column-width="proportional-column-width(25%)"/>
+            <fo:table-column column-width="proportional-column-width(50%)"/>
+            <fo:table-body>
+              <fo:table-row>
+                <fo:table-cell>
+                  <fo:block>cell1%</fo:block>
+                </fo:table-cell>
+                <fo:table-cell background-color="yellow">
+                  <fo:block>cell2%</fo:block>
+                </fo:table-cell>
+                <fo:table-cell background-color="orange">
+                  <fo:block>cell3%</fo:block>
+                </fo:table-cell>
+              </fo:table-row>
+            </fo:table-body>
+          </fo:table>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
@@ -95,5 +113,18 @@
     <!-- cell 6 -->
     <eval expected="cell6" xpath="//flow/block[2]/block[3]/block[1]/lineArea"/>
     <eval expected="180000" xpath="//flow/block[2]/block[3]/@ipd"/>
+    
+    <!-- Percentages should yield the same result as numbers -->
+    <!-- cell 1% -->
+    <eval expected="cell1%" xpath="//flow/block[3]/block[1]/block[1]/lineArea"/>
+    <eval expected="90000" xpath="//flow/block[3]/block[1]/@ipd"/>
+
+    <!-- cell 2% -->
+    <eval expected="cell2%" xpath="//flow/block[3]/block[2]/block[1]/lineArea"/>
+    <eval expected="90000" xpath="//flow/block[3]/block[2]/@ipd"/>
+
+    <!-- cell 3% -->
+    <eval expected="cell3%" xpath="//flow/block[3]/block[3]/block[1]/lineArea"/>
+    <eval expected="180000" xpath="//flow/block[3]/block[3]/@ipd"/>
   </checks>
 </testcase>



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org