/// <summary> /// Creates the anchor. /// </summary> /// <param name="userAnchor">The user anchor.</param> /// <returns></returns> public static EscherRecord CreateAnchor(HSSFAnchor userAnchor) { if (userAnchor is HSSFClientAnchor) { HSSFClientAnchor a = (HSSFClientAnchor)userAnchor; EscherClientAnchorRecord anchor = new EscherClientAnchorRecord(); anchor.RecordId=EscherClientAnchorRecord.RECORD_ID; anchor.Options=(short)0x0000; anchor.Flag=(short)a.AnchorType; anchor.Col1=(short)Math.Min(a.Col1, a.Col2); anchor.Dx1=(short)a.Dx1; anchor.Row1=(short)Math.Min(a.Row1, a.Row2); anchor.Dy1=(short)a.Dy1; anchor.Col2=(short)Math.Max(a.Col1, a.Col2); anchor.Dx2=(short)a.Dx2; anchor.Row2=(short)Math.Max(a.Row1, a.Row2); anchor.Dy2=(short)a.Dy2; return anchor; } else { HSSFChildAnchor a = (HSSFChildAnchor)userAnchor; EscherChildAnchorRecord anchor = new EscherChildAnchorRecord(); anchor.RecordId=EscherChildAnchorRecord.RECORD_ID; anchor.Options=(short)0x0000; anchor.Dx1=(short)Math.Min(a.Dx1, a.Dx2); anchor.Dy1=(short)Math.Min(a.Dy1, a.Dy2); anchor.Dx2=(short)Math.Max(a.Dx2, a.Dx1); anchor.Dy2=(short)Math.Max(a.Dy2, a.Dy1); return anchor; } }
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; }
/// <summary> /// Creates the lowerlevel escher records for this shape. /// </summary> /// <param name="hssfShape">The HSSF shape.</param> /// <param name="shapeId">The shape id.</param> /// <returns></returns> private EscherContainerRecord CreateSpContainer(HSSFSimpleShape hssfShape, int shapeId) { HSSFShape shape = hssfShape; EscherContainerRecord spContainer = new EscherContainerRecord(); EscherSpRecord sp = new EscherSpRecord(); EscherOptRecord opt = new EscherOptRecord(); EscherRecord anchor = new EscherClientAnchorRecord(); EscherClientDataRecord clientData = new EscherClientDataRecord(); spContainer.RecordId=EscherContainerRecord.SP_CONTAINER; spContainer.Options=(short)0x000F; sp.RecordId=EscherSpRecord.RECORD_ID; sp.Options=(short)((EscherAggregate.ST_LINE << 4) | 0x2); sp.ShapeId=shapeId; sp.Flags=EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE; opt.RecordId=EscherOptRecord.RECORD_ID; opt.AddEscherProperty(new EscherShapePathProperty(EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX)); opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 1048592)); AddStandardOptions(shape, opt); HSSFAnchor userAnchor = shape.Anchor; if (userAnchor.IsHorizontallyFlipped) sp.Flags=sp.Flags | EscherSpRecord.FLAG_FLIPHORIZ; if (userAnchor.IsVerticallyFlipped) sp.Flags=sp.Flags | EscherSpRecord.FLAG_FLIPVERT; anchor = CreateAnchor(userAnchor); clientData.RecordId=EscherClientDataRecord.RECORD_ID; clientData.Options=((short)0x0000); spContainer.AddChildRecord(sp); spContainer.AddChildRecord(opt); spContainer.AddChildRecord(anchor); spContainer.AddChildRecord(clientData); return spContainer; }
/// <summary> /// Creates a new client anchor and defaults all the anchor positions to 0. /// </summary> public HSSFClientAnchor() { //Is this necessary? this._escherClientAnchor = new EscherClientAnchorRecord(); }
public HSSFClientAnchor(EscherClientAnchorRecord escherClientAnchorRecord) { this._escherClientAnchor = escherClientAnchorRecord; }
protected override void CreateEscherAnchor() { _escherClientAnchor = new EscherClientAnchorRecord(); }
/// <summary> /// Creates the lowerlevel escher records for this shape. /// </summary> /// <param name="hssfShape">The HSSF shape.</param> /// <param name="shapeId">The shape id.</param> /// <returns></returns> private EscherContainerRecord CreateSpContainer(HSSFTextbox hssfShape, int shapeId) { HSSFTextbox shape = hssfShape; EscherContainerRecord spContainer = new EscherContainerRecord(); EscherSpRecord sp = new EscherSpRecord(); EscherOptRecord opt = new EscherOptRecord(); EscherRecord anchor = new EscherClientAnchorRecord(); EscherClientDataRecord clientData = new EscherClientDataRecord(); escherTextbox = new EscherTextboxRecord(); spContainer.RecordId=EscherContainerRecord.SP_CONTAINER; spContainer.Options=(short)0x000F; sp.RecordId=EscherSpRecord.RECORD_ID; sp.Options=(short)((EscherAggregate.ST_TEXTBOX << 4) | 0x2); sp.ShapeId=shapeId; sp.Flags=EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE; opt.RecordId=EscherOptRecord.RECORD_ID; // opt.AddEscherProperty( new EscherBoolProperty( EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 262144 ) ); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTID, 0)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTLEFT, shape.MarginLeft)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTRIGHT, shape.MarginRight)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTBOTTOM, shape.MarginBottom)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTTOP, shape.MarginTop)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__WRAPTEXT, 0)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__ANCHORTEXT, 0)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, 0x00080000)); AddStandardOptions(shape, opt); HSSFAnchor userAnchor = shape.Anchor; // if (userAnchor.IsHorizontallyFlipped()) // sp.Flags(sp.Flags | EscherSpRecord.FLAG_FLIPHORIZ); // if (userAnchor.IsVerticallyFlipped()) // sp.Flags(sp.Flags | EscherSpRecord.FLAG_FLIPVERT); anchor = CreateAnchor(userAnchor); clientData.RecordId=EscherClientDataRecord.RECORD_ID; clientData.Options=(short)0x0000; escherTextbox.RecordId=EscherTextboxRecord.RECORD_ID; escherTextbox.Options=(short)0x0000; spContainer.AddChildRecord(sp); spContainer.AddChildRecord(opt); spContainer.AddChildRecord(anchor); spContainer.AddChildRecord(clientData); spContainer.AddChildRecord(escherTextbox); return spContainer; }
private EscherClientAnchorRecord CreateRecord() { EscherClientAnchorRecord r = new EscherClientAnchorRecord(); r.Col1=(short)55; r.Col2=(short)44; r.Dx1=(short)33; r.Dx2=(short)22; r.Dy1=(short)11; r.Dy2=(short)66; r.Flag=(short)77; r.Row1=(short)88; r.Row2=(short)99; r.Options=(short)0x0001; r.RemainingData=new byte[] { (byte)0xFF, (byte)0xDD }; return r; }
public void TestCreateClientAnchorFromContainer() { EscherContainerRecord container = new EscherContainerRecord(); EscherClientAnchorRecord escher = new EscherClientAnchorRecord(); escher.Flag=((short)3); escher.Col1=((short)11); escher.Col2=((short)12); escher.Row1=((short)13); escher.Row2=((short)14); escher.Dx1=((short)15); escher.Dx2=((short)16); escher.Dy1=((short)17); escher.Dy2=((short)18); container.AddChildRecord(escher); HSSFClientAnchor anchor = (HSSFClientAnchor)HSSFAnchor.CreateAnchorFromEscher(container); Assert.AreEqual(anchor.Col1, 11); Assert.AreEqual(escher.Col1, 11); Assert.AreEqual(anchor.Col2, 12); Assert.AreEqual(escher.Col2, 12); Assert.AreEqual(anchor.Row1, 13); Assert.AreEqual(escher.Row1, 13); Assert.AreEqual(anchor.Row2, 14); Assert.AreEqual(escher.Row2, 14); Assert.AreEqual(anchor.Dx1, 15); Assert.AreEqual(escher.Dx1, 15); Assert.AreEqual(anchor.Dx2, 16); Assert.AreEqual(escher.Dx2, 16); Assert.AreEqual(anchor.Dy1, 17); Assert.AreEqual(escher.Dy1, 17); Assert.AreEqual(anchor.Dy2, 18); Assert.AreEqual(escher.Dy2, 18); }
public void TestClientAnchorFromEscher() { EscherClientAnchorRecord escher = new EscherClientAnchorRecord(); escher.Col1=((short)11); escher.Col2=((short)12); escher.Row1=((short)13); escher.Row2=((short)14); escher.Dx1=((short)15); escher.Dx2=((short)16); escher.Dy1=((short)17); escher.Dy2=((short)18); HSSFClientAnchor anchor = new HSSFClientAnchor(escher); Assert.AreEqual(anchor.Col1, 11); Assert.AreEqual(escher.Col1, 11); Assert.AreEqual(anchor.Col2, 12); Assert.AreEqual(escher.Col2, 12); Assert.AreEqual(anchor.Row1, 13); Assert.AreEqual(escher.Row1, 13); Assert.AreEqual(anchor.Row2, 14); Assert.AreEqual(escher.Row2, 14); Assert.AreEqual(anchor.Dx1, 15); Assert.AreEqual(escher.Dx1, 15); Assert.AreEqual(anchor.Dx2, 16); Assert.AreEqual(escher.Dx2, 16); Assert.AreEqual(anchor.Dy1, 17); Assert.AreEqual(escher.Dy1, 17); Assert.AreEqual(anchor.Dy2, 18); Assert.AreEqual(escher.Dy2, 18); }
/// <summary> /// Creates a new client anchor and defaults all the anchor positions to 0. /// </summary> public HSSFClientAnchor() { this._escherClientAnchor = new EscherClientAnchorRecord(); }