joerg 2003/08/20 10:29:07
Modified: src/blocks/poi/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements EPCell.java CellType.java Cell.java . status.xml Log: POI: fixed formula support (Bug 22574, thanks to Neil Bacon) Revision Changes Path 1.4 +3 -2 cocoon-2.1/src/blocks/poi/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPCell.java Index: EPCell.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/poi/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPCell.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- EPCell.java 14 Jun 2003 00:26:27 -0000 1.3 +++ EPCell.java 20 Aug 2003 17:29:07 -0000 1.4 @@ -233,7 +233,8 @@ */ public void initialize(final Attribute[] attributes, final ElementProcessor parent) throws IOException { super.initialize(attributes, parent); - int cellType = -1; + // default value (when <gmr:Cell> has no ValueType attribute) + int cellType = CellType.CELL_TYPE_FORMULA; try { cellType = getCellType(); } catch (NullPointerException ignored) { 1.3 +13 -24 cocoon-2.1/src/blocks/poi/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/CellType.java Index: CellType.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/poi/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/CellType.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CellType.java 11 Mar 2003 19:05:01 -0000 1.2 +++ CellType.java 20 Aug 2003 17:29:07 -0000 1.3 @@ -52,8 +52,6 @@ package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements; - - import org.apache.poi.hssf.usermodel.HSSFCell; /** @@ -62,8 +60,10 @@ * @author Marc Johnson ([EMAIL PROTECTED]) * @version CVS $Id$ */ -public class CellType -{ +public class CellType { + + + public static final int CELL_TYPE_FORMULA = -1; public static final int CELL_TYPE_EMPTY = 10; public static final int CELL_TYPE_BOOLEAN = 20; public static final int CELL_TYPE_INTEGER = 30; @@ -73,33 +73,27 @@ public static final int CELL_TYPE_CELLRANGE = 70; public static final int CELL_TYPE_ARRAY = 80; - private CellType() - { + private CellType() { } /** * Is this a valid cell type? * * @param val value to be checked - * * @return true if valid, false otherwise */ - - public static boolean isValid(final int val) - { - switch (val) - { - + public static boolean isValid(final int val) { + switch (val) { case CELL_TYPE_EMPTY : case CELL_TYPE_BOOLEAN : case CELL_TYPE_INTEGER : case CELL_TYPE_FLOAT : case CELL_TYPE_ERROR : case CELL_TYPE_STRING : + case CELL_TYPE_FORMULA : case CELL_TYPE_CELLRANGE : case CELL_TYPE_ARRAY : return true; - default : return false; } @@ -109,22 +103,17 @@ * Convert a CellType enum into an HSSFCell enum * * @param val the value to be converted - * * @return the converted value */ - - static int convertCellType(final int val) - { - switch (val) - { - + static int convertCellType(final int val) { + switch (val) { case CELL_TYPE_INTEGER : case CELL_TYPE_FLOAT : return HSSFCell.CELL_TYPE_NUMERIC; - case CELL_TYPE_STRING : return HSSFCell.CELL_TYPE_STRING; - + case CELL_TYPE_FORMULA : + return HSSFCell.CELL_TYPE_FORMULA; default : return HSSFCell.CELL_TYPE_BLANK; } 1.5 +1 -8 cocoon-2.1/src/blocks/poi/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/Cell.java Index: Cell.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/poi/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/Cell.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Cell.java 8 Aug 2003 13:42:47 -0000 1.4 +++ Cell.java 20 Aug 2003 17:29:07 -0000 1.5 @@ -108,13 +108,6 @@ * @exception IOException */ void setContent(final String content) throws IOException { - /* This part is plain wrong: in gnumeric a formula cell is a cell lacking the ValueType attribute - Disabled this code until someone implements it correctly. - if (content.charAt(0) == '=') { - //seems like a kludge but this is actually how gnumeric does it - _cell.setCellType(HSSFCell.CELL_TYPE_FORMULA); - } - */ if (_cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) { try { if (_celltype == CellType.CELL_TYPE_FLOAT) { 1.128 +5 -1 cocoon-2.1/status.xml Index: status.xml =================================================================== RCS file: /home/cvs/cocoon-2.1/status.xml,v retrieving revision 1.127 retrieving revision 1.128 diff -u -r1.127 -r1.128 --- status.xml 19 Aug 2003 08:43:00 -0000 1.127 +++ status.xml 20 Aug 2003 17:29:07 -0000 1.128 @@ -189,6 +189,10 @@ <changes> <release version="@version@" date="@date@"> + <action dev="JH" type="fix" fixes-bug="22574" due-to="Neil Bacon" due-to-email="[EMAIL PROTECTED]"> + POI block: fixed formula support. If no ValueType attribute is set on + <gmr:Cell/>, the cell content will be interpreted as formula. + </action> <action dev="CZ" type="add" fixes-bug="21848" due-to="Unico Hommes" due-to-email="[EMAIL PROTECTED]"> Applying patch for using 'host' in the logging patterns. </action>