📄 namerecord.java
字号:
/** gets the option flag * @return option flag */ public short getOptionFlag(){ return field_1_option_flag; } /** returns the keyboard shortcut * @return keyboard shortcut */ public byte getKeyboardShortcut(){ return field_2_keyboard_shortcut ; } /** gets the name length * @return name length */ public byte getNameTextLength(){ return field_3_length_name_text; } /** get the definition length * @return definition length */ public short getDefinitionTextLength(){ return field_4_length_name_definition; } /** gets the index to extern sheet * @return index to extern sheet */ public short getUnused(){ return field_5_index_to_sheet; } /** gets the custom menu length * @return custom menu length */ public byte getCustomMenuLength(){ return field_7_length_custom_menu; } /** gets the description text length * @return description text length */ public byte getDescriptionTextLength(){ return field_8_length_description_text; } /** gets the help topic length * @return help topic length */ public byte getHelpTopicLength(){ return field_9_length_help_topic_text; } /** get the status bar text length * @return satus bar length */ public byte getStatusBarLength(){ return field_10_length_status_bar_text; } /** gets the name compressed Unicode flag * @return compressed unicode flag */ public byte getCompressedUnicodeFlag() { return field_11_compressed_unicode_flag; } /** * @return true if name is hidden */ public boolean isHiddenName() { return (field_1_option_flag & OPT_HIDDEN_NAME) != 0; } /** * @return true if name is a function */ public boolean isFunctionName() { return (field_1_option_flag & OPT_FUNCTION_NAME) != 0; } /** * @return true if name is a command */ public boolean isCommandName() { return (field_1_option_flag & OPT_COMMAND_NAME) != 0; } /** * @return true if function macro or command macro */ public boolean isMacro() { return (field_1_option_flag & OPT_MACRO) != 0; } /** * @return true if array formula or user defined */ public boolean isComplexFunction() { return (field_1_option_flag & OPT_COMPLEX) != 0; } /**Convenience Function to determine if the name is a built-in name */ public boolean isBuiltInName() { return ((this.getOptionFlag() & OPT_BUILTIN) != 0); } /** gets the name * @return name */ public String getNameText(){ return this.isBuiltInName() ? this.translateBuiltInName(this.getBuiltInName()) : field_12_name_text; } /** Gets the Built In Name * @return the built in Name */ public byte getBuiltInName() { return this.field_12_builtIn_name; } /** gets the definition, reference (Formula) * @return definition -- can be null if we cant parse ptgs */ public List getNameDefinition() { return field_13_name_definition; } public void setNameDefinition(Stack nameDefinition) { field_13_name_definition = nameDefinition; } /** get the custom menu text * @return custom menu text */ public String getCustomMenuText(){ return field_14_custom_menu_text; } /** gets the description text * @return description text */ public String getDescriptionText(){ return field_15_description_text; } /** get the help topic text * @return gelp topic text */ public String getHelpTopicText(){ return field_16_help_topic_text; } /** gets the status bar text * @return status bar text */ public String getStatusBarText(){ return field_17_status_bar_text; } /** * called by constructor, should throw runtime exception in the event of a * record passed with a differing ID. * * @param id alleged id for this record */ protected void validateSid(short id) { if (id != sid) { throw new RecordFormatException("NOT A valid Name RECORD"); } } /** * called by the class that is responsible for writing this sucker. * Subclasses should implement this so that their data is passed back in a * byte array. * * @param offset to begin writing at * @param data byte array containing instance data * @return number of bytes written */ public int serialize( int offset, byte[] data ) { LittleEndian.putShort( data, 0 + offset, sid ); // size defined below LittleEndian.putShort( data, 4 + offset, getOptionFlag() ); data[6 + offset] = getKeyboardShortcut(); data[7 + offset] = getNameTextLength(); LittleEndian.putShort( data, 8 + offset, getDefinitionTextLength() ); LittleEndian.putShort( data, 10 + offset, getUnused() ); LittleEndian.putShort( data, 12 + offset, getEqualsToIndexToSheet() ); data[14 + offset] = getCustomMenuLength(); data[15 + offset] = getDescriptionTextLength(); data[16 + offset] = getHelpTopicLength(); data[17 + offset] = getStatusBarLength(); data[18 + offset] = getCompressedUnicodeFlag(); /* temp: gjs if (isBuiltInName()) { LittleEndian.putShort( data, 2 + offset, (short) ( 16 + field_13_raw_name_definition.length ) ); data[19 + offset] = field_12_builtIn_name; System.arraycopy( field_13_raw_name_definition, 0, data, 20 + offset, field_13_raw_name_definition.length ); return 20 + field_13_raw_name_definition.length; } else { */ LittleEndian.putShort( data, 2 + offset, (short) ( 15 + getTextsLength() ) ); int start_of_name_definition = 19 + field_3_length_name_text; if (this.isBuiltInName()) { //can send the builtin name directly in data [19 + offset] = this.getBuiltInName(); } else { StringUtil.putCompressedUnicode( getNameText(), data, 19 + offset ); } if ( this.field_13_name_definition != null ) { serializePtgs( data, start_of_name_definition + offset ); } else { System.arraycopy( field_13_raw_name_definition, 0, data , start_of_name_definition + offset, field_13_raw_name_definition.length ); } int start_of_custom_menu_text = start_of_name_definition + field_4_length_name_definition; StringUtil.putCompressedUnicode( getCustomMenuText(), data, start_of_custom_menu_text + offset ); int start_of_description_text = start_of_custom_menu_text + field_7_length_custom_menu; StringUtil.putCompressedUnicode( getDescriptionText(), data, start_of_description_text + offset ); int start_of_help_topic_text = start_of_description_text + field_8_length_description_text; StringUtil.putCompressedUnicode( getHelpTopicText(), data, start_of_help_topic_text + offset ); int start_of_status_bar_text = start_of_help_topic_text + field_9_length_help_topic_text; StringUtil.putCompressedUnicode( getStatusBarText(), data, start_of_status_bar_text + offset ); return getRecordSize(); /* } */ } private void serializePtgs(byte [] data, int offset) { int pos = offset; for (int k = 0; k < field_13_name_definition.size(); k++) { Ptg ptg = ( Ptg ) field_13_name_definition.get(k); ptg.writeBytes(data, pos); pos += ptg.getSize(); } } /** gets the length of all texts * @return total length */ public int getTextsLength(){ int result; result = getNameTextLength() + getDefinitionTextLength() + getDescriptionTextLength() + getHelpTopicLength() + getStatusBarLength(); return result; } /** returns the record size */ public int getRecordSize(){ int result; result = 19 + getTextsLength(); return result; } /** gets the extern sheet number * @return extern sheet index */ public short getExternSheetNumber(){ if (field_13_name_definition == null || field_13_name_definition.isEmpty()) return 0; Ptg ptg = (Ptg) field_13_name_definition.peek(); short result = 0; if (ptg.getClass() == Area3DPtg.class){ result = ((Area3DPtg) ptg).getExternSheetIndex(); } else if (ptg.getClass() == Ref3DPtg.class){ result = ((Ref3DPtg) ptg).getExternSheetIndex(); } return result; } /** sets the extern sheet number * @param externSheetNumber extern sheet number */ public void setExternSheetNumber(short externSheetNumber){ Ptg ptg; if (field_13_name_definition == null || field_13_name_definition.isEmpty()){ field_13_name_definition = new Stack(); ptg = createNewPtg();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -