Line 58
Link Here
|
|
|
58 |
import org.apache.poi.util.HexDump; |
Line 73
Link Here
|
|
|
74 |
* @author Sergei Kozello (sergeikozello at mail.ru) |
Line 91
Link Here
|
|
|
93 |
private byte field_12_builtIn_name; |
Line 93
Link Here
|
93 |
private byte[] field_13_raw_name_definition = null; // raw data |
96 |
private byte[] field_13_raw_name_definition; // raw data |
94 |
-- |
|
|
Line 381
Link Here
|
381 |
LittleEndian.putShort(data, 2 + offset, (short)( 15 + getTextsLength())); |
384 |
// size defined below |
382 |
-- |
|
|
Lines 393-417
Link Here
|
393 |
|
396 |
|
394 |
StringUtil.putCompressedUnicode(getNameText(), data , 19 + offset); |
397 |
if ( ( field_1_option_flag & (short)0x20 ) != 0 ) { |
395 |
|
398 |
LittleEndian.putShort(data, 2 + offset, (short)( 16 + field_13_raw_name_definition.length )); |
396 |
int start_of_name_definition = 19 + field_3_length_name_text; |
399 |
|
397 |
if (this.field_13_name_definition != null) { |
400 |
data [19 + offset] = field_12_builtIn_name; |
398 |
serializePtgs(data, start_of_name_definition + offset); |
401 |
System.arraycopy( field_13_raw_name_definition, 0, data, 20 + offset, field_13_raw_name_definition.length ); |
399 |
} else { |
402 |
|
400 |
System.arraycopy(field_13_raw_name_definition,0,data |
403 |
return 20 + field_13_raw_name_definition.length; |
401 |
,start_of_name_definition + offset,field_13_raw_name_definition.length); |
404 |
} |
402 |
} |
405 |
else { |
403 |
|
406 |
LittleEndian.putShort(data, 2 + offset, (short)( 15 + getTextsLength())); |
404 |
int start_of_custom_menu_text = start_of_name_definition + field_4_length_name_definition; |
407 |
|
405 |
StringUtil.putCompressedUnicode(getCustomMenuText(), data , start_of_custom_menu_text + offset); |
408 |
|
406 |
|
409 |
StringUtil.putCompressedUnicode(getNameText(), data , 19 + offset); |
407 |
int start_of_description_text = start_of_custom_menu_text + field_8_length_description_text; |
410 |
|
408 |
StringUtil.putCompressedUnicode(getDescriptionText(), data , start_of_description_text + offset); |
411 |
int start_of_name_definition = 19 + field_3_length_name_text; |
409 |
|
412 |
if (this.field_13_name_definition != null) { |
410 |
int start_of_help_topic_text = start_of_description_text + field_9_length_help_topic_text; |
413 |
serializePtgs(data, start_of_name_definition + offset); |
411 |
StringUtil.putCompressedUnicode(getHelpTopicText(), data , start_of_help_topic_text + offset); |
414 |
} else { |
412 |
|
415 |
System.arraycopy(field_13_raw_name_definition,0,data |
413 |
int start_of_status_bar_text = start_of_help_topic_text + field_10_length_status_bar_text; |
416 |
,start_of_name_definition + offset,field_13_raw_name_definition.length); |
414 |
StringUtil.putCompressedUnicode(getStatusBarText(), data , start_of_status_bar_text + offset); |
417 |
} |
415 |
|
418 |
|
416 |
|
419 |
int start_of_custom_menu_text = start_of_name_definition + field_4_length_name_definition; |
417 |
return getRecordSize(); |
420 |
StringUtil.putCompressedUnicode(getCustomMenuText(), data , start_of_custom_menu_text + offset); |
418 |
-- |
421 |
|
|
|
422 |
int start_of_description_text = start_of_custom_menu_text + field_8_length_description_text; |
423 |
StringUtil.putCompressedUnicode(getDescriptionText(), data , start_of_description_text + offset); |
424 |
|
425 |
int start_of_help_topic_text = start_of_description_text + field_9_length_help_topic_text; |
426 |
StringUtil.putCompressedUnicode(getHelpTopicText(), data , start_of_help_topic_text + offset); |
427 |
|
428 |
int start_of_status_bar_text = start_of_help_topic_text + field_10_length_status_bar_text; |
429 |
StringUtil.putCompressedUnicode(getStatusBarText(), data , start_of_status_bar_text + offset); |
430 |
|
431 |
return getRecordSize(); |
432 |
} |
Lines 582-605
Link Here
|
582 |
field_11_compressed_unicode_flag= data [14 + offset]; |
597 |
|
583 |
field_12_name_text = new String(data, 15 + offset, |
598 |
if ( ( field_1_option_flag & (short)0x20 ) != 0 ) { |
584 |
LittleEndian.ubyteToInt(field_3_length_name_text)); |
599 |
// DEBUG |
585 |
|
600 |
// System.out.println( "Built-in name" ); |
586 |
int start_of_name_definition = 15 + field_3_length_name_text; |
601 |
|
587 |
field_13_name_definition = getParsedExpressionTokens(data, field_4_length_name_definition, |
602 |
field_11_compressed_unicode_flag = data[ 14 + offset ]; |
588 |
offset, start_of_name_definition); |
603 |
field_12_builtIn_name = data[ 15 + offset ]; |
589 |
|
604 |
|
590 |
int start_of_custom_menu_text = start_of_name_definition + field_4_length_name_definition; |
605 |
if ( (field_12_builtIn_name & (short)0x07) != 0 ) { |
591 |
field_14_custom_menu_text = new String(data, start_of_custom_menu_text + offset, |
606 |
field_12_name_text = "Print_Titles"; |
592 |
LittleEndian.ubyteToInt(field_7_length_custom_menu)); |
607 |
|
593 |
|
608 |
// DEBUG |
594 |
int start_of_description_text = start_of_custom_menu_text + field_8_length_description_text; |
609 |
// System.out.println( field_12_name_text ); |
595 |
field_15_description_text = new String(data, start_of_description_text + offset, |
610 |
|
596 |
LittleEndian.ubyteToInt(field_8_length_description_text)); |
611 |
field_13_raw_name_definition = new byte[ field_4_length_name_definition ]; |
597 |
|
612 |
System.arraycopy( data, 16 + offset, field_13_raw_name_definition, 0, field_13_raw_name_definition.length ); |
598 |
int start_of_help_topic_text = start_of_description_text + field_9_length_help_topic_text; |
613 |
|
599 |
field_16_help_topic_text = new String(data, start_of_help_topic_text + offset, |
614 |
// DEBUG |
600 |
LittleEndian.ubyteToInt(field_9_length_help_topic_text)); |
615 |
// System.out.println( HexDump.toHex( field_13_raw_name_definition ) ); |
601 |
|
616 |
} |
602 |
int start_of_status_bar_text = start_of_help_topic_text + field_10_length_status_bar_text; |
617 |
} |
603 |
field_17_status_bar_text = new String(data, start_of_status_bar_text + offset, |
618 |
else { |
604 |
LittleEndian.ubyteToInt(field_10_length_status_bar_text)); |
619 |
|
605 |
|
620 |
field_11_compressed_unicode_flag= data [14 + offset]; |
606 |
-- |
621 |
field_12_name_text = new String(data, 15 + offset, |
|
|
622 |
LittleEndian.ubyteToInt(field_3_length_name_text)); |
623 |
|
624 |
int start_of_name_definition = 15 + field_3_length_name_text; |
625 |
field_13_name_definition = getParsedExpressionTokens(data, field_4_length_name_definition, |
626 |
offset, start_of_name_definition); |
627 |
|
628 |
int start_of_custom_menu_text = start_of_name_definition + field_4_length_name_definition; |
629 |
field_14_custom_menu_text = new String(data, start_of_custom_menu_text + offset, |
630 |
LittleEndian.ubyteToInt(field_7_length_custom_menu)); |
631 |
|
632 |
int start_of_description_text = start_of_custom_menu_text + field_8_length_description_text; |
633 |
field_15_description_text = new String(data, start_of_description_text + offset, |
634 |
LittleEndian.ubyteToInt(field_8_length_description_text)); |
635 |
|
636 |
int start_of_help_topic_text = start_of_description_text + field_9_length_help_topic_text; |
637 |
field_16_help_topic_text = new String(data, start_of_help_topic_text + offset, |
638 |
LittleEndian.ubyteToInt(field_9_length_help_topic_text)); |
639 |
|
640 |
int start_of_status_bar_text = start_of_help_topic_text + field_10_length_status_bar_text; |
641 |
field_17_status_bar_text = new String(data, start_of_status_bar_text + offset, |
642 |
LittleEndian.ubyteToInt(field_10_length_status_bar_text)); |
643 |
} |
Line 637
Link Here
|
|
|
675 |
} |
676 |
/* |
677 |
20 00 |
678 |
00 |
679 |
01 |
680 |
1A 00 // sz = 0x1A = 26 |
681 |
00 00 |
682 |
01 00 |
683 |
00 |
684 |
00 |
685 |
00 |
686 |
00 |
687 |
00 // unicode flag |
688 |
07 // name |
689 |
|
690 |
29 17 00 3B 00 00 00 00 FF FF 00 00 02 00 3B 00 //{ 26 |
691 |
00 07 00 07 00 00 00 FF 00 10 // } |
692 |
|
693 |
|
694 |
|
695 |
20 00 |
696 |
00 |
697 |
01 |
698 |
0B 00 // sz = 0xB = 11 |
699 |
00 00 |
700 |
01 00 |
701 |
00 |
702 |
00 |
703 |
00 |
704 |
00 |
705 |
00 // unicode flag |
706 |
07 // name |
707 |
|
708 |
3B 00 00 07 00 07 00 00 00 FF 00 // { 11 } |
709 |
*/ |
710 |
/* |
711 |
18, 00, |
712 |
1B, 00, |
713 |
|
714 |
20, 00, |
715 |
00, |
716 |
01, |
717 |
0B, 00, |
718 |
00, |
719 |
00, |
720 |
00, |
721 |
00, |
722 |
00, |
723 |
07, |
724 |
3B 00 00 07 00 07 00 00 00 FF 00 ] |
725 |
*/ |
726 |
|
727 |
/** |
728 |
* @see Object#toString() |
729 |
*/ |
730 |
public String toString() { |
731 |
StringBuffer buffer = new StringBuffer(); |
732 |
|
733 |
buffer.append("[NAME]\n"); |
734 |
buffer.append(" .option flags = ").append( HexDump.toHex( field_1_option_flag ) ) |
735 |
.append("\n"); |
736 |
buffer.append(" .keyboard shortcut = ").append( HexDump.toHex( field_2_keyboard_shortcut ) ) |
737 |
.append("\n"); |
738 |
buffer.append(" .length of the name = ").append( field_3_length_name_text ) |
739 |
.append("\n"); |
740 |
buffer.append(" .size of the formula data = ").append( field_4_length_name_definition ) |
741 |
.append("\n"); |
742 |
buffer.append(" .unused = ").append( field_5_index_to_sheet ) |
743 |
.append("\n"); |
744 |
buffer.append(" .( 0 = Global name, otherwise index to sheet (one-based) ) = ").append( field_6_equals_to_index_to_sheet ) |
745 |
.append("\n"); |
746 |
buffer.append(" .Length of menu text (character count) = ").append( field_7_length_custom_menu ) |
747 |
.append("\n"); |
748 |
buffer.append(" .Length of description text (character count) = ").append( field_8_length_description_text ) |
749 |
.append("\n"); |
750 |
buffer.append(" .Length of help topic text (character count) = ").append( field_9_length_help_topic_text ) |
751 |
.append("\n"); |
752 |
buffer.append(" .Length of status bar text (character count) = ").append( field_10_length_status_bar_text ) |
753 |
.append("\n"); |
754 |
buffer.append(" .Name (Unicode flag) = ").append( field_11_compressed_unicode_flag ) |
755 |
.append("\n"); |
756 |
buffer.append(" .Name (Unicode text) = ").append( field_12_name_text ) |
757 |
.append("\n"); |
758 |
buffer.append(" .Formula data (RPN token array without size field) = ").append( HexDump.toHex( field_13_raw_name_definition ) ) |
759 |
.append("\n"); |
760 |
buffer.append(" .Menu text (Unicode string without length field) = ").append( field_14_custom_menu_text ) |
761 |
.append("\n"); |
762 |
buffer.append(" .Description text (Unicode string without length field) = ").append( field_15_description_text ) |
763 |
.append("\n"); |
764 |
buffer.append(" .Help topic text (Unicode string without length field) = ").append( field_16_help_topic_text ) |
765 |
.append("\n"); |
766 |
buffer.append(" .Status bar text (Unicode string without length field) = ").append( field_17_status_bar_text ) |
767 |
.append("\n"); |
768 |
buffer.append("[/NAME]\n"); |
769 |
|
770 |
return buffer.toString(); |