Exemplo n.º 1
0
        public void TestReadContinued()
        {
            //simulate a continues Drawing record
            MemoryStream out1 = new MemoryStream();
            //main part
            DrawingRecord dg = new DrawingRecord();

            byte[] data1 = new byte[8224];
            Arrays.Fill(data1, (byte)1);
            dg.SetData(data1);
            byte[] dataX = dg.Serialize();
            out1.Write(dataX, 0, dataX.Length);

            //continued part
            byte[] data2 = new byte[4048];
            Arrays.Fill(data2, (byte)2);
            ContinueRecord cn = new ContinueRecord(data2);

            dataX = cn.Serialize();
            out1.Write(dataX, 0, dataX.Length);

            List <Record> rec = RecordFactory.CreateRecords(new MemoryStream(out1.ToArray()));

            Assert.AreEqual(2, rec.Count);
            Assert.IsTrue(rec[0] is DrawingRecord);
            Assert.IsTrue(rec[1] is ContinueRecord);

            Assert.IsTrue(Arrays.Equals(data1, ((DrawingRecord)rec[0]).RecordData));
            Assert.IsTrue(Arrays.Equals(data2, ((ContinueRecord)rec[1]).Data));
        }
Exemplo n.º 2
0
        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.SetData(HexRead.ReadFromString(msoDrawingRecord1));

            ObjRecord r1 = new ObjRecord();

            DrawingRecord d2 = new DrawingRecord();

            d2.SetData(HexRead.ReadFromString(msoDrawingRecord2));

            ObjRecord r2 = new ObjRecord();

            List <RecordBase> records = new List <RecordBase>();

            records.Add(d1);
            records.Add(r1);
            records.Add(d2);
            records.Add(r2);

            EscherAggregate aggregate = EscherAggregate.CreateAggregate(records, 0);

            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 );
        }
Exemplo n.º 3
0
        private static DrawingRecord CreateDrawingRecord()
        {
            //throw new NotImplementedException();
            byte[] drawingData = HexRead.ReadFromString("0F 00 02 F0 48 00 00 00 30 00 08 F0 " +
                                                        "08 00 00 00 01 00 00 00 00 0C 00 00 0F 00 03 F0 " +
                                                        "30 00 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 0C 00 00 " +
                                                        "05 00 00 00");

            DrawingRecord retval = new DrawingRecord();

            retval.SetData(drawingData);
            return(retval);
        }
Exemplo n.º 4
0
        public void TestCreateAggregate()
        {
            String msoDrawingRecord1 =
                "0F 00 02 F0 20 01 00 00 10 00 08 F0 08 00 00 00 \n" +
                "03 00 00 00 02 04 00 00 0F 00 03 F0 08 01 00 00 \n" +
                "0F 00 04 F0 28 00 00 00 01 00 09 F0 10 00 00 00 \n" +
                "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n" +
                "02 00 0A F0 08 00 00 00 00 04 00 00 05 00 00 00 \n" +
                "0F 00 04 F0 64 00 00 00 42 01 0A F0 08 00 00 00 \n" +
                "01 04 00 00 00 0A 00 00 73 00 0B F0 2A 00 00 00 \n" +
                "BF 00 08 00 08 00 44 01 04 00 00 00 7F 01 00 00 \n" +
                "01 00 BF 01 00 00 11 00 C0 01 40 00 00 08 FF 01 \n" +
                "10 00 10 00 BF 03 00 00 08 00 00 00 10 F0 12 00 \n" +
                "00 00 00 00 01 00 54 00 05 00 45 00 01 00 88 03 \n" +
                "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.SetData(HexRead.ReadFromString(msoDrawingRecord1));

            ObjRecord r1 = new ObjRecord();

            DrawingRecord d2 = new DrawingRecord();

            d2.SetData(HexRead.ReadFromString(msoDrawingRecord2));

            TextObjectRecord r2 = new TextObjectRecord();

            r2.Str = (new HSSFRichTextString("Aggregated"));
            NoteRecord n2 = new NoteRecord();

            List <RecordBase> recordStream = new List <RecordBase>();

            recordStream.Add(InternalSheet.CreateBOF());
            recordStream.Add(d1);
            recordStream.Add(r1);
            recordStream.Add(CreateWindow2Record());
            recordStream.Add(EOFRecord.instance);

            ConfirmAggregatedRecords(recordStream);


            recordStream = new List <RecordBase>();
            recordStream.Add(InternalSheet.CreateBOF());
            recordStream.Add(d1);
            recordStream.Add(r1);
            recordStream.Add(d2);
            recordStream.Add(r2);
            recordStream.Add(CreateWindow2Record());
            recordStream.Add(EOFRecord.instance);

            ConfirmAggregatedRecords(recordStream);

            recordStream = new List <RecordBase>();
            recordStream.Add(InternalSheet.CreateBOF());
            recordStream.Add(d1);
            recordStream.Add(r1);
            recordStream.Add(d2);
            recordStream.Add(r2);
            recordStream.Add(n2);
            recordStream.Add(CreateWindow2Record());
            recordStream.Add(EOFRecord.instance);

            ConfirmAggregatedRecords(recordStream);
        }