/// <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); }
/// <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) { HSSFPicture shape = (HSSFPicture)hssfShape; EscherContainerRecord spContainer = new EscherContainerRecord(); EscherSpRecord sp = new EscherSpRecord(); EscherOptRecord opt = new EscherOptRecord(); EscherRecord anchor; EscherClientDataRecord clientData = new EscherClientDataRecord(); spContainer.RecordId = EscherContainerRecord.SP_CONTAINER; spContainer.Options = (short)0x000F; sp.RecordId = EscherSpRecord.RECORD_ID; sp.Options = (short)((EscherAggregate.ST_PICTUREFRAME << 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, 0x00800080 ) ; opt.AddEscherProperty(new EscherSimpleProperty(EscherProperties.BLIP__BLIPTODISPLAY, false, true, shape.PictureIndex)); // opt.AddEscherProperty( new EscherComplexProperty( EscherProperties.BLIP__BLIPFILENAME, true, new byte[] { (byte)0x74, (byte)0x00, (byte)0x65, (byte)0x00, (byte)0x73, (byte)0x00, (byte)0x74, (byte)0x00, (byte)0x00, (byte)0x00 } ) ; // opt.AddEscherProperty( new EscherSimpleProperty( EscherProperties.Fill__FillTYPE, 0x00000003 ) ; 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 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); }
public void TestCreateChildAnchorFromContainer() { EscherContainerRecord container = new EscherContainerRecord(); EscherChildAnchorRecord escher = new EscherChildAnchorRecord(); escher.Dx1 = ((short)15); escher.Dx2 = ((short)16); escher.Dy1 = ((short)17); escher.Dy2 = ((short)18); container.AddChildRecord(escher); HSSFChildAnchor anchor = (HSSFChildAnchor)HSSFAnchor.CreateAnchorFromEscher(container); 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 Best49423() { HSSFWorkbook workbook = HSSFTestDataSamples.OpenSampleWorkbook("49423.xls"); bool found = false; int numSheets = workbook.NumberOfSheets; for (int i = 0; i < numSheets; i++) { HSSFSheet sheet = workbook.GetSheetAt(i) as HSSFSheet; IList <HSSFShape> shapes = (sheet.DrawingPatriarch as HSSFPatriarch).Children; foreach (HSSFShape shape in shapes) { HSSFAnchor anchor = shape.Anchor; if (anchor is HSSFClientAnchor) { // absolute coordinates HSSFClientAnchor clientAnchor = (HSSFClientAnchor)anchor; Assert.IsNotNull(clientAnchor); //System.out.Println(clientAnchor.Row1 + "," + clientAnchor.Row2); found = true; } else if (anchor is HSSFChildAnchor) { // shape is grouped and the anchor is expressed in the coordinate system of the group HSSFChildAnchor childAnchor = (HSSFChildAnchor)anchor; Assert.IsNotNull(childAnchor); //System.out.Println(childAnchor.Dy1 + "," + childAnchor.Dy2); found = true; } } } Assert.IsTrue(found, "Should find some images via Client or Child anchors, but did not find any at all"); }
/// <summary> /// Creates an escher anchor record from a HSSFAnchor. /// </summary> /// <param name="userAnchor">The high level anchor to Convert.</param> /// <returns>An escher anchor record.</returns> protected virtual EscherRecord CreateAnchor(HSSFAnchor userAnchor) { return(ConvertAnchor.CreateAnchor(userAnchor)); }
public static EscherRecord GetEscherAnchor(HSSFAnchor anchor) { return(anchor.GetEscherAnchor()); }
private void CheckWorkbookBack(HSSFWorkbook wb) { HSSFWorkbook wbBack = HSSFTestDataSamples.WriteOutAndReadBack(wb); Assert.IsNotNull(wbBack); HSSFSheet sheetBack = wbBack.GetSheetAt(0) as HSSFSheet; Assert.IsNotNull(sheetBack); HSSFPatriarch patriarchBack = sheetBack.DrawingPatriarch as HSSFPatriarch; Assert.IsNotNull(patriarchBack); IList <HSSFShape> children = patriarchBack.Children; Assert.AreEqual(4, children.Count); HSSFShape hssfShape = children[(0)]; Assert.IsTrue(hssfShape is HSSFSimpleShape); HSSFAnchor anchor = hssfShape.Anchor; Assert.IsTrue(anchor is HSSFClientAnchor); Assert.AreEqual(0, anchor.Dx1); Assert.AreEqual(512, anchor.Dx2); Assert.AreEqual(0, anchor.Dy1); Assert.AreEqual(100, anchor.Dy2); HSSFClientAnchor cAnchor = (HSSFClientAnchor)anchor; Assert.AreEqual(1, cAnchor.Col1); Assert.AreEqual(1, cAnchor.Col2); Assert.AreEqual(1, cAnchor.Row1); Assert.AreEqual(1, cAnchor.Row2); hssfShape = children[(1)]; Assert.IsTrue(hssfShape is HSSFSimpleShape); anchor = hssfShape.Anchor; Assert.IsTrue(anchor is HSSFClientAnchor); Assert.AreEqual(512, anchor.Dx1); Assert.AreEqual(1023, anchor.Dx2); Assert.AreEqual(0, anchor.Dy1); Assert.AreEqual(100, anchor.Dy2); cAnchor = (HSSFClientAnchor)anchor; Assert.AreEqual(1, cAnchor.Col1); Assert.AreEqual(1, cAnchor.Col2); Assert.AreEqual(1, cAnchor.Row1); Assert.AreEqual(1, cAnchor.Row2); hssfShape = children[(2)]; Assert.IsTrue(hssfShape is HSSFSimpleShape); anchor = hssfShape.Anchor; Assert.IsTrue(anchor is HSSFClientAnchor); Assert.AreEqual(0, anchor.Dx1); Assert.AreEqual(512, anchor.Dx2); Assert.AreEqual(0, anchor.Dy1); Assert.AreEqual(100, anchor.Dy2); cAnchor = (HSSFClientAnchor)anchor; Assert.AreEqual(2, cAnchor.Col1); Assert.AreEqual(2, cAnchor.Col2); Assert.AreEqual(2, cAnchor.Row1); Assert.AreEqual(2, cAnchor.Row2); hssfShape = children[(3)]; Assert.IsTrue(hssfShape is HSSFSimpleShape); anchor = hssfShape.Anchor; Assert.IsTrue(anchor is HSSFClientAnchor); Assert.AreEqual(0, anchor.Dx1); Assert.AreEqual(512, anchor.Dx2); Assert.AreEqual(100, anchor.Dy1); Assert.AreEqual(200, anchor.Dy2); cAnchor = (HSSFClientAnchor)anchor; Assert.AreEqual(2, cAnchor.Col1); Assert.AreEqual(2, cAnchor.Col2); Assert.AreEqual(2, cAnchor.Row1); Assert.AreEqual(2, cAnchor.Row2); }