public void TestConvertSharedFormulasOperandClasses_bug45123() { ILittleEndianInput in1 = TestcaseRecordInputStream.CreateLittleEndian(SHARED_FORMULA_WITH_REF_ARRAYS_DATA); int encodedLen = in1.ReadUShort(); Ptg[] sharedFormula = Ptg.ReadTokens(encodedLen, in1); SharedFormula sf = new SharedFormula(SpreadsheetVersion.EXCEL97); Ptg[] ConvertedFormula = sf.ConvertSharedFormulas(sharedFormula, 100, 200); RefPtg refPtg = (RefPtg)ConvertedFormula[1]; Assert.AreEqual("$C101", refPtg.ToFormulaString()); if (refPtg.PtgClass == Ptg.CLASS_REF) { throw new AssertionException("Identified bug 45123"); } ConfirmOperandClasses(sharedFormula, ConvertedFormula); }
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); } }
/** * @param in the stream to read data from * @param cbFContinued the seconf short in the record header * @param cmoOt the Containing Obj's {@link CommonObjectDataSubRecord#field_1_objectType} */ public LbsDataSubRecord(LittleEndianInput in1, int cbFContinued, int cmoOt) { _cbFContinued = cbFContinued; int encodedTokenLen = in1.ReadUShort(); if (encodedTokenLen > 0) { 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"); } _linkPtg = ptgs[0]; switch (encodedTokenLen - formulaSize - 6) { case 1: _unknownPostFormulaByte = (byte)in1.ReadByte(); break; case 0: _unknownPostFormulaByte = null; break; default: throw new RecordFormatException("Unexpected leftover bytes"); } } _cLines = in1.ReadUShort(); _iSel = in1.ReadUShort(); _flags = in1.ReadUShort(); _idEdit = in1.ReadUShort(); // From [MS-XLS].pdf 2.5.147 FtLbsData: // This field MUST exist if and only if the Containing Obj?s cmo.ot is equal to 0x14. if (cmoOt == 0x14) { _dropData = new LbsDropData(in1); } // From [MS-XLS].pdf 2.5.147 FtLbsData: // This array MUST exist if and only if the fValidPlex flag (0x2) is set if ((_flags & 0x2) != 0) { _rgLines = new String[_cLines]; for (int i = 0; i < _cLines; i++) { _rgLines[i] = StringUtil.ReadUnicodeString(in1); } } // bits 5-6 in the _flags specify the type // of selection behavior this list control is expected to support // From [MS-XLS].pdf 2.5.147 FtLbsData: // This array MUST exist if and only if the wListType field is not equal to 0. if (((_flags >> 4) & 0x2) != 0) { _bsels = new bool[_cLines]; for (int i = 0; i < _cLines; i++) { _bsels[i] = in1.ReadByte() == 1; } } }