public void SetUp() { dgg = new EscherDggRecord(); dgg.FileIdClusters = (new EscherDggRecord.FileIdCluster[0]); drawingManager2 = new DrawingManager2(dgg); }
public void TestDrawingGroupExists() { EscherDggRecord dgg = new EscherDggRecord(); dgg.DrawingsSaved=(1); dgg.FileIdClusters=(new EscherDggRecord.FileIdCluster[]{ new EscherDggRecord.FileIdCluster( 2, 10 )}); DrawingManager dm = new DrawingManager(dgg); Assert.IsFalse(dm.DrawingGroupExists((short)1)); Assert.IsTrue(dm.DrawingGroupExists((short)2)); Assert.IsFalse(dm.DrawingGroupExists((short)3)); }
public void TestFindFreeSPIDBlock() { EscherDggRecord dgg = new EscherDggRecord(); DrawingManager dm = new DrawingManager(dgg); dgg.ShapeIdMax = (1024); Assert.AreEqual(2048, dm.FindFreeSPIDBlock()); dgg.ShapeIdMax = (1025); Assert.AreEqual(2048, dm.FindFreeSPIDBlock()); dgg.ShapeIdMax = (2047); Assert.AreEqual(2048, dm.FindFreeSPIDBlock()); }
public void TestFindNewDrawingGroupId() { EscherDggRecord dgg = new EscherDggRecord(); dgg.DrawingsSaved=(1); dgg.FileIdClusters=(new EscherDggRecord.FileIdCluster[]{ new EscherDggRecord.FileIdCluster( 2, 10 )}); DrawingManager dm = new DrawingManager(dgg); Assert.AreEqual(1, dm.FindNewDrawingGroupId()); dgg.FileIdClusters=(new EscherDggRecord.FileIdCluster[]{ new EscherDggRecord.FileIdCluster( 1, 10 ), new EscherDggRecord.FileIdCluster( 2, 10 )}); Assert.AreEqual(3, dm.FindNewDrawingGroupId()); }
public void TestCreateDgRecord() { EscherDggRecord dgg = new EscherDggRecord(); dgg.DrawingsSaved=(0); dgg.FileIdClusters=(new EscherDggRecord.FileIdCluster[] { }); DrawingManager dm = new DrawingManager(dgg); EscherDgRecord dgRecord = dm.CreateDgRecord(); Assert.AreEqual(-1, dgRecord.LastMSOSPID); Assert.AreEqual(0, dgRecord.NumShapes); Assert.AreEqual(1, dm.Dgg.DrawingsSaved); Assert.AreEqual(1, dm.Dgg.FileIdClusters.Length); Assert.AreEqual(1, dm.Dgg.FileIdClusters[0].DrawingGroupId); Assert.AreEqual(0, dm.Dgg.FileIdClusters[0].NumShapeIdsUsed); }
public void TestAllocateShapeId() { EscherDggRecord dgg = new EscherDggRecord(); dgg.DrawingsSaved=(0); dgg.FileIdClusters=(new EscherDggRecord.FileIdCluster[] { }); DrawingManager dm = new DrawingManager(dgg); EscherDgRecord dg = dm.CreateDgRecord(); int shapeId = dm.AllocateShapeId(dg.DrawingGroupId); Assert.AreEqual(1024, shapeId); Assert.AreEqual(1025, dgg.ShapeIdMax); Assert.AreEqual(1, dgg.DrawingsSaved); Assert.AreEqual(1, dgg.FileIdClusters[0].DrawingGroupId); Assert.AreEqual(1, dgg.FileIdClusters[0].NumShapeIdsUsed); Assert.AreEqual(1024, dg.LastMSOSPID); Assert.AreEqual(1, dg.NumShapes); }
public void TestFillFields() { String hexData = "00 00 " + "06 F0 " + "18 00 00 00 " + "02 04 00 00 " + "02 00 00 00 " + "02 00 00 00 " + "01 00 00 00 " + "01 00 00 00 02 00 00 00"; byte[] data = HexRead.ReadFromString(hexData); EscherDggRecord r = new EscherDggRecord(); int bytesWritten = r.FillFields(data, new DefaultEscherRecordFactory()); Assert.AreEqual(32, bytesWritten); Assert.AreEqual(0x402, r.ShapeIdMax); Assert.AreEqual(0x02, r.NumIdClusters); Assert.AreEqual(0x02, r.NumShapesSaved); Assert.AreEqual(0x01, r.DrawingsSaved); Assert.AreEqual(1, r.FileIdClusters.Length); Assert.AreEqual(0x01, r.FileIdClusters[0].DrawingGroupId); Assert.AreEqual(0x02, r.FileIdClusters[0].NumShapeIdsUsed); }
Hashtable dgMap = new Hashtable(); // key = Short(drawingId), value=EscherDgRecord public DrawingManager(EscherDggRecord dgg) { this.dgg = dgg; }
/** * Creates a primary drawing Group record. If it already * exists then it's modified. */ public void CreateDrawingGroup() { if (drawingManager == null) { EscherContainerRecord dggContainer = new EscherContainerRecord(); EscherDggRecord dgg = new EscherDggRecord(); EscherOptRecord opt = new EscherOptRecord(); EscherSplitMenuColorsRecord splitMenuColors = new EscherSplitMenuColorsRecord(); dggContainer.RecordId=unchecked((short)0xF000); dggContainer.Options=(short)0x000F; dgg.RecordId=EscherDggRecord.RECORD_ID; dgg.Options=(short)0x0000; dgg.ShapeIdMax=1024; dgg.NumShapesSaved=0; dgg.DrawingsSaved=0; dgg.FileIdClusters=new EscherDggRecord.FileIdCluster[] { }; drawingManager = new DrawingManager2(dgg); EscherContainerRecord bstoreContainer = null; if (escherBSERecords.Count > 0) { bstoreContainer = new EscherContainerRecord(); bstoreContainer.RecordId=EscherContainerRecord.BSTORE_CONTAINER; bstoreContainer.Options=(short)((escherBSERecords.Count << 4) | 0xF); for (IEnumerator iterator = escherBSERecords.GetEnumerator(); iterator.MoveNext(); ) { EscherRecord escherRecord = (EscherRecord)iterator.Current; bstoreContainer.AddChildRecord(escherRecord); } } opt.RecordId=unchecked((short)0xF00B); opt.Options=(short)0x0033; opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 524296)); opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, 0x08000041)); opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, 134217792)); splitMenuColors.RecordId=unchecked((short)0xF11E); splitMenuColors.Options=(short)0x0040; splitMenuColors.Color1=0x0800000D; splitMenuColors.Color2=0x0800000C; splitMenuColors.Color3=0x08000017; splitMenuColors.Color4=0x100000F7; dggContainer.AddChildRecord(dgg); if (bstoreContainer != null) dggContainer.AddChildRecord(bstoreContainer); dggContainer.AddChildRecord(opt); dggContainer.AddChildRecord(splitMenuColors); int dgLoc = FindFirstRecordLocBySid(DrawingGroupRecord.sid); if (dgLoc == -1) { DrawingGroupRecord drawingGroup = new DrawingGroupRecord(); drawingGroup.AddEscherRecord(dggContainer); int loc = FindFirstRecordLocBySid(CountryRecord.sid); Records.Insert(loc + 1, drawingGroup); } else { DrawingGroupRecord drawingGroup = new DrawingGroupRecord(); drawingGroup.AddEscherRecord(dggContainer); Records[dgLoc]= drawingGroup; } } }
private EscherDggRecord CreateRecord() { EscherDggRecord r = new EscherDggRecord(); r.Options=(short)0x0000; r.RecordId=EscherDggRecord.RECORD_ID; r.ShapeIdMax=0x402; r.NumShapesSaved=0x02; r.DrawingsSaved=0x01; r.FileIdClusters=new EscherDggRecord.FileIdCluster[] { new EscherDggRecord.FileIdCluster( 1, 2 ) }; return r; }
public void TestRecordSize() { EscherDggRecord r = new EscherDggRecord(); r.FileIdClusters=new EscherDggRecord.FileIdCluster[] { new EscherDggRecord.FileIdCluster(0, 0) }; Assert.AreEqual(32, r.RecordSize); }