/*
 * Copyright 1999-2004 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.flow;

// XML
import org.xml.sax.Locator;

import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.Length;
import org.apache.fop.datatypes.Numeric;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;

/**
 * Class modelling the fo:table-column object.
 */
public class TableColumn extends FObj {
    // The value of properties relevant for fo:table-column.
    private CommonBorderPaddingBackground commonBorderPaddingBackground;
    // private ToBeImplementedProperty borderAfterPrecedence;
    // private ToBeImplementedProperty borderBeforePrecedence;
    // private ToBeImplementedProperty borderEndPrecedence;
    // private ToBeImplementedProperty borderStartPrecedence;
    private Numeric columnNumber;
    private Length columnWidth;
    private Numeric numberColumnsRepeated;
    private Numeric numberColumnsSpanned;
    private int visibility;
    // End of property values
    
    /**
     * @param parent FONode that is the parent of this object
     */
    public TableColumn(FONode parent) {
        super(parent);
    }

    /**
     * @see org.apache.fop.fo.FObj#bind(PropertyList)
     */
    public void bind(PropertyList pList) throws FOPException {
        commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps();
        // borderAfterPrecedence = pList.get(PR_BORDER_AFTER_PRECEDENCE);
        // borderBeforePrecedence = pList.get(PR_BORDER_BEFORE_PRECEDENCE);
        // borderEndPrecedence = pList.get(PR_BORDER_END_PRECEDENCE);
        // borderStartPrecedence = pList.get(PR_BORDER_START_PRECEDENCE);
        columnNumber = pList.get(PR_COLUMN_NUMBER).getNumeric();
        columnWidth = pList.get(PR_COLUMN_WIDTH).getLength();
        numberColumnsRepeated = pList.get(PR_NUMBER_COLUMNS_REPEATED).getNumeric();
        numberColumnsSpanned = pList.get(PR_NUMBER_COLUMNS_SPANNED).getNumeric();
        visibility = pList.get(PR_VISIBILITY).getEnum();
    }

    /**
     * @see org.apache.fop.fo.FONode#startOfNode()
     */
    protected void startOfNode() throws FOPException {
        getFOEventHandler().startColumn(this);
    }

    /**
     * @see org.apache.fop.fo.FONode#endOfNode
     */
    protected void endOfNode() throws FOPException {
        getFOEventHandler().endColumn(this);
    }

    /**
     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
     * XSL Content Model: empty
     */
    protected void validateChildNode(Locator loc, String nsURI, String localName) 
        throws ValidationException {
            invalidChildError(loc, nsURI, localName);
    }

    /**
     * Return the Common Border, Padding, and Background Properties.
     */
    public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
        return commonBorderPaddingBackground;
    }

    /**
     * Return the "column-width" property.
     */
    public Length getColumnWidth() {
        return columnWidth;
    }

    /**
     * Return the "column-number" property.
     */
    public int getColumnNumber() {
        return columnNumber.getValue();
    }

    /**
     * @return value for number of columns repeated
     */
    public int getNumberColumnsRepeated() {
        return numberColumnsRepeated.getValue();
    }
    
    public String getName() {
        return "fo:table-column";
    }

    /**
     * @see org.apache.fop.fo.FObj#getNameId()
     */
    public int getNameId() {
        return FO_TABLE_COLUMN;
    }
}


@@ -21,9 +21,9 @@
 -200
-4
+5
  The
@@ -962,32 +962,81 @@
 ationException;%0A
+import org.apache.fop.fo.expr.PropertyException;%0A
 import org.apach
@@ -2779,24 +2779,783 @@
 .getEnum();%0A
+        %0A        if (columnNumber.getValue() %3C 0) %7B%0A            //not catching 0 here because it is the indication that no %0A            //column-number has been specified%0A            throw new PropertyException(%22column-number must be 1 or bigger, %22%0A                    + %22but got %22 + columnNumber.getValue());%0A        %7D%0A        if (numberColumnsRepeated.getValue() %3C= 0) %7B%0A            throw new PropertyException(%22number-columns-repeated must be 1 or bigger, %22%0A                    + %22but got %22 + numberColumnsRepeated.getValue());%0A        %7D%0A        if (numberColumnsSpanned.getValue() %3C= 0) %7B%0A            throw new PropertyException(%22number-columns-spanned must be 1 or bigger, %22%0A                    + %22but got %22 + numberColumnsSpanned.getValue());%0A        %7D%0A
     %7D%0A%0A    /
@@ -4209,33 +4209,34 @@
 %0A    /**%0A     * 
-R
+@r
 eturn the Common
@@ -4426,33 +4426,34 @@
 %0A    /**%0A     * 
-R
+@r
 eturn the %22colum
@@ -4566,17 +4566,188 @@
 %0A     * 
-R
+@return true if the %22column-number%22 property was set.%0A     */%0A    public boolean hasColumnNumber() %7B%0A        return (columnNumber.getValue() %3E= 1);%0A    %7D%0A%0A    /**%0A     * @r
 eturn th
@@ -5032,24 +5032,75 @@
 %0A    %7D%0A    %0A
+    /** @see org.apache.fop.fo.FONode#getName() */%0A
     public S
@@ -5157,39 +5157,32 @@
 ;%0A    %7D%0A%0A    /**
-%0A     *
  @see org.apache
@@ -5205,21 +5205,16 @@
 NameId()
-%0A    
  */%0A    

Checks and an addtional method to determine whether a column-number is set.