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

📄 namerecord.java

📁 java 报表 to office文档: 本包由java语言开发
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        } else {            ptg = (Ptg) field_13_name_definition.peek();        }        if (ptg.getClass() == Area3DPtg.class){            ((Area3DPtg) ptg).setExternSheetIndex(externSheetNumber);        } else if (ptg.getClass() == Ref3DPtg.class){            ((Ref3DPtg) ptg).setExternSheetIndex(externSheetNumber);        }    }    private Ptg createNewPtg(){        Ptg ptg = new Area3DPtg();        field_13_name_definition.push(ptg);        return ptg;    }    /** gets the reference , the area only (range)     * @return area reference     */    public String getAreaReference(Workbook book){        if (field_13_name_definition == null || field_13_name_definition.isEmpty()) return "Error";        Ptg ptg = (Ptg) field_13_name_definition.peek();        String result = "";        if (ptg.getClass() == Area3DPtg.class){            result = ptg.toFormulaString(book);        } else if (ptg.getClass() == Ref3DPtg.class){            result = ptg.toFormulaString(book);        } else if (ptg.getClass() == DeletedArea3DPtg.class || ptg.getClass() == DeletedRef3DPtg.class) {        	result = "#REF!"   ;     }        return result;    }    /** sets the reference , the area only (range)     * @param ref area reference     */    public void setAreaReference(String ref){        //Trying to find if what ptg do we need        RangeAddress ra = new RangeAddress(ref);        Ptg oldPtg;        Ptg ptg;        if (field_13_name_definition==null ||field_13_name_definition.isEmpty()){            field_13_name_definition = new Stack();            oldPtg = createNewPtg();        } else {            //Trying to find extern sheet index            oldPtg = (Ptg) field_13_name_definition.pop();        }        short externSheetIndex = 0;        if (oldPtg.getClass() == Area3DPtg.class){            externSheetIndex =  ((Area3DPtg) oldPtg).getExternSheetIndex();        } else if (oldPtg.getClass() == Ref3DPtg.class){            externSheetIndex =  ((Ref3DPtg) oldPtg).getExternSheetIndex();        }        if (ra.hasRange()) {            ptg = new Area3DPtg();            ((Area3DPtg) ptg).setExternSheetIndex(externSheetIndex);            ((Area3DPtg) ptg).setArea(ref);            this.setDefinitionTextLength((short)ptg.getSize());        } else {            ptg = new Ref3DPtg();            ((Ref3DPtg) ptg).setExternSheetIndex(externSheetIndex);            ((Ref3DPtg) ptg).setArea(ref);            this.setDefinitionTextLength((short)ptg.getSize());        }        field_13_name_definition.push(ptg);    }    /**     * called by the constructor, should set class level fields.  Should throw     * runtime exception for bad/icomplete data.     *     * @param data raw data     * @param size size of data     * @param offset of the record's data (provided a big array of the file)     */    protected void fillFields(byte[] data, short size, int offset) {        field_1_option_flag             = LittleEndian.getShort(data, 0 + offset);        field_2_keyboard_shortcut       = data [2 + offset];        field_3_length_name_text        = data [3 + offset];        field_4_length_name_definition  = LittleEndian.getShort(data, 4 + offset);        field_5_index_to_sheet          = LittleEndian.getShort(data, 6 + offset);        field_6_equals_to_index_to_sheet= LittleEndian.getShort(data, 8 + offset);        field_7_length_custom_menu      = data [10 + offset];        field_8_length_description_text = data [11 + offset];        field_9_length_help_topic_text  = data [12 + offset];        field_10_length_status_bar_text = data [13 + offset];                /*        temp: gjs        if (isBuiltInName()) {            // DEBUG            // System.out.println( "Built-in name" );            field_11_compressed_unicode_flag = data[ 14 + offset ];            field_12_builtIn_name = data[ 15 + offset ];            if ( (field_12_builtIn_name & (short)0x07) != 0 ) {                field_12_name_text = "Print_Titles";                // DEBUG                // System.out.println( field_12_name_text );                field_13_raw_name_definition = new byte[ field_4_length_name_definition ];                System.arraycopy( data, 16 + offset, field_13_raw_name_definition, 0, field_13_raw_name_definition.length );                // DEBUG                // System.out.println( HexDump.toHex( field_13_raw_name_definition ) );            }        }        else { */                field_11_compressed_unicode_flag= data [14 + offset];                        			//store the name in byte form if it's a builtin name			if (this.isBuiltInName()) {				field_12_builtIn_name = data[ 15 + offset ];			}                        field_12_name_text = StringUtil.getFromCompressedUnicode(data, 15 + offset,            LittleEndian.ubyteToInt(field_3_length_name_text));                    int start_of_name_definition    = 15 + field_3_length_name_text;            field_13_name_definition = getParsedExpressionTokens(data, field_4_length_name_definition,            offset, start_of_name_definition);                int start_of_custom_menu_text   = start_of_name_definition + field_4_length_name_definition;            field_14_custom_menu_text       = StringUtil.getFromCompressedUnicode(data, start_of_custom_menu_text + offset,            LittleEndian.ubyteToInt(field_7_length_custom_menu));                int start_of_description_text   = start_of_custom_menu_text + field_7_length_custom_menu;;            field_15_description_text       = StringUtil.getFromCompressedUnicode(data, start_of_description_text + offset,            LittleEndian.ubyteToInt(field_8_length_description_text));                int start_of_help_topic_text    = start_of_description_text + field_8_length_description_text;            field_16_help_topic_text        = StringUtil.getFromCompressedUnicode(data, start_of_help_topic_text + offset,            LittleEndian.ubyteToInt(field_9_length_help_topic_text));                int start_of_status_bar_text       = start_of_help_topic_text + field_9_length_help_topic_text;            field_17_status_bar_text        = StringUtil.getFromCompressedUnicode(data, start_of_status_bar_text +  offset,            LittleEndian.ubyteToInt(field_10_length_status_bar_text));        /*} */    }    private Stack getParsedExpressionTokens(byte [] data, short size,        int offset, int start_of_expression) {        Stack stack = new Stack();        int   pos           = start_of_expression + offset;        int   sizeCounter   = 0;        try {            while (sizeCounter < size) {                Ptg ptg = Ptg.createPtg(data, pos);                pos += ptg.getSize();                sizeCounter += ptg.getSize();                stack.push(ptg);                field_13_raw_name_definition=new byte[size];                System.arraycopy(data,offset,field_13_raw_name_definition,0,size);            }        } catch (java.lang.UnsupportedOperationException uoe) {            System.err.println("[WARNING] Unknown Ptg "                    + uoe.getMessage() + "for named range: "+ field_12_name_text);            field_13_raw_name_definition=new byte[size];            System.arraycopy(data,offset,field_13_raw_name_definition,0,size);            return null;        }        return stack;    }    /**     * return the non static version of the id for this record.     */    public short getSid() {        return this.sid;    }    /*      20 00       00       01       1A 00 // sz = 0x1A = 26      00 00       01 00       00       00       00       00       00 // unicode flag      07 // name            29 17 00 3B 00 00 00 00 FF FF 00 00 02 00 3B 00 //{ 26      00 07 00 07 00 00 00 FF 00 10                   //  }                        20 00       00       01       0B 00 // sz = 0xB = 11      00 00       01 00       00       00       00       00       00 // unicode flag      07 // name            3B 00 00 07 00 07 00 00 00 FF 00   // { 11 }  */    /*      18, 00,       1B, 00,             20, 00,       00,       01,       0B, 00,       00,       00,       00,       00,       00,       07,       3B 00 00 07 00 07 00 00 00 FF 00 ]          */    /**     * @see Object#toString()     */    public String toString() {        StringBuffer buffer = new StringBuffer();        buffer.append("[NAME]\n");        buffer.append("    .option flags         = ").append( HexDump.toHex( field_1_option_flag ) )            .append("\n");        buffer.append("    .keyboard shortcut    = ").append( HexDump.toHex( field_2_keyboard_shortcut ) )            .append("\n");        buffer.append("    .length of the name   = ").append( field_3_length_name_text )            .append("\n");        buffer.append("    .size of the formula data = ").append( field_4_length_name_definition )            .append("\n");        buffer.append("    .unused                   = ").append( field_5_index_to_sheet )            .append("\n");        buffer.append("    .index to sheet (1-based, 0=Global)           = ").append( field_6_equals_to_index_to_sheet )            .append("\n");        buffer.append("    .Length of menu text (character count)        = ").append( field_7_length_custom_menu )            .append("\n");        buffer.append("    .Length of description text (character count) = ").append( field_8_length_description_text )            .append("\n");        buffer.append("    .Length of help topic text (character count)  = ").append( field_9_length_help_topic_text )            .append("\n");        buffer.append("    .Length of status bar text (character count)  = ").append( field_10_length_status_bar_text )            .append("\n");        buffer.append("    .Name (Unicode flag)  = ").append( field_11_compressed_unicode_flag )            .append("\n");        buffer.append("    .Name (Unicode text)  = ").append( getNameText() )            .append("\n");        buffer.append("    .Formula data (RPN token array without size field)      = ").append( HexDump.toHex(                        ((field_13_raw_name_definition != null) ? field_13_raw_name_definition : new byte[0] ) ) )            .append("\n");                    buffer.append("    .Menu text (Unicode string without length field)        = ").append( field_14_custom_menu_text )            .append("\n");        buffer.append("    .Description text (Unicode string without length field) = ").append( field_15_description_text )            .append("\n");        buffer.append("    .Help topic text (Unicode string without length field)  = ").append( field_16_help_topic_text )            .append("\n");        buffer.append("    .Status bar text (Unicode string without length field)  = ").append( field_17_status_bar_text )            .append("\n");        if (field_13_raw_name_definition != null)            buffer.append(org.apache.poi.util.HexDump.dump(this.field_13_raw_name_definition,0,0));        buffer.append("[/NAME]\n");                return buffer.toString();    }	/**Creates a human readable name for built in types	 * @return Unknown if the built-in name cannot be translated	 */	protected String translateBuiltInName(byte name)	{	    switch (name)	    {	        case NameRecord.BUILTIN_AUTO_ACTIVATE :     return "Auto_Activate";	        case NameRecord.BUILTIN_AUTO_CLOSE :        return "Auto_Close";	        case NameRecord.BUILTIN_AUTO_DEACTIVATE :   return "Auto_Deactivate";	        case NameRecord.BUILTIN_AUTO_OPEN :         return "Auto_Open";	        case NameRecord.BUILTIN_CONSOLIDATE_AREA :  return "Consolidate_Area";	        case NameRecord.BUILTIN_CRITERIA :          return "Criteria";	        case NameRecord.BUILTIN_DATABASE :          return "Database";	        case NameRecord.BUILTIN_DATA_FORM :         return "Data_Form";            	        case NameRecord.BUILTIN_PRINT_AREA :        return "Print_Area";	        case NameRecord.BUILTIN_PRINT_TITLE :       return "Print_Titles";	        case NameRecord.BUILTIN_RECORDER :          return "Recorder";	        case NameRecord.BUILTIN_SHEET_TITLE :       return "Sheet_Title";	        	    }	    	    return "Unknown";	}	}

⌨️ 快捷键说明

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