cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicola...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements EPStyle.java
Date Thu, 07 Mar 2002 07:50:09 GMT
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 (acoliver@apache.org).
  
  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:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message