You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2008/04/07 05:23:06 UTC

svn commit: r645352 - in /poi/trunk/src: documentation/content/xdocs/ java/org/apache/poi/hssf/record/ java/org/apache/poi/hssf/record/cf/ java/org/apache/poi/hssf/usermodel/ testcases/org/apache/poi/hssf/record/ testcases/org/apache/poi/hssf/usermodel/

Author: josh
Date: Sun Apr  6 20:23:04 2008
New Revision: 645352

URL: http://svn.apache.org/viewvc?rev=645352&view=rev
Log:
30311 - More work on Conditional Formatting - patch from Dmitriy

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/record/CFRuleRecord.java
    poi/trunk/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=645352&r1=645351&r2=645352&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Sun Apr  6 20:23:04 2008
@@ -37,6 +37,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.0.3-beta1" date="2008-04-??">
+           <action dev="POI-DEVELOPERS" type="add">30311 - More work on Conditional Formatting</action>
            <action dev="POI-DEVELOPERS" type="fix">refactored all junits' usage of HSSF.testdata.path to one place</action>
            <action dev="POI-DEVELOPERS" type="fix">44739 - Small fixes for conditional formatting (regions with max row/col index)</action>
            <action dev="POI-DEVELOPERS" type="add">Implement Sheet.removeShape(Shape shape) in HSLF</action>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=645352&r1=645351&r2=645352&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sun Apr  6 20:23:04 2008
@@ -34,6 +34,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.0.3-beta1" date="2008-04-??">
+           <action dev="POI-DEVELOPERS" type="add">30311 - More work on Conditional Formatting</action>
            <action dev="POI-DEVELOPERS" type="fix">refactored all junits' usage of HSSF.testdata.path to one place</action>
            <action dev="POI-DEVELOPERS" type="fix">44739 - Small fixes for conditional formatting (regions with max row/col index)</action>
            <action dev="RK" type="add">44694 - HPSF: Support for property sets without sections</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/CFRuleRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/CFRuleRecord.java?rev=645352&r1=645351&r2=645352&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/CFRuleRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/CFRuleRecord.java Sun Apr  6 20:23:04 2008
@@ -238,6 +238,17 @@
 		this.fontFormatting = fontFormatting;
 		setOptionFlag(fontFormatting != null, font);
 	}
+	public FontFormatting getFontFormatting()
+	{
+		if( containsFontFormattingBlock())
+		{
+			return fontFormatting;
+		}
+		else
+		{
+			return null;
+		}
+	}
 	
 	public boolean containsAlignFormattingBlock()
 	{
@@ -257,6 +268,17 @@
 		this.borderFormatting = borderFormatting;
 		setOptionFlag(borderFormatting != null, bord);
 	}
+	public BorderFormatting getBorderFormatting()
+	{
+		if( containsBorderFormattingBlock())
+		{
+			return borderFormatting;
+		}
+		else
+		{
+			return null;
+		}
+	}
 	
 	public boolean containsPatternFormattingBlock()
 	{
@@ -267,7 +289,17 @@
 		this.patternFormatting = patternFormatting;
 		setOptionFlag(patternFormatting!=null, patt);
 	}
-
+	public PatternFormatting getPatternFormatting()
+	{
+		if( containsPatternFormattingBlock())
+		{
+			return patternFormatting;
+		}
+		else
+		{
+			return null;
+		}
+	}
 	
 	public boolean containsProtectionFormattingBlock()
 	{
@@ -616,12 +648,6 @@
 		return rec;
 	}
 
-	public FontFormatting getFontFormatting()
-	{
-		return fontFormatting;
-	}
-
-	
 	/**
 	 * @return <code>null</code> if <tt>formula</tt> was null.
 	 */

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java?rev=645352&r1=645351&r2=645352&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java Sun Apr  6 20:23:04 2008
@@ -45,8 +45,8 @@
     private static final int OFFSET_OPTION_FLAGS = 88;
     private static final int OFFSET_ESCAPEMENT_TYPE_MODIFIED = 92;
     private static final int OFFSET_UNDERLINE_TYPE_MODIFIED = 96;
-    private static final int OFFSET_NOT_USED1 = 100;
-    private static final int OFFSET_NOT_USED2 = 104;
+    private static final int OFFSET_FONT_WEIGHT_MODIFIED = 100;
+    private static final int OFFSET_NOT_USED = 104;
     private static final int OFFSET_FONT_FORMATING_END = 116;
 
     
@@ -56,7 +56,6 @@
     private static final BitField posture		= BitFieldFactory.getInstance(0x00000002);
     private static final BitField outline		= BitFieldFactory.getInstance(0x00000008);
     private static final BitField shadow		= BitFieldFactory.getInstance(0x00000010);
-    private static final BitField condense		= BitFieldFactory.getInstance(0x00000020);
     private static final BitField cancellation	= BitFieldFactory.getInstance(0x00000080);
     
     // OPTION FLAGS MASKS
@@ -64,7 +63,6 @@
     private static final BitField styleModified			= BitFieldFactory.getInstance(0x00000002);
     private static final BitField outlineModified 		= BitFieldFactory.getInstance(0x00000008);
     private static final BitField shadowModified 		= BitFieldFactory.getInstance(0x00000010);
-    private static final BitField condenseModified		= BitFieldFactory.getInstance(0x00000020);
     private static final BitField cancellationModified	= BitFieldFactory.getInstance(0x00000080);
 
     /**
@@ -125,10 +123,9 @@
     	
     	this.setFontHeight((short)-1);
     	this.setItalic(false);
-    	this.setBold(false);
+    	this.setFontWieghtModified(false);
     	this.setOutline(false);
     	this.setShadow(false);
-    	this.setCondense(false);
     	this.setStrikeout(false);
     	this.setEscapementType((short)0);
     	this.setUnderlineType((byte)0);
@@ -137,15 +134,13 @@
     	this.setFontStyleModified(false);
     	this.setFontOutlineModified(false);
     	this.setFontShadowModified(false);
-    	this.setFontCondenseModified(false);
     	this.setFontCancellationModified(false);
     	
     	this.setEscapementTypeModified(false);
     	this.setUnderlineTypeModified(false);
     	
     	LittleEndian.putShort(record, OFFSET_FONT_NAME, (short)0);
-    	LittleEndian.putInt(record, OFFSET_NOT_USED1, 0x00000001);
-    	LittleEndian.putInt(record, OFFSET_NOT_USED2, 0x00000001);
+    	LittleEndian.putInt(record, OFFSET_NOT_USED, 0x00000001);
     	LittleEndian.putShort(record, OFFSET_FONT_FORMATING_END, (short)0x0001);
     }
     
@@ -249,16 +244,6 @@
     	return getFontOption(shadow);
     }
 
-    public void setCondense(boolean on)
-    {
-    	setFontOption(on, condense);
-    }
-
-    public boolean isCondenseOn()
-    {
-    	return getFontOption(condense);
-    }
-
     /**
      * set the font to be stricken out or not
      *
@@ -420,6 +405,7 @@
     	return getOptionFlag(styleModified);
     }
 
+    
     public void setFontStyleModified(boolean modified)
     {
     	setOptionFlag(modified, styleModified);
@@ -444,16 +430,6 @@
     {
     	setOptionFlag(modified, shadowModified);
     }
-    public boolean isFontCondenseModified()
-    {
-    	return getOptionFlag(condenseModified);
-    }
-    
-    public void setFontCondenseModified(boolean modified)
-    {
-    	setOptionFlag(modified, condenseModified);
-    }
-    
     public void setFontCancellationModified(boolean modified)
     {
     	setOptionFlag(modified, cancellationModified);
@@ -469,7 +445,6 @@
     	int value = modified? 0 : 1;
     	LittleEndian.putInt(record,OFFSET_ESCAPEMENT_TYPE_MODIFIED, value);
     }
-    
     public boolean isEscapementTypeModified()
     {
     	int escapementModified = LittleEndian.getInt(record,OFFSET_ESCAPEMENT_TYPE_MODIFIED);
@@ -488,6 +463,18 @@
     	return underlineModified == 0;
     }
     
+    public void setFontWieghtModified(boolean modified)
+    {
+    	int value = modified? 0 : 1;
+    	LittleEndian.putInt(record,OFFSET_FONT_WEIGHT_MODIFIED, value);
+    }
+
+    public boolean isFontWeightModified()
+    {
+    	int fontStyleModified = LittleEndian.getInt(record,OFFSET_FONT_WEIGHT_MODIFIED);
+    	return fontStyleModified == 0;
+    }
+
     public String toString()
     {
         StringBuffer buffer = new StringBuffer();
@@ -521,14 +508,6 @@
         {
             buffer.append("    .font shadow is not modified\n");
         }
-        if( isFontCondenseModified() )
-        {
-            buffer.append("    .font condense = ").append(isCondenseOn()).append("\n");
-        }
-        else
-        {
-            buffer.append("    .font condense is not modified\n");
-        }
         
         if( isFontCancellationModified() )
         {
@@ -572,11 +551,32 @@
         }
         buffer.append("    .color index = ").append("0x"+Integer.toHexString(getFontColorIndex()).toUpperCase()).append("\n");
         
+
+        buffer.append("    ====\n");
+        buffer.append("    ["+OFFSET_FONT_HEIGHT+"] FONT HEIGHT: "+intToHex(OFFSET_FONT_HEIGHT)+"\n");
+        buffer.append("    ["+OFFSET_FONT_OPTIONS+"] FONT OPTIONS: "+intToHex(OFFSET_FONT_OPTIONS)+"\n");
+        buffer.append("    ["+OFFSET_FONT_WEIGHT+"] FONT WEIGHT: "+shortToHex(OFFSET_FONT_WEIGHT)+"\n");
+        buffer.append("    ["+OFFSET_ESCAPEMENT_TYPE+"] FONT ESCAPEMENT: "+shortToHex(OFFSET_ESCAPEMENT_TYPE)+"\n");
+        buffer.append("    ["+OFFSET_UNDERLINE_TYPE+"] FONT UNDERLINE: "+byteToHex(OFFSET_UNDERLINE_TYPE)+"\n");
+        buffer.append("    ["+(OFFSET_UNDERLINE_TYPE+1)+"] FONT NOT USED: "+byteToHex(OFFSET_UNDERLINE_TYPE+1)+"\n");
+        buffer.append("    ["+(OFFSET_UNDERLINE_TYPE+2)+"] FONT NOT USED: "+byteToHex(OFFSET_UNDERLINE_TYPE+2)+"\n");
+        buffer.append("    ["+(OFFSET_UNDERLINE_TYPE+3)+"] FONT NOT USED: "+byteToHex(OFFSET_UNDERLINE_TYPE+3)+"\n");
+        buffer.append("    ["+OFFSET_FONT_COLOR_INDEX+"] FONT COLIDX: "+intToHex(OFFSET_FONT_COLOR_INDEX)+"\n");
+        buffer.append("    ["+(OFFSET_FONT_COLOR_INDEX+4)+"] FONT NOT USED: "+intToHex(OFFSET_FONT_COLOR_INDEX+4)+"\n");
+        buffer.append("    ["+OFFSET_OPTION_FLAGS+"] FONT OPTIONS: "+intToHex(OFFSET_OPTION_FLAGS)+"\n");
+        buffer.append("    ["+OFFSET_ESCAPEMENT_TYPE_MODIFIED+"] FONT ESC MOD: "+intToHex(OFFSET_ESCAPEMENT_TYPE_MODIFIED)+"\n");
+        buffer.append("    ["+OFFSET_UNDERLINE_TYPE_MODIFIED+"] FONT UND MOD: "+intToHex(OFFSET_UNDERLINE_TYPE_MODIFIED)+"\n");
+        buffer.append("    ["+OFFSET_FONT_WEIGHT+"] FONT WGH MOD: "+intToHex(OFFSET_FONT_WEIGHT)+"\n");
+        buffer.append("    ["+OFFSET_NOT_USED+"] FONT NOT USED: "+intToHex(OFFSET_NOT_USED)+"\n");
+        buffer.append("    ["+(OFFSET_NOT_USED+4)+"] FONT NOT USED: "+intToHex(OFFSET_NOT_USED+4)+"\n");
+        buffer.append("    ["+(OFFSET_NOT_USED+8)+"] FONT NOT USED: "+intToHex(OFFSET_NOT_USED+8)+"\n");
+        buffer.append("    ["+OFFSET_FONT_FORMATING_END+"] FONT FORMATTING END: "+shortToHex(OFFSET_FONT_FORMATING_END)+"\n");
+        buffer.append("    ====\n");
         
         buffer.append("    [/Font Formatting]\n");
         return buffer.toString();
     }
-    
+
     public Object clone() 
     {
       FontFormatting rec = new FontFormatting();
@@ -588,4 +588,18 @@
       }
       return rec;
     }
+
+	private String intToHex(int offset)
+	{
+		return Integer.toHexString(LittleEndian.getInt(record, offset));
+	}
+	private String shortToHex(int offset)
+	{
+		return Integer.toHexString(LittleEndian.getShort(record, offset)&0xFFFF);
+	}
+	private String byteToHex(int offset)
+	{
+		return Integer.toHexString(record[offset]&0xFF);
+	}
+	
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java?rev=645352&r1=645351&r2=645352&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java Sun Apr  6 20:23:04 2008
@@ -65,6 +65,11 @@
 		borderFormatting = new BorderFormatting();
 	}
 
+	protected HSSFBorderFormatting(BorderFormatting borderFormatting)
+	{
+		this.borderFormatting = borderFormatting;
+	}
+	
 	protected BorderFormatting getBorderFormattingBlock()
 	{
 		return borderFormatting;

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java?rev=645352&r1=645351&r2=645352&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java Sun Apr  6 20:23:04 2008
@@ -17,8 +17,6 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import java.util.List;
-
 import org.apache.poi.hssf.model.FormulaParser;
 import org.apache.poi.hssf.model.Workbook;
 import org.apache.poi.hssf.record.CFRuleRecord;
@@ -40,9 +38,6 @@
 public final class HSSFConditionalFormattingRule
 {
     private static final byte CELL_COMPARISON = CFRuleRecord.CONDITION_TYPE_CELL_VALUE_IS;
- 
-
-
 
 	private final CFRuleRecord cfRuleRecord;
 	private final Workbook workbook;
@@ -73,6 +68,19 @@
 		FontFormatting block = fontFmt==null ? null : fontFmt.getFontFormattingBlock();
 		cfRuleRecord.setFontFormatting(block);
 	}
+	
+	/**
+	 * @return - font formatting object  if defined,  <code>null</code> otherwise
+	 */
+	public HSSFFontFormatting getFontFormatting()
+	{
+		FontFormatting ff = cfRuleRecord.getFontFormatting();
+		if ( ff == null ) {
+			return null;
+		}
+		return new HSSFFontFormatting(ff);
+	}
+	
 	/**
 	 * @param borderFmt pass <code>null</code> to signify 'border unchanged'
 	 */
@@ -82,6 +90,17 @@
 		cfRuleRecord.setBorderFormatting(block);
 	}
 	/**
+	 * @return - border formatting object  if defined,  <code>null</code> otherwise
+	 */
+	public HSSFBorderFormatting getBorderFormatting()
+	{
+		BorderFormatting bf = cfRuleRecord.getBorderFormatting();
+		if ( bf == null ) {
+			return null;
+		}
+		return new HSSFBorderFormatting(bf);
+	}
+	/**
 	 * @param patternFmt pass <code>null</code> to signify 'pattern unchanged'
 	 */
 	public void setPatternFormatting(HSSFPatternFormatting patternFmt)
@@ -89,6 +108,17 @@
 		PatternFormatting block = patternFmt==null ? null : patternFmt.getPatternFormattingBlock();
 		cfRuleRecord.setPatternFormatting(block);
 	}
+	/**
+	 * @return - pattern formatting object  if defined, <code>null</code> otherwise
+	 */
+	public HSSFPatternFormatting getPatternFormatting()
+	{
+		PatternFormatting pf = cfRuleRecord.getPatternFormatting();
+		if ( pf == null ) {
+			return null;
+		}
+		return new HSSFPatternFormatting(pf);
+	}
 	
 	public String getFormula1()
 	{
@@ -112,11 +142,9 @@
 
 	private String toFormulaString(Ptg[] parsedExpression)
 	{
-		String formula = null;
-		if(parsedExpression!=null)
-		{
-		formula = FormulaParser.toFormulaString(workbook, parsedExpression);
+		if(parsedExpression ==null) {
+			return null;
 		}
-		return formula;
+		return FormulaParser.toFormulaString(workbook, parsedExpression);
 	}
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java?rev=645352&r1=645351&r2=645352&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java Sun Apr  6 20:23:04 2008
@@ -25,64 +25,51 @@
  * @author Dmitriy Kumshayev
  *
  */
-public class HSSFFontFormatting
+public final class HSSFFontFormatting
 {
-    /**
-     * Escapement type - None
-     */
-    public final static short     SS_NONE             = FontFormatting.SS_NONE;
+	/** Escapement type - None */
+	public final static short SS_NONE  = FontFormatting.SS_NONE;
+	/** Escapement type - Superscript */
+	public final static short SS_SUPER = FontFormatting.SS_SUPER;
+	/** Escapement type - Subscript */
+	public final static short SS_SUB   = FontFormatting.SS_SUB;
     
-    /**
-     * Escapement type - Superscript
-     */
-    public final static short     SS_SUPER            = FontFormatting.SS_SUPER;
+	/** Underline type - None */ 
+	public final static byte U_NONE              = FontFormatting.U_NONE;
+    /** Underline type - Single */ 
+	public final static byte U_SINGLE            = FontFormatting.U_SINGLE;
+    /** Underline type - Double */ 
+	public final static byte U_DOUBLE            = FontFormatting.U_DOUBLE;
+	/**  Underline type - Single Accounting */ 
+	public final static byte U_SINGLE_ACCOUNTING = FontFormatting.U_SINGLE_ACCOUNTING;
+    /** Underline type - Double Accounting */ 
+	public final static byte U_DOUBLE_ACCOUNTING = FontFormatting.U_DOUBLE_ACCOUNTING;
     
-    /**
-     * Escapement type - Subscript
-     */
-    public final static short     SS_SUB              = FontFormatting.SS_SUB;
-    
-    /**
-     *  Underline type - None
-     */ 
-    public final static byte      U_NONE              = FontFormatting.U_NONE;
-    /**
-     *  Underline type - Single
-     */ 
-    public final static byte      U_SINGLE            = FontFormatting.U_SINGLE;
-    /**
-     *  Underline type - Double
-     */ 
-    public final static byte      U_DOUBLE            = FontFormatting.U_DOUBLE;
-    /**
-     *  Underline type - Single Accounting
-     */ 
-    public final static byte      U_SINGLE_ACCOUNTING = FontFormatting.U_SINGLE_ACCOUNTING;
-    /**
-     *  Underline type - Double Accounting
-     */ 
-    public final static byte      U_DOUBLE_ACCOUNTING = FontFormatting.U_DOUBLE_ACCOUNTING;
-    
-	private FontFormatting fontFormatting;
+	private final FontFormatting fontFormatting;
 	
 	public HSSFFontFormatting()
 	{
 		fontFormatting = new FontFormatting();
 	}
 
+	protected HSSFFontFormatting(FontFormatting ff)
+	{
+		fontFormatting = ff;
+	}
+	
 	protected FontFormatting getFontFormattingBlock()
 	{
 		return fontFormatting;
 	}
 
-    /**
-     * get the type of super or subscript for the font
-     *
-     * @return super or subscript option
-     * @see #SS_NONE
-     * @see #SS_SUPER
-     * @see #SS_SUB
-     */
+	/**
+	 * get the type of super or subscript for the font
+	 *
+	 * @return super or subscript option
+	 * @see #SS_NONE
+	 * @see #SS_SUPER
+	 * @see #SS_SUB
+	 */
 	public short getEscapementType()
 	{
 		return fontFormatting.getEscapementType();
@@ -96,22 +83,22 @@
 		return fontFormatting.getFontColorIndex();
 	}
 
-    /**
-     * gets the height of the font in 1/20th point units
-     *
-     * @return fontheight (in points/20); or -1 if not modified
-     */
+	/**
+	 * gets the height of the font in 1/20th point units
+	 *
+	 * @return fontheight (in points/20); or -1 if not modified
+	 */
 	public short getFontHeight()
 	{
 		return fontFormatting.getFontHeight();
 	}
 
-    /**
-     * get the font weight for this font (100-1000dec or 0x64-0x3e8).  Default is
-     * 0x190 for normal and 0x2bc for bold
-     *
-     * @return bw - a number between 100-1000 for the fonts "boldness"
-     */
+	/**
+	 * get the font weight for this font (100-1000dec or 0x64-0x3e8).  Default is
+	 * 0x190 for normal and 0x2bc for bold
+	 *
+	 * @return bw - a number between 100-1000 for the fonts "boldness"
+	 */
 
 	public short getFontWeight()
 	{
@@ -127,38 +114,30 @@
 		return fontFormatting.getRawRecord();
 	}
 
-    /**
-     * get the type of underlining for the font
-     *
-     * @return font underlining type
-     *
-     * @see #U_NONE
-     * @see #U_SINGLE
-     * @see #U_DOUBLE
-     * @see #U_SINGLE_ACCOUNTING
-     * @see #U_DOUBLE_ACCOUNTING
-     */
+	/**
+	 * get the type of underlining for the font
+	 *
+	 * @return font underlining type
+	 *
+	 * @see #U_NONE
+	 * @see #U_SINGLE
+	 * @see #U_DOUBLE
+	 * @see #U_SINGLE_ACCOUNTING
+	 * @see #U_DOUBLE_ACCOUNTING
+	 */
 	public short getUnderlineType()
 	{
 		return fontFormatting.getUnderlineType();
 	}
 
-    /**
-     * get whether the font weight is set to bold or not
-     *
-     * @return bold - whether the font is bold or not
-     */
-	public boolean isBold()
-	{
-		return fontFormatting.isBold();
-	}
-
 	/**
-	 * @return  whether the font is condense or not
+	 * get whether the font weight is set to bold or not
+	 *
+	 * @return bold - whether the font is bold or not
 	 */
-	public boolean isCondenseOn()
+	public boolean isBold()
 	{
-		return fontFormatting.isFontOutlineModified() && fontFormatting.isCondenseOn();
+		return fontFormatting.isFontWeightModified() && fontFormatting.isBold();
 	}
 
 	/**
@@ -178,14 +157,6 @@
 	}
 
 	/**
-	 * @return true if font condense type was modified from default   
-	 */
-	public boolean isFontCondenseModified()
-	{
-		return fontFormatting.isFontCondenseModified();
-	}
-
-	/**
 	 * @return true if font outline type was modified from default   
 	 */
 	public boolean isFontOutlineModified()
@@ -249,66 +220,61 @@
 		return fontFormatting.isUnderlineTypeModified();
 	}
 
-    /**
-     * set font style options.
-     * 
-     * @param italic - if true, set posture style to italic, otherwise to normal 
-     * @param bold- if true, set font weight to bold, otherwise to normal
-     */
+	/**
+	 * @return true if font weight was modified from default   
+	 */
+	public boolean isFontWeightModified()
+	{
+		return fontFormatting.isFontWeightModified();
+	}
+
+	/**
+	 * set font style options.
+	 * 
+	 * @param italic - if true, set posture style to italic, otherwise to normal 
+	 * @param bold- if true, set font weight to bold, otherwise to normal
+	 */
 	
 	public void setFontStyle(boolean italic, boolean bold)
 	{
-    	boolean modified = italic || bold;
-    	fontFormatting.setItalic(italic);
-    	fontFormatting.setBold(bold);
-    	fontFormatting.setFontStyleModified(modified);
+		boolean modified = italic || bold;
+		fontFormatting.setItalic(italic);
+		fontFormatting.setBold(bold);
+		fontFormatting.setFontStyleModified(modified);
+		fontFormatting.setFontWieghtModified(modified);
 	}
 
-    /**
-     * set font style options to default values (non-italic, non-bold)
-     */
+	/**
+	 * set font style options to default values (non-italic, non-bold)
+	 */
 	public void resetFontStyle()
 	{
 		setFontStyle(false,false);
 	}
 
-    /**
-     * set the escapement type for the font
-     *
-     * @param escapementType  super or subscript option
-     * @see #SS_NONE
-     * @see #SS_SUPER
-     * @see #SS_SUB
-     */
-	public void setCondense(boolean on)
-	{
-		fontFormatting.setCondense(on);
-		fontFormatting.setFontCondenseModified(on);
-	}
-
-    /**
-     * set the escapement type for the font
-     *
-     * @param escapementType  super or subscript option
-     * @see #SS_NONE
-     * @see #SS_SUPER
-     * @see #SS_SUB
-     */
+	/**
+	 * set the escapement type for the font
+	 *
+	 * @param escapementType  super or subscript option
+	 * @see #SS_NONE
+	 * @see #SS_SUPER
+	 * @see #SS_SUB
+	 */
 	public void setEscapementType(short escapementType)
 	{
-    	switch(escapementType)
-    	{
-    		case HSSFFontFormatting.SS_SUB:
-    		case HSSFFontFormatting.SS_SUPER:
-    			fontFormatting.setEscapementType(escapementType);
-    			fontFormatting.setEscapementTypeModified(true);
-    	    	break;
-    		case HSSFFontFormatting.SS_NONE:
-    			fontFormatting.setEscapementType(escapementType);
-    			fontFormatting.setEscapementTypeModified(false);
-    	    	break;
-    		default:
-    	}
+		switch(escapementType)
+		{
+			case HSSFFontFormatting.SS_SUB:
+			case HSSFFontFormatting.SS_SUPER:
+				fontFormatting.setEscapementType(escapementType);
+				fontFormatting.setEscapementTypeModified(true);
+				break;
+			case HSSFFontFormatting.SS_NONE:
+				fontFormatting.setEscapementType(escapementType);
+				fontFormatting.setEscapementTypeModified(false);
+				break;
+			default:
+		}
 	}
 
 	/**
@@ -339,15 +305,6 @@
 	}
 
 	/**
-	 * @param modified
-	 * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontCondenseModified(boolean)
-	 */
-	public void setFontCondenseModified(boolean modified)
-	{
-		fontFormatting.setFontCondenseModified(modified);
-	}
-
-	/**
 	 * @param height
 	 * @see org.apache.poi.hssf.record.cf.FontFormatting#setFontHeight(short)
 	 */
@@ -413,35 +370,35 @@
 		fontFormatting.setFontCancellationModified(strike);
 	}
 
-    /**
-     * set the type of underlining type for the font
-     *
-     * @param u  super or subscript option
-     *
-     * @see #U_NONE
-     * @see #U_SINGLE
-     * @see #U_DOUBLE
-     * @see #U_SINGLE_ACCOUNTING
-     * @see #U_DOUBLE_ACCOUNTING
-     */
+	/**
+	 * set the type of underlining type for the font
+	 *
+	 * @param u  super or subscript option
+	 *
+	 * @see #U_NONE
+	 * @see #U_SINGLE
+	 * @see #U_DOUBLE
+	 * @see #U_SINGLE_ACCOUNTING
+	 * @see #U_DOUBLE_ACCOUNTING
+	 */
 	public void setUnderlineType(short underlineType)
 	{
-    	switch(underlineType)
-    	{
-    		case HSSFFontFormatting.U_SINGLE:
-    		case HSSFFontFormatting.U_DOUBLE:
-    		case HSSFFontFormatting.U_SINGLE_ACCOUNTING:
-    		case HSSFFontFormatting.U_DOUBLE_ACCOUNTING:
-    			fontFormatting.setUnderlineType(underlineType);
-    	    	setUnderlineTypeModified(true);
-    	    	break;
-    			
-    		case HSSFFontFormatting.U_NONE:
-    			fontFormatting.setUnderlineType(underlineType);
-    	    	setUnderlineTypeModified(false);
-    	    	break;
-    	    default:
-    	}
+		switch(underlineType)
+		{
+			case HSSFFontFormatting.U_SINGLE:
+			case HSSFFontFormatting.U_DOUBLE:
+			case HSSFFontFormatting.U_SINGLE_ACCOUNTING:
+			case HSSFFontFormatting.U_DOUBLE_ACCOUNTING:
+				fontFormatting.setUnderlineType(underlineType);
+				setUnderlineTypeModified(true);
+				break;
+				
+			case HSSFFontFormatting.U_NONE:
+				fontFormatting.setUnderlineType(underlineType);
+				setUnderlineTypeModified(false);
+				break;
+			default:
+		}
 	}
 
 	/**
@@ -452,5 +409,4 @@
 	{
 		fontFormatting.setUnderlineTypeModified(modified);
 	}
-	
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java?rev=645352&r1=645351&r2=645352&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java Sun Apr  6 20:23:04 2008
@@ -27,50 +27,54 @@
  */
 public class HSSFPatternFormatting
 {
-    /**  No background */
-    public final static short NO_FILL 				=  PatternFormatting.NO_FILL;
-    /**  Solidly filled */
-    public final static short SOLID_FOREGROUND 		=  PatternFormatting.SOLID_FOREGROUND;
-    /**  Small fine dots */
-    public final static short FINE_DOTS 			=  PatternFormatting.FINE_DOTS;
-    /**  Wide dots */
-    public final static short ALT_BARS 				=  PatternFormatting.ALT_BARS;
-    /**  Sparse dots */
-    public final static short SPARSE_DOTS 			=  PatternFormatting.SPARSE_DOTS;
-    /**  Thick horizontal bands */
-    public final static short THICK_HORZ_BANDS 		=  PatternFormatting.THICK_HORZ_BANDS;
-    /**  Thick vertical bands */
-    public final static short THICK_VERT_BANDS 		=  PatternFormatting.THICK_VERT_BANDS;
-    /**  Thick backward facing diagonals */
-    public final static short THICK_BACKWARD_DIAG 	=  PatternFormatting.THICK_BACKWARD_DIAG;
-    /**  Thick forward facing diagonals */
-    public final static short THICK_FORWARD_DIAG 	=  PatternFormatting.THICK_FORWARD_DIAG;
-    /**  Large spots */
-    public final static short BIG_SPOTS 			=  PatternFormatting.BIG_SPOTS;
-    /**  Brick-like layout */
-    public final static short BRICKS 				=  PatternFormatting.BRICKS;
-    /**  Thin horizontal bands */
-    public final static short THIN_HORZ_BANDS 		=  PatternFormatting.THIN_HORZ_BANDS;
-    /**  Thin vertical bands */
-    public final static short THIN_VERT_BANDS 		=  PatternFormatting.THIN_VERT_BANDS;
-    /**  Thin backward diagonal */
-    public final static short THIN_BACKWARD_DIAG 	=  PatternFormatting.THIN_BACKWARD_DIAG;
-    /**  Thin forward diagonal */
-    public final static short THIN_FORWARD_DIAG 	=  PatternFormatting.THIN_FORWARD_DIAG;
-    /**  Squares */
-    public final static short SQUARES 				=  PatternFormatting.SQUARES;
-    /**  Diamonds */
-    public final static short DIAMONDS 				=  PatternFormatting.DIAMONDS;
-    /**  Less Dots */
-    public final static short LESS_DOTS 			=  PatternFormatting.LESS_DOTS;
-    /**  Least Dots */
-    public final static short LEAST_DOTS 			=  PatternFormatting.LEAST_DOTS;
+	/**  No background */
+	public final static short NO_FILL 				=  PatternFormatting.NO_FILL;
+	/**  Solidly filled */
+	public final static short SOLID_FOREGROUND 		=  PatternFormatting.SOLID_FOREGROUND;
+	/**  Small fine dots */
+	public final static short FINE_DOTS 			=  PatternFormatting.FINE_DOTS;
+	/**  Wide dots */
+	public final static short ALT_BARS 				=  PatternFormatting.ALT_BARS;
+	/**  Sparse dots */
+	public final static short SPARSE_DOTS 			=  PatternFormatting.SPARSE_DOTS;
+	/**  Thick horizontal bands */
+	public final static short THICK_HORZ_BANDS 		=  PatternFormatting.THICK_HORZ_BANDS;
+	/**  Thick vertical bands */
+	public final static short THICK_VERT_BANDS 		=  PatternFormatting.THICK_VERT_BANDS;
+	/**  Thick backward facing diagonals */
+	public final static short THICK_BACKWARD_DIAG 	=  PatternFormatting.THICK_BACKWARD_DIAG;
+	/**  Thick forward facing diagonals */
+	public final static short THICK_FORWARD_DIAG 	=  PatternFormatting.THICK_FORWARD_DIAG;
+	/**  Large spots */
+	public final static short BIG_SPOTS 			=  PatternFormatting.BIG_SPOTS;
+	/**  Brick-like layout */
+	public final static short BRICKS 				=  PatternFormatting.BRICKS;
+	/**  Thin horizontal bands */
+	public final static short THIN_HORZ_BANDS 		=  PatternFormatting.THIN_HORZ_BANDS;
+	/**  Thin vertical bands */
+	public final static short THIN_VERT_BANDS 		=  PatternFormatting.THIN_VERT_BANDS;
+	/**  Thin backward diagonal */
+	public final static short THIN_BACKWARD_DIAG 	=  PatternFormatting.THIN_BACKWARD_DIAG;
+	/**  Thin forward diagonal */
+	public final static short THIN_FORWARD_DIAG 	=  PatternFormatting.THIN_FORWARD_DIAG;
+	/**  Squares */
+	public final static short SQUARES 				=  PatternFormatting.SQUARES;
+	/**  Diamonds */
+	public final static short DIAMONDS 				=  PatternFormatting.DIAMONDS;
+	/**  Less Dots */
+	public final static short LESS_DOTS 			=  PatternFormatting.LESS_DOTS;
+	/**  Least Dots */
+	public final static short LEAST_DOTS 			=  PatternFormatting.LEAST_DOTS;
 
 	private PatternFormatting patternFormatting;
 	
 	public HSSFPatternFormatting()
 	{
 		patternFormatting = new PatternFormatting();
+	}
+	protected HSSFPatternFormatting(PatternFormatting patternFormatting)
+	{
+		this.patternFormatting = patternFormatting;
 	}
 
 	protected PatternFormatting getPatternFormattingBlock()

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java?rev=645352&r1=645351&r2=645352&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java Sun Apr  6 20:23:04 2008
@@ -182,14 +182,13 @@
 		// Check for defaults
 		assertFalse(fontFormatting.isEscapementTypeModified());
 		assertFalse(fontFormatting.isFontCancellationModified());
-		assertFalse(fontFormatting.isFontCondenseModified());
 		assertFalse(fontFormatting.isFontOutlineModified());
 		assertFalse(fontFormatting.isFontShadowModified());
 		assertFalse(fontFormatting.isFontStyleModified());
 		assertFalse(fontFormatting.isUnderlineTypeModified());
+		assertFalse(fontFormatting.isFontWeightModified());
 
 		assertFalse(fontFormatting.isBold());
-		assertFalse(fontFormatting.isCondenseOn());
 		assertFalse(fontFormatting.isItalic());
 		assertFalse(fontFormatting.isOutlineOn());
 		assertFalse(fontFormatting.isShadowOn());
@@ -198,7 +197,7 @@
 		assertEquals(0, fontFormatting.getEscapementType());
 		assertEquals(-1, fontFormatting.getFontColorIndex());
 		assertEquals(-1, fontFormatting.getFontHeight());
-		assertEquals(400, fontFormatting.getFontWeight());
+		assertEquals(0, fontFormatting.getFontWeight());
 		assertEquals(0, fontFormatting.getUnderlineType());
 
 		fontFormatting.setBold(true);
@@ -206,11 +205,6 @@
 		fontFormatting.setBold(false);
 		assertFalse(fontFormatting.isBold());
 
-		fontFormatting.setCondense(true);
-		assertTrue(fontFormatting.isCondenseOn());
-		fontFormatting.setCondense(false);
-		assertFalse(fontFormatting.isCondenseOn());
-
 		fontFormatting.setEscapementType(FontFormatting.SS_SUB);
 		assertEquals(FontFormatting.SS_SUB, fontFormatting.getEscapementType());
 		fontFormatting.setEscapementType(FontFormatting.SS_SUPER);
@@ -223,6 +217,11 @@
 		fontFormatting.setEscapementTypeModified(true);
 		assertTrue(fontFormatting.isEscapementTypeModified());
 
+		fontFormatting.setFontWieghtModified(false);
+		assertFalse(fontFormatting.isFontWeightModified());
+		fontFormatting.setFontWieghtModified(true);
+		assertTrue(fontFormatting.isFontWeightModified());
+
 		fontFormatting.setFontCancellationModified(false);
 		assertFalse(fontFormatting.isFontCancellationModified());
 		fontFormatting.setFontCancellationModified(true);
@@ -230,11 +229,6 @@
 
 		fontFormatting.setFontColorIndex((short)10);
 		assertEquals(10,fontFormatting.getFontColorIndex());
-
-		fontFormatting.setFontCondenseModified(false);
-		assertFalse(fontFormatting.isFontCondenseModified());
-		fontFormatting.setFontCondenseModified(true);
-		assertTrue(fontFormatting.isFontCondenseModified());
 
 		fontFormatting.setFontHeight((short)100);
 		assertEquals(100,fontFormatting.getFontHeight());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java?rev=645352&r1=645351&r2=645352&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java Sun Apr  6 20:23:04 2008
@@ -28,7 +28,7 @@
  */
 public final class TestHSSFConditionalFormatting extends TestCase
 {
-	public void testLastAndFirstColumns() 
+	public void testCreateCF() 
 	{
 		HSSFWorkbook workbook = new HSSFWorkbook();
 		HSSFSheet sheet = workbook.createSheet();
@@ -82,9 +82,27 @@
 		HSSFConditionalFormattingRule rule1 = cf.getRule(0);
 		assertEquals("7",rule1.getFormula1()); 
 		assertNull(rule1.getFormula2());
+		
+		HSSFFontFormatting    r1fp = rule1.getFontFormatting();
+		assertNotNull(r1fp);
+		
+		assertTrue(r1fp.isItalic());
+		assertFalse(r1fp.isBold());
+
+		HSSFBorderFormatting  r1bf = rule1.getBorderFormatting();
+		assertNotNull(r1bf);
+		assertEquals(HSSFBorderFormatting.BORDER_THIN, r1bf.getBorderBottom());
+		assertEquals(HSSFBorderFormatting.BORDER_THICK,r1bf.getBorderTop());
+		assertEquals(HSSFBorderFormatting.BORDER_DASHED,r1bf.getBorderLeft());
+		assertEquals(HSSFBorderFormatting.BORDER_DOTTED,r1bf.getBorderRight());
+
+		HSSFPatternFormatting r1pf = rule1.getPatternFormatting();
+		assertNotNull(r1pf);
+		assertEquals(HSSFColor.RED.index,r1pf.getFillBackgroundColor());		
 
 		HSSFConditionalFormattingRule rule2 = cf.getRule(1);
 		assertEquals("2",rule2.getFormula2()); 
 		assertEquals("1",rule2.getFormula1()); 
 	}
+	
 }



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