public TableStylesRecord(RecordInputStream in1) { rt = in1.ReadUShort(); grbitFrt = in1.ReadUShort(); in1.ReadFully(unused); cts = in1.ReadInt(); int cchDefListStyle = in1.ReadUShort(); int cchDefPivotStyle = in1.ReadUShort(); rgchDefListStyle = in1.ReadUnicodeLEString(cchDefListStyle); rgchDefPivotStyle = in1.ReadUnicodeLEString(cchDefPivotStyle); }
public TableStylesRecord(RecordInputStream in1) { rt = in1.ReadUShort(); grbitFrt = in1.ReadUShort(); in1.ReadFully(unused); cts = in1.ReadInt(); int cchDefListStyle = in1.ReadUShort(); int cchDefPivotStyle = in1.ReadUShort(); rgchDefListStyle = in1.ReadUnicodeLEString(cchDefListStyle); rgchDefPivotStyle = in1.ReadUnicodeLEString(cchDefPivotStyle); }
public ExtendedPivotTableViewFieldsRecord(RecordInputStream in1) { grbit1 = in1.ReadInt(); grbit2 = in1.ReadUByte(); citmShow = in1.ReadUByte(); isxdiSort = in1.ReadUShort(); isxdiShow = in1.ReadUShort(); // This record seems to have different valid encodings switch (in1.Remaining) { case 0: // as per "Microsoft Excel Developer's Kit" book // older version of SXVDEX - doesn't seem to have a sub-total name reserved1 = 0; reserved2 = 0; subName = null; return; case 10: // as per "MICROSOFT OFFICE EXCEL 97-2007 BINARY FILE FORMAT SPECIFICATION" pdf break; default: throw new RecordFormatException("Unexpected remaining size (" + in1.Remaining + ")"); } int cchSubName = in1.ReadUShort(); reserved1 = in1.ReadInt(); reserved2 = in1.ReadInt(); if (cchSubName != STRING_NOT_PRESENT_LEN) { subName = in1.ReadUnicodeLEString(cchSubName); } }
/** * Constructs an Label record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public LabelRecord(RecordInputStream in1) { field_1_row = in1.ReadUShort(); field_2_column = in1.ReadUShort(); field_3_xf_index = in1.ReadShort(); field_4_string_len = in1.ReadShort(); field_5_unicode_flag = (byte)in1.ReadByte(); if (field_4_string_len > 0) { if (IsUncompressedUnicode) { field_6_value = in1.ReadUnicodeLEString(field_4_string_len); } else { field_6_value = in1.ReadCompressedUnicode(field_4_string_len); } } else { field_6_value = ""; } if (in1.Remaining > 0) { logger.Log(POILogger.INFO, "LabelRecord data remains: " + in1.Remaining + " : " + HexDump.ToHex(in1.ReadRemainder())); } }
/** * Constructs a Font record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public FontRecord(RecordInputStream in1) { field_1_font_height = in1.ReadShort(); field_2_attributes = in1.ReadShort(); field_3_color_palette_index = in1.ReadShort(); field_4_bold_weight = in1.ReadShort(); field_5_base_sub_script = in1.ReadShort(); field_6_underline = (byte)in1.ReadByte(); field_7_family = (byte)in1.ReadByte(); field_8_charset = (byte)in1.ReadByte(); field_9_zero = (byte)in1.ReadByte(); int field_10_font_name_len = (byte)in1.ReadByte(); int unicodeFlags = in1.ReadUByte(); // options byte present always (even if no character data) if (field_10_font_name_len > 0) { if (unicodeFlags == 0) { // Is compressed Unicode field_11_font_name = in1.ReadCompressedUnicode(field_10_font_name_len); } else { // Is not compressed Unicode field_11_font_name = in1.ReadUnicodeLEString(field_10_font_name_len); } } else { field_11_font_name = ""; } }
/** * Constructs an Label record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public LabelRecord(RecordInputStream in1) { field_1_row = in1.ReadUShort(); field_2_column = in1.ReadUShort(); field_3_xf_index = in1.ReadShort(); field_4_string_len = in1.ReadShort(); field_5_unicode_flag = (byte)in1.ReadByte(); if (field_4_string_len > 0) { if (IsUncompressedUnicode) { field_6_value = in1.ReadUnicodeLEString(field_4_string_len); } else { field_6_value = in1.ReadCompressedUnicode(field_4_string_len); } } else { field_6_value = ""; } if (in1.Remaining > 0) { logger.Log(POILogger.INFO, "LabelRecord data remains: " +in1.Remaining + " : " + HexDump.ToHex(in1.ReadRemainder())); } }
/** * Constructs a SeriesText record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public SeriesTextRecord(RecordInputStream in1) { field_1_id = in1.ReadShort(); field_2_textLength = (byte)in1.ReadByte(); field_3_undocumented = (byte)in1.ReadByte(); field_4_text = in1.ReadUnicodeLEString(field_2_textLength); }
private static String ReadRawString(RecordInputStream in1, int textLength) { byte compressByte = (byte)in1.ReadByte(); bool isCompressed = (compressByte & 0x01) == 0; if (isCompressed) { return(in1.ReadCompressedUnicode(textLength)); } return(in1.ReadUnicodeLEString(textLength)); }
/** * Constructs a String record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public StringRecord(RecordInputStream in1) { int field_1_string_length = in1.ReadShort(); _is16bitUnicode = in1.ReadByte() != 0x00; if (_is16bitUnicode) { _text = in1.ReadUnicodeLEString(field_1_string_length); } else { _text = in1.ReadCompressedUnicode(field_1_string_length); } }
/** * construct a unicode string record and fill its fields, ID is ignored * @param in the RecordInPutstream to read the record from */ public UnicodeString(RecordInputStream in1) { field_1_charCount = in1.ReadShort(); field_2_optionflags = (byte)in1.ReadByte(); int RunCount = 0; int extensionLength = 0; //Read the number of rich Runs if rich text. if (IsRichText) { RunCount = in1.ReadShort(); } //Read the size of extended data if present. if (IsExtendedText) { extensionLength = in1.ReadInt(); } bool isCompressed = ((field_2_optionflags & 1) == 0); if (isCompressed) { field_3_string = in1.ReadCompressedUnicode(CharCount); } else { field_3_string = in1.ReadUnicodeLEString(CharCount); } if (IsRichText && (RunCount > 0)) { field_4_format_Runs = new List <FormatRun>(RunCount); for (int i = 0; i < RunCount; i++) { field_4_format_Runs.Add(new FormatRun(in1)); } } if (IsExtendedText && (extensionLength > 0)) { field_5_ext_rst = new byte[extensionLength]; for (int i = 0; i < extensionLength; i++) { field_5_ext_rst[i] = (byte)in1.ReadByte(); } } }
/** * construct a unicode string record and fill its fields, ID is ignored * @param in the RecordInputstream to read the record from */ public UnicodeString(RecordInputStream in1) { field_1_charCount = in1.ReadShort(); field_2_optionflags = (byte)in1.ReadByte(); int RunCount = 0; int extensionLength = 0; //Read the number of rich Runs if rich text. if (IsRichText) { RunCount = in1.ReadShort(); } //Read the size of extended data if present. if (IsExtendedText) { extensionLength = in1.ReadInt(); } bool IsCompressed = ((field_2_optionflags & 1) == 0); if (IsCompressed) { field_3_string = in1.ReadCompressedUnicode(CharCount); } else { field_3_string = in1.ReadUnicodeLEString(CharCount); } if (IsRichText && (RunCount > 0)) { field_4_format_Runs = new List <FormatRun>(RunCount); for (int i = 0; i < RunCount; i++) { field_4_format_Runs.Add(new FormatRun(in1)); } } if (IsExtendedText && (extensionLength > 0)) { field_5_ext_rst = new ExtRst(new ContinuableRecordInput(in1), extensionLength); if (field_5_ext_rst.DataSize + 4 != extensionLength) { _logger.Log(POILogger.WARN, "ExtRst was supposed to be " + extensionLength + " bytes long, but seems to actually be " + (field_5_ext_rst.DataSize + 4)); } } }
/** Create a StringPtg from a stream */ public StringPtg(RecordInputStream in1) { field_1_Length = in1.ReadUByte(); field_2_options = (byte)in1.ReadByte(); if (fHighByte.IsSet(field_2_options)) { field_3_string = in1.ReadUnicodeLEString(field_1_Length); } else { field_3_string = in1.ReadCompressedUnicode(field_1_Length); } // SetValue(new String(data, offset+3, data[offset+1] + 256*data[offset+2])); }
/** * Constructs a String record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public StringRecord(RecordInputStream in1) { int field_1_string_length = in1.ReadShort(); _is16bitUnicode = in1.ReadByte() != 0x00; if (_is16bitUnicode) { _text = in1.ReadUnicodeLEString(field_1_string_length); } else { _text = in1.ReadCompressedUnicode(field_1_string_length); } }
public ExternalNameRecord(RecordInputStream in1) { field_1_option_flag = in1.ReadShort(); field_2_index = in1.ReadShort(); field_3_not_used = in1.ReadShort(); int nameLength = in1.ReadUByte(); int multibyteFlag = in1.ReadUByte(); if (multibyteFlag == 0) { field_4_name = in1.ReadCompressedUnicode(nameLength); } else { field_4_name = in1.ReadUnicodeLEString(nameLength); } if (!HasFormula) { if (!IsStdDocumentNameIdentifier && !IsOLELink && IsAutomaticLink) { // both need to be incremented int nColumns = in1.ReadUByte() + 1; int nRows = in1.ReadShort() + 1; int totalCount = nRows * nColumns; _ddeValues = ConstantValueParser.Parse(in1, totalCount); _nColumns = nColumns; _nRows = nRows; } if (in1.Remaining > 0) { throw ReadFail("Some Unread data (is formula present?)"); } field_5_name_definition = null; return; } int nBytesRemaining = in1.Available(); if (in1.Remaining <= 0) { throw ReadFail("Ran out of record data trying to read formula."); } short formulaLen = in1.ReadShort(); nBytesRemaining -= 2; field_5_name_definition = NPOI.SS.Formula.Formula.Read(formulaLen, in1, nBytesRemaining); }
/** * Constructs a BoundSheetRecord and Sets its fields appropriately * * @param in the RecordInputstream to Read the record from */ public BoundSheetRecord(RecordInputStream in1) { field_1_position_of_BOF = in1.ReadInt(); // bof field_2_option_flags = in1.ReadShort(); // flags int field_3_sheetname_length = in1.ReadUByte(); // len(str) field_4_isMultibyteUnicode = (byte)in1.ReadByte(); // Unicode if (this.IsMultibyte) { field_5_sheetname = in1.ReadUnicodeLEString(field_3_sheetname_length); } else { field_5_sheetname = in1.ReadCompressedUnicode(field_3_sheetname_length); } }
/** * Constructs a Format record and Sets its fields appropriately. * @param in the RecordInputstream to Read the record from */ public FormatRecord(RecordInputStream in1) { field_1_index_code = in1.ReadShort(); int field_3_unicode_len = in1.ReadShort(); field_3_hasMultibyte = (in1.ReadByte() & (byte)0x01) != 0; if (field_3_hasMultibyte) { // Unicode field_4_formatstring = in1.ReadUnicodeLEString(field_3_unicode_len); } else { // not Unicode field_4_formatstring = in1.ReadCompressedUnicode(field_3_unicode_len); } }
/** * Constructs a Format record and Sets its fields appropriately. * @param in the RecordInputstream to Read the record from */ public FormatRecord(RecordInputStream in1) { field_1_index_code = in1.ReadShort(); field_3_unicode_len = in1.ReadShort(); field_3_unicode_flag = (in1.ReadByte() & (byte)0x01) != 0; if (field_3_unicode_flag) { // Unicode field_4_formatstring = in1.ReadUnicodeLEString(field_3_unicode_len); } else { // not Unicode field_4_formatstring = in1.ReadCompressedUnicode(field_3_unicode_len); } }
public ExternalNameRecord(RecordInputStream in1) { field_1_option_flag = in1.ReadShort(); field_2_index = in1.ReadShort(); field_3_not_used = in1.ReadShort(); int nameLength = in1.ReadUByte(); int multibyteFlag = in1.ReadUByte(); if (multibyteFlag == 0) { field_4_name = in1.ReadCompressedUnicode(nameLength); } else { field_4_name = in1.ReadUnicodeLEString(nameLength); } if (!HasFormula) { if (!IsStdDocumentNameIdentifier && !IsOLELink && IsAutomaticLink) { // both need to be incremented int nColumns = in1.ReadUByte() + 1; int nRows = in1.ReadShort() + 1; int totalCount = nRows * nColumns; _ddeValues = ConstantValueParser.Parse(in1, totalCount); _nColumns = nColumns; _nRows = nRows; } if (in1.Remaining > 0) { throw ReadFail("Some Unread data (is formula present?)"); } field_5_name_definition = null; return; } int nBytesRemaining = in1.Available(); if (in1.Remaining <= 0) { throw ReadFail("Ran out of record data trying to read formula."); } short formulaLen = in1.ReadShort(); nBytesRemaining -= 2; field_5_name_definition = NPOI.SS.Formula.Formula.Read(formulaLen, in1, nBytesRemaining); }
/** * Constructs a BoundSheetRecord and Sets its fields appropriately * * @param in the RecordInputstream to Read the record from */ public BoundSheetRecord(RecordInputStream in1) { field_1_position_of_BOF = in1.ReadInt(); // bof field_2_option_flags = in1.ReadShort(); // flags int field_3_sheetname_length = in1.ReadUByte(); // len(str) field_4_isMultibyteUnicode = (byte)in1.ReadByte(); // Unicode if (this.IsMultibyte) { field_5_sheetname = in1.ReadUnicodeLEString(field_3_sheetname_length); } else { field_5_sheetname = in1.ReadCompressedUnicode(field_3_sheetname_length); } }
/// <summary> /// Initializes a new instance of the <see cref="FooterRecord"/> class. /// </summary> /// <param name="in1">the RecordInputstream to Read the record from</param> public FooterRecord(RecordInputStream in1) { if (in1.Remaining > 0) { field_1_footer_len = (byte)in1.ReadByte(); /** These two fields are a bit odd. They are not documented*/ field_2_reserved = (byte)in1.ReadByte(); field_3_unicode_flag = (byte)in1.ReadByte(); // Unicode if (IsMultibyte) { field_4_footer = in1.ReadUnicodeLEString(LittleEndian.UByteToInt(field_1_footer_len)); } else { field_4_footer = in1.ReadCompressedUnicode(LittleEndian.UByteToInt(field_1_footer_len)); } } }
/// <summary> /// Initializes a new instance of the <see cref="FooterRecord"/> class. /// </summary> /// <param name="in1">the RecordInputstream to Read the record from</param> public FooterRecord(RecordInputStream in1) { if (in1.Remaining > 0) { field_1_footer_len = (byte)in1.ReadByte(); /** These two fields are a bit odd. They are not documented*/ field_2_reserved = (byte)in1.ReadByte(); field_3_unicode_flag = (byte)in1.ReadByte(); // Unicode if (IsMultibyte) { field_4_footer = in1.ReadUnicodeLEString(LittleEndian.UByteToInt(field_1_footer_len)); } else { field_4_footer = in1.ReadCompressedUnicode(LittleEndian.UByteToInt(field_1_footer_len)); } } }
/** * Constructs a Name record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public NameRecord(RecordInputStream in1) { field_1_option_flag = in1.ReadShort(); field_2_keyboard_shortcut = (byte)in1.ReadByte(); int field_3_length_name_text = in1.ReadByte(); int field_4_length_name_definition = in1.ReadShort(); field_5_externSheetIndex_plus1 = in1.ReadShort(); field_6_sheetNumber = in1.ReadUShort(); int field_7_length_custom_menu = in1.ReadUByte(); int field_8_length_description_text = in1.ReadUByte(); int field_9_length_help_topic_text = in1.ReadUByte(); int field_10_length_status_bar_text = in1.ReadUByte(); //store the name in byte form if it's a built-in name field_11_nameIsMultibyte = (in1.ReadByte() != 0); if (IsBuiltInName) { field_12_built_in_code = (byte)in1.ReadByte(); } else { if (field_11_nameIsMultibyte) { field_12_name_text = in1.ReadUnicodeLEString(field_3_length_name_text); } else { field_12_name_text = in1.ReadCompressedUnicode(field_3_length_name_text); } } int nBytesAvailable = in1.Available() - (field_7_length_custom_menu + field_8_length_description_text + field_9_length_help_topic_text + field_10_length_status_bar_text); field_13_name_definition = SSFormula.Formula.Read(field_4_length_name_definition, in1, nBytesAvailable); //Who says that this can only ever be compressed unicode??? field_14_custom_menu_text = in1.ReadCompressedUnicode(field_7_length_custom_menu); field_15_description_text = in1.ReadCompressedUnicode(field_8_length_description_text); field_16_help_topic_text = in1.ReadCompressedUnicode(field_9_length_help_topic_text); field_17_status_bar_text = in1.ReadCompressedUnicode(field_10_length_status_bar_text); }
public ViewFieldsRecord(RecordInputStream in1) { sxaxis = in1.ReadShort(); cSub = in1.ReadShort(); grbitSub = in1.ReadShort(); cItm = in1.ReadShort(); int cchName = in1.ReadUShort(); if (cchName != STRING_NOT_PRESENT_LEN) { int flag = in1.ReadByte(); if ((flag & 0x01) != 0) { _name = in1.ReadUnicodeLEString(cchName); } else { _name = in1.ReadCompressedUnicode(cchName); } } }
protected HeaderFooterBase(RecordInputStream in1) { if (in1.Remaining > 0) { int field_1_footer_len = in1.ReadShort(); field_2_hasMultibyte = in1.ReadByte() != 0x00; if (field_2_hasMultibyte) { field_3_text = in1.ReadUnicodeLEString(field_1_footer_len); } else { field_3_text = in1.ReadCompressedUnicode(field_1_footer_len); } } else { // Note - this is unusual for BIFF records in general, but normal for header / footer records: // when the text is empty string, the whole record is empty (just the 4 byte BIFF header) field_3_text = ""; } }
/** * Constructs an Label record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public LabelRecord(RecordInputStream in1) { field_1_row = in1.ReadUShort(); field_2_column = in1.ReadUShort(); field_3_xf_index = in1.ReadShort(); field_4_string_len = in1.ReadShort(); field_5_unicode_flag = (byte)in1.ReadByte(); if (field_4_string_len > 0) { if (IsUnCompressedUnicode) { field_6_value = in1.ReadUnicodeLEString(field_4_string_len); } else { field_6_value = in1.ReadCompressedUnicode(field_4_string_len); } } else { field_6_value = ""; } }
protected HeaderFooterBase(RecordInputStream in1) { if (in1.Remaining > 0) { int field_1_footer_len = in1.ReadShort(); field_2_hasMultibyte = in1.ReadByte() != 0x00; if (field_2_hasMultibyte) { field_3_text = in1.ReadUnicodeLEString(field_1_footer_len); } else { field_3_text = in1.ReadCompressedUnicode(field_1_footer_len); } } else { // Note - this is unusual for BIFF records in general, but normal for header / footer records: // when the text is empty string, the whole record is empty (just the 4 byte BIFF header) field_3_text = ""; } }
/** * Constructs an Label record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public LabelRecord(RecordInputStream in1) { field_1_row = in1.ReadUShort(); field_2_column = in1.ReadUShort(); field_3_xf_index = in1.ReadShort(); field_4_string_len = in1.ReadShort(); field_5_unicode_flag = (byte)in1.ReadByte(); if (field_4_string_len > 0) { if (IsUncompressedUnicode) { field_6_value = in1.ReadUnicodeLEString(field_4_string_len); } else { field_6_value = in1.ReadCompressedUnicode(field_4_string_len); } } else { field_6_value = ""; } }
/** * Constructs a Font record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public FontRecord(RecordInputStream in1) { field_1_font_height = in1.ReadShort(); field_2_attributes = in1.ReadShort(); field_3_color_palette_index = in1.ReadShort(); field_4_bold_weight = in1.ReadShort(); field_5_base_sub_script = in1.ReadShort(); field_6_underline = (byte)in1.ReadByte(); field_7_family = (byte)in1.ReadByte(); field_8_charset = (byte)in1.ReadByte(); field_9_zero = (byte)in1.ReadByte(); field_10_font_name_len = (byte)in1.ReadByte(); if (field_10_font_name_len > 0) { if (in1.ReadByte() == 0) { // Is compressed Unicode field_11_font_name = in1.ReadCompressedUnicode(LittleEndian.UByteToInt(field_10_font_name_len)); } else { // Is not compressed Unicode field_11_font_name = in1.ReadUnicodeLEString(field_10_font_name_len); } } }
/** * Read hyperlink from input stream * * @param in the stream to Read from */ public HyperlinkRecord(RecordInputStream in1) { try { rwFirst = in1.ReadShort(); rwLast = in1.ReadUShort(); colFirst = in1.ReadShort(); colLast = in1.ReadShort(); // 16-byte GUID guid = new byte[16]; in1.Read(guid, 0, guid.Length); label_opts = in1.ReadInt(); link_opts = in1.ReadInt(); if ((link_opts & HLINK_LABEL) != 0) { int label_len = in1.ReadInt(); label = in1.ReadUnicodeLEString(label_len); } if ((link_opts & HLINK_URL) != 0) { moniker = new byte[16]; in1.Read(moniker, 0, moniker.Length); if (Arrays.Equals(URL_MONIKER, moniker)) { int len = in1.ReadInt(); address = in1.ReadUnicodeLEString( (len - URL_TAIL.Length)/2); //minus the length of tail tail = in1.ReadRemainder(); } else if (Arrays.Equals(FILE_MONIKER, moniker)) { file_opts = in1.ReadShort(); int len = in1.ReadInt(); byte[] path_bytes = new byte[len]; in1.Read(path_bytes, 0, path_bytes.Length); address = Encoding.UTF8.GetString(path_bytes); tail = in1.ReadRemainder(); } } else if ((link_opts & HLINK_PLACE) != 0) { int len = in1.ReadInt(); address = in1.ReadUnicodeLEString(len); } } catch (IOException) { throw; } }
private static String ReadRawString(RecordInputStream in1, int textLength) { byte compressByte = (byte)in1.ReadByte(); bool isCompressed = (compressByte & 0x01) == 0; if (isCompressed) { return in1.ReadCompressedUnicode(textLength); } return in1.ReadUnicodeLEString(textLength); }
/** * Constructs a Font record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public FontRecord(RecordInputStream in1) { field_1_font_height = in1.ReadShort(); field_2_attributes = in1.ReadShort(); field_3_color_palette_index = in1.ReadShort(); field_4_bold_weight = in1.ReadShort(); field_5_base_sub_script = in1.ReadShort(); field_6_underline = (byte)in1.ReadByte(); field_7_family = (byte)in1.ReadByte(); field_8_charset = (byte)in1.ReadByte(); field_9_zero = (byte)in1.ReadByte(); field_10_font_name_len = (byte)in1.ReadByte(); if (field_10_font_name_len > 0) { if (in1.ReadByte() == 0) { // Is compressed Unicode field_11_font_name = in1.ReadCompressedUnicode(LittleEndian.UByteToInt(field_10_font_name_len)); } else { // Is not compressed Unicode field_11_font_name = in1.ReadUnicodeLEString(field_10_font_name_len); } } }
/** * Read hyperlink from input stream * * @param in the stream to Read from */ public HyperlinkRecord(RecordInputStream in1) { _range = new CellRangeAddress(in1); // 16-byte GUID _guid = new GUID(in1); /** * streamVersion (4 bytes): An unsigned integer that specifies the version number * of the serialization implementation used to save this structure. This value MUST equal 2. */ int streamVersion = in1.ReadInt(); if (streamVersion != 0x00000002) { throw new RecordFormatException("Stream Version must be 0x2 but found " + streamVersion); } _linkOpts = in1.ReadInt(); if ((_linkOpts & HLINK_LABEL) != 0) { int label_len = in1.ReadInt(); _label = in1.ReadUnicodeLEString(label_len); } if ((_linkOpts & HLINK_TARGET_FRAME) != 0) { int len = in1.ReadInt(); _targetFrame = in1.ReadUnicodeLEString(len); } if ((_linkOpts & HLINK_URL) != 0 && (_linkOpts & HLINK_UNC_PATH) != 0) { _moniker = null; int nChars = in1.ReadInt(); _address = in1.ReadUnicodeLEString(nChars); } if ((_linkOpts & HLINK_URL) != 0 && (_linkOpts & HLINK_UNC_PATH) == 0) { _moniker = new GUID(in1); if (URL_MONIKER.Equals(_moniker)) { int length = in1.ReadInt(); /** * The value of <code>length<code> be either the byte size of the url field * (including the terminating NULL character) or the byte size of the url field plus 24. * If the value of this field is set to the byte size of the url field, * then the tail bytes fields are not present. */ int remaining = in1.Remaining; if (length == remaining) { int nChars = length / 2; _address = in1.ReadUnicodeLEString(nChars); } else { int nChars = (length - TAIL_SIZE) / 2; _address = in1.ReadUnicodeLEString(nChars); /** * TODO: make sense of the remaining bytes * According to the spec they consist of: * 1. 16-byte GUID: This field MUST equal * {0xF4815879, 0x1D3B, 0x487F, 0xAF, 0x2C, 0x82, 0x5D, 0xC4, 0x85, 0x27, 0x63} * 2. Serial version, this field MUST equal 0 if present. * 3. URI Flags */ _uninterpretedTail = ReadTail(URL_uninterpretedTail, in1); } } else if (FILE_MONIKER.Equals(_moniker)) { _fileOpts = in1.ReadShort(); int len = in1.ReadInt(); _shortFilename = StringUtil.ReadCompressedUnicode(in1, len); _uninterpretedTail = ReadTail(FILE_uninterpretedTail, in1); int size = in1.ReadInt(); if (size > 0) { int charDataSize = in1.ReadInt(); //From the spec: An optional unsigned integer that MUST be 3 if present int optFlags = in1.ReadUShort(); if (optFlags != 0x0003) { throw new RecordFormatException("Expected 0x3 but found " + optFlags); } _address = StringUtil.ReadUnicodeLE(in1, charDataSize / 2); } else { _address = null; } } else if (STD_MONIKER.Equals(_moniker)) { _fileOpts = in1.ReadShort(); int len = in1.ReadInt(); byte[] path_bytes = new byte[len]; in1.ReadFully(path_bytes); _address = Encoding.UTF8.GetString(path_bytes); } } if ((_linkOpts & HLINK_PLACE) != 0) { int len = in1.ReadInt(); _textMark = in1.ReadUnicodeLEString(len); } if (in1.Remaining > 0) { Console.WriteLine(HexDump.ToHex(in1.ReadRemainder())); } }
/** * Read hyperlink from input stream * * @param in the stream to Read from */ public HyperlinkRecord(RecordInputStream in1) { _range = new CellRangeAddress(in1); // 16-byte GUID _guid = new GUID(in1); /* * streamVersion (4 bytes): An unsigned integer that specifies the version number * of the serialization implementation used to save this structure. This value MUST equal 2. */ int streamVersion = in1.ReadInt(); if (streamVersion != 0x00000002) { throw new RecordFormatException("Stream Version must be 0x2 but found " + streamVersion); } _linkOpts = in1.ReadInt(); if ((_linkOpts & HLINK_LABEL) != 0) { int label_len = in1.ReadInt(); _label = in1.ReadUnicodeLEString(label_len); } if ((_linkOpts & HLINK_TARGET_FRAME) != 0) { int len = in1.ReadInt(); _targetFrame = in1.ReadUnicodeLEString(len); } if ((_linkOpts & HLINK_URL) != 0 && (_linkOpts & HLINK_UNC_PATH) != 0) { _moniker = null; int nChars = in1.ReadInt(); _address = in1.ReadUnicodeLEString(nChars); } if ((_linkOpts & HLINK_URL) != 0 && (_linkOpts & HLINK_UNC_PATH) == 0) { _moniker = new GUID(in1); if (URL_MONIKER.Equals(_moniker)) { int length = in1.ReadInt(); /* * The value of <code>length<code> be either the byte size of the url field * (including the terminating NULL character) or the byte size of the url field plus 24. * If the value of this field is set to the byte size of the url field, * then the tail bytes fields are not present. */ int remaining = in1.Remaining; if (length == remaining) { int nChars = length / 2; _address = in1.ReadUnicodeLEString(nChars); } else { int nChars = (length - TAIL_SIZE) / 2; _address = in1.ReadUnicodeLEString(nChars); /* * TODO: make sense of the remaining bytes * According to the spec they consist of: * 1. 16-byte GUID: This field MUST equal * {0xF4815879, 0x1D3B, 0x487F, 0xAF, 0x2C, 0x82, 0x5D, 0xC4, 0x85, 0x27, 0x63} * 2. Serial version, this field MUST equal 0 if present. * 3. URI Flags */ _uninterpretedTail = ReadTail(URL_uninterpretedTail, in1); } } else if (FILE_MONIKER.Equals(_moniker)) { _fileOpts = in1.ReadShort(); int len = in1.ReadInt(); _shortFilename = StringUtil.ReadCompressedUnicode(in1, len); _uninterpretedTail = ReadTail(FILE_uninterpretedTail, in1); int size = in1.ReadInt(); if (size > 0) { int charDataSize = in1.ReadInt(); //From the spec: An optional unsigned integer that MUST be 3 if present // but some files has 4 int usKeyValue = in1.ReadUShort(); _address = StringUtil.ReadUnicodeLE(in1, charDataSize / 2); } else { _address = null; } } else if (STD_MONIKER.Equals(_moniker)) { _fileOpts = in1.ReadShort(); int len = in1.ReadInt(); byte[] path_bytes = new byte[len]; in1.ReadFully(path_bytes); _address = Encoding.UTF8.GetString(path_bytes); } } if ((_linkOpts & HLINK_PLACE) != 0) { int len = in1.ReadInt(); _textMark = in1.ReadUnicodeLEString(len); } if (in1.Remaining > 0) { Console.WriteLine(HexDump.ToHex(in1.ReadRemainder())); } }
/** * Constructs a Font record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public FontRecord(RecordInputStream in1) { field_1_font_height = in1.ReadShort(); field_2_attributes = in1.ReadShort(); field_3_color_palette_index = in1.ReadShort(); field_4_bold_weight = in1.ReadShort(); field_5_base_sub_script = in1.ReadShort(); field_6_underline = (byte)in1.ReadByte(); field_7_family = (byte)in1.ReadByte(); field_8_charset = (byte)in1.ReadByte(); field_9_zero = (byte)in1.ReadByte(); int field_10_font_name_len = (byte)in1.ReadByte(); int unicodeFlags = in1.ReadUByte(); // options byte present always (even if no character data) if (field_10_font_name_len > 0) { if (unicodeFlags == 0) { // Is compressed Unicode field_11_font_name = in1.ReadCompressedUnicode(field_10_font_name_len); } else { // Is not compressed Unicode field_11_font_name = in1.ReadUnicodeLEString(field_10_font_name_len); } } else { field_11_font_name = ""; } }
/** * Constructs an EmbeddedObjectRef record and Sets its fields appropriately. * * @param in the record input stream. */ public EmbeddedObjectRefSubRecord(RecordInputStream in1) { // Much guess-work going on here due to lack of any documentation. // See similar source code in OOO: // http://lxr.go-oo.org/source/sc/sc/source/filter/excel/xiescher.cxx // 1223 void XclImpOleObj::ReadPictFmla( XclImpStream& rStrm, sal_uInt16 nRecSize ) int streamIdOffset = in1.ReadShort(); // OOO calls this 'nFmlaLen' int dataLenAfterFormula = in1.Remaining - streamIdOffset; int formulaSize = in1.ReadUShort(); field_1_unknown_int = in1.ReadInt(); byte[] formulaRawBytes = ReadRawData(in1, formulaSize); field_2_refPtg = ReadRefPtg(formulaRawBytes); if (field_2_refPtg == null) { // common case // field_2_n16 seems to be 5 here // The formula almost looks like tTbl but the row/column values seem like garbage. field_2_unknownFormulaData = formulaRawBytes; } else { field_2_unknownFormulaData = null; } int stringByteCount; if (in1.Remaining >= dataLenAfterFormula + 3) { int tag = in1.ReadByte(); if (tag != 0x03) { throw new RecordFormatException("Expected byte 0x03 here"); } int nChars = in1.ReadUShort(); if (nChars > 0) { // OOO: the 4th way Xcl stores a unicode string: not even a Grbit byte present if Length 0 field_3_unicode_flag = (in1.ReadByte() & 0x01) != 0; if (field_3_unicode_flag) { field_4_ole_classname = in1.ReadUnicodeLEString(nChars); stringByteCount = nChars * 2; } else { field_4_ole_classname = in1.ReadCompressedUnicode(nChars); stringByteCount = nChars; } } else { field_4_ole_classname = ""; stringByteCount = 0; } } else { field_4_ole_classname = null; stringByteCount = 0; } // Pad to next 2-byte boundary if (((stringByteCount + formulaSize) % 2) != 0) { int b = in1.ReadByte(); if (field_2_refPtg != null && field_4_ole_classname == null) { field_4_unknownByte = (byte)b; } } int nUnexpectedPadding = in1.Remaining - dataLenAfterFormula; if (nUnexpectedPadding > 0) { Console.WriteLine("Discarding " + nUnexpectedPadding + " unexpected padding bytes "); ReadRawData(in1, nUnexpectedPadding); } // Fetch the stream ID if (dataLenAfterFormula >= 4) { field_5_stream_id = in1.ReadInt(); } else { field_5_stream_id = null; } field_6_unknown = in1.ReadRemainder(); }
/** * Constructs a Name record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public NameRecord(RecordInputStream in1) { field_1_option_flag = in1.ReadShort(); field_2_keyboard_shortcut = (byte)in1.ReadByte(); int field_3_length_name_text = in1.ReadByte(); int field_4_length_name_definition = in1.ReadShort(); field_5_externSheetIndex_plus1 = in1.ReadShort(); field_6_sheetNumber = in1.ReadUShort(); int field_7_length_custom_menu = in1.ReadUByte(); int field_8_length_description_text = in1.ReadUByte(); int field_9_length_help_topic_text = in1.ReadUByte(); int field_10_length_status_bar_text = in1.ReadUByte(); //store the name in byte form if it's a built-in name field_11_nameIsMultibyte = (in1.ReadByte() != 0); if (IsBuiltInName) { field_12_built_in_code = (byte)in1.ReadByte(); } else { if (field_11_nameIsMultibyte) { field_12_name_text = in1.ReadUnicodeLEString(field_3_length_name_text); } else { field_12_name_text = in1.ReadCompressedUnicode(field_3_length_name_text); } } int nBytesAvailable = in1.Available() - (field_7_length_custom_menu + field_8_length_description_text + field_9_length_help_topic_text + field_10_length_status_bar_text); field_13_name_definition = SSFormula.Formula.Read(field_4_length_name_definition, in1, nBytesAvailable); //Who says that this can only ever be compressed unicode??? field_14_custom_menu_text = in1.ReadCompressedUnicode(field_7_length_custom_menu); field_15_description_text = in1.ReadCompressedUnicode(field_8_length_description_text); field_16_help_topic_text = in1.ReadCompressedUnicode(field_9_length_help_topic_text); field_17_status_bar_text = in1.ReadCompressedUnicode(field_10_length_status_bar_text); }