⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 extendedformatrecord.java

📁 java 读写word excel ppt
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* ====================================================================   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.==================================================================== */        package org.apache.poi.hssf.record;import org.apache.poi.util.BitField;import org.apache.poi.util.BitFieldFactory;import org.apache.poi.util.LittleEndian;/** * Title:        Extended Format Record * Description:  Probably one of the more complex records.  There are two breeds: *               Style and Cell. *<P> *               It should be noted that fields in the extended format record are *               somewhat arbitrary.  Almost all of the fields are bit-level, but *               we name them as best as possible by functional group.  In some *               places this is better than others. *<P> * * REFERENCE:  PG 426 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> * @author Andrew C. Oliver (acoliver at apache dot org) * @version 2.0-pre */public class ExtendedFormatRecord    extends Record{    public final static short     sid                 = 0xE0;    // null constant    public final static short     NULL                = (short)0xfff0;    // xf type    public final static short     XF_STYLE            = 1;    public final static short     XF_CELL             = 0;    // borders    public final static short     NONE                = 0x0;    public final static short     THIN                = 0x1;    public final static short     MEDIUM              = 0x2;    public final static short     DASHED              = 0x3;    public final static short     DOTTED              = 0x4;    public final static short     THICK               = 0x5;    public final static short     DOUBLE              = 0x6;    public final static short     HAIR                = 0x7;    public final static short     MEDIUM_DASHED       = 0x8;    public final static short     DASH_DOT            = 0x9;    public final static short     MEDIUM_DASH_DOT     = 0xA;    public final static short     DASH_DOT_DOT        = 0xB;    public final static short     MEDIUM_DASH_DOT_DOT = 0xC;    public final static short     SLANTED_DASH_DOT    = 0xD;    // alignment    public final static short     GENERAL             = 0x0;    public final static short     LEFT                = 0x1;    public final static short     CENTER              = 0x2;    public final static short     RIGHT               = 0x3;    public final static short     FILL                = 0x4;    public final static short     JUSTIFY             = 0x5;    public final static short     CENTER_SELECTION    = 0x6;    // vertical alignment    public final static short     VERTICAL_TOP        = 0x0;    public final static short     VERTICAL_CENTER     = 0x1;    public final static short     VERTICAL_BOTTOM     = 0x2;    public final static short     VERTICAL_JUSTIFY    = 0x3;    // fill    public final static short     NO_FILL             = 0  ;    public final static short     SOLID_FILL          = 1  ;    public final static short     FINE_DOTS           = 2  ;    public final static short     ALT_BARS            = 3  ;    public final static short     SPARSE_DOTS         = 4  ;    public final static short     THICK_HORZ_BANDS    = 5  ;    public final static short     THICK_VERT_BANDS    = 6  ;    public final static short     THICK_BACKWARD_DIAG = 7  ;    public final static short     THICK_FORWARD_DIAG  = 8  ;    public final static short     BIG_SPOTS           = 9  ;    public final static short     BRICKS              = 10 ;    public final static short     THIN_HORZ_BANDS     = 11 ;    public final static short     THIN_VERT_BANDS     = 12 ;    public final static short     THIN_BACKWARD_DIAG  = 13 ;    public final static short     THIN_FORWARD_DIAG   = 14 ;    public final static short     SQUARES             = 15 ;    public final static short     DIAMONDS            = 16 ;    // fields in BOTH style and Cell XF records    private short                 field_1_font_index;             // not bit-mapped    private short                 field_2_format_index;           // not bit-mapped    // field_3_cell_options bit map    static final private BitField _locked       = BitFieldFactory.getInstance(0x0001);    static final private BitField _hidden       = BitFieldFactory.getInstance(0x0002);    static final private BitField _xf_type      = BitFieldFactory.getInstance(0x0004);    static final private BitField _123_prefix   = BitFieldFactory.getInstance(0x0008);    static final private BitField _parent_index = BitFieldFactory.getInstance(0xFFF0);    private short                 field_3_cell_options;    // field_4_alignment_options bit map    static final private BitField _alignment          = BitFieldFactory.getInstance(0x0007);    static final private BitField _wrap_text          = BitFieldFactory.getInstance(0x0008);    static final private BitField _vertical_alignment = BitFieldFactory.getInstance(0x0070);    static final private BitField _justify_last       = BitFieldFactory.getInstance(0x0080);    static final private BitField _rotation           = BitFieldFactory.getInstance(0xFF00);    private short                 field_4_alignment_options;    // field_5_indention_options    static final private BitField _indent                         =        BitFieldFactory.getInstance(0x000F);    static final private BitField _shrink_to_fit                  =        BitFieldFactory.getInstance(0x0010);    static final private BitField _merge_cells                    =        BitFieldFactory.getInstance(0x0020);    static final private BitField _reading_order                  =        BitFieldFactory.getInstance(0x00C0);    // apparently bits 8 and 9 are unused    static final private BitField _indent_not_parent_format       =        BitFieldFactory.getInstance(0x0400);    static final private BitField _indent_not_parent_font         =        BitFieldFactory.getInstance(0x0800);    static final private BitField _indent_not_parent_alignment    =        BitFieldFactory.getInstance(0x1000);    static final private BitField _indent_not_parent_border       =        BitFieldFactory.getInstance(0x2000);    static final private BitField _indent_not_parent_pattern      =        BitFieldFactory.getInstance(0x4000);    static final private BitField _indent_not_parent_cell_options =        BitFieldFactory.getInstance(0x8000);    private short                 field_5_indention_options;    // field_6_border_options bit map    static final private BitField _border_left   = BitFieldFactory.getInstance(0x000F);    static final private BitField _border_right  = BitFieldFactory.getInstance(0x00F0);    static final private BitField _border_top    = BitFieldFactory.getInstance(0x0F00);    static final private BitField _border_bottom = BitFieldFactory.getInstance(0xF000);    private short                 field_6_border_options;    // all three of the following attributes are palette options    // field_7_palette_options bit map    static final private BitField _left_border_palette_idx  =        BitFieldFactory.getInstance(0x007F);    static final private BitField _right_border_palette_idx =        BitFieldFactory.getInstance(0x3F80);    static final private BitField _diag                     =        BitFieldFactory.getInstance(0xC000);    private short                 field_7_palette_options;    // field_8_adtl_palette_options bit map    static final private BitField _top_border_palette_idx    =        BitFieldFactory.getInstance(0x0000007F);    static final private BitField _bottom_border_palette_idx =        BitFieldFactory.getInstance(0x00003F80);    static final private BitField _adtl_diag                 =        BitFieldFactory.getInstance(0x001fc000);    static final private BitField _adtl_diag_line_style      =        BitFieldFactory.getInstance(0x01e00000);    // apparently bit 25 is unused    static final private BitField _adtl_fill_pattern         =        BitFieldFactory.getInstance(0xfc000000);    private int                   field_8_adtl_palette_options;   // additional to avoid 2    // field_9_fill_palette_options bit map    static final private BitField _fill_foreground = BitFieldFactory.getInstance(0x007F);    static final private BitField _fill_background = BitFieldFactory.getInstance(0x3f80);    // apparently bits 15 and 14 are unused    private short                 field_9_fill_palette_options;    /**     * Constructor ExtendedFormatRecord     *     *     */    public ExtendedFormatRecord()    {    }    /**     * Constructs an ExtendedFormat record and sets its fields appropriately.     *     * @param id     id must be 0xE0 or an exception will be throw upon validation     * @param size  the size of the data area of the record     * @param data  data of the record (should not contain sid/len)     */    public ExtendedFormatRecord(RecordInputStream in)    {        super(in);    }    protected void validateSid(short id)    {        if (id != sid)        {            throw new RecordFormatException("NOT A EXTENDED FORMAT RECORD");        }    }    protected void fillFields(RecordInputStream in)    {        field_1_font_index           = in.readShort();        field_2_format_index         = in.readShort();        field_3_cell_options         = in.readShort();        field_4_alignment_options    = in.readShort();        field_5_indention_options    = in.readShort();        field_6_border_options       = in.readShort();        field_7_palette_options      = in.readShort();        field_8_adtl_palette_options = in.readInt();        field_9_fill_palette_options = in.readShort();    }    /**     * set the index to the FONT record (which font to use 0 based)     *     *     * @param index to the font     * @see org.apache.poi.hssf.record.FontRecord     */    public void setFontIndex(short index)    {        field_1_font_index = index;    }    /**     *  set the index to the Format record (which FORMAT to use 0-based)     *     *     * @param index to the format record     * @see org.apache.poi.hssf.record.FormatRecord     */    public void setFormatIndex(short index)    {        field_2_format_index = index;    }    /**     * sets the options bitmask - you can also use corresponding option bit setters     * (see other methods that reference this one)     *     *     * @param options bitmask to set     *     */    public void setCellOptions(short options)    {        field_3_cell_options = options;    }    // These are the bit fields in cell options    /**     * set whether the cell is locked or not     *     *     * @param locked - if the cell is locked     * @see #setCellOptions(short)     */    public void setLocked(boolean locked)    {        field_3_cell_options = _locked.setShortBoolean(field_3_cell_options,                locked);    }    /**     * set whether the cell is hidden or not     *     *     * @param hidden - if the cell is hidden     * @see #setCellOptions(short)     */    public void setHidden(boolean hidden)    {        field_3_cell_options = _hidden.setShortBoolean(field_3_cell_options,                hidden);    }    /**     * set whether the cell is a cell or style XFRecord     *     *     * @param type - cell or style (0/1)     * @see #XF_STYLE     * @see #XF_CELL     * @see #setCellOptions(short)     */    public void setXFType(short type)    {        field_3_cell_options = _xf_type.setShortValue(field_3_cell_options,                type);    }    /**     * set some old holdover from lotus 123.  Who cares, its all over for Lotus.     * RIP Lotus.     *     * @param prefix - the lotus thing to set.     * @see #setCellOptions(short)     */    public void set123Prefix(boolean prefix)    {        field_3_cell_options =            _123_prefix.setShortBoolean(field_3_cell_options, prefix);    }    // present in both but NULL except in cell records    /**     * for cell XF types this is the parent style (usually 0/normal).  For     * style this should be NULL.     *     * @param parent  index of parent XF     * @see #NULL     * @see #setCellOptions(short)     */    public void setParentIndex(short parent)    {        field_3_cell_options =            _parent_index.setShortValue(field_3_cell_options, parent);    }    // end bitfields in cell options    /**     * set the alignment options bitmask.  See corresponding bitsetter methods     * that reference this one.     *     *     * @param options     - the bitmask to set     */    public void setAlignmentOptions(short options)    {        field_4_alignment_options = options;    }    /**     * set the horizontal alignment of the cell.     *     *     * @param align - how to align the cell (see constants)     * @see #GENERAL     * @see #LEFT     * @see #CENTER     * @see #RIGHT     * @see #FILL     * @see #JUSTIFY     * @see #CENTER_SELECTION     * @see #setAlignmentOptions(short)     */    public void setAlignment(short align)    {        field_4_alignment_options =            _alignment.setShortValue(field_4_alignment_options, align);    }    /**     * set whether to wrap the text in the cell     *     *     * @param wrapped - whether or not to wrap the cell text     * @see #setAlignmentOptions(short)     */    public void setWrapText(boolean wrapped)    {        field_4_alignment_options =            _wrap_text.setShortBoolean(field_4_alignment_options, wrapped);    }    /**     * set the vertical alignment of text in the cell     *     *     * @param align     where to align the text     * @see #VERTICAL_TOP     * @see #VERTICAL_CENTER     * @see #VERTICAL_BOTTOM     * @see #VERTICAL_JUSTIFY     *     * @see #setAlignmentOptions(short)     */    public void setVerticalAlignment(short align)    {        field_4_alignment_options =            _vertical_alignment.setShortValue(field_4_alignment_options,                                              align);    }    /**     * Dunno.  Docs just say this is for far east versions..  (I'm guessing it     * justifies for right-to-left read languages)     *     *     * @param justify     * @see #setAlignmentOptions(short)     */    public void setJustifyLast(short justify)    {   // for far east languages supported only for format always 0 for US        field_4_alignment_options =            _justify_last.setShortValue(field_4_alignment_options, justify);    }    /**     * set the degree of rotation.  (I've not actually seen this used anywhere)     *     *     * @param rotation the degree of rotation     * @see #setAlignmentOptions(short)     */    public void setRotation(short rotation)    {        field_4_alignment_options =            _rotation.setShortValue(field_4_alignment_options, rotation);    }    /**     * set the indent options bitmask  (see corresponding bitmask setters that reference     * this field)     *     *     * @param options bitmask to set.     *     */

⌨️ 快捷键说明

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