public void Test_45778() { byte[] data = HexRead.ReadFromString( "15, 00, 12, 00, 14, 00, 01, 00, 01, 00, " + "01, 21, 00, 00, 3C, 13, F4, 03, 00, 00, " + "00, 00, 0C, 00, 14, 00, 00, 00, 00, 00, " + "00, 00, 00, 00, 00, 00, 01, 00, 08, 00, 00, " + "00, 10, 00, 00, 00, " + "13, 00, EE, 1F, " + "00, 00, " + "08, 00, " + //number of items "08, 00, " + //selected item "01, 03, " + //flags "00, 00, " + //objId //LbsDropData "0A, 00, " + //flags "14, 00, " + //the number of lines to be displayed in the dropdown "6C, 00, " + //the smallest width in pixels allowed for the dropdown window "00, 00, " + //num chars "00, 00"); RecordInputStream in1 = TestcaseRecordInputStream.Create(ObjRecord.sid, data); // check read OK ObjRecord record = new ObjRecord(in1); SubRecord sr = record.SubRecords[(2)]; Assert.IsTrue(sr is LbsDataSubRecord); LbsDataSubRecord lbs = (LbsDataSubRecord)sr; Assert.AreEqual(8, lbs.NumberOfItems); Assert.IsNull(lbs.Formula); // check that it re-Serializes to the same data byte[] ser = record.Serialize(); TestcaseRecordInputStream.ConfirmRecordEncoding(ObjRecord.sid, data, ser); }
public void TestReadManualComboWithFormula() { byte[] data = HexRead.ReadFromString("" + "5D 00 66 00 " + "15 00 12 00 14 00 02 00 11 20 00 00 00 00 " + "20 44 C6 04 00 00 00 00 0C 00 14 00 04 F0 C6 04 " + "00 00 00 00 00 00 01 00 06 00 00 00 10 00 00 00 " + "0E 00 0C 00 05 00 80 44 C6 04 24 09 00 02 00 02 " + "13 00 DE 1F 10 00 09 00 80 44 C6 04 25 0A 00 0F " + "00 02 00 02 00 02 06 00 03 00 08 00 00 00 00 00 " + "08 00 00 00 00 00 00 00 " // TODO sometimes last byte is non-zero ); RecordInputStream in1 = TestcaseRecordInputStream.Create(data); ObjRecord or = new ObjRecord(in1); byte[] data2 = or.Serialize(); if (data2.Length == 8228) { throw new AssertionException("Identified bug 45778"); } Assert.AreEqual(data.Length, data2.Length, "Encoded length"); for (int i = 0; i < data.Length; i++) { if (data[i] != data2[i]) { throw new AssertionException("Encoded data differs at index " + i); } } Assert.IsTrue(Arrays.Equals(data, data2)); }
public void TestFillFields() { String hexData = "01 00 " + "10 F0 " + "14 00 00 00 " + "4D 00 37 00 21 00 58 00 " + "0B 00 2C 00 16 00 63 00 " + "42 00 " + "FF DD"; byte[] data = HexRead.ReadFromString(hexData); EscherClientAnchorRecord r = new EscherClientAnchorRecord(); int bytesWritten = r.FillFields(data, new DefaultEscherRecordFactory()); Assert.AreEqual(28, bytesWritten); Assert.AreEqual((short)55, r.Col1); Assert.AreEqual((short)44, r.Col2); Assert.AreEqual((short)33, r.Dx1); Assert.AreEqual((short)22, r.Dx2); Assert.AreEqual((short)11, r.Dy1); Assert.AreEqual((short)66, r.Dy2); Assert.AreEqual((short)77, r.Flag); Assert.AreEqual((short)88, r.Row1); Assert.AreEqual((short)99, r.Row2); Assert.AreEqual((short)0x0001, r.Options); Assert.AreEqual((byte)0xFF, r.RemainingData[0]); Assert.AreEqual((byte)0xDD, r.RemainingData[1]); }
public void TestCreateProperties() { String dataStr = "41 C1 " + // propid, complex ind "03 00 00 00 " + // size of complex property "01 00 " + // propid, complex ind "00 00 00 00 " + // value "41 C1 " + // propid, complex ind "03 00 00 00 " + // size of complex property "01 02 03 " + "01 02 03 " ; byte[] data = HexRead.ReadFromString(dataStr); EscherPropertyFactory f = new EscherPropertyFactory(); IList props = f.CreateProperties(data, 0, (short)3); EscherComplexProperty p1 = (EscherComplexProperty)props[0]; Assert.AreEqual(unchecked ((short)0xC141), p1.Id); Assert.AreEqual("[01, 02, 03, ]", HexDump.ToHex(p1.ComplexData)); EscherComplexProperty p3 = (EscherComplexProperty)props[2]; Assert.AreEqual(unchecked ((short)0xC141), p3.Id); Assert.AreEqual("[01, 02, 03, ]", HexDump.ToHex(p3.ComplexData)); }
public void TestChangeOfCompressionFlag_bug25866() { byte[] changingFlagSimpleData = HexRead.ReadFromString("" + "AA AA " // fake SID + "06 00 " // first rec len 6 + HED_DUMP1 ); RecordInputStream in1 = TestcaseRecordInputStream.Create(changingFlagSimpleData); String actual; try { actual = in1.ReadUnicodeLEString(18); } catch (ArgumentException e) { if ("compressByte in continue records must be 1 while Reading unicode LE string".Equals(e.Message)) { throw new AssertionException("Identified bug 45866"); } throw e; } Assert.AreEqual("\u591A\u8A00\u8A9E - Multilingual", actual); }
public void TestMixedContinue() { /** * Taken from a real test sample file 39512.xls. See Bug 39512 for details. */ String dump = //OBJ "5D 00 48 00 15 00 12 00 0C 00 3C 00 11 00 A0 2E 03 01 CC 42 " + "CF 00 00 00 00 00 0A 00 0C 00 00 00 00 00 00 00 00 00 00 00 " + "03 00 0B 00 06 00 28 01 03 01 00 00 12 00 08 00 00 00 00 00 " + "00 00 03 00 11 00 04 00 3D 00 00 00 00 00 00 00 " + //MSODRAWING "EC 00 08 00 00 00 0D F0 00 00 00 00 " + //TXO (and 2 trailing CONTINUE records) //"B6 01 12 00 22 02 00 00 00 00 00 00 00 00 10 00 10 00 00 00 " + //"00 00 3C 00 21 00 01 4F 00 70 00 74 00 69 00 6F 00 6E 00 20 " + //"00 42 00 75 00 74 00 74 00 6F 00 6E 00 20 00 33 00 39 00 3C " + //"00 10 00 00 00 05 00 00 00 00 00 10 00 00 00 00 00 00 00 " + "B6 01 12 00 22 02 00 00 00 00 00 00 00 00 10 00 10 00 00 00 00 00 " + "3C 00 11 00 00 4F 70 74 69 6F 6E 20 42 75 74 74 6F 6E 20 33 39 " + "3C 00 10 00 00 00 05 00 00 00 00 00 10 00 00 00 00 00 00 00 " + // another CONTINUE "3C 00 7E 00 0F 00 04 F0 7E 00 00 00 92 0C 0A F0 08 00 00 00 " + "3D 04 00 00 00 0A 00 00 A3 00 0B F0 3C 00 00 00 7F 00 00 01 " + "00 01 80 00 8C 01 03 01 85 00 01 00 00 00 8B 00 02 00 00 00 " + "BF 00 08 00 1A 00 7F 01 29 00 29 00 81 01 41 00 00 08 BF 01 " + "00 00 10 00 C0 01 40 00 00 08 FF 01 00 00 08 00 00 00 10 F0 " + "12 00 00 00 02 00 02 00 A0 03 18 00 B5 00 04 00 30 02 1A 00 " + "00 00 00 00 11 F0 00 00 00 00 " + //OBJ "5D 00 48 00 15 00 12 00 0C 00 3D 00 11 00 8C 01 03 01 C8 59 CF 00 00 " + "00 00 00 0A 00 0C 00 00 00 00 00 00 00 00 00 00 00 03 00 0B 00 06 00 " + "7C 16 03 01 00 00 12 00 08 00 00 00 00 00 00 00 03 00 11 00 04 00 01 " + "00 00 00 00 00 00 00"; byte[] data = HexRead.ReadFromString(dump); IList records = RecordFactory.CreateRecords(new MemoryStream(data)); Assert.AreEqual(5, records.Count); Assert.IsTrue(records[0] is ObjRecord); Assert.IsTrue(records[1] is DrawingRecord); Assert.IsTrue(records[2] is TextObjectRecord); Assert.IsTrue(records[3] is ContinueRecord); Assert.IsTrue(records[4] is ObjRecord); //Serialize and verify that the Serialized data is1 the same as the original MemoryStream out1 = new MemoryStream(); for (IEnumerator it = records.GetEnumerator(); it.MoveNext();) { Record rec = (Record)it.Current; byte[] serialdata = rec.Serialize(); out1.Write(serialdata, 0, serialdata.Length); } byte[] ser = out1.ToArray(); Assert.AreEqual(data.Length, ser.Length); Assert.IsTrue(Arrays.Equals(data, ser)); }
public void Test_Remove_padding() { byte[] data = HexRead.ReadFromString( "5D, 00, 4C, 00, " + "15, 00, 12, 00, 12, 00, 01, 00, 11, 00, " + "00, 00, 00, 00, 00, 00, 00, 00, 00, 00, " + "00, 00, 0C, 00, 14, 00, 00, 00, 00, 00, " + "00, 00, 00, 00, 00, 00, 01, 00, 09, 00, " + "00, 00, 0F, 00, 01, 00, " + "13, 00, 1B, 00, " + "10, 00, " + //next 16 bytes is a ptg aray "09, 00, 00, 00, 00, 00, 25, 09, 00, 0C, 00, 07, 00, 07, 00, 00, " + "01, 00, " + //num lines "00, 00, " + //selected "08, 00, " + "00, 00, " + "00, 00, 00, 00, 00"); //pAdding bytes RecordInputStream in1 = TestcaseRecordInputStream.Create(data); // check read OK ObjRecord record = new ObjRecord(in1); // check that it re-Serializes to the same data byte[] ser = record.Serialize(); Assert.AreEqual(data.Length - 5, ser.Length); for (int i = 0; i < ser.Length; i++) Assert.AreEqual(data[i], ser[i]); //check we can read the Trimmed record RecordInputStream in2 = TestcaseRecordInputStream.Create(ser); ObjRecord record2 = new ObjRecord(in2); byte[] ser2 = record2.Serialize(); Assert.IsTrue(Arrays.Equals(ser, ser2)); }
public void Test_47701() { byte[] data = HexRead.ReadFromString( "15, 00, 12, 00, 12, 00, 02, 00, 11, 20, " + "00, 00, 00, 00, 80, 3D, 03, 05, 00, 00, " + "00, 00, 0C, 00, 14, 00, 00, 00, 00, 00, " + "00, 00, 00, 00, 00, 00, 01, 00, 0A, 00, " + "00, 00, 10, 00, 01, 00, 13, 00, EE, 1F, " + "10, 00, 09, 00, 40, 9F, 74, 01, 25, 09, " + "00, 0C, 00, 07, 00, 07, 00, 07, 04, 00, " + "00, 00, 08, 00, 00, 00"); RecordInputStream in1 = TestcaseRecordInputStream.Create(ObjRecord.sid, data); // check read OK ObjRecord record = new ObjRecord(in1); Assert.AreEqual(3, record.SubRecords.Count); SubRecord sr = record.SubRecords[(2)]; Assert.IsTrue(sr is LbsDataSubRecord); LbsDataSubRecord lbs = (LbsDataSubRecord)sr; Assert.AreEqual(4, lbs.NumberOfItems); Assert.IsTrue(lbs.Formula is AreaPtg); AreaPtg ptg = (AreaPtg)lbs.Formula; CellRangeAddress range = new CellRangeAddress( ptg.FirstRow, ptg.LastRow, ptg.FirstColumn, ptg.LastColumn); Assert.AreEqual("H10:H13", range.FormatAsString()); // check that it re-Serializes to the same data byte[] ser = record.Serialize(); TestcaseRecordInputStream.ConfirmRecordEncoding(ObjRecord.sid, data, ser); }
public void TestshortRecordWrittenByMSAccess() { /* * Data taken from two example files * ex42564-21435.xls * bug_42794.xls (from bug 42794 attachment 20429) * In both cases, this data is found at offset 0x0C1C. */ byte[] data = HexRead.ReadFromString("" + "5C 00 39 00 " + "36 00 00 41 20 73 61 74 69 73 66 69 65 64 20 4D " + "69 63 72 6F 73 6F 66 74 20 4F 66 66 69 63 65 39 " + "20 55 73 65 72" + "20 20 20 20 20 20 20 20 20 20 20 " + "20 20 20 20 20 20 20 20 20"); RecordInputStream in1 = TestcaseRecordInputStream.Create(data); WriteAccessRecord rec = new WriteAccessRecord(in1); Assert.AreEqual("A satisfied Microsoft Office9 User", rec.Username); byte[] expectedEncoding = HexRead.ReadFromString("" + "22 00 00 41 20 73 61 74 69 73 66 69 65 64 20 4D " + "69 63 72 6F 73 6F 66 74 20 4F 66 66 69 63 65 39 " + "20 55 73 65 72" + "20 20 20 20 20 20 20 20 20 20 20 " + HEX_SIXTYFOUR_SPACES); TestcaseRecordInputStream.ConfirmRecordEncoding(WriteAccessRecord.sid, expectedEncoding, rec.Serialize()); }
public void TestBadFirstField_bug48096() { /** * Data taken from the sample file referenced in Bugzilla 48096, file offset 0x0D45. * The apparent problem is that the first data short field has been written with the * wrong <i>endianness</n>. Excel seems to ignore whatever value is present in this * field, and always reWrites it as (C1, 01). POI now does the same. */ byte[] badData = HexRead.ReadFromString("C1 01 08 00 01 C1 00 00 00 01 69 61"); byte[] goodData = HexRead.ReadFromString("C1 01 08 00 C1 01 00 00 00 01 69 61"); RecordInputStream in1 = TestcaseRecordInputStream.Create(badData); RecalcIdRecord r; try { r = new RecalcIdRecord(in1); } catch (RecordFormatException e) { if (e.Message.Equals("expected 449 but got 49409")) { throw new AssertionException("Identified bug 48096"); } throw e; } Assert.AreEqual(0, in1.Remaining); Assert.IsTrue(Arrays.Equals(r.Serialize(), goodData)); }
public void TestOlderFormat_bug46918() { // There are 10 SXVDEX records in the file (not uploaded) that originated bugzilla 46918 // They all had the following hex encoding: byte[] data = HexRead.ReadFromString("00 01 0A 00 1E 14 00 0A FF FF FF FF 00 00"); RecordInputStream in1 = TestcaseRecordInputStream.Create(data); ExtendedPivotTableViewFieldsRecord rec; try { rec = new ExtendedPivotTableViewFieldsRecord(in1); } catch (RecordFormatException e) { if (e.Message.Equals("Not enough data (0) to read requested (2) bytes")) { throw new AssertionException("Identified bug 46918"); } throw e; } byte[] expReserData = HexRead.ReadFromString("1E 14 00 0A FF FF FF FF 00 00" + "FF FF 00 00 00 00 00 00 00 00"); TestcaseRecordInputStream.ConfirmRecordEncoding(ExtendedPivotTableViewFieldsRecord.sid, expReserData, rec.Serialize()); }
/** * Makes sure the record stream starts with {@link BOFRecord} and then {@link WindowOneRecord} * The second record is Gets decrypted so this method also Checks its content. */ private void ConfirmReadInitialRecords(RecordFactoryInputStream rfis) { Assert.AreEqual(typeof(BOFRecord), rfis.NextRecord().GetType()); WindowOneRecord rec1 = (WindowOneRecord)rfis.NextRecord(); Assert.IsTrue(Arrays.Equals(HexRead.ReadFromString(SAMPLE_WINDOW1), rec1.Serialize())); }
public void TestRead() { String hex = "21 02 25 00 01 00 01 00 01 01 00 00 00 00 00 00 " + "17 00 65 00 00 01 00 02 C0 02 C0 65 00 00 01 00 " + "03 C0 03 C0 04 62 01 07 00"; byte[] data = HexRead.ReadFromString(hex); RecordInputStream in1 = TestcaseRecordInputStream.Create(data); ArrayRecord r1 = new ArrayRecord(in1); CellRangeAddress8Bit range = r1.Range; Assert.AreEqual(1, range.FirstColumn); Assert.AreEqual(1, range.LastColumn); Assert.AreEqual(1, range.FirstRow); Assert.AreEqual(1, range.LastRow); Ptg[] ptg = r1.FormulaTokens; Assert.AreEqual(FormulaRenderer.ToFormulaString(null, ptg), "MAX(C1:C2-D1:D2)"); //construct a new ArrayRecord with the same contents as r1 Ptg[] fmlaPtg = FormulaParser.Parse("MAX(C1:C2-D1:D2)", null, FormulaType.Array, 0); ArrayRecord r2 = new ArrayRecord(Formula.Create(fmlaPtg), new CellRangeAddress8Bit(1, 1, 1, 1)); byte[] ser = r2.Serialize(); //serialize and check that the data is the same as in r1 Assert.AreEqual(HexDump.ToHex(data), HexDump.ToHex(ser)); }
/** * @param expectedFirstInt expected value of the first int read from the decrypted stream */ public StreamTester(MockStream ms, String keyDigestHex, int expectedFirstInt) { _ms = ms; byte[] keyDigest = HexRead.ReadFromString(keyDigestHex); _bds = new Biff8DecryptingStream(_ms, 0, new Biff8EncryptionKey(keyDigest)); Assert.AreEqual(expectedFirstInt, _bds.ReadInt()); _errorsOccurred = false; }
public TestEscherBlipWMFRecord() { dataStr = "2C 15 18 F0 34 00 00 00 01 01 01 01 01 01 01 01 " + "01 01 01 01 01 01 01 01 06 00 00 00 03 00 00 00 " + "01 00 00 00 04 00 00 00 02 00 00 00 0A 00 00 00 " + "0B 00 00 00 05 00 00 00 08 07 01 02"; data = HexRead.ReadFromString(dataStr); }
public void TestMixedContinue() { /** * Taken from a real test sample file 39512.xls. See Bug 39512 for details. */ String dump = //OBJ "5D, 00, 48, 00, 15, 00, 12, 00, 0C, 00, 3C, 00, 11, 00, A0, 2E, 03, 01, CC, 42, " + "CF, 00, 00, 00, 00, 00, 0A, 00, 0C, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, " + "03, 00, 0B, 00, 06, 00, 28, 01, 03, 01, 00, 00, 12, 00, 08, 00, 00, 00, 00, 00, " + "00, 00, 03, 00, 11, 00, 04, 00, 3D, 00, 00, 00, 00, 00, 00, 00, " + //MSODRAWING "EC, 00, 08, 00, 00, 00, 0D, F0, 00, 00, 00, 00, " + //TXO "B6, 01, 12, 00, 22, 02, 00, 00, 00, 00, 00, 00, 00, 00, 10, 00, 10, 00, 00, 00, " + "00, 00, 3C, 00, 21, 00, 01, 4F, 00, 70, 00, 74, 00, 69, 00, 6F, 00, 6E, 00, 20, " + "00, 42, 00, 75, 00, 74, 00, 74, 00, 6F, 00, 6E, 00, 20, 00, 33, 00, 39, 00, 3C, " + "00, 10, 00, 00, 00, 05, 00, 00, 00, 00, 00, 10, 00, 00, 00, 00, 00, 00, 00, " + //CONTINUE "3C, 00, 7E, 00, 0F, 00, 04, F0, 7E, 00, 00, 00, 92, 0C, 0A, F0, 08, 00, 00, 00, " + "3D, 04, 00, 00, 00, 0A, 00, 00, A3, 00, 0B, F0, 3C, 00, 00, 00, 7F, 00, 00, 01, " + "00, 01, 80, 00, 8C, 01, 03, 01, 85, 00, 01, 00, 00, 00, 8B, 00, 02, 00, 00, 00, " + "BF, 00, 08, 00, 1A, 00, 7F, 01, 29, 00, 29, 00, 81, 01, 41, 00, 00, 08, BF, 01, " + "00, 00, 10, 00, C0, 01, 40, 00, 00, 08, FF, 01, 00, 00, 08, 00, 00, 00, 10, F0, " + "12, 00, 00, 00, 02, 00, 02, 00, A0, 03, 18, 00, B5, 00, 04, 00, 30, 02, 1A, 00, " + "00, 00, 00, 00, 11, F0, 00, 00, 00, 00, " + //OBJ "5D, 00, 48, 00, 15, 00, 12, 00, 0C, 00, 3D, 00, 11, 00, 8C, 01, 03, 01, C8, 59, CF, 00, 00, " + "00, 00, 00, 0A, 00, 0C, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 03, 00, 0B, 00, 06, 00, " + "7C, 16, 03, 01, 00, 00, 12, 00, 08, 00, 00, 00, 00, 00, 00, 00, 03, 00, 11, 00, 04, 00, 01, " + "00, 00, 00, 00, 00, 00, 00"; byte[] data = HexRead.ReadFromString(dump); IList records = RecordFactory.CreateRecords(new MemoryStream(data)); Assert.AreEqual(5, records.Count); Assert.IsTrue(records[0] is ObjRecord); Assert.IsTrue(records[1] is DrawingRecord); Assert.IsTrue(records[2] is TextObjectRecord); Assert.IsTrue(records[3] is ContinueRecord); Assert.IsTrue(records[4] is ObjRecord); //Serialize and verify that the Serialized data is1 the same as the original MemoryStream out1 = new MemoryStream(); for (IEnumerator it = records.GetEnumerator(); it.MoveNext();) { Record rec = (Record)it.Current; byte[] serialdata = rec.Serialize(); out1.Write(serialdata, 0, serialdata.Length); } byte[] ser = out1.ToArray(); Assert.AreEqual(data.Length, ser.Length); Assert.IsTrue(Arrays.Equals(data, ser)); }
public void TestFillFields() { string TestData = "0F 02 " + // options "11 F1 " + // record id "00 00 00 00"; // remaining bytes UnknownEscherRecord r = new UnknownEscherRecord(); IEscherRecordFactory factory = new DefaultEscherRecordFactory(); r.FillFields(HexRead.ReadFromString(TestData), factory); Assert.AreEqual(0x020F, r.Options); Assert.AreEqual(unchecked ((short)0xF111), r.RecordId); Assert.IsTrue(r.IsContainerRecord); Assert.AreEqual(8, r.RecordSize); Assert.AreEqual(0, r.ChildRecords.Count); Assert.AreEqual(0, r.Data.Length); TestData = "00 02 " + // options "11 F1 " + // record id "04 00 00 00 " + // remaining bytes "01 02 03 04"; r = new UnknownEscherRecord(); r.FillFields(HexRead.ReadFromString(TestData), factory); Assert.AreEqual(0x0200, r.Options); Assert.AreEqual(unchecked ((short)0xF111), r.RecordId); Assert.AreEqual(12, r.RecordSize); Assert.IsFalse(r.IsContainerRecord); Assert.AreEqual(0, r.ChildRecords.Count); Assert.AreEqual(4, r.Data.Length); Assert.AreEqual(1, r.Data[0]); Assert.AreEqual(2, r.Data[1]); Assert.AreEqual(3, r.Data[2]); Assert.AreEqual(4, r.Data[3]); TestData = "0F 02 " + // options "11 F1 " + // record id "08 00 00 00 " + // remaining bytes "00 02 " + // options "FF FF " + // record id "00 00 00 00"; // remaining bytes r = new UnknownEscherRecord(); r.FillFields(HexRead.ReadFromString(TestData), factory); Assert.AreEqual(0x020F, r.Options); Assert.AreEqual(unchecked ((short)0xF111), r.RecordId); Assert.AreEqual(8, r.RecordSize); Assert.IsTrue(r.IsContainerRecord); Assert.AreEqual(1, r.ChildRecords.Count); Assert.AreEqual(unchecked ((short)0xFFFF), r.GetChild(0).RecordId); }
public void Test52337() { // document summary stream from test1-excel.doc attached to Bugzilla 52337 String hex = "FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00 00 00 00 00" + "00 00 00 00 02 00 00 00 02 D5 CD D5 9C 2E 1B 10 93 97 08 00" + "2B 2C F9 AE 44 00 00 00 05 D5 CD D5 9C 2E 1B 10 93 97 08 00" + "2B 2C F9 AE 58 01 00 00 14 01 00 00 0C 00 00 00 01 00 00 00" + "68 00 00 00 0F 00 00 00 70 00 00 00 05 00 00 00 98 00 00 00" + "06 00 00 00 A0 00 00 00 11 00 00 00 A8 00 00 00 17 00 00 00" + "B0 00 00 00 0B 00 00 00 B8 00 00 00 10 00 00 00 C0 00 00 00" + "13 00 00 00 C8 00 00 00 16 00 00 00 D0 00 00 00 0D 00 00 00" + "D8 00 00 00 0C 00 00 00 F3 00 00 00 02 00 00 00 E4 04 00 00" + "1E 00 00 00 20 00 00 00 44 65 70 61 72 74 6D 65 6E 74 20 6F" + "66 20 49 6E 74 65 72 6E 61 6C 20 41 66 66 61 69 72 73 00 00" + "03 00 00 00 05 00 00 00 03 00 00 00 01 00 00 00 03 00 00 00" + "47 03 00 00 03 00 00 00 0F 27 0B 00 0B 00 00 00 00 00 00 00" + "0B 00 00 00 00 00 00 00 0B 00 00 00 00 00 00 00 0B 00 00 00" + "00 00 00 00 1E 10 00 00 01 00 00 00 0F 00 00 00 54 68 69 73" + "20 69 73 20 61 20 74 65 73 74 00 0C 10 00 00 02 00 00 00 1E" + "00 00 00 06 00 00 00 54 69 74 6C 65 00 03 00 00 00 01 00 00" + "00 00 00 00 A8 00 00 00 03 00 00 00 00 00 00 00 20 00 00 00" + "01 00 00 00 38 00 00 00 02 00 00 00 40 00 00 00 01 00 00 00" + "02 00 00 00 0C 00 00 00 5F 50 49 44 5F 48 4C 49 4E 4B 53 00" + "02 00 00 00 E4 04 00 00 41 00 00 00 60 00 00 00 06 00 00 00" + "03 00 00 00 74 00 74 00 03 00 00 00 09 00 00 00 03 00 00 00" + "00 00 00 00 03 00 00 00 05 00 00 00 1F 00 00 00 0C 00 00 00" + "4E 00 6F 00 72 00 6D 00 61 00 6C 00 32 00 2E 00 78 00 6C 00" + "73 00 00 00 1F 00 00 00 0A 00 00 00 53 00 68 00 65 00 65 00" + "74 00 31 00 21 00 44 00 32 00 00 00 "; byte[] bytes = HexRead.ReadFromString(hex); PropertySet ps = PropertySetFactory.Create(new ByteArrayInputStream(bytes)); DocumentSummaryInformation dsi = (DocumentSummaryInformation)ps; Section s = (Section)dsi.Sections[0]; Object hdrs = s.GetProperty(PropertyIDMap.PID_HEADINGPAIR); Assert.IsNotNull(hdrs, "PID_HEADINGPAIR was not found"); Assert.IsTrue(hdrs is byte[], "PID_HEADINGPAIR: expected byte[] but was " + hdrs.GetType()); // parse the value Vector v = new Vector((short)Variant.VT_VARIANT); v.Read((byte[])hdrs, 0); TypedPropertyValue[] items = v.Values; Assert.AreEqual(2, items.Length); Assert.IsNotNull(items[0].Value); Assert.IsTrue(items[0].Value is CodePageString, "first item must be CodePageString but was " + items[0].GetType()); Assert.IsNotNull(items[1].Value); Assert.IsTrue(Number.IsInteger(items[1].Value), "second item must be Integer but was " + items[1].Value.GetType()); Assert.AreEqual(1, (int)items[1].Value); }
public void TestOneReservedByte() { byte[] inpData = HexRead.ReadFromString("7D 00 0B 00 00 00 00 00 24 02 0F 00 00 00 01"); byte[] outData = HexRead.ReadFromString("7D 00 0C 00 00 00 00 00 24 02 0F 00 00 00 01 00"); RecordInputStream in1 = TestcaseRecordInputStream.Create(inpData); ColumnInfoRecord cir = new ColumnInfoRecord(in1); Assert.AreEqual(0, in1.Remaining); Assert.IsTrue(Arrays.Equals(outData, cir.Serialize())); }
public void TestBasicDeSerializeReserialize() { byte[] data = HexRead.ReadFromString( "C1 01" + // rt "00 00" + // reserved "1D EB 01 00"); // engine id RecalcIdRecord r = Create(data); TestcaseRecordInputStream.ConfirmRecordEncoding(RecalcIdRecord.sid, data, r.Serialize()); }
private static PageItemRecord ConfirmSerialize(String hexDump) { byte[] data = HexRead.ReadFromString(hexDump); RecordInputStream in1 = TestcaseRecordInputStream.Create(PageItemRecord.sid, data); PageItemRecord rec = new PageItemRecord(in1); Assert.AreEqual(0, in1.Remaining); Assert.AreEqual(4 + data.Length, rec.RecordSize); byte[] data2 = rec.Serialize(); TestcaseRecordInputStream.ConfirmRecordEncoding(PageItemRecord.sid, data, data2); return(rec); }
public void TestCreateAggregate() { String msoDrawingRecord1 = "0F 00 02 F0 20 01 00 00 10 00 08 F0 08 00 00 00 " + "03 00 00 00 02 04 00 00 0F 00 03 F0 08 01 00 00 " + "0F 00 04 F0 28 00 00 00 01 00 09 F0 10 00 00 00 " + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + "02 00 0A F0 08 00 00 00 00 04 00 00 05 00 00 00 " + "0F 00 04 F0 64 00 00 00 42 01 0A F0 08 00 00 00 " + "01 04 00 00 00 0A 00 00 73 00 0B F0 2A 00 00 00 " + "BF 00 08 00 08 00 44 01 04 00 00 00 7F 01 00 00 " + "01 00 BF 01 00 00 11 00 C0 01 40 00 00 08 FF 01 " + "10 00 10 00 BF 03 00 00 08 00 00 00 10 F0 12 00 " + "00 00 00 00 01 00 54 00 05 00 45 00 01 00 88 03 " + "05 00 94 00 00 00 11 F0 00 00 00 00"; String msoDrawingRecord2 = "0F 00 04 F0 64 00 00 00 42 01 0A F0 08 00 00 00 " + "02 04 00 00 80 0A 00 00 73 00 0B F0 2A 00 00 00 " + "BF 00 08 00 08 00 44 01 04 00 00 00 7F 01 00 00 " + "01 00 BF 01 00 00 11 00 C0 01 40 00 00 08 FF 01 " + "10 00 10 00 BF 03 00 00 08 00 00 00 10 F0 12 00 " + "00 00 00 00 01 00 8D 03 05 00 E4 00 03 00 4D 03 " + "0B 00 0C 00 00 00 11 F0 00 00 00 00"; DrawingRecord d1 = new DrawingRecord(); d1.Data = (HexRead.ReadFromString(msoDrawingRecord1)); ObjRecord r1 = new ObjRecord(); DrawingRecord d2 = new DrawingRecord(); d2.Data = (HexRead.ReadFromString(msoDrawingRecord2)); ObjRecord r2 = new ObjRecord(); ArrayList records = new ArrayList(); records.Add(d1); records.Add(r1); records.Add(d2); records.Add(r2); DrawingManager2 drawingManager = new DrawingManager2(new EscherDggRecord()); EscherAggregate aggregate = EscherAggregate.CreateAggregate(records, 0, drawingManager); Assert.AreEqual(1, aggregate.EscherRecords.Count); Assert.AreEqual(unchecked ((short)0xF002), aggregate.GetEscherRecord(0).RecordId); Assert.AreEqual(2, aggregate.GetEscherRecord(0).ChildRecords.Count); // System.out.println( "aggregate = " + aggregate ); }
public static byte[] Decode(string[] hexDataLines) { MemoryStream baos = new MemoryStream(hexDataLines.Length * 32 + 32); for (int i = 0; i < hexDataLines.Length; i++) { byte[] lineData = HexRead.ReadFromString(hexDataLines[i]); baos.Write(lineData, 0, lineData.Length); } return(baos.ToArray()); }
public void TestChangeFromUnCompressedToCompressed() { byte[] changingFlagSimpleData = HexRead.ReadFromString("" + "AA AA " // fake SID + "0F 00 " // first rec len 15 + HED_DUMP2 ); RecordInputStream in1 = TestcaseRecordInputStream.Create(changingFlagSimpleData); String actual = in1.ReadCompressedUnicode(18); Assert.AreEqual("Multilingual - \u591A\u8A00\u8A9E", actual); }
public void TestReSerialize() { byte[] data = HexRead .ReadFromString("" + "20 00 00 01 0B 00 00 00 01 00 00 00 00 00 00 06 3B 00 00 00 00 02 00 00 00 09 00]"); RecordInputStream in1 = TestcaseRecordInputStream.Create(NameRecord.sid, data); NameRecord nr = new NameRecord(in1); Assert.AreEqual(0x0020, nr.OptionFlag); byte[] data2 = nr.Serialize(); TestcaseRecordInputStream.ConfirmRecordEncoding(NameRecord.sid, data, data2); }
private static byte[] ReadSampleHexData(String sampleFileName, String sectionName,int recSid) { Stream is1 = HSSFTestDataSamples.OpenSampleFileStream(sampleFileName); byte[] data; try { data = HexRead.ReadData(is1, sectionName); } catch (IOException) { throw; } return TestcaseRecordInputStream.MergeDataAndSid(recSid, data.Length, data); }
public void TestUnicodeFlag_bug46693() { byte[] data = HexRead.ReadFromString("01 00 01 00 01 00 04 00 05 00 00 6D 61 72 63 6F"); RecordInputStream in1 = TestcaseRecordInputStream.Create(ViewFieldsRecord.sid, data); ViewFieldsRecord rec = new ViewFieldsRecord(in1); if (in1.Remaining == 1) { throw new AssertionException("Identified bug 46693b"); } Assert.AreEqual(0, in1.Remaining); Assert.AreEqual(4 + data.Length, rec.RecordSize); }
public void Test41946() { string dataStr1 = "03 08 0B F0 00 03 00 00 81 00 30 65 01 00 82 00 98 B2 00 00 83 00 30 65 01 " + "00 84 00 98 B2 00 00 85 00 00 00 00 00 87 00 01 00 00 00 88 00 00 00 00 00 " + "89 00 00 00 00 00 BF 00 00 00 0F 00 0C 01 F4 00 00 10 0D 01 00 00 00 20 0E " + "01 00 00 00 20 80 01 00 00 00 00 81 01 04 00 00 08 82 01 00 00 01 00 83 01 " + "00 00 00 08 84 01 00 00 01 00 85 01 00 00 00 20 86 41 00 00 00 00 87 C1 00 " + "00 00 00 88 01 00 00 00 00 89 01 00 00 00 00 8A 01 00 00 00 00 8B 01 00 00 " + "00 00 8C 01 00 00 00 00 8D 01 00 00 00 00 8E 01 00 00 00 00 8F 01 00 00 00 " + "00 90 01 00 00 00 00 91 01 00 00 00 00 92 01 00 00 00 00 93 01 00 00 00 00 " + "94 01 00 00 00 00 95 01 00 00 00 00 96 01 00 00 00 00 97 C1 00 00 00 00 98 " + "01 00 00 00 00 99 01 00 00 00 00 9A 01 00 00 00 00 9B 01 00 00 00 00 9C 01 " + "03 00 00 40 BF 01 0C 00 1E 00 C0 01 01 00 00 08 C1 01 00 00 01 00 C2 01 FF " + "FF FF 00 C3 01 00 00 00 20 C4 01 00 00 00 00 C5 41 00 00 00 00 C6 C1 00 00 " + "00 00 C7 01 00 00 00 00 C8 01 00 00 00 00 C9 01 00 00 00 00 CA 01 00 00 00 " + "00 CB 01 35 25 00 00 CC 01 00 00 08 00 CD 01 00 00 00 00 CE 01 00 00 00 00 " + "CF C1 00 00 00 00 D7 01 02 00 00 00 FF 01 06 00 0E 00 00 02 00 00 00 00 01 " + "02 02 00 00 08 02 02 CB CB CB 00 03 02 00 00 00 20 04 02 00 00 01 00 05 02 " + "38 63 00 00 06 02 38 63 00 00 07 02 00 00 00 00 08 02 00 00 00 00 09 02 00 " + "00 01 00 0A 02 00 00 00 00 0B 02 00 00 00 00 0C 02 00 00 01 00 0D 02 00 00 " + "00 00 0E 02 00 00 00 00 0F 02 00 01 00 00 10 02 00 00 00 00 11 02 00 00 00 " + "00 3F 02 00 00 03 00 80 02 00 00 00 00 81 02 00 00 01 00 82 02 05 00 00 00 " + "83 02 9C 31 00 00 84 02 00 00 00 00 85 02 F0 F9 06 00 86 02 00 00 00 00 87 " + "02 F7 00 00 10 88 02 00 00 00 20 BF 02 01 00 0F 00 C0 02 00 00 00 00 C1 02 " + "00 00 00 00 C2 02 64 00 00 00 C3 02 00 00 00 00 C4 02 00 00 00 00 C5 02 00 " + "00 00 00 C6 02 00 00 00 00 C7 02 00 00 00 00 C8 02 00 00 00 00 C9 02 00 00 " + "00 00 CA 02 30 75 00 00 CB 02 D0 12 13 00 CC 02 30 ED EC FF CD 02 40 54 89 " + "00 CE 02 00 80 00 00 CF 02 00 80 FF FF D0 02 00 00 79 FF D1 02 32 00 00 00 " + "D2 02 20 4E 00 00 D3 02 50 C3 00 00 D4 02 00 00 00 00 D5 02 10 27 00 00 D6 " + "02 70 94 00 00 D7 02 B0 3C FF FF D8 02 00 00 00 00 D9 02 10 27 00 00 DA 02 " + "70 94 00 00 FF 02 16 00 1F 00 04 03 01 00 00 00 41 03 A8 29 01 00 42 03 00 " + "00 00 00 43 03 03 00 00 00 44 03 7C BE 01 00 45 03 00 00 00 00 7F 03 00 00 " + "0F 00 84 03 7C BE 01 00 85 03 00 00 00 00 86 03 7C BE 01 00 87 03 00 00 00 " + "00"; EscherOptRecord r = new EscherOptRecord(); byte[] data = HexRead.ReadFromString(dataStr1); r.FillFields(data, 0, new DefaultEscherRecordFactory()); Assert.AreEqual(unchecked ((short)0xF00B), r.RecordId); byte[] data1 = r.Serialize(); EscherOptRecord opt2 = new EscherOptRecord(); opt2.FillFields(data1, new DefaultEscherRecordFactory()); byte[] data2 = opt2.Serialize(); Assert.IsTrue(Arrays.Equals(data1, data2)); }
public void TestFillExtras() { byte[] examples = HexRead.ReadFromString("" + "88 03 67 06 07 00 00 00 00 00 00 23 00 00 00 4D " + "61 63 72 6F 31 3A 01 00 00 00 11 00 00 4D 61 63 " + "72 6F 20 72 65 63 6F 72 64 65 64 20 32 37 2D 53 " + "65 70 2D 39 33 20 62 79 20 41 4C 4C 57 4F 52"); NameRecord name = new NameRecord(TestcaseRecordInputStream.Create(NameRecord.sid, examples)); string description = name.DescriptionText; Assert.IsNotNull(description); Assert.IsTrue(description.EndsWith("Macro recorded 27-Sep-93 by ALLWOR")); }
public void TestReadString() { byte[] changingFlagFullData = HexRead.ReadFromString("" + "AA AA " // fake SID + "12 00 " // first rec len 18 (15 + next 3 bytes) + "12 00 " // total chars 18 + "00 " // this bit compressed + HED_DUMP2 ); RecordInputStream in1 = TestcaseRecordInputStream.Create(changingFlagFullData); String actual = in1.ReadString(); Assert.AreEqual("Multilingual - \u591A\u8A00\u8A9E", actual); }