/* ==================================================================== Licensed to the Apache Software Foundation (ASF) Under one or more contributor license agreements. See the NOTICE file distributed with this work for Additional information regarding copyright ownership. The ASF licenses this file to You Under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed Under the License is distributed on an "AS Is" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations Under the License. ==================================================================== */ namespace HH.WMS.Utils.NPOI.HSSF.UserModel { using System; using System.IO; using System.Collections; using HH.WMS.Utils.NPOI.HSSF.Record; using HH.WMS.Utils.NPOI.SS.UserModel; /// /// Represents a Font used in a workbook. /// @version 1.0-pre /// @author Andrew C. Oliver /// public class HSSFFont:HH.WMS.Utils.NPOI.SS.UserModel.IFont { public const String FONT_ARIAL = "Arial"; private FontRecord font; private short index; /// /// Initializes a new instance of the class. /// /// The index. /// The record. public HSSFFont(short index, FontRecord rec) { font = rec; this.index = index; } /// /// Get the name for the font (i.e. Arial) /// /// the name of the font to use public String FontName { get { return font.FontName; } set { font.FontName = value; } } /// /// Get the index within the HSSFWorkbook (sequence within the collection of Font objects) /// /// Unique index number of the Underlying record this Font represents (probably you don't care /// Unless you're comparing which one is which) public short Index { get { return index; } } /// /// Get or sets 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.. /// /// height in 1/20ths of a point. public short FontHeight { get { return font.FontHeight; } set { font.FontHeight = value; } } /// /// Gets or sets the font height in points. /// /// height in the familiar Unit of measure - points. public short FontHeightInPoints { get { return (short)(font.FontHeight / 20); } set { font.FontHeight=(short)(value * 20); } } /// /// Gets or sets whether to use italics or not /// /// true if this instance is italic; otherwise, false. public bool IsItalic { get { return font.IsItalic; } set { font.IsItalic=value; } } /// /// Get whether to use a strikeout horizontal line through the text or not /// /// /// strikeout or not /// public bool IsStrikeout { get { return font.IsStrikeout; } set { font.IsStrikeout=value; } } /// /// Gets or sets the color for the font. /// /// The color to use. public short Color { get { return font.ColorPaletteIndex; } set { font.ColorPaletteIndex=value; } } /// /// Gets or sets the boldness to use /// /// The boldweight. public short Boldweight { get { return font.BoldWeight; } set { font.BoldWeight=value; } } /// /// Gets or sets normal,base or subscript. /// /// offset type to use (none,base,sub) public short TypeOffset { get { return font.SuperSubScript; } set { font.SuperSubScript=(short)value; } } /// /// Gets or sets the type of text Underlining to use /// /// The Underlining type. public byte Underline { get { return font.Underline; } set { font.Underline=(byte)value; } } /// /// Gets or sets the char set to use. /// /// The char set. public short Charset { get { return font.Charset; } set { font.Charset = (byte)value; } } /// /// Returns a that represents the current . /// /// /// A that represents the current . /// public override String ToString() { return "HH.WMS.Utils.NPOI.HSSF.UserModel.HSSFFont{" + font + "}"; } /// /// Serves as a hash function for a particular type. /// /// /// A hash code for the current . /// public override int GetHashCode() { int prime = 31; int result = 1; result = prime * result + ((font == null) ? 0 : font.GetHashCode()); result = prime * result + index; return result; } /// /// Determines whether the specified is equal to the current . /// /// The to compare with the current . /// /// true if the specified is equal to the current ; otherwise, false. /// /// /// The parameter is null. /// public override bool Equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj is HSSFFont) { HSSFFont other = (HSSFFont)obj; if (font == null) { if (other.font != null) return false; } else if (!font.Equals(other.font)) return false; if (index != other.index) return false; return true; } return false; } } }