public void TestLinkFormula()
        {
            RecordInputStream is1 = new RecordInputStream(new MemoryStream(linkData));

            is1.NextRecord();
            TextObjectRecord rec = new TextObjectRecord(is1);

            Ptg ptg = rec.LinkRefPtg;

            Assert.IsNotNull(ptg);
            Assert.AreEqual(typeof(RefPtg), ptg.GetType());
            RefPtg rptg = (RefPtg)ptg;

            Assert.AreEqual("T2", rptg.ToFormulaString());

            byte[] data2 = rec.Serialize();
            Assert.AreEqual(linkData.Length, data2.Length);
            Assert.IsTrue(Arrays.Equals(linkData, data2));
        }
Exemple #2
0
        public void TestConvertSharedFormulasOperandClasses_bug45123()
        {
            RecordInputStream in1        = TestcaseRecordInputStream.Create(0, SHARED_FORMULA_WITH_REF_ARRAYS_DATA);
            short             encodedLen = in1.ReadShort();

            Ptg[] sharedFormula = Ptg.ReadTokens(encodedLen, in1);

            Ptg[] convertedFormula = SharedFormulaRecord.ConvertSharedFormulas(sharedFormula, 100, 200);

            RefPtg refPtg = (RefPtg)convertedFormula[1];

            Assert.AreEqual("$C101", refPtg.ToFormulaString());
            if (refPtg.PtgClass == Ptg.CLASS_REF)
            {
                throw new AssertFailedException("Identified bug 45123");
            }

            ConfirmOperandClasses(sharedFormula, convertedFormula);
        }
Exemple #3
0
        public void TestReSerialize()
        {
            FormulaRecord formulaRecord = new FormulaRecord();

            formulaRecord.Row              = (/*setter*/ 1);
            formulaRecord.Column           = (/*setter*/ (short)1);
            formulaRecord.ParsedExpression = (/*setter*/ new Ptg[] { new RefPtg("B$5"), });
            formulaRecord.Value            = (/*setter*/ 3.3);
            byte[] ser = formulaRecord.Serialize();
            Assert.AreEqual(31, ser.Length);

            RecordInputStream in1 = TestcaseRecordInputStream.Create(ser);
            FormulaRecord     fr2 = new FormulaRecord(in1);

            Assert.AreEqual(3.3, fr2.Value, 0.0);
            Ptg[] ptgs = fr2.ParsedExpression;
            Assert.AreEqual(1, ptgs.Length);
            RefPtg rp = (RefPtg)ptgs[0];

            Assert.AreEqual("B$5", rp.ToFormulaString());
        }
Exemple #4
0
        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);
        }