Fields Summary |
---|
public static final short | sid |
public static final byte | BUILTIN_CONSOLIDATE_AREAIncluded for completeness sake, not implemented |
public static final byte | BUILTIN_AUTO_OPENIncluded for completeness sake, not implemented |
public static final byte | BUILTIN_AUTO_CLOSEIncluded for completeness sake, not implemented |
public static final byte | BUILTIN_DATABASEIncluded for completeness sake, not implemented |
public static final byte | BUILTIN_CRITERIAIncluded for completeness sake, not implemented |
public static final byte | BUILTIN_PRINT_AREA |
public static final byte | BUILTIN_PRINT_TITLE |
public static final byte | BUILTIN_RECORDERIncluded for completeness sake, not implemented |
public static final byte | BUILTIN_DATA_FORMIncluded for completeness sake, not implemented |
public static final byte | BUILTIN_AUTO_ACTIVATEIncluded for completeness sake, not implemented |
public static final byte | BUILTIN_AUTO_DEACTIVATEIncluded for completeness sake, not implemented |
public static final byte | BUILTIN_SHEET_TITLEIncluded for completeness sake, not implemented |
public static final short | OPT_HIDDEN_NAME |
public static final short | OPT_FUNCTION_NAME |
public static final short | OPT_COMMAND_NAME |
public static final short | OPT_MACRO |
public static final short | OPT_COMPLEX |
public static final short | OPT_BUILTIN |
public static final short | OPT_BINDATA |
private short | field_1_option_flag |
private byte | field_2_keyboard_shortcut |
private byte | field_3_length_name_text |
private short | field_4_length_name_definition |
private short | field_5_index_to_sheet |
private short | field_6_equals_to_index_to_sheet |
private byte | field_7_length_custom_menu |
private byte | field_8_length_description_text |
private byte | field_9_length_help_topic_text |
private byte | field_10_length_status_bar_text |
private byte | field_11_compressed_unicode_flag |
private byte | field_12_builtIn_name |
private String | field_12_name_text |
private Stack | field_13_name_definition |
private String | field_14_custom_menu_text |
private String | field_15_description_text |
private String | field_16_help_topic_text |
private String | field_17_status_bar_text |
Methods Summary |
---|
private org.apache.poi.hssf.record.formula.Ptg | createNewPtg()
Ptg ptg = new Area3DPtg();
field_13_name_definition.push(ptg);
return ptg;
|
protected void | fillFields(org.apache.poi.hssf.record.RecordInputStream in)called by the constructor, should set class level fields. Should throw
runtime exception for bad/icomplete data.
field_1_option_flag = in.readShort();
field_2_keyboard_shortcut = in.readByte();
field_3_length_name_text = in.readByte();
field_4_length_name_definition = in.readShort();
field_5_index_to_sheet = in.readShort();
field_6_equals_to_index_to_sheet= in.readShort();
field_7_length_custom_menu = in.readByte();
field_8_length_description_text = in.readByte();
field_9_length_help_topic_text = in.readByte();
field_10_length_status_bar_text = in.readByte();
//store the name in byte form if it's a builtin name
field_11_compressed_unicode_flag= in.readByte();
if (this.isBuiltInName()) {
field_12_builtIn_name = in.readByte();
} else {
if (field_11_compressed_unicode_flag == 1) {
field_12_name_text = in.readCompressedUnicode(field_3_length_name_text);
} else {
field_12_name_text = in.readCompressedUnicode(field_3_length_name_text);
}
}
field_13_name_definition = Ptg.createParsedExpressionTokens(field_4_length_name_definition, in);
//Who says that this can only ever be compressed unicode???
field_14_custom_menu_text = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_7_length_custom_menu));
field_15_description_text = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_8_length_description_text));
field_16_help_topic_text = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_9_length_help_topic_text));
field_17_status_bar_text = in.readCompressedUnicode(LittleEndian.ubyteToInt(field_10_length_status_bar_text));
/*} */
|
public java.lang.String | getAreaReference(org.apache.poi.hssf.model.Workbook book)gets the reference , the area only (range)
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;
|
public byte | getBuiltInName()Gets the Built In Name
return this.field_12_builtIn_name;
|
public byte | getCompressedUnicodeFlag()gets the name compressed Unicode flag
return field_11_compressed_unicode_flag;
|
public byte | getCustomMenuLength()gets the custom menu length
return field_7_length_custom_menu;
|
public java.lang.String | getCustomMenuText()get the custom menu text
return field_14_custom_menu_text;
|
public short | getDefinitionLength()get the definition length
return field_4_length_name_definition;
|
public java.lang.String | getDescriptionText()gets the description text
return field_15_description_text;
|
public byte | getDescriptionTextLength()gets the description text length
return field_8_length_description_text;
|
public short | getEqualsToIndexToSheet()
return field_6_equals_to_index_to_sheet;
|
public short | getExternSheetNumber()gets the extern sheet number
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;
|
public byte | getFnGroup()
int masked = field_1_option_flag & 0x0fc0;
return (byte) (masked >> 4);
|
public byte | getHelpTopicLength()gets the help topic length
return field_9_length_help_topic_text;
|
public java.lang.String | getHelpTopicText()get the help topic text
return field_16_help_topic_text;
|
public short | getIndexToSheet()Convenience method to retrieve the index the name refers to.
return getEqualsToIndexToSheet();
|
public byte | getKeyboardShortcut()returns the keyboard shortcut
return field_2_keyboard_shortcut ;
|
public java.util.List | getNameDefinition()gets the definition, reference (Formula)
return field_13_name_definition;
|
private int | getNameDefinitionSize()
int result = 0;
List list = field_13_name_definition;
for (int k = 0; k < list.size(); k++)
{
Ptg ptg = ( Ptg ) list.get(k);
result += ptg.getSize();
}
return result;
|
public java.lang.String | getNameText()gets the name
return this.isBuiltInName() ? this.translateBuiltInName(this.getBuiltInName()) : field_12_name_text;
|
public byte | getNameTextLength()gets the name length
return field_3_length_name_text;
|
public short | getOptionFlag()gets the option flag
return field_1_option_flag;
|
public int | getRecordSize()returns the record size
int result;
result = 19 + getTextsLength() + getNameDefinitionSize();
return result;
|
public short | getSid()return the non static version of the id for this record.
return sid;
|
public byte | getStatusBarLength()get the status bar text length
return field_10_length_status_bar_text;
|
public java.lang.String | getStatusBarText()gets the status bar text
return field_17_status_bar_text;
|
public int | getTextsLength()gets the length of all texts
int result;
result = getNameTextLength() + getDescriptionTextLength() +
getHelpTopicLength() + getStatusBarLength();
return result;
|
public short | getUnused()gets the index to extern sheet
return field_5_index_to_sheet;
|
public boolean | isBuiltInName()Convenience Function to determine if the name is a built-in name
return ((this.getOptionFlag() & OPT_BUILTIN) != 0);
|
public boolean | isCommandName()
return (field_1_option_flag & OPT_COMMAND_NAME) != 0;
|
public boolean | isComplexFunction()
return (field_1_option_flag & OPT_COMPLEX) != 0;
|
public boolean | isFunctionName()
return (field_1_option_flag & OPT_FUNCTION_NAME) != 0;
|
public boolean | isHiddenName()
return (field_1_option_flag & OPT_HIDDEN_NAME) != 0;
|
public boolean | isMacro()
return (field_1_option_flag & OPT_MACRO) != 0;
|
public int | serialize(int offset, byte[] data)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.
LittleEndian.putShort( data, 0 + offset, sid );
short size = (short)( 15 + getTextsLength() + getNameDefinitionSize());
LittleEndian.putShort( data, 2 + offset, size );
// size defined below
LittleEndian.putShort( data, 4 + offset, getOptionFlag() );
data[6 + offset] = getKeyboardShortcut();
data[7 + offset] = getNameTextLength();
LittleEndian.putShort( data, 8 + offset, getDefinitionLength() );
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
{ */
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 );
}
Ptg.serializePtgStack(field_13_name_definition, data, start_of_name_definition + offset );
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();
/* } */
|
public void | setAreaReference(java.lang.String ref)sets the reference , the area only (range)
//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);
|
public void | setCompressedUnicodeFlag(byte flag)sets the compressed unicode flag
field_11_compressed_unicode_flag = flag;
|
public void | setCustomMenuLength(byte length)sets the custom menu length
field_7_length_custom_menu = length;
|
public void | setCustomMenuText(java.lang.String text)sets the custom menu text
field_14_custom_menu_text = text;
|
public void | setDefinitionTextLength(short length)sets the definition (reference - formula) length
field_4_length_name_definition = length;
|
public void | setDescriptionText(java.lang.String text)sets the description text
field_15_description_text = text;
|
public void | setDescriptionTextLength(byte length)sets the length of named range description
field_8_length_description_text = length;
|
public void | setEqualsToIndexToSheet(short value)
field_6_equals_to_index_to_sheet = value;
|
public void | setExternSheetNumber(short externSheetNumber)sets the extern sheet number
Ptg ptg;
if (field_13_name_definition == null || field_13_name_definition.isEmpty()){
field_13_name_definition = new Stack();
ptg = createNewPtg();
} 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);
}
|
public void | setHelpTopicLength(byte length)sets the help topic length
field_9_length_help_topic_text = length;
|
public void | setHelpTopicText(java.lang.String text)sets the help topic text
field_16_help_topic_text = text;
|
public void | setKeyboardShortcut(byte shortcut)sets the keyboard shortcut
field_2_keyboard_shortcut = shortcut;
|
public void | setNameDefinition(java.util.Stack nameDefinition)
field_13_name_definition = nameDefinition;
|
public void | setNameText(java.lang.String name)sets the name of the named range
field_12_name_text = name;
|
public void | setNameTextLength(byte length)sets the name of the named range length
field_3_length_name_text = length;
|
public void | setOptionFlag(short flag)sets the option flag for the named range
field_1_option_flag = flag;
|
public void | setStatusBarLength(byte length)sets the length of the status bar text
field_10_length_status_bar_text = length;
|
public void | setStatusBarText(java.lang.String text)sets the status bar text
field_17_status_bar_text = text;
|
public void | setUnused(short index)sets the index number to the extern sheet (thats is what writen in documentation
but as i saw , it works differently)
field_5_index_to_sheet = index;
// field_6_equals_to_index_to_sheet is equal to field_5_index_to_sheet
// field_6_equals_to_index_to_sheet = index;
|
public java.lang.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(" .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");
buffer.append("[/NAME]\n");
return buffer.toString();
|
protected java.lang.String | translateBuiltInName(byte name)Creates a human readable name for built in types
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";
|
protected void | validateSid(short id)called by constructor, should throw runtime exception in the event of a
record passed with a differing ID.
if (id != sid) {
throw new RecordFormatException("NOT A valid Name RECORD");
}
|