fontrecord.java

来自「EXCEL read and write」· Java 代码 · 共 602 行 · 第 1/2 页

JAVA
602
字号
     * @return italics - whether the font is italics or not     * @see #getAttributes()     */    public boolean isItalic()    {        return italic.isSet(field_2_attributes);    }    /**     * get whether the font is to be stricken out or not     *     * @return strike - whether the font is stricken out or not     * @see #getAttributes()     */    public boolean isStruckout()    {        return strikeout.isSet(field_2_attributes);    }    /**     * whether to use the mac outline font style thing (mac only) - Some mac person     * should comment this instead of me doing it (since I have no idea)     *     * @return mac - whether to do that mac font outline thing or not     * @see #getAttributes()     */    public boolean isMacoutlined()    {        return macoutline.isSet(field_2_attributes);    }    /**     * whether to use the mac shado font style thing (mac only) - Some mac person     * should comment this instead of me doing it (since I have no idea)     *     * @return mac - whether to do that mac font shadow thing or not     * @see #getAttributes()     */    public boolean isMacshadowed()    {        return macshadow.isSet(field_2_attributes);    }    /**     * get the font's color palette index     *     * @return cpi - font color index     */    public short getColorPaletteIndex()    {        return field_3_color_palette_index;    }    /**     * get the bold 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 getBoldWeight()    {        return field_4_bold_weight;    }    /**     * 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 getSuperSubScript()    {        return field_5_super_sub_script;    }    /**     * get the type of underlining for the font     *     * @return super or subscript option     *     * @see #U_NONE     * @see #U_SINGLE     * @see #U_DOUBLE     * @see #U_SINGLE_ACCOUNTING     * @see #U_DOUBLE_ACCOUNTING     */    public byte getUnderline()    {        return field_6_underline;    }    /**     * get the font family (TODO)     *     * @return family     */    public byte getFamily()    {        return field_7_family;    }    /**     * get the character set     *     * @return charset - characterset     */    public byte getCharset()    {        return field_8_charset;    }    /**     * get the length of the fontname string     *     * @return length of the font name     * @see #getFontName()     */    public byte getFontNameLength()    {        return field_10_font_name_len;    }    /**     * get the name of the font     *     * @return fn - name of the font (i.e. "Arial")     */    public String getFontName()    {        return field_11_font_name;    }    public String toString()    {        StringBuffer buffer = new StringBuffer();        buffer.append("[FONT]\n");        buffer.append("    .fontheight      = ")            .append(Integer.toHexString(getFontHeight())).append("\n");        buffer.append("    .attributes      = ")            .append(Integer.toHexString(getAttributes())).append("\n");        buffer.append("         .italic     = ").append(isItalic())            .append("\n");        buffer.append("         .strikout   = ").append(isStruckout())            .append("\n");        buffer.append("         .macoutlined= ").append(isMacoutlined())            .append("\n");        buffer.append("         .macshadowed= ").append(isMacshadowed())            .append("\n");        buffer.append("    .colorpalette    = ")            .append(Integer.toHexString(getColorPaletteIndex())).append("\n");        buffer.append("    .boldweight      = ")            .append(Integer.toHexString(getBoldWeight())).append("\n");        buffer.append("    .supersubscript  = ")            .append(Integer.toHexString(getSuperSubScript())).append("\n");        buffer.append("    .underline       = ")            .append(Integer.toHexString(getUnderline())).append("\n");        buffer.append("    .family          = ")            .append(Integer.toHexString(getFamily())).append("\n");        buffer.append("    .charset         = ")            .append(Integer.toHexString(getCharset())).append("\n");        buffer.append("    .namelength      = ")            .append(Integer.toHexString(getFontNameLength())).append("\n");        buffer.append("    .fontname        = ").append(getFontName())            .append("\n");        buffer.append("[/FONT]\n");        return buffer.toString();    }    public int serialize(int offset, byte [] data)    {        int realflen = getFontNameLength() * 2;        LittleEndian.putShort(data, 0 + offset, sid);        LittleEndian.putShort(            data, 2 + offset,            ( short ) (15 + realflen                       + 1));   // 19 - 4 (sid/len) + font name length = datasize        // undocumented single byte (1)        LittleEndian.putShort(data, 4 + offset, getFontHeight());        LittleEndian.putShort(data, 6 + offset, getAttributes());        LittleEndian.putShort(data, 8 + offset, getColorPaletteIndex());        LittleEndian.putShort(data, 10 + offset, getBoldWeight());        LittleEndian.putShort(data, 12 + offset, getSuperSubScript());        data[ 14 + offset ] = getUnderline();        data[ 15 + offset ] = getFamily();        data[ 16 + offset ] = getCharset();        data[ 17 + offset ] = field_9_zero;        data[ 18 + offset ] = getFontNameLength();        data[ 19 + offset ] = ( byte ) 1;        if (getFontName() != null) {           StringUtil.putUnicodeLE(getFontName(), data, 20 + offset);        }        return getRecordSize();    }    public int getRecordSize()    {    	// Note - no matter the original, we always    	//  re-serialise the font name as unicode        return (getFontNameLength() * 2) + 20;    }    public short getSid()    {        return sid;    }        /**     * Clones all the font style information from another     *  FontRecord, onto this one. This      *  will then hold all the same font style options.     */    public void cloneStyleFrom(FontRecord source) {        field_1_font_height         = source.field_1_font_height;         field_2_attributes          = source.field_2_attributes;        field_3_color_palette_index = source.field_3_color_palette_index;        field_4_bold_weight         = source.field_4_bold_weight;        field_5_super_sub_script    = source.field_5_super_sub_script;        field_6_underline           = source.field_6_underline;        field_7_family              = source.field_7_family;        field_8_charset             = source.field_8_charset;        field_9_zero                = source.field_9_zero;        field_10_font_name_len      = source.field_10_font_name_len;        field_11_font_name          = source.field_11_font_name;    }	public int hashCode() {		final int prime = 31;		int result = 1;		result = prime				* result				+ ((field_11_font_name == null) ? 0 : field_11_font_name						.hashCode());		result = prime * result + field_1_font_height;		result = prime * result + field_2_attributes;		result = prime * result + field_3_color_palette_index;		result = prime * result + field_4_bold_weight;		result = prime * result + field_5_super_sub_script;		result = prime * result + field_6_underline;		result = prime * result + field_7_family;		result = prime * result + field_8_charset;		result = prime * result + field_9_zero;		result = prime * result + field_10_font_name_len;		return result;	}		/**	 * Does this FontRecord have all the same font	 *  properties as the supplied FontRecord?	 * Note that {@link #equals(Object)} will check	 *  for exact objects, while this will check	 *  for exact contents, because normally the	 *  font record's position makes a big	 *  difference too.  	 */	public boolean sameProperties(FontRecord other) {		return 		field_1_font_height         == other.field_1_font_height &&		field_2_attributes          == other.field_2_attributes &&		field_3_color_palette_index == other.field_3_color_palette_index &&		field_4_bold_weight         == other.field_4_bold_weight &&		field_5_super_sub_script    == other.field_5_super_sub_script &&		field_6_underline           == other.field_6_underline &&		field_7_family              == other.field_7_family &&		field_8_charset             == other.field_8_charset &&		field_9_zero                == other.field_9_zero &&		field_10_font_name_len      == other.field_10_font_name_len &&		field_11_font_name.equals(other.field_11_font_name)		;	}	/**	 * Only returns two for the same exact object -	 *  creating a second FontRecord with the same	 *  properties won't be considered equal, as 	 *  the record's position in the record stream	 *  matters.	 */	public boolean equals(Object obj) {		if (this == obj)			return true;		return false;	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?