private int GetTertiaryPropertyValue(int propertyId, int defaultValue) { EscherContainerRecord shapeDescription = od.GetEscherShapeRecordContainer(GetShapeId()); if (shapeDescription == null) { return(defaultValue); } EscherRecord escherTertiaryOptRecord = (EscherRecord)shapeDescription .GetChildById(EscherTertiaryOptRecord.RECORD_ID); if (escherTertiaryOptRecord == null) { return(defaultValue); } EscherSimpleProperty escherProperty = (EscherSimpleProperty)((EscherOptRecord)escherTertiaryOptRecord) .Lookup(propertyId); if (escherProperty == null) { return(defaultValue); } int value = escherProperty.PropertyValue; return(value); }
/** * Get the value of a simple escher property for this shape. * * @param propId The id of the property. One of the constants defined in EscherOptRecord. */ public int GetEscherProperty(short propId, int defaultValue) { EscherOptRecord opt = (EscherOptRecord)GetEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); EscherSimpleProperty prop = (EscherSimpleProperty)GetEscherProperty(opt, propId); return(prop == null ? defaultValue : prop.PropertyValue); }
public byte[] GetPictureData() { EscherContainerRecord shapeDescription = od.GetEscherShapeRecordContainer(GetShapeId()); if (shapeDescription == null) { return(null); } EscherRecord escherOptRecord = (EscherRecord)shapeDescription .GetChildById(EscherOptRecord.RECORD_ID); if (escherOptRecord == null) { return(null); } EscherSimpleProperty escherProperty = (EscherSimpleProperty)((EscherOptRecord)escherOptRecord) .Lookup(EscherProperties.BLIP__BLIPTODISPLAY); if (escherProperty == null) { return(null); } int bitmapIndex = escherProperty.PropertyValue; EscherBlipRecord escherBlipRecord = od.GetBitmapRecord(bitmapIndex); if (escherBlipRecord == null) { return(null); } return(escherBlipRecord.PictureData); }
/** * Returns line style. One of the constants defined in this class. * * @return style of the line. */ public int GetLineStyle() { EscherOptRecord opt = (EscherOptRecord)GetEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); EscherSimpleProperty prop = (EscherSimpleProperty)GetEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE); return(prop == null ? Line.LINE_SIMPLE : prop.PropertyValue); }
/** * @return color of the line. If color is not Set returns <code>java.awt.Color.black</code> */ public Color GetLineColor() { EscherOptRecord opt = (EscherOptRecord)GetEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); EscherSimpleProperty p1 = (EscherSimpleProperty)GetEscherProperty(opt, EscherProperties.LINESTYLE__COLOR); EscherSimpleProperty p2 = (EscherSimpleProperty)GetEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH); int p2val = p2 == null ? 0 : p2.PropertyValue; Color clr = null; if ((p2val & 0x8) != 0 || (p2val & 0x10) != 0) { int rgb = p1 == null ? 0 : p1.PropertyValue; if (rgb >= 0x8000000) { int idx = rgb % 0x8000000; if (Sheet != null) { ColorSchemeAtom ca = Sheet.GetColorScheme(); if (idx >= 0 && idx <= 7) { rgb = ca.GetColor(idx); } } } Color tmp = new Color(rgb, true); clr = new Color(tmp.GetBlue(), tmp.GetGreen(), tmp.GetRed()); } return(clr); }
/** * Gets line dashing. One of the PEN_* constants defined in this class. * * @return dashing of the line. */ public int GetLineDashing() { EscherOptRecord opt = (EscherOptRecord)GetEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); EscherSimpleProperty prop = (EscherSimpleProperty)GetEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING); return(prop == null ? Line.PEN_SOLID : prop.PropertyValue); }
/** * Returns width of the line in in points */ public double GetLineWidth() { EscherOptRecord opt = (EscherOptRecord)GetEscherChild(_escherContainer, EscherOptRecord.RECORD_ID); EscherSimpleProperty prop = (EscherSimpleProperty)GetEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH); double width = prop == null ? DEFAULT_LINE_WIDTH : (double)prop.PropertyValue / EMU_PER_POINT; return(width); }
public void ResetBackgroundImage() { EscherSimpleProperty property = (EscherSimpleProperty)GetOptRecord().Lookup(EscherProperties.FILL__PATTERNTEXTURE); if (null != property) { EscherBSERecord bse = ((HSSFWorkbook)((HSSFPatriarch)Patriarch).Sheet.Workbook).Workbook.GetBSERecord(property.PropertyValue); bse.Ref = (bse.Ref - 1); GetOptRecord().RemoveEscherProperty(EscherProperties.FILL__PATTERNTEXTURE); } SetPropertyValue(new EscherSimpleProperty(EscherProperties.FILL__FILLTYPE, false, false, FILL_TYPE_SOLID)); }
private void SetHidden(bool value) { EscherSimpleProperty property = (EscherSimpleProperty)GetOptRecord().Lookup(EscherProperties.GROUPSHAPE__PRINT); // see http://msdn.microsoft.com/en-us/library/dd949807(v=office.12).aspx if (value) { SetPropertyValue(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, false, false, property.PropertyValue | GROUP_SHAPE_HIDDEN_MASK)); } else { SetPropertyValue(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, false, false, property.PropertyValue & GROUP_SHAPE_NOT_HIDDEN_MASK)); } }
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); }
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); }
/** * Converts the Records into UserModel * objects on the bound HSSFPatriarch */ public void ConvertRecordsToUserModel() { if (patriarch == null) { throw new InvalidOperationException("Must call SetPatriarch() first"); } // The top level container ought to have // the DgRecord and the container of one container // per shape Group (patriach overall first) EscherContainerRecord topContainer = (EscherContainerRecord)GetEscherContainer(); if (topContainer == null) { return; } topContainer = (EscherContainerRecord) topContainer.ChildContainers[0]; IList <EscherContainerRecord> tcc = topContainer.ChildContainers; if (tcc.Count == 0) { throw new InvalidOperationException("No child escher containers at the point that should hold the patriach data, and one container per top level shape!"); } // First up, Get the patriach position // This Is in the first EscherSpgrRecord, in // the first container, with a EscherSRecord too EscherContainerRecord patriachContainer = (EscherContainerRecord)tcc[0]; EscherSpgrRecord spgr = null; for (IEnumerator it = patriachContainer.ChildRecords.GetEnumerator(); it.MoveNext();) { EscherRecord r = (EscherRecord)it.Current; if (r is EscherSpgrRecord) { spgr = (EscherSpgrRecord)r; break; } } if (spgr != null) { patriarch.SetCoordinates( spgr.RectX1, spgr.RectY1, spgr.RectX2, spgr.RectY2 ); } // Now Process the containers for each Group // and objects for (int i = 1; i < tcc.Count; i++) { EscherContainerRecord shapeContainer = (EscherContainerRecord)tcc[i]; //Console.Error.WriteLine("\n\n*****\n\n"); //Console.Error.WriteLine(shapeContainer); // Could be a Group, or a base object if (shapeContainer.RecordId == EscherContainerRecord.SPGR_CONTAINER) { if (shapeContainer.ChildRecords.Count > 0) { // Group HSSFShapeGroup group = new HSSFShapeGroup(null, new HSSFClientAnchor()); patriarch.Children.Add(group); EscherContainerRecord groupContainer = (EscherContainerRecord)shapeContainer.GetChild(0); ConvertRecordsToUserModel(groupContainer, group); } } else if (shapeContainer.RecordId == EscherContainerRecord.SP_CONTAINER) { EscherSpRecord spRecord = shapeContainer.GetChildById(EscherSpRecord.RECORD_ID); int type = spRecord.Options >> 4; switch (type) { case ST_TEXTBOX: // TextBox HSSFTextbox box = new HSSFTextbox(null, new HSSFClientAnchor()); patriarch.Children.Add(box); ConvertRecordsToUserModel(shapeContainer, box); break; case ST_PICTUREFRAME: // Duplicated from // org.apache.poi.hslf.model.Picture.getPictureIndex() EscherOptRecord opt = (EscherOptRecord)GetEscherChild(shapeContainer, EscherOptRecord.RECORD_ID); EscherSimpleProperty prop = (EscherSimpleProperty)opt.Lookup(EscherProperties.BLIP__BLIPTODISPLAY); if (prop != null) { int pictureIndex = prop.PropertyValue; EscherClientAnchorRecord anchorRecord = (EscherClientAnchorRecord)GetEscherChild(shapeContainer, EscherClientAnchorRecord.RECORD_ID); HSSFClientAnchor anchor = new HSSFClientAnchor(); anchor.Col1 = anchorRecord.Col1; anchor.Col2 = anchorRecord.Col2; anchor.Dx1 = anchorRecord.Dx1; anchor.Dx2 = anchorRecord.Dx2; anchor.Dy1 = anchorRecord.Dy1; anchor.Dy2 = anchorRecord.Dy2; anchor.Row1 = anchorRecord.Row1; anchor.Row2 = anchorRecord.Row2; HSSFPicture picture = new HSSFPicture(null, anchor); picture.PictureIndex = pictureIndex; patriarch.AddShape(picture); } break; } } else { // Base level ConvertRecordsToUserModel(shapeContainer, patriarch); } } // Now, clear any trace of what records make up // the patriarch // Otherwise, everything will go horribly wrong // when we try to Write out again.... // clearEscherRecords(); drawingManager.GetDgg().FileIdClusters = new EscherDggRecord.FileIdCluster[0]; // TODO: Support Converting our records // back into shapes log.Log(POILogger.WARN, "Not Processing objects into Patriarch!"); }
public int GetBackgroundImageId() { EscherSimpleProperty property = (EscherSimpleProperty)GetOptRecord().Lookup(EscherProperties.FILL__PATTERNTEXTURE); return(property == null ? 0 : property.PropertyValue); }