/// <summary> /// Sets standard escher options for a comment. /// This method is responsible for Setting default background, /// shading and other comment properties. /// </summary> /// <param name="shape">The highlevel shape.</param> /// <param name="opt">The escher records holding the proerties</param> /// <returns>The number of escher options added</returns> protected override int AddStandardOptions(HSSFShape shape, EscherOptRecord opt) { base.AddStandardOptions(shape, opt); //Remove Unnecessary properties inherited from TextboxShape for (int i = 0; i < opt.EscherProperties.Count; i++) { EscherProperty prop = opt.EscherProperties[i]; switch (prop.Id) { case EscherProperties.TEXT__TEXTLEFT: case EscherProperties.TEXT__TEXTRIGHT: case EscherProperties.TEXT__TEXTTOP: case EscherProperties.TEXT__TEXTBOTTOM: case EscherProperties.GROUPSHAPE__PRINT: case EscherProperties.Fill__FillBACKCOLOR: case EscherProperties.LINESTYLE__COLOR: opt.EscherProperties.Remove(prop); i--; break; } } HSSFComment comment = (HSSFComment)shape; opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, comment.Visible ? 0x000A0000 : 0x000A0002)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x00030003)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x00000000)); opt.SortProperties(); return(opt.EscherProperties.Count); // # options Added }
/// <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); }
/// <summary> /// Sets standard escher options for a comment. /// This method is responsible for Setting default background, /// shading and other comment properties. /// </summary> /// <param name="shape">The highlevel shape.</param> /// <param name="opt">The escher records holding the proerties</param> /// <returns>The number of escher options added</returns> protected override int AddStandardOptions(HSSFShape shape, EscherOptRecord opt) { base.AddStandardOptions(shape, opt); //Remove Unnecessary properties inherited from TextboxShape IList props = (IList)opt.EscherProperties.Clone(); for (IEnumerator iterator = props.GetEnumerator(); iterator.MoveNext();) { EscherProperty prop = (EscherProperty)iterator.Current; switch (prop.Id) { case EscherProperties.TEXT__TEXTLEFT: case EscherProperties.TEXT__TEXTRIGHT: case EscherProperties.TEXT__TEXTTOP: case EscherProperties.TEXT__TEXTBOTTOM: case EscherProperties.GROUPSHAPE__PRINT: case EscherProperties.Fill__FillBACKCOLOR: case EscherProperties.LINESTYLE__COLOR: opt.EscherProperties.Remove(prop); break; } } HSSFComment comment = (HSSFComment)shape; opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, comment.Visible ? 0x000A0000 : 0x000A0002)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x00030003)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x00000000)); opt.SortProperties(); return(opt.EscherProperties.Count); // # options Added }
/** * Returns escher property by id. * * @return escher property or <code>null</code> if not found. */ public static EscherProperty GetEscherProperty(EscherOptRecord opt, int propId) { if (opt != null) { for (List <EscherProperty> .Enumerator iterator = opt.EscherProperties.GetEnumerator(); iterator.MoveNext();) { EscherProperty prop = (EscherProperty)iterator.Current; if (prop.PropertyNumber == propId) { return(prop); } } } return(null); }
/** * Set an escher property for this shape. * * @param opt The opt record to Set the properties to. * @param propId The id of the property. One of the constants defined in EscherOptRecord. * @param value value of the property. If value = -1 then the property is Removed. */ public static void SetEscherProperty(EscherOptRecord opt, short propId, int value) { List <EscherProperty> props = opt.EscherProperties; for (List <EscherProperty> .Enumerator iterator = props.GetEnumerator(); iterator.MoveNext();) { EscherProperty prop = (EscherProperty)iterator.Current; if (prop.Id == propId) { props.Remove(iterator.Current); } } if (value != -1) { opt.AddEscherProperty(new EscherSimpleProperty(propId, value)); opt.SortProperties(); } }
protected void SetPropertyValue(EscherProperty property) { _optRecord.SetEscherProperty(property); }
public EscherPropertyTreeNode(EscherProperty ep) { this.Record = ep; this.Text = ep.Name; this.ImageKey = "Binary"; }
/** * build shape tree from escher container * @param container root escher container from which escher records must be taken * @param agg - EscherAggregate * @param out - shape container to which shapes must be added * @param root - node to create HSSFObjectData shapes */ public static void CreateShapeTree(EscherContainerRecord container, EscherAggregate agg, HSSFShapeContainer out1, DirectoryNode root) { if (container.RecordId == EscherContainerRecord.SPGR_CONTAINER) { ObjRecord obj = null; EscherClientDataRecord clientData = (EscherClientDataRecord)((EscherContainerRecord)container.GetChild(0)).GetChildById(EscherClientDataRecord.RECORD_ID); if (null != clientData) { obj = (ObjRecord)agg.GetShapeToObjMapping()[clientData]; } HSSFShapeGroup group = new HSSFShapeGroup(container, obj); IList <EscherContainerRecord> children = container.ChildContainers; // skip the first child record, it is group descriptor for (int i = 0; i < children.Count; i++) { EscherContainerRecord spContainer = children[(i)]; if (i != 0) { CreateShapeTree(spContainer, agg, group, root); } } out1.AddShape(group); } else if (container.RecordId == EscherContainerRecord.SP_CONTAINER) { Dictionary <EscherRecord, Record.Record> shapeToObj = agg.GetShapeToObjMapping(); ObjRecord objRecord = null; TextObjectRecord txtRecord = null; foreach (EscherRecord record in container.ChildRecords) { switch (record.RecordId) { case EscherClientDataRecord.RECORD_ID: objRecord = (ObjRecord)shapeToObj[(record)]; break; case EscherTextboxRecord.RECORD_ID: txtRecord = (TextObjectRecord)shapeToObj[(record)]; break; } } if (IsEmbeddedObject(objRecord)) { HSSFObjectData objectData = new HSSFObjectData(container, objRecord, root); out1.AddShape(objectData); return; } CommonObjectDataSubRecord cmo = (CommonObjectDataSubRecord)objRecord.SubRecords[0]; HSSFShape shape; switch (cmo.ObjectType) { case CommonObjectType.Picture: shape = new HSSFPicture(container, objRecord); break; case CommonObjectType.Rectangle: shape = new HSSFSimpleShape(container, objRecord, txtRecord); break; case CommonObjectType.Line: shape = new HSSFSimpleShape(container, objRecord); break; case CommonObjectType.ComboBox: shape = new HSSFCombobox(container, objRecord); break; case CommonObjectType.MicrosoftOfficeDrawing: EscherOptRecord optRecord = (EscherOptRecord)container.GetChildById(EscherOptRecord.RECORD_ID); EscherProperty property = optRecord.Lookup(EscherProperties.GEOMETRY__VERTICES); if (null != property) { shape = new HSSFPolygon(container, objRecord, txtRecord); } else { shape = new HSSFSimpleShape(container, objRecord, txtRecord); } break; case CommonObjectType.Text: shape = new HSSFTextbox(container, objRecord, txtRecord); break; case CommonObjectType.Comment: shape = new HSSFComment(container, objRecord, txtRecord, agg.GetNoteRecordByObj(objRecord)); break; default: shape = new HSSFSimpleShape(container, objRecord, txtRecord); break; } out1.AddShape(shape); } }