public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((font == null) ? 0 : font.hashCode()); result = prime * result + index; return result; }
public String toString() { StringBuffer sb = new StringBuffer(); sb.append("[FONT]\n"); sb.append(" .fontheight = ").append(HexDump.shortToHex(getFontHeight())).append("\n"); sb.append(" .attributes = ").append(HexDump.shortToHex(getAttributes())).append("\n"); sb.append(" .italic = ").append(isItalic()).append("\n"); sb.append(" .strikout = ").append(isStruckout()).append("\n"); sb.append(" .macoutlined= ").append(isMacoutlined()).append("\n"); sb.append(" .macshadowed= ").append(isMacshadowed()).append("\n"); sb.append(" .colorpalette = ").append(HexDump.shortToHex(getColorPaletteIndex())).append("\n"); sb.append(" .boldweight = ").append(HexDump.shortToHex(getBoldWeight())).append("\n"); sb.append(" .supersubscript= ").append(HexDump.shortToHex(getSuperSubScript())).append("\n"); sb.append(" .underline = ").append(HexDump.byteToHex(getUnderline())).append("\n"); sb.append(" .family = ").append(HexDump.byteToHex(getFamily())).append("\n"); sb.append(" .charset = ").append(HexDump.byteToHex(getCharset())).append("\n"); sb.append(" .fontname = ").append(getFontName()).append("\n"); sb.append("[/FONT]\n"); return sb.toString(); }
/** * creates a Font record with the following magic values: <P> * fontheight = 0xc8<P> * attributes = 0x0<P> * color palette index = 0x7fff<P> * bold weight = 0x190<P> * Font Name Length = 5 <P> * Font Name = Arial <P> */ private static FontRecord createFont() { FontRecord retval = new FontRecord(); retval.setFontHeight(( short ) 0xc8); retval.setAttributes(( short ) 0x0); retval.setColorPaletteIndex(( short ) 0x7fff); retval.setBoldWeight(( short ) 0x190); retval.setFontName("Arial"); return retval; }
public void serialize(LittleEndianOutput out) { out.writeShort(getFontHeight()); out.writeShort(getAttributes()); out.writeShort(getColorPaletteIndex()); out.writeShort(getBoldWeight()); out.writeShort(getSuperSubScript()); out.writeByte(getUnderline()); out.writeByte(getFamily()); out.writeByte(getCharset()); out.writeByte(field_9_zero); int fontNameLen = field_11_font_name.length(); out.writeByte(fontNameLen); boolean hasMultibyte = StringUtil.hasMultibyte(field_11_font_name); out.writeByte(hasMultibyte ? 0x01 : 0x00); if (fontNameLen > 0) { if (hasMultibyte) { StringUtil.putUnicodeLE(field_11_font_name, out); } else { StringUtil.putCompressedUnicode(field_11_font_name, out); } } } protected int getDataSize() {
public void cloneStyleFrom(HSSFCellStyle source) { // First we need to clone the extended format // record _format.cloneStyleFrom(source._format); // Handle matching things if we cross workbooks if(_workbook != source._workbook) { lastDateFormat.set(Short.MIN_VALUE); lastFormats.set(null); getDataFormatStringCache.set(null); // Then we need to clone the format string, // and update the format record for this short fmt = (short)_workbook.createFormat(source.getDataFormatString() ); setDataFormat(fmt); // Finally we need to clone the font, // and update the format record for this FontRecord fr = _workbook.createNewFont(); fr.cloneStyleFrom( source._workbook.getFontRecordAt( source.getFontIndexAsInt() ) ); HSSFFont font = new HSSFFont( (short)_workbook.getFontIndex(fr), fr ); setFont(font); } }
/** * get the font height in unit's of 1/20th of a point. Maybe you might want to * use the getFontHeightInPoints which matches to the familiar 10, 12, 14 etc.. * @return short - height in 1/20ths of a point * @see #getFontHeightInPoints() */ public short getFontHeight() { return font.getFontHeight(); }
/** * get if the font is bold or not */ public boolean getBold() { return font.getBoldWeight() == BOLDWEIGHT_BOLD; }
/** * get whether to use italics or not * @return italics or not */ public boolean getItalic() { return font.isItalic(); }
/** * get the name for the font (i.e. Arial) * @return String representing the name of the font to use * @see #FONT_ARIAL */ public String getFontName() { return font.getFontName(); }
/** * get the color for the font * @return color to use * @see #COLOR_NORMAL * @see #COLOR_RED * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) */ public short getColor() { return font.getColorPaletteIndex(); }
/** * get whether to use a strikeout horizontal line through the text or not * @return strikeout or not */ public boolean getStrikeout() { return font.isStruckout(); }
/** * get type of text underlining to use * @return underlining type * @see #U_NONE * @see #U_SINGLE * @see #U_DOUBLE * @see #U_SINGLE_ACCOUNTING * @see #U_DOUBLE_ACCOUNTING */ public byte getUnderline() { return font.getUnderline(); }
case FontBasisRecord.sid: return new FontBasisRecord(in); case FontIndexRecord.sid: return new FontIndexRecord(in); case FontRecord.sid: return new FontRecord(in); case FooterRecord.sid: return new FooterRecord(in); case FormatRecord.sid: return new FormatRecord(in);
public void serialize(LittleEndianOutput out) { out.writeShort(getFontHeight()); out.writeShort(getAttributes()); out.writeShort(getColorPaletteIndex()); out.writeShort(getBoldWeight()); out.writeShort(getSuperSubScript()); out.writeByte(getUnderline()); out.writeByte(getFamily()); out.writeByte(getCharset()); out.writeByte(field_9_zero); int fontNameLen = field_11_font_name.length(); out.writeByte(fontNameLen); boolean hasMultibyte = StringUtil.hasMultibyte(field_11_font_name); out.writeByte(hasMultibyte ? 0x01 : 0x00); if (fontNameLen > 0) { if (hasMultibyte) { StringUtil.putUnicodeLE(field_11_font_name, out); } else { StringUtil.putCompressedUnicode(field_11_font_name, out); } } } protected int getDataSize() {
public void cloneStyleFrom(HSSFCellStyle source) { // First we need to clone the extended format // record _format.cloneStyleFrom(source._format); // Handle matching things if we cross workbooks if(_workbook != source._workbook) { lastDateFormat.set(Short.MIN_VALUE); lastFormats.set(null); getDataFormatStringCache.set(null); // Then we need to clone the format string, // and update the format record for this short fmt = (short)_workbook.createFormat(source.getDataFormatString() ); setDataFormat(fmt); // Finally we need to clone the font, // and update the format record for this FontRecord fr = _workbook.createNewFont(); fr.cloneStyleFrom( source._workbook.getFontRecordAt( source.getFontIndexAsInt() ) ); HSSFFont font = new HSSFFont( (short)_workbook.getFontIndex(fr), fr ); setFont(font); } }
/** * get the font height * @return short - height in the familiar unit of measure - points * @see #getFontHeight() */ public short getFontHeightInPoints() { return ( short ) (font.getFontHeight() / 20); }
/** * get if the font is bold or not */ public boolean getBold() { return font.getBoldWeight() == BOLDWEIGHT_BOLD; }
/** * get whether to use italics or not * @return italics or not */ public boolean getItalic() { return font.isItalic(); }
/** * get the name for the font (i.e. Arial) * @return String representing the name of the font to use * @see #FONT_ARIAL */ public String getFontName() { return font.getFontName(); }
/** * get the color for the font * @return color to use * @see #COLOR_NORMAL * @see #COLOR_RED * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) */ public short getColor() { return font.getColorPaletteIndex(); }