private void CheckSerializeComplex() { //Complex escher record EscherOptRecord r = new EscherOptRecord(); r.Options = (short)0x0033; r.RecordId = unchecked ((short)0xF00B); EscherBoolProperty prop1 = new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1); EscherComplexProperty prop2 = new EscherComplexProperty((short)1, false, new byte[] { 0x01, 0x02 }); EscherBoolProperty prop3 = new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1); r.AddEscherProperty(prop1); r.AddEscherProperty(prop2); r.AddEscherProperty(prop3); byte[] data = new byte[28]; int bytesWritten = r.Serialize(0, data); Assert.AreEqual(28, bytesWritten); string dataStr = "[33, 00, " + "0B, F0, " + "14, 00, 00, 00, " + "BF, 00, 01, 00, 00, 00, " + "01, 80, 02, 00, 00, 00, " + "BF, 00, 01, 00, 00, 00, " + "01, 02]"; Assert.AreEqual(dataStr, HexDump.ToHex(data)); }
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)); }
/// <summary> /// Does this HSSFPatriarch contain a chart? /// (Technically a reference to a chart, since they /// Get stored in a different block of records) /// FIXME - detect chart in all cases (only seems /// to work on some charts so far) /// </summary> /// <returns> /// <c>true</c> if this instance contains chart; otherwise, <c>false</c>. /// </returns> public bool ContainsChart() { // TODO - support charts properly in usermodel // We're looking for a EscherOptRecord EscherOptRecord optRecord = (EscherOptRecord) _boundAggregate.FindFirstWithId(EscherOptRecord.RECORD_ID); if (optRecord == null) { // No opt record, can't have chart return(false); } for (IEnumerator it = optRecord.EscherProperties.GetEnumerator(); it.MoveNext();) { EscherProperty prop = (EscherProperty)it.Current; if (prop.PropertyNumber == 896 && prop.IsComplex) { EscherComplexProperty cp = (EscherComplexProperty)prop; String str = StringUtil.GetFromUnicodeLE(cp.ComplexData); //Console.Error.WriteLine(str); if (str.Equals("Chart 1\0")) { return(true); } } } return(false); }
public override byte[] GetBytes() { if (this.Record is EscherSimpleProperty) { EscherSimpleProperty esp = (EscherSimpleProperty)this.Record; byte[] data = new byte[esp.PropertySize]; esp.SerializeSimplePart(data, 0); return(data); } else if (this.Record is EscherComplexProperty) { EscherComplexProperty esp = (EscherComplexProperty)this.Record; byte[] data = new byte[esp.PropertySize]; esp.SerializeComplexPart(data, 0); return(data); } return(null); }
private void CheckFillFieldsComplex() { string dataStr = "33 00 " + "0B F0 " + "14 00 00 00 " + "BF 00 01 00 00 00 " + "01 80 02 00 00 00 " + "BF 00 01 00 00 00 " + "01 02"; EscherOptRecord r = new EscherOptRecord(); r.FillFields(HexRead.ReadFromString(dataStr), new DefaultEscherRecordFactory()); Assert.AreEqual((short)0x0033, r.Options); Assert.AreEqual(unchecked ((short)0xF00B), r.RecordId); Assert.AreEqual(3, r.EscherProperties.Count); EscherBoolProperty prop1 = new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1); EscherComplexProperty prop2 = new EscherComplexProperty((short)1, false, new byte[] { 0x01, 0x02 }); EscherBoolProperty prop3 = new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1); Assert.AreEqual(prop1, r.GetEscherProperty(0)); Assert.AreEqual(prop2, r.GetEscherProperty(1)); Assert.AreEqual(prop3, r.GetEscherProperty(2)); }
public void TestPropertyNames() { EscherProperty p1 = new EscherSimpleProperty(EscherProperties.GROUPSHAPE__SHAPENAME, 0); Assert.AreEqual("groupshape.shapename", p1.Name); Assert.AreEqual(EscherProperties.GROUPSHAPE__SHAPENAME, p1.PropertyNumber); Assert.IsFalse(p1.IsComplex); EscherProperty p2 = new EscherComplexProperty( EscherProperties.GROUPSHAPE__SHAPENAME, false, new byte[10]); Assert.AreEqual("groupshape.shapename", p2.Name); Assert.AreEqual(EscherProperties.GROUPSHAPE__SHAPENAME, p2.PropertyNumber); Assert.IsTrue(p2.IsComplex); Assert.IsFalse(p2.IsBlipId); EscherProperty p3 = new EscherComplexProperty( EscherProperties.GROUPSHAPE__SHAPENAME, true, new byte[10]); Assert.AreEqual("groupshape.shapename", p3.Name); Assert.AreEqual(EscherProperties.GROUPSHAPE__SHAPENAME, p3.PropertyNumber); Assert.IsTrue(p3.IsComplex); Assert.IsTrue(p3.IsBlipId); }
/** * Name of this picture. * * @param name of this picture */ public void SetPictureName(String name){ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); try { byte[] data = (name + '\u0000').GetBytes("UTF-16LE"); EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.BLIP__BLIPFILENAME, false, data); opt.AddEscherProperty(prop); } catch (UnsupportedEncodingException e){ throw new HSLFException(e); } }
protected void afterInsert(Sheet sheet){ ExControl ctrl = GetExControl(); ctrl.GetExControlAtom().SetSlideId(sheet._getSheetNumber()); try { String name = ctrl.GetProgId() + "-" + GetControlIndex(); byte[] data = (name + '\u0000').GetBytes("UTF-16LE"); EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.GROUPSHAPE__SHAPENAME, false, data); EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); opt.AddEscherProperty(prop); } catch (UnsupportedEncodingException e){ throw new HSLFException(e); } }