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]); }
/** * Create a new Shape * * @param isChild <code>true</code> if the Line is inside a group, <code>false</code> otherwise * @return the record Container which holds this shape */ protected EscherContainerRecord CreateSpContainer(bool IsChild) { _escherContainer = new EscherContainerRecord(); _escherContainer.SetRecordId(EscherContainerRecord.SP_CONTAINER); _escherContainer.SetOptions((short)15); EscherSpRecord sp = new EscherSpRecord(); int flags = EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE; if (isChild) flags |= EscherSpRecord.FLAG_CHILD; sp.SetFlags(flags); _escherContainer.AddChildRecord(sp); EscherOptRecord opt = new EscherOptRecord(); opt.SetRecordId(EscherOptRecord.RECORD_ID); _escherContainer.AddChildRecord(opt); EscherRecord anchor; if (isChild) anchor = new EscherChildAnchorRecord(); else { anchor = new EscherClientAnchorRecord(); //hack. internal variable EscherClientAnchorRecord.shortRecord can be //Initialized only in FillFields(). We need to Set shortRecord=false; byte[] header = new byte[16]; LittleEndian.PutUshort(header, 0, 0); LittleEndian.PutUshort(header, 2, 0); LittleEndian.PutInt(header, 4, 8); anchor.FillFields(header, 0, null); } _escherContainer.AddChildRecord(anchor); return _escherContainer; }