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 vh...@apache.org on 2007/08/18 19:00:52 UTC

svn commit: r567294 - in /xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo: ./ flow/ properties/

Author: vhennebert
Date: Sat Aug 18 10:00:50 2007
New Revision: 567294

URL: http://svn.apache.org/viewvc?view=rev&rev=567294
Log:
Extract inner classes to work around buggy 1.3 JRE and thus keep 1.3 compatibility.
Patch provided by Adrian Cumiskey (bugzilla #43156).

Added:
    xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/FOCharIterator.java   (with props)
    xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/properties/ColumnNumberPropertyMaker.java   (with props)
Modified:
    xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/FOPropertyMapping.java
    xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/RecursiveCharIterator.java
    xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/Character.java
    xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/TableBody.java
    xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/TableFObj.java

Modified: xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/FOPropertyMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/FOPropertyMapping.java?view=diff&rev=567294&r1=567293&r2=567294
==============================================================================
--- xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/FOPropertyMapping.java (original)
+++ xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/FOPropertyMapping.java Sat Aug 18 10:00:50 2007
@@ -31,7 +31,7 @@
 import org.apache.fop.fo.properties.BoxPropShorthandParser;
 import org.apache.fop.fo.properties.CharacterProperty;
 import org.apache.fop.fo.properties.ColorProperty;
-import org.apache.fop.fo.flow.TableFObj.ColumnNumberPropertyMaker;
+import org.apache.fop.fo.properties.ColumnNumberPropertyMaker;
 import org.apache.fop.fo.properties.CondLengthProperty;
 import org.apache.fop.fo.properties.CorrespondingPropertyMaker;
 import org.apache.fop.fo.properties.DimensionPropertyMaker;

Modified: xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/RecursiveCharIterator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/RecursiveCharIterator.java?view=diff&rev=567294&r1=567293&r2=567294
==============================================================================
--- xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/RecursiveCharIterator.java (original)
+++ xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/RecursiveCharIterator.java Sat Aug 18 10:00:50 2007
@@ -113,7 +113,7 @@
      */
     public boolean hasNext() {
         while (curCharIter != null) {
-            if (curCharIter.hasNext() == false) {
+            if (!curCharIter.hasNext()) {
                 getNextCharIter();
             } else {
                 return true;
@@ -123,7 +123,7 @@
     }
 
     /**
-     * @see org.apache.fop.fo.CharIterator#nextChar()
+     * {@inheritDoc}
      */
     public char nextChar() throws NoSuchElementException {
         if (curCharIter != null) {

Modified: xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/Character.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/Character.java?view=diff&rev=567294&r1=567293&r2=567294
==============================================================================
--- xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/Character.java (original)
+++ xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/Character.java Sat Aug 18 10:00:50 2007
@@ -20,7 +20,6 @@
 package org.apache.fop.fo.flow;
 
 import java.awt.Color;
-import java.util.NoSuchElementException;
 
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.datatypes.Length;
@@ -29,17 +28,12 @@
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
-import org.apache.fop.fo.properties.CommonAural;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonFont;
 import org.apache.fop.fo.properties.CommonHyphenation;
-import org.apache.fop.fo.properties.CommonMarginInline;
-import org.apache.fop.fo.properties.CommonRelativePosition;
 import org.apache.fop.fo.properties.CommonTextDecoration;
-import org.apache.fop.fo.properties.KeepProperty;
 import org.apache.fop.fo.properties.Property;
 import org.apache.fop.fo.properties.SpaceProperty;
-import org.apache.fop.util.CharUtilities;
 import org.xml.sax.Locator;
 
 /**
@@ -63,7 +57,8 @@
     private Length alignmentAdjust;
     private int alignmentBaseline;
     private Length baselineShift;
-    private char character;
+    /** Holds the character value */
+    protected char character;
     private Color color;
     private int dominantBaseline;
     // private ToBeImplementedProperty glyphOrientationHorizontal;
@@ -102,7 +97,7 @@
     }
 
     /**
-     * @see org.apache.fop.fo.FObj#bind(PropertyList)
+     * {@inheritDoc}
      */
     public void bind(PropertyList pList) throws FOPException {
         super.bind(pList);
@@ -126,7 +121,7 @@
     }
 
     /**
-     * @see org.apache.fop.fo.FONode#startOfNode
+     * {@inheritDoc}
      */
     protected void startOfNode() throws FOPException {
         super.startOfNode();
@@ -134,8 +129,7 @@
     }
 
     /**
-     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
-     * XSL Content Model: empty
+     * {@inheritDoc}
      */
     protected void validateChildNode(Locator loc, String nsURI, String localName) 
         throws ValidationException {
@@ -143,7 +137,7 @@
     }
 
     /**
-     * @see org.apache.fop.fo.FObj#charIterator
+     * {@inheritDoc}
      */
     public CharIterator charIterator() {
         return new FOCharIterator(this);
@@ -238,48 +232,18 @@
         return wordSpacing; 
     }
 
-    /** @see org.apache.fop.fo.FONode#getLocalName() */
+    /**
+     * {@inheritDoc}
+     */
     public String getLocalName() {
         return "character";
     }
     
     /**
-     * @see org.apache.fop.fo.FObj#getNameId()
+     * {@inheritDoc}
      */
     public int getNameId() {
         return FO_CHARACTER;
-    }
-    
-    private class FOCharIterator extends CharIterator {
-
-        private boolean bFirst = true;
-        private Character foChar;
-        
-        FOCharIterator(Character foChar) {
-            this.foChar = foChar;
-        }
-        
-        public boolean hasNext() {
-            return bFirst;
-        }
-
-        public char nextChar() {
-            if (bFirst) {
-                bFirst = false;
-                return foChar.character;
-            } else {
-                throw new NoSuchElementException();
-            }
-        }
-
-        public void remove() {
-            foChar.parent.removeChild(foChar);
-        }
-
-        public void replaceChar(char c) {
-            foChar.character = c;
-        }
-
     }
 
 }

Added: xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/FOCharIterator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/FOCharIterator.java?view=auto&rev=567294
==============================================================================
--- xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/FOCharIterator.java (added)
+++ xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/FOCharIterator.java Sat Aug 18 10:00:50 2007
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.flow;
+
+import java.util.NoSuchElementException;
+
+import org.apache.fop.fo.CharIterator;
+
+/**
+ * Used by the RecursiveCharIterator to iterate over a Character
+ */
+public class FOCharIterator extends CharIterator {
+
+    private boolean bFirst = true;
+    private Character foChar;
+    
+    /**
+     * Main constructor
+     * @param foChar the FOCharacter
+     */
+    protected FOCharIterator(Character foChar) {
+        this.foChar = foChar;
+    }
+    
+    /**
+     * @return true if this iterator has another character available
+     */
+    public boolean hasNext() {
+        return bFirst;
+    }
+
+    /**
+     * @return the next character
+     */
+    public char nextChar() {
+        if (bFirst) {
+            bFirst = false;
+            return foChar.character;
+        } else {
+            throw new NoSuchElementException();
+        }
+    }
+
+    /**
+     * Removes the child from the parent
+     */
+    public void remove() {
+        foChar.getParent().removeChild(foChar);
+    }
+
+    /**
+     * Replaces the character with another one
+     * @param c the replacement character
+     */
+    public void replaceChar(char c) {
+        foChar.character = c;
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/FOCharIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/FOCharIterator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/TableBody.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/TableBody.java?view=diff&rev=567294&r1=567293&r2=567294
==============================================================================
--- xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/TableBody.java (original)
+++ xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/TableBody.java Sat Aug 18 10:00:50 2007
@@ -21,9 +21,7 @@
 
 // Java
 import java.util.BitSet;
-import java.util.Iterator;
 import java.util.List;
-import java.util.ListIterator;
 
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
@@ -33,13 +31,8 @@
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
-import org.apache.fop.fo.StaticPropertyList;
 import org.apache.fop.fo.ValidationException;
-import org.apache.fop.fo.flow.TableFObj.PendingSpan;
-import org.apache.fop.fo.properties.CommonAccessibility;
-import org.apache.fop.fo.properties.CommonAural;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.fo.properties.CommonRelativePosition;
 
 /**
  * Class modelling the fo:table-body object.
@@ -290,7 +283,7 @@
      * 
      * @return the next column number to use
      */
-    protected int getCurrentColumnIndex() {
+    public int getCurrentColumnIndex() {
         return columnIndex;
     }
 
@@ -301,7 +294,7 @@
      * 
      * @param newIndex  the new column index
      */
-    protected void setCurrentColumnIndex(int newIndex) {
+    public void setCurrentColumnIndex(int newIndex) {
         columnIndex = newIndex;
     }
 
@@ -309,7 +302,7 @@
      * Resets the current column index for the TableBody
      *
      */
-    protected void resetColumnIndex() {
+    public void resetColumnIndex() {
         columnIndex = 1;
         for (int i = usedColumnIndices.length(); --i >= 0;) {
             usedColumnIndices.clear(i);
@@ -362,7 +355,7 @@
      *          b) there is no previous cell (implicit 
      *             start of row)
      */
-    protected boolean previousCellEndedRow() {
+    public boolean previousCellEndedRow() {
         if (firstChild != null) {
             FONode prevNode = getChildNodes().lastNode();
             if (prevNode.getNameId() == FO_TABLE_CELL) {

Modified: xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/TableFObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/TableFObj.java?view=diff&rev=567294&r1=567293&r2=567294
==============================================================================
--- xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/TableFObj.java (original)
+++ xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/flow/TableFObj.java Sat Aug 18 10:00:50 2007
@@ -227,7 +227,7 @@
      * 
      * @return the next column number to use
      */
-    protected int getCurrentColumnIndex() {
+    public int getCurrentColumnIndex() {
         return 0;
     }
     
@@ -239,7 +239,7 @@
      * 
      * @param   newIndex    new value for column index
      */
-    protected void setCurrentColumnIndex(int newIndex) {
+    public void setCurrentColumnIndex(int newIndex) {
         //do nothing by default
     }
         
@@ -287,104 +287,5 @@
      */
     protected void flagColumnIndices(int start, int end) {
         //nop
-    }
-    
-    /**
-     * PropertyMaker subclass for the column-number property
-     *
-     */
-    public static class ColumnNumberPropertyMaker extends NumberProperty.Maker {
-
-        /**
-         * Constructor
-         * @param propId    the id of the property for which the maker should 
-         *                  be created
-         */
-        public ColumnNumberPropertyMaker(int propId) {
-            super(propId);
-        }
-
-        /**
-         * @see PropertyMaker#make(PropertyList)
-         */
-        public Property make(PropertyList propertyList) 
-                throws PropertyException {
-            FObj fo = propertyList.getFObj();
-
-            if (fo.getNameId() == Constants.FO_TABLE_CELL
-                    || fo.getNameId() == Constants.FO_TABLE_COLUMN) {
-                if (fo.getNameId() == Constants.FO_TABLE_CELL
-                        && fo.getParent().getNameId() != Constants.FO_TABLE_ROW
-                        && (propertyList.get(Constants.PR_STARTS_ROW).getEnum() 
-                                == Constants.EN_TRUE)) {
-                    TableBody parent = (TableBody) fo.getParent();
-                    if (!parent.previousCellEndedRow()) {
-                        parent.resetColumnIndex();
-                    }
-                }
-            }
-            return NumberProperty.getInstance(
-                    ((TableFObj) fo.getParent()).getCurrentColumnIndex());
-        }
-        
-        
-        /**
-         * Check the value of the column-number property. 
-         * Return the parent's column index (initial value) in case 
-         * of a negative or zero value
-         * 
-         * @see org.apache.fop.fo.properties.PropertyMaker#make(
-         *              org.apache.fop.fo.PropertyList, 
-         *              java.lang.String, 
-         *              org.apache.fop.fo.FObj)
-         */
-        public Property make(PropertyList propertyList, String value, FObj fo) 
-                    throws PropertyException {
-            Property p = super.make(propertyList, value, fo);
-            
-            TableFObj parent = (TableFObj) propertyList.getParentFObj();
-            
-            int columnIndex = p.getNumeric().getValue();
-            if (columnIndex <= 0) {
-                log.warn("Specified negative or zero value for "
-                        + "column-number on " + fo.getName() + ": "
-                        + columnIndex + " forced to " 
-                        + parent.getCurrentColumnIndex());
-                return NumberProperty.getInstance(parent.getCurrentColumnIndex());
-            } else {
-                double tmpIndex = p.getNumeric().getNumericValue();
-                if (tmpIndex - columnIndex > 0.0) {
-                    columnIndex = (int) Math.round(tmpIndex);
-                    log.warn("Rounding specified column-number of "
-                            + tmpIndex + " to " + columnIndex);
-                    p = NumberProperty.getInstance(columnIndex);
-                }
-            }
-            
-            parent.setCurrentColumnIndex(columnIndex);
-            
-            int colSpan = propertyList.get(Constants.PR_NUMBER_COLUMNS_SPANNED)
-                                .getNumeric().getValue();
-            int i = -1;
-            while (++i < colSpan) {
-                if (parent.isColumnNumberUsed(columnIndex + i)) {
-                    /* if column-number is already in use by another 
-                     * cell/column => error!
-                     */
-                    StringBuffer errorMessage = new StringBuffer();
-                    errorMessage.append(fo.getName() + " overlaps in column ")
-                           .append(columnIndex + i);
-                    org.xml.sax.Locator loc = fo.getLocator();
-                    if (loc != null && loc.getLineNumber() != -1) {
-                        errorMessage.append(" (line #")
-                            .append(loc.getLineNumber()).append(", column #")
-                            .append(loc.getColumnNumber()).append(")");
-                    }
-                    throw new PropertyException(errorMessage.toString());
-                }
-            }
-            
-            return p;
-        }
-    }
+    }    
 }

Added: xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/properties/ColumnNumberPropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/properties/ColumnNumberPropertyMaker.java?view=auto&rev=567294
==============================================================================
--- xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/properties/ColumnNumberPropertyMaker.java (added)
+++ xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/properties/ColumnNumberPropertyMaker.java Sat Aug 18 10:00:50 2007
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.flow.TableBody;
+import org.apache.fop.fo.flow.TableFObj;
+
+/**
+ * PropertyMaker subclass for the column-number property
+ *
+ */
+public class ColumnNumberPropertyMaker extends NumberProperty.Maker {
+
+    /**
+     * Constructor
+     * @param propId    the id of the property for which the maker should 
+     *                  be created
+     */
+    public ColumnNumberPropertyMaker(int propId) {
+        super(propId);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Property make(PropertyList propertyList) 
+            throws PropertyException {
+        FObj fo = propertyList.getFObj();
+
+        if (fo.getNameId() == Constants.FO_TABLE_CELL
+                || fo.getNameId() == Constants.FO_TABLE_COLUMN) {
+            if (fo.getNameId() == Constants.FO_TABLE_CELL
+                    && fo.getParent().getNameId() != Constants.FO_TABLE_ROW
+                    && (propertyList.get(Constants.PR_STARTS_ROW).getEnum() 
+                            == Constants.EN_TRUE)) {
+                TableBody parent = (TableBody) fo.getParent();
+                if (!parent.previousCellEndedRow()) {
+                    parent.resetColumnIndex();
+                }
+            }
+        }
+        return NumberProperty.getInstance(
+                ((TableFObj) fo.getParent()).getCurrentColumnIndex());
+    }
+    
+    
+    /**
+     * Check the value of the column-number property. 
+     * Return the parent's column index (initial value) in case 
+     * of a negative or zero value
+     * 
+     * {@inheritDoc}
+     */
+    public Property make(PropertyList propertyList, String value, FObj fo) 
+                throws PropertyException {
+        Property p = super.make(propertyList, value, fo);
+        
+        TableFObj parent = (TableFObj) propertyList.getParentFObj();
+        
+        int columnIndex = p.getNumeric().getValue();
+        if (columnIndex <= 0) {
+            Log log = LogFactory.getLog(TableFObj.class);
+            log.warn("Specified negative or zero value for "
+                    + "column-number on " + fo.getName() + ": "
+                    + columnIndex + " forced to " 
+                    + parent.getCurrentColumnIndex());
+            return NumberProperty.getInstance(parent.getCurrentColumnIndex());
+        } else {
+            double tmpIndex = p.getNumeric().getNumericValue();
+            if (tmpIndex - columnIndex > 0.0) {
+                columnIndex = (int) Math.round(tmpIndex);
+                Log log = LogFactory.getLog(TableFObj.class);
+                log.warn("Rounding specified column-number of "
+                        + tmpIndex + " to " + columnIndex);
+                p = NumberProperty.getInstance(columnIndex);
+            }
+        }
+        
+        parent.setCurrentColumnIndex(columnIndex);
+        
+        int colSpan = propertyList.get(Constants.PR_NUMBER_COLUMNS_SPANNED)
+                            .getNumeric().getValue();
+        int i = -1;
+        while (++i < colSpan) {
+            if (parent.isColumnNumberUsed(columnIndex + i)) {
+                /* if column-number is already in use by another 
+                 * cell/column => error!
+                 */
+                StringBuffer errorMessage = new StringBuffer();
+                errorMessage.append(fo.getName() + " overlaps in column ")
+                       .append(columnIndex + i);
+                org.xml.sax.Locator loc = fo.getLocator();
+                if (loc != null && loc.getLineNumber() != -1) {
+                    errorMessage.append(" (line #")
+                        .append(loc.getLineNumber()).append(", column #")
+                        .append(loc.getColumnNumber()).append(")");
+                }
+                throw new PropertyException(errorMessage.toString());
+            }
+        }
+        
+        return p;
+    }
+}
+

Propchange: xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/properties/ColumnNumberPropertyMaker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/fop-0_94/src/java/org/apache/fop/fo/properties/ColumnNumberPropertyMaker.java
------------------------------------------------------------------------------
    svn:keywords = Id



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