/// <summary> /// Creates the low level OBJ record for this shape. /// </summary> /// <param name="hssfShape">The HSSFShape.</param> /// <param name="shapeId">The shape id.</param> /// <returns></returns> private ObjRecord CreateObjRecord(HSSFShape hssfShape, int shapeId) { HSSFShape shape = hssfShape; ObjRecord obj = new ObjRecord(); CommonObjectDataSubRecord c = new CommonObjectDataSubRecord(); c.ObjectType=(CommonObjectType)((HSSFSimpleShape)shape).ShapeType; // c.ObjectId((short) ( 1 )); c.ObjectId=((short)(shapeId)); c.IsLocked=true; c.IsPrintable=true; c.IsAutoFill=true; c.IsAutoline=true; // c.Reserved2( 0x012C0A84 ); c.Reserved2=(0x0); // UnknownRecord sub1 = new UnknownRecord( (short)0x7, (short)0x2, new byte[] { 0x09, 0x00 } ); // UnknownRecord sub2 = new UnknownRecord( (short)0x8, (short)0x2, new byte[] { 0x01, 0x00 } ); EndSubRecord e = new EndSubRecord(); obj.AddSubRecord(c); // obj.AddSubRecord( sub1 ); // obj.AddSubRecord( sub2 ); obj.AddSubRecord(e); return obj; }
/// <summary> /// Construct a new textbox with the given parent and anchor. /// </summary> /// <param name="parent">The parent.</param> /// <param name="anchor">One of HSSFClientAnchor or HSSFChildAnchor</param> public HSSFTextbox(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { HorizontalAlignment = HorizontalTextAlignment.Left; VerticalAlignment = VerticalTextAlignment.Top; this.String = (new HSSFRichTextString("")); }
/// <summary> /// Construct a new textbox with the given parent and anchor. /// </summary> /// <param name="parent">The parent.</param> /// <param name="anchor">One of HSSFClientAnchor or HSSFChildAnchor</param> public HSSFTextbox(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { HorizontalAlignment = (HORIZONTAL_ALIGNMENT_LEFT); VerticalAlignment = (VERTICAL_ALIGNMENT_TOP); this.String = (new HSSFRichTextString("")); }
/// <summary> /// Constructs a picture object. /// </summary> /// <param name="parent">The parent.</param> /// <param name="anchor">The anchor.</param> public HSSFPicture(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { base.ShapeType = (OBJECT_TYPE_PICTURE); CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord)GetObjRecord().SubRecords[0]; cod.ObjectType = CommonObjectType.PICTURE; }
/// <summary> /// Construct a new textbox with the given parent and anchor. /// </summary> /// <param name="parent">The parent.</param> /// <param name="anchor">One of HSSFClientAnchor or HSSFChildAnchor</param> public HSSFTextbox(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { ShapeType = (OBJECT_TYPE_TEXT); halign = HORIZONTAL_ALIGNMENT_LEFT; valign = VERTICAL_ALIGNMENT_TOP; }
public HSSFCombobox(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { base.ShapeType = (OBJECT_TYPE_COMBO_BOX); CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord)GetObjRecord().SubRecords[0]; cod.ObjectType = CommonObjectType.ComboBox; }
/// <summary> /// Construct a new textbox with the given parent and anchor. /// </summary> /// <param name="parent">The parent.</param> /// <param name="anchor">One of HSSFClientAnchor or HSSFChildAnchor</param> public HSSFTextbox(HSSFShape parent, HSSFAnchor anchor):base(parent, anchor) { ShapeType = (OBJECT_TYPE_TEXT); halign = HORIZONTAL_ALIGNMENT_LEFT; valign = VERTICAL_ALIGNMENT_TOP; }
public HSSFCombobox(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { base.ShapeType = (OBJECT_TYPE_COMBO_BOX); CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord)GetObjRecord().SubRecords[0]; cod.ObjectType = CommonObjectType.COMBO_BOX; }
/// <summary> /// Create a new shape with the specified parent and anchor. /// </summary> /// <param name="parent">The parent.</param> /// <param name="anchor">The anchor.</param> public HSSFShape(HSSFShape parent, HSSFAnchor anchor) { this.parent = parent; this.anchor = anchor; this._escherContainer = CreateSpContainer(); _optRecord = (EscherOptRecord)_escherContainer.GetChildById(EscherOptRecord.RECORD_ID); _objRecord = CreateObjRecord(); }
/** * @param shape to be removed * @return true of shape is removed */ public bool RemoveShape(HSSFShape shape) { bool isRemoved = _mainSpgrContainer.RemoveChildRecord(shape.GetEscherContainer()); if (isRemoved) { shape.AfterRemove(this); _shapes.Remove(shape); } return(isRemoved); }
public bool RemoveShape(HSSFShape shape) { bool isRemoved = GetEscherContainer().RemoveChildRecord(shape.GetEscherContainer()); if (isRemoved) { shape.AfterRemove(this.Patriarch); shapes.Remove(shape); } return(isRemoved); }
internal override void AfterRemove(HSSFPatriarch patriarch) { patriarch.GetBoundAggregate().RemoveShapeToObjRecord(GetEscherContainer().ChildContainers[0] .GetChildById(EscherClientDataRecord.RECORD_ID)); for (int i = 0; i < shapes.Count; i++) { HSSFShape shape = (HSSFShape)shapes[i]; RemoveShape(shape); shape.AfterRemove(Patriarch); } shapes.Clear(); }
/// <summary> /// Construct a new comment with the given parent and anchor. /// </summary> /// <param name="parent"></param> /// <param name="anchor">defines position of this anchor in the sheet</param> public HSSFComment(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { this.ShapeType = (OBJECT_TYPE_COMMENT); //default color for comments this.FillColor = 0x08000050; //by default comments are hidden visible = false; author = ""; }
private void SetFlipFlags(HSSFShape shape) { EscherSpRecord sp = (EscherSpRecord)shape.GetEscherContainer().GetChildById(EscherSpRecord.RECORD_ID); if (shape.Anchor.IsHorizontallyFlipped) { sp.Flags = (sp.Flags | EscherSpRecord.FLAG_FLIPHORIZ); } if (shape.Anchor.IsVerticallyFlipped) { sp.Flags = (sp.Flags | EscherSpRecord.FLAG_FLIPVERT); } }
private void OnCreate(HSSFShape shape) { EscherContainerRecord spgrContainer = _boundAggregate.GetEscherContainer().ChildContainers[0]; EscherContainerRecord spContainer = shape.GetEscherContainer(); int shapeId = NewShapeId(); shape.ShapeId = shapeId; spgrContainer.AddChildRecord(spContainer); shape.AfterInsert(this); SetFlipFlags(shape); }
/// <summary> /// Construct a new comment with the given parent and anchor. /// </summary> /// <param name="parent"></param> /// <param name="anchor">defines position of this anchor in the sheet</param> public HSSFComment(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { _note = CreateNoteRecord(); //default color for comments this.FillColor = 0x08000050; //by default comments are hidden Visible = false; Author = ""; CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord)GetObjRecord().SubRecords[0]; cod.ObjectType = CommonObjectType.COMMENT; }
/// <summary> /// Construct a new comment with the given parent and anchor. /// </summary> /// <param name="parent"></param> /// <param name="anchor">defines position of this anchor in the sheet</param> public HSSFComment(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { _note = CreateNoteRecord(); //default color for comments this.FillColor = 0x08000050; //by default comments are hidden Visible = false; Author = ""; CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord)GetObjRecord().SubRecords[0]; cod.ObjectType = CommonObjectType.Comment; }
/// <summary> /// Create a new shape object used to Create the escher records. /// </summary> /// <param name="hssfShape">The simple shape this Is based on.</param> /// <param name="shapeId">The shape id.</param> /// <returns></returns> public static AbstractShape CreateShape(HSSFShape hssfShape, int shapeId) { AbstractShape shape; if (hssfShape is HSSFComment) { shape = new CommentShape((HSSFComment)hssfShape, shapeId); } else if (hssfShape is HSSFTextbox) { shape = new TextboxShape((HSSFTextbox)hssfShape, shapeId); } else if (hssfShape is HSSFPolygon) { shape = new PolygonShape((HSSFPolygon)hssfShape, shapeId); } else if (hssfShape is HSSFSimpleShape) { HSSFSimpleShape simpleShape = (HSSFSimpleShape)hssfShape; switch (simpleShape.ShapeType) { case HSSFSimpleShape.OBJECT_TYPE_PICTURE: shape = new PictureShape(simpleShape, shapeId); break; case HSSFSimpleShape.OBJECT_TYPE_LINE: shape = new LineShape(simpleShape, shapeId); break; case HSSFSimpleShape.OBJECT_TYPE_OVAL: case HSSFSimpleShape.OBJECT_TYPE_RECTANGLE: shape = new SimpleFilledShape(simpleShape, shapeId); break; case HSSFSimpleShape.OBJECT_TYPE_COMBO_BOX: shape = new ComboboxShape(simpleShape, shapeId); break; default: throw new ArgumentException("Do not know how to handle this type of shape"); } } else { throw new ArgumentException("Unknown shape type"); } EscherSpRecord sp = (EscherSpRecord)shape.SpContainer.GetChildById(EscherSpRecord.RECORD_ID); if (hssfShape.Parent!= null) sp.Flags=sp.Flags | EscherSpRecord.FLAG_CHILD; return shape; }
/// <summary> /// Creates the low level OBJ record for this shape. /// </summary> /// <param name="hssfShape">The HSSF shape.</param> /// <param name="shapeId">The shape id.</param> /// <returns></returns> private ObjRecord CreateObjRecord(HSSFShape hssfShape, int shapeId) { HSSFShape shape = hssfShape; ObjRecord obj = new ObjRecord(); CommonObjectDataSubRecord c = new CommonObjectDataSubRecord(); c.ObjectType=(CommonObjectType)((HSSFSimpleShape)shape).ShapeType; c.ObjectId=((short)(shapeId)); c.IsLocked=(true); c.IsPrintable=(true); c.IsAutoFill=(true); c.IsAutoline=(true); EndSubRecord e = new EndSubRecord(); obj.AddSubRecord(c); obj.AddSubRecord(e); return obj; }
/// <summary> /// Creates the lowerlevel OBJ records for this shape. /// </summary> /// <param name="hssfShape">The HSSF shape.</param> /// <param name="shapeId">The shape id.</param> /// <returns></returns> private ObjRecord CreateObjRecord(HSSFShape hssfShape, int shapeId) { HSSFShape shape = hssfShape; ObjRecord obj = new ObjRecord(); CommonObjectDataSubRecord c = new CommonObjectDataSubRecord(); c.ObjectType=CommonObjectType.MICROSOFT_OFFICE_DRAWING; c.ObjectId=((short)(shapeId)); c.IsLocked=(true); c.IsPrintable=(true); c.IsAutoFill=(true); c.IsAutoline=(true); EndSubRecord e = new EndSubRecord(); obj.AddSubRecord(c); obj.AddSubRecord(e); return obj; }
private void OnCreate(HSSFShape shape) { if (this.Patriarch != null) { EscherContainerRecord spContainer = shape.GetEscherContainer(); int shapeId = this.Patriarch.NewShapeId(); shape.ShapeId = (shapeId); GetEscherContainer().AddChildRecord(spContainer); shape.AfterInsert(Patriarch); EscherSpRecord sp; if (shape is HSSFShapeGroup) { sp = (EscherSpRecord)shape.GetEscherContainer().ChildContainers[0].GetChildById(EscherSpRecord.RECORD_ID); } else { sp = (EscherSpRecord)shape.GetEscherContainer().GetChildById(EscherSpRecord.RECORD_ID); } sp.Flags = sp.Flags | EscherSpRecord.FLAG_CHILD; } }
public void AddShape(HSSFShape shape) { shape.Patriarch = (this.Patriarch); shape.Parent = (this); shapes.Add(shape); }
/// <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 }
public static EscherContainerRecord GetEscherContainer(HSSFShape shape) { return shape.GetEscherContainer(); }
/// <summary> /// Initializes a new instance of the <see cref="HSSFSimpleShape"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="anchor">The anchor.</param> public HSSFSimpleShape(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { }
/// <summary> /// Add standard properties to the opt record. These properties effect /// all records. /// </summary> /// <param name="shape">The user model shape.</param> /// <param name="opt">The opt record to Add the properties to.</param> /// <returns>The number of options Added.</returns> protected virtual int AddStandardOptions(HSSFShape shape, EscherOptRecord opt) { opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080000)); // opt.AddEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080008 ) ); if (shape.IsNoFill) { // Wonderful... none of the spec's give any clue as to what these constants mean. opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.Fill__NOFillHITTEST, 0x00110000)); } else { opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.Fill__NOFillHITTEST, 0x00010000)); } opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.Fill__FillCOLOR, shape.FillColor)); opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000)); opt.AddEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, shape.LineStyleColor)); int options = 5; if (shape.LineWidth != HSSFShape.LINEWIDTH_DEFAULT) { opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, shape.LineWidth)); options++; } if (shape.LineStyle != HSSFShape.LINESTYLE_SOLID) { opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, shape.LineStyle)); opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, 0)); if (shape.LineStyle == HSSFShape.LINESTYLE_NONE) opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000)); else opt.AddEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008)); options += 3; } opt.SortProperties(); return options; // # options Added }
/// <summary> /// Initializes a new instance of the <see cref="HSSFSimpleShape"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="anchor">The anchor.</param> public HSSFSimpleShape(HSSFShape parent, HSSFAnchor anchor):base(parent, anchor) { }
/// <summary> /// Initializes a new instance of the <see cref="HSSFSimpleShape"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="anchor">The anchor.</param> public HSSFSimpleShape(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { _textObjectRecord = CreateTextObjRecord(); }
/// <summary> /// Create a new shape with the specified parent and anchor. /// </summary> /// <param name="parent">The parent.</param> /// <param name="anchor">The anchor.</param> protected HSSFShape(HSSFShape parent, HSSFAnchor anchor) { this.parent = parent; this.anchor = anchor; }
public void AddShape(HSSFShape shape) { shape.Patriarch = this.Patriarch; shape.Parent = this; shapes.Add(shape); }
public HSSFShapeGroup(HSSFShape parent, HSSFAnchor anchor):base(parent, anchor) { }
/// <summary> /// Constructs a picture object. /// </summary> /// <param name="parent">The parent.</param> /// <param name="anchor">The anchor.</param> public HSSFPicture(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { this.ShapeType = (OBJECT_TYPE_PICTURE); }
/** * add a shape to this drawing */ public void AddShape(HSSFShape shape) { shape.Patriarch = this; _shapes.Add(shape); }
public HSSFShapeGroup(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { _spgrRecord = (EscherSpgrRecord)((EscherContainerRecord)GetEscherContainer().GetChild(0)).GetChildById(EscherSpgrRecord.RECORD_ID); }
public HSSFPolygon(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { }
/// <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 }
public static EscherOptRecord GetOptRecord(HSSFShape shape) { return shape.GetOptRecord(); }
/// <summary> /// Construct a new comment with the given parent and anchor. /// </summary> /// <param name="parent"></param> /// <param name="anchor">defines position of this anchor in the sheet</param> public HSSFComment(HSSFShape parent, HSSFAnchor anchor) : this(parent, anchor, CreateNoteRecord()) { }
public static ObjRecord GetObjRecord(HSSFShape shape) { return shape.GetObjRecord(); }
/// <summary> /// Initializes a new instance of the <see cref="HSSFSimpleShape"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="anchor">The anchor.</param> public HSSFSimpleShape(HSSFShape parent, HSSFAnchor anchor) :base(parent, anchor) { _textObjectRecord = CreateTextObjRecord(); }
public static void SetShapeId(HSSFShape shape, int id) { shape.ShapeId = (id); }
public HSSFShapeGroup(HSSFShape parent, HSSFAnchor anchor) : base(parent, anchor) { }
/** * add a shape to this drawing */ internal void AddShape(HSSFShape shape) { shape._patriarch = this; _shapes.Add(shape); }
/** * @param shape to be removed * @return true of shape is removed */ public bool RemoveShape(HSSFShape shape) { bool isRemoved = _mainSpgrContainer.RemoveChildRecord(shape.GetEscherContainer()); if (isRemoved) { shape.AfterRemove(this); _shapes.Remove(shape); } return isRemoved; }
/// <summary> /// Creates the lowerlevel OBJ records for this shape. /// </summary> /// <param name="hssfShape">The HSSF shape.</param> /// <param name="shapeId">The shape id.</param> /// <returns></returns> private ObjRecord CreateObjRecord(HSSFShape hssfShape, int shapeId) { HSSFShape shape = hssfShape; ObjRecord obj = new ObjRecord(); CommonObjectDataSubRecord c = new CommonObjectDataSubRecord(); c.ObjectType = (CommonObjectType)OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING; c.ObjectId = GetCmoObjectId(shapeId); c.IsLocked = true; c.IsPrintable = true; c.IsAutoFill = true; c.IsAutoline = true; EndSubRecord e = new EndSubRecord(); obj.AddSubRecord(c); obj.AddSubRecord(e); return obj; }