aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2008-04-07 12:51:50 +0000
committerNick Burch <nick@apache.org>2008-04-07 12:51:50 +0000
commitcbecd918ab99c788d6208e75736b39c066b39cc0 (patch)
treebc09f0da599d2fb98a19fd5706c9c66939c24b25 /src/java
parent559508b7e0e1a9eb30fe129ed094b9771f1f9f68 (diff)
downloadpoi-cbecd918ab99c788d6208e75736b39c066b39cc0.tar.gz
poi-cbecd918ab99c788d6208e75736b39c066b39cc0.zip
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645478 via svnmerge from
https://svn.apache.org:443/repos/asf/poi/trunk ........ r645348 | josh | 2008-04-07 04:02:03 +0100 (Mon, 07 Apr 2008) | 1 line refactored all hssf junits to get test sample data in the in one place ........ r645352 | josh | 2008-04-07 04:23:04 +0100 (Mon, 07 Apr 2008) | 2 lines 30311 - More work on Conditional Formatting - patch from Dmitriy ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@645483 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/hssf/record/CFRuleRecord.java40
-rw-r--r--src/java/org/apache/poi/hssf/record/cf/FontFormatting.java92
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java5
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java48
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java300
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java80
-rw-r--r--src/java/org/apache/poi/util/HexRead.java15
7 files changed, 308 insertions, 272 deletions
diff --git a/src/java/org/apache/poi/hssf/record/CFRuleRecord.java b/src/java/org/apache/poi/hssf/record/CFRuleRecord.java
index 43da6260ac..0890f1f32d 100644
--- a/src/java/org/apache/poi/hssf/record/CFRuleRecord.java
+++ b/src/java/org/apache/poi/hssf/record/CFRuleRecord.java
@@ -238,6 +238,17 @@ public final class CFRuleRecord extends Record
this.fontFormatting = fontFormatting;
setOptionFlag(fontFormatting != null, font);
}
+ public FontFormatting getFontFormatting()
+ {
+ if( containsFontFormattingBlock())
+ {
+ return fontFormatting;
+ }
+ else
+ {
+ return null;
+ }
+ }
public boolean containsAlignFormattingBlock()
{
@@ -257,6 +268,17 @@ public final class CFRuleRecord extends Record
this.borderFormatting = borderFormatting;
setOptionFlag(borderFormatting != null, bord);
}
+ public BorderFormatting getBorderFormatting()
+ {
+ if( containsBorderFormattingBlock())
+ {
+ return borderFormatting;
+ }
+ else
+ {
+ return null;
+ }
+ }
public boolean containsPatternFormattingBlock()
{
@@ -267,7 +289,17 @@ public final class CFRuleRecord extends Record
this.patternFormatting = patternFormatting;
setOptionFlag(patternFormatting!=null, patt);
}
-
+ public PatternFormatting getPatternFormatting()
+ {
+ if( containsPatternFormattingBlock())
+ {
+ return patternFormatting;
+ }
+ else
+ {
+ return null;
+ }
+ }
public boolean containsProtectionFormattingBlock()
{
@@ -616,12 +648,6 @@ public final class CFRuleRecord extends Record
return rec;
}
- public FontFormatting getFontFormatting()
- {
- return fontFormatting;
- }
-
-
/**
* @return <code>null</code> if <tt>formula</tt> was null.
*/
diff --git a/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java b/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java
index 1e6abee7c9..eaae02de30 100644
--- a/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java
+++ b/src/java/org/apache/poi/hssf/record/cf/FontFormatting.java
@@ -45,8 +45,8 @@ public class FontFormatting
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 @@ public class FontFormatting
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 @@ public class FontFormatting
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 @@ public class FontFormatting
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 @@ public class FontFormatting
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 @@ public class FontFormatting
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 @@ public class FontFormatting
return getOptionFlag(styleModified);
}
+
public void setFontStyleModified(boolean modified)
{
setOptionFlag(modified, styleModified);
@@ -444,16 +430,6 @@ public class FontFormatting
{
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 @@ public class FontFormatting
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 @@ public class FontFormatting
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 @@ public class FontFormatting
{
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 @@ public class FontFormatting
}
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 @@ public class FontFormatting
}
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);
+ }
+
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java b/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java
index 408c774b62..ba2d587624 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFBorderFormatting.java
@@ -65,6 +65,11 @@ public final class HSSFBorderFormatting
borderFormatting = new BorderFormatting();
}
+ protected HSSFBorderFormatting(BorderFormatting borderFormatting)
+ {
+ this.borderFormatting = borderFormatting;
+ }
+
protected BorderFormatting getBorderFormattingBlock()
{
return borderFormatting;
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java b/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java
index 8f220fdf6e..490ff4d342 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormattingRule.java
@@ -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 @@ import org.apache.poi.hssf.record.formula.Ptg;
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 @@ public final class HSSFConditionalFormattingRule
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 @@ public final class HSSFConditionalFormattingRule
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 @@ public final class HSSFConditionalFormattingRule
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 @@ public final class HSSFConditionalFormattingRule
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);
}
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java b/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java
index ee1352fc8c..12ea90698f 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFFontFormatting.java
@@ -25,64 +25,51 @@ import org.apache.poi.hssf.record.cf.FontFormatting;
* @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 @@ public class HSSFFontFormatting
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 @@ public class HSSFFontFormatting
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 @@ public class HSSFFontFormatting
}
/**
- * @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 @@ public class HSSFFontFormatting
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 @@ public class HSSFFontFormatting
}
/**
- * @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 @@ public class HSSFFontFormatting
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 @@ public class HSSFFontFormatting
{
fontFormatting.setUnderlineTypeModified(modified);
}
-
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java
index 352a5b4872..b94d19601a 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPatternFormatting.java
@@ -27,44 +27,44 @@ import org.apache.poi.hssf.record.cf.PatternFormatting;
*/
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;
@@ -72,6 +72,10 @@ public class HSSFPatternFormatting
{
patternFormatting = new PatternFormatting();
}
+ protected HSSFPatternFormatting(PatternFormatting patternFormatting)
+ {
+ this.patternFormatting = patternFormatting;
+ }
protected PatternFormatting getPatternFormattingBlock()
{
diff --git a/src/java/org/apache/poi/util/HexRead.java b/src/java/org/apache/poi/util/HexRead.java
index 868258d01a..cd11ccc640 100644
--- a/src/java/org/apache/poi/util/HexRead.java
+++ b/src/java/org/apache/poi/util/HexRead.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.util;
@@ -25,6 +23,7 @@ import java.util.ArrayList;
/**
* Utilities to read hex from files.
+ * TODO - move to test packages
*
* @author Marc Johnson
* @author Glen Stampoultzis (glens at apache.org)
@@ -62,10 +61,8 @@ public class HexRead
*
* @see #readData(String)
*/
- public static byte[] readData( String filename, String section ) throws IOException
- {
- File file = new File( filename );
- FileInputStream stream = new FileInputStream( file );
+ public static byte[] readData(InputStream stream, String section ) throws IOException {
+
try
{
StringBuffer sectionText = new StringBuffer();
@@ -100,6 +97,12 @@ public class HexRead
}
throw new IOException( "Section '" + section + "' not found" );
}
+ public static byte[] readData( String filename, String section ) throws IOException
+ {
+ File file = new File( filename );
+ FileInputStream stream = new FileInputStream( file );
+ return readData(stream, section);
+ }
static public byte[] readData( InputStream stream, int eofChar )
throws IOException