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); } }
public ArrayRecord(RecordInputStream in1) : base(in1) { _options = in1.ReadUShort(); _field3notUsed = in1.ReadInt(); int formulaTokenLen = in1.ReadUShort(); int totalFormulaLen = in1.Available(); _formula = LF.Utils.NPOI.SS.Formula.Formula.Read(formulaTokenLen, in1, totalFormulaLen); }
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); }
/// <summary> /// Constructs a Selection record and Sets its fields appropriately. /// </summary> /// <param name="in1">the RecordInputstream to Read the record from</param> public SelectionRecord(RecordInputStream in1) { field_1_pane = (byte)in1.ReadByte(); field_2_row_active_cell = in1.ReadUShort(); field_3_col_active_cell = in1.ReadShort(); field_4_ref_active_cell = in1.ReadShort(); int field_5_num_refs = in1.ReadUShort(); field_6_refs = new CellRangeAddress8Bit[field_5_num_refs]; for (int i = 0; i < field_5_num_refs; i++) { field_6_refs[i] = new CellRangeAddress8Bit(in1); } }
public FeatRecord(RecordInputStream in1) { futureHeader = new FtrHeader(in1); isf_sharedFeatureType = in1.ReadShort(); reserved1 = (byte)in1.ReadByte(); reserved2 = in1.ReadInt(); int cref = in1.ReadUShort(); cbFeatData = in1.ReadInt(); reserved3 = in1.ReadShort(); cellRefs = new CellRangeAddress[cref]; for (int i = 0; i < cellRefs.Length; i++) { cellRefs[i] = new CellRangeAddress(in1); } switch (isf_sharedFeatureType) { case FeatHdrRecord.SHAREDFEATURES_ISFPROTECTION: sharedFeature = new FeatProtection(in1); break; case FeatHdrRecord.SHAREDFEATURES_ISFFEC2: sharedFeature = new FeatFormulaErr2(in1); break; case FeatHdrRecord.SHAREDFEATURES_ISFFACTOID: sharedFeature = new FeatSmartTag(in1); break; default: System.Console.WriteLine("Unknown Shared Feature " + isf_sharedFeatureType + " found!"); break; } }
/** * Constructs a MulBlank record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public MulBlankRecord(RecordInputStream in1) { _row = in1.ReadUShort(); _first_col = in1.ReadShort(); _xfs = ParseXFs(in1); _last_col = in1.ReadShort(); }
/** * Constructs a BoolErr record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public BoolErrRecord(RecordInputStream in1) : base(in1) { switch (in1.Remaining) { case 2: _value = in1.ReadByte(); break; case 3: _value = in1.ReadUShort(); break; default: throw new RecordFormatException("Unexpected size (" + in1.Remaining + ") for BOOLERR record."); } int flag = in1.ReadUByte(); switch (flag) { case 0: _isError = false; break; case 1: _isError = true; break; default: throw new RecordFormatException("Unexpected isError flag (" + flag + ") for BOOLERR record."); } }
/** * Constructs a MulRK record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public MulRKRecord(RecordInputStream in1) { field_1_row = in1.ReadUShort(); field_2_first_col = in1.ReadShort(); field_3_rks = RkRec.ParseRKs(in1); field_4_last_col = in1.ReadShort(); }
/** * Constructs a <c>NoteRecord</c> and Fills its fields * from the supplied <c>RecordInputStream</c>. * * @param in the stream to Read from */ public NoteRecord(RecordInputStream in1) { field_1_row = in1.ReadShort(); field_2_col = in1.ReadUShort(); field_3_flags = in1.ReadShort(); field_4_shapeid = in1.ReadUShort(); int length = in1.ReadShort(); field_5_hasMultibyte = in1.ReadByte() != 0x00; if (field_5_hasMultibyte) { field_6_author = StringUtil.ReadUnicodeLE(in1, length); } else { field_6_author = StringUtil.ReadCompressedUnicode(in1, length); } if (in1.Available() == 1) { field_7_padding = (byte)in1.ReadByte(); } }
/** * @param in the RecordInputstream to read the record from */ public CellRangeAddressList(RecordInputStream in1) { int nItems = in1.ReadUShort(); _list = new ArrayList(nItems); for (int k = 0; k < nItems; k++) { _list.Add(new CellRangeAddress(in1)); } }
/** * Constructs a DBCellRecord and Sets its fields appropriately * @param in the RecordInputstream to Read the record from */ public DBCellRecord(RecordInputStream in1) { field_1_row_offset = in1.ReadUShort(); int size = in1.Remaining; field_2_cell_offsets = new short[size / 2]; for (int i = 0; i < field_2_cell_offsets.Length; i++) { field_2_cell_offsets[i] = in1.ReadShort(); } }
/** * Constructs a MergedCellsRecord and Sets its fields appropriately * @param in the RecordInputstream to Read the record from */ public MergeCellsRecord(RecordInputStream in1) { int nRegions = in1.ReadUShort(); CellRangeAddress[] cras = new CellRangeAddress[nRegions]; for (int i = 0; i < nRegions; i++) { cras[i] = new CellRangeAddress(in1); } _numberOfRegions = nRegions; _startIndex = 0; _regions = cras; }
/** * Constructs a ColumnInfo record and Sets its fields appropriately * @param in the RecordInputstream to Read the record from */ public ColumnInfoRecord(RecordInputStream in1) { _first_col = in1.ReadUShort(); _last_col = in1.ReadUShort(); _col_width = in1.ReadUShort(); _xf_index = in1.ReadUShort(); _options = in1.ReadUShort(); switch (in1.Remaining) { case 2: // usual case field_6_reserved = in1.ReadUShort(); break; case 1: // often COLINFO Gets encoded 1 byte short // shouldn't matter because this field Is Unused field_6_reserved = in1.ReadByte(); break; case 0: // According to bugzilla 48332, // "SoftArtisans OfficeWriter for Excel" totally skips field 6 // Excel seems to be OK with this, and assumes zero. field_6_reserved = 0; break; default: throw new Exception("Unusual record size remaining=(" + in1.Remaining + ")"); } }
/** * Constructs a WriteAccess record and Sets its fields appropriately. * @param in the RecordInputstream to Read the record from */ public WriteAccessRecord(RecordInputStream in1) { if (in1.Remaining > DATA_SIZE) { throw new RecordFormatException("Expected data size (" + DATA_SIZE + ") but got (" + in1.Remaining + ")"); } // The string is always 112 characters (padded with spaces), therefore // this record can not be continued. int nChars = in1.ReadUShort(); int is16BitFlag = in1.ReadUByte(); if (nChars > DATA_SIZE || (is16BitFlag & 0xFE) != 0) { // String header looks wrong (probably missing) // OOO doc says this is optional anyway. // reconstruct data byte[] data = new byte[3 + in1.Remaining]; LittleEndian.PutUShort(data, 0, nChars); LittleEndian.PutByte(data, 2, is16BitFlag); in1.ReadFully(data, 3, data.Length - 3); char[] data1=new char[data.Length]; for (int i = 0; i < data.Length; i++) { data1[i] = (char)data[i]; } String rawValue = new String(data1); Username = rawValue.Trim(); return; } String rawText; if ((is16BitFlag & 0x01) == 0x00) { rawText = StringUtil.ReadCompressedUnicode(in1, nChars); } else { rawText = StringUtil.ReadUnicodeLE(in1, nChars); } field_1_username = rawText.Trim(); // consume padding int padSize = in1.Remaining; while (padSize > 0) { // in some cases this seems to be garbage (non spaces) in1.ReadUByte(); padSize--; } }
/** * 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 = ""; } }
public FilePassRecord(RecordInputStream in1) { _encryptionType = in1.ReadUShort(); switch (_encryptionType) { case ENCRYPTION_XOR: throw new RecordFormatException("HSSF does not currently support XOR obfuscation"); case ENCRYPTION_OTHER: // handled below break; default: throw new RecordFormatException("Unknown encryption type " + _encryptionType); } _encryptionInfo = in1.ReadUShort(); switch (_encryptionInfo) { case ENCRYPTION_OTHER_RC4: // handled below break; case ENCRYPTION_OTHER_CAPI_2: case ENCRYPTION_OTHER_CAPI_3: throw new RecordFormatException( "HSSF does not currently support CryptoAPI encryption"); default: throw new RecordFormatException("Unknown encryption info " + _encryptionInfo); } _minorVersionNo = in1.ReadUShort(); if (_minorVersionNo != 1) { throw new RecordFormatException("Unexpected VersionInfo number for RC4Header " + _minorVersionNo); } _docId = Read(in1, 16); _saltData = Read(in1, 16); _saltHash = Read(in1, 16); }
public DataItemRecord(RecordInputStream in1) { isxvdData = in1.ReadUShort(); iiftab = in1.ReadUShort(); df = in1.ReadUShort(); isxvd = in1.ReadUShort(); isxvi = in1.ReadUShort(); ifmt = in1.ReadUShort(); name = in1.ReadString(); }
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); } } }
public ViewDefinitionRecord(RecordInputStream in1) { rwFirst = in1.ReadUShort(); rwLast = in1.ReadUShort(); colFirst = in1.ReadUShort(); colLast = in1.ReadUShort(); rwFirstHead = in1.ReadUShort(); rwFirstData = in1.ReadUShort(); colFirstData = in1.ReadUShort(); iCache = in1.ReadUShort(); reserved = in1.ReadUShort(); sxaxis4Data = in1.ReadUShort(); ipos4Data = in1.ReadUShort(); cDim = in1.ReadUShort(); cDimRw = in1.ReadUShort(); cDimCol = in1.ReadUShort(); cDimPg = in1.ReadUShort(); cDimData = in1.ReadUShort(); cRw = in1.ReadUShort(); cCol = in1.ReadUShort(); grbit = in1.ReadUShort(); itblAutoFmt = in1.ReadUShort(); int cchName = in1.ReadUShort(); int cchData = in1.ReadUShort(); name = StringUtil.ReadUnicodeString(in1, cchName); dataField = StringUtil.ReadUnicodeString(in1, cchData); }
/** * Constructs a DV record and Sets its fields appropriately. * * @param in the RecordInputstream to Read the record from */ public DVRecord(RecordInputStream in1) { _option_flags = in1.ReadInt(); _promptTitle = ReadUnicodeString(in1); _errorTitle = ReadUnicodeString(in1); _promptText = ReadUnicodeString(in1); _errorText = ReadUnicodeString(in1); int field_size_first_formula = in1.ReadUShort(); _not_used_1 = in1.ReadShort(); //read first formula data condition _formula1 = LF.Utils.NPOI.SS.Formula.Formula.Read(field_size_first_formula, in1); int field_size_sec_formula = in1.ReadUShort(); _not_used_2 = in1.ReadShort(); //read sec formula data condition _formula2 = LF.Utils.NPOI.SS.Formula.Formula.Read(field_size_sec_formula, in1); //read cell range address list with all affected ranges _regions = new CellRangeAddressList(in1); }
/** * Constructs a WindowProtect record and Sets its fields appropriately. * @param in the RecordInputstream to Read the record from */ public WindowProtectRecord(RecordInputStream in1) : this(in1.ReadUShort()) { }
/** * 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())); } }
protected CellRecord(RecordInputStream in1) { _rowIndex = in1.ReadUShort(); _columnIndex = in1.ReadUShort(); _formatIndex = in1.ReadUShort(); }
/** * Constructs a RECALCID record and Sets its fields appropriately. * @param in the RecordInputstream to Read the record from */ public RecalcIdRecord(RecordInputStream in1) { in1.ReadUShort(); // field 'rt' should have value 0x01C1, but Excel doesn't care during reading _reserved0 = in1.ReadUShort(); _engineId = in1.ReadInt(); }
public ExternalNameRecord(RecordInputStream in1) { field_1_option_flag = in1.ReadShort(); field_2_ixals = in1.ReadShort(); field_3_not_used = in1.ReadShort(); int numChars = in1.ReadUByte(); field_4_name = StringUtil.ReadUnicodeString(in1, numChars); // the record body can take different forms. // The form is dictated by the values of 3-th and 4-th bits in field_1_option_flag if (!IsOLELink && !IsStdDocumentNameIdentifier) { // another switch: the fWantAdvise bit specifies whether the body describes // an external defined name or a DDE data item if (IsAutomaticLink) { if (in1.Available() > 0) { //body specifies DDE data item int nColumns = in1.ReadUByte() + 1; int nRows = in1.ReadShort() + 1; int totalCount = nRows * nColumns; _ddeValues = ConstantValueParser.Parse(in1, totalCount); _nColumns = nColumns; _nRows = nRows; } } else { //body specifies an external defined name int formulaLen = in1.ReadUShort(); field_5_name_definition = Formula.Read(formulaLen, in1); } } //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 = LF.Utils.NPOI.SS.Formula.Formula.Read(formulaLen, in1, nBytesRemaining); }
/** * Constructs a UseSelFS record and Sets its fields appropriately. * @param in the RecordInputstream to Read the record from */ public UseSelFSRecord(RecordInputStream in1) : this(in1.ReadUShort()) { }
public Break(RecordInputStream in1) { main = in1.ReadUShort() - 1; subFrom = in1.ReadUShort(); subTo = in1.ReadUShort(); }
/** * Constructs a RefreshAll record and Sets its fields appropriately. * @param in the RecordInputstream to Read the record from */ public RefreshAllRecord(RecordInputStream in1) : this(in1.ReadUShort()) { }
public TextObjectRecord(RecordInputStream in1) { field_1_options = in1.ReadUShort(); field_2_textOrientation = in1.ReadUShort(); field_3_reserved4 = in1.ReadUShort(); field_4_reserved5 = in1.ReadUShort(); field_5_reserved6 = in1.ReadUShort(); int field_6_textLength = in1.ReadUShort(); int field_7_formattingDataLength = in1.ReadUShort(); field_8_reserved7 = in1.ReadInt(); if (in1.Remaining > 0) { // Text Objects can have simple reference formulas // (This bit not mentioned in the MS document) if (in1.Remaining < 11) { throw new RecordFormatException("Not enough remaining data for a link formula"); } int formulaSize = in1.ReadUShort(); _unknownPreFormulaInt = in1.ReadInt(); Ptg[] ptgs = Ptg.ReadTokens(formulaSize, in1); if (ptgs.Length != 1) { throw new RecordFormatException("Read " + ptgs.Length + " tokens but expected exactly 1"); } _linkRefPtg = (OperandPtg)ptgs[0]; if (in1.Remaining > 0) { _unknownPostFormulaByte = (byte)in1.ReadByte(); } else { _unknownPostFormulaByte = null; } } else { _linkRefPtg = null; } if (in1.Remaining > 0) { throw new RecordFormatException("Unused " + in1.Remaining + " bytes at end of record"); } String text; if (field_6_textLength > 0) { text = ReadRawString(in1, field_6_textLength); } else { text = ""; } _text = new HSSFRichTextString(text); if (field_7_formattingDataLength > 0) { ProcessFontRuns(in1, _text, field_7_formattingDataLength); } }
/** * Constructs a DefaultColumnWidth record and Sets its fields appropriately. * @param in the RecordInputstream to Read the record from */ public DefaultColWidthRecord(RecordInputStream in1) { field_1_col_width = in1.ReadUShort(); }