nicolaken 02/03/06 23:50:09 Modified: src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements EPStyle.java Log: Fixed repeated value in cell bug. Patch by Mr. Andrew C. Oliver ([EMAIL PROTECTED]). Revision Changes Path 1.3 +67 -10 xml-cocoon2/src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPStyle.java Index: EPStyle.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPStyle.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- EPStyle.java 6 Mar 2002 21:02:19 -0000 1.2 +++ EPStyle.java 7 Mar 2002 07:50:09 -0000 1.3 @@ -163,12 +163,15 @@ Hashtable colorhash = sregion.getColorHash(); HSSFCellStyle style = sregion.getStyle(); - style.setAlignment(getHorizontalAlignment().getCode()); - style.setVerticalAlignment(getVerticalAlignment().getCode()); + short cnvhalign = convertAlignment(getHorizontalAlignment().getCode()); + style.setAlignment(cnvhalign); + short cnvvalign = convertVAlignment(getVerticalAlignment().getCode()); + style.setVerticalAlignment(cnvvalign); style.setFillPattern((short)getShade()); - - if (getShade() == 1) { //normally this fill is set to true and the colors are "reversed" - //according to Gnumeric sources + + + if (getShade() == 1) { //TODO: change to constant when upgrade to new HSSF + //solid w/foreground, bg doesn't matter getLogger().debug("shade = 1"); HSSFColor color = (HSSFColor) colorhash.get(getBackgroundColor().toString()); if (color == null) { @@ -202,11 +205,6 @@ invalid = true; } - - - - - //style.setFillForegroundColor( } @@ -568,5 +566,64 @@ return (!invalid); } + /** + * deal with mismatch between gnumeric align and Excel + */ + private short convertAlignment(short alignment) { + short retval=HSSFCellStyle.ALIGN_GENERAL; // its 0 + + switch (alignment) { + case 1: + retval = HSSFCellStyle.ALIGN_GENERAL; + break; + case 2: + retval = HSSFCellStyle.ALIGN_LEFT; + break; + case 4: + retval = HSSFCellStyle.ALIGN_RIGHT; + break; + case 8: + retval = HSSFCellStyle.ALIGN_CENTER; + break; + case 16: + retval = HSSFCellStyle.ALIGN_FILL; + break; + case 32: + retval = HSSFCellStyle.ALIGN_JUSTIFY; + break; + case 64: + retval = HSSFCellStyle.ALIGN_CENTER_SELECTION; + break; + default: + retval = HSSFCellStyle.ALIGN_GENERAL; + } + + return retval; + } + + /** + * deal with mismatch between gnumeric valign and Excel + */ + private short convertVAlignment(short alignment) { + short retval=HSSFCellStyle.VERTICAL_TOP; // its 0 + + switch (alignment) { + case 1: + retval = HSSFCellStyle.VERTICAL_TOP; + break; + case 2: + retval = HSSFCellStyle.VERTICAL_BOTTOM; + break; + case 4: + retval = HSSFCellStyle.VERTICAL_CENTER; + break; + case 8: + retval = HSSFCellStyle.VERTICAL_JUSTIFY; + break; + default: + retval = HSSFCellStyle.VERTICAL_TOP; + } + return retval; + } } // end public class EPStyle
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]