internal CT_Shape newCommentShape() { CT_Shape shape = new CT_Shape(); shape.id = "_x0000_s" + (++_shapeId); shape.type = "#" + _shapeTypeId; shape.style = "position:absolute; visibility:hidden"; shape.fillcolor = ("#ffffe1"); shape.insetmode = (ST_InsetMode.auto); shape.AddNewFill().color = ("#ffffe1"); CT_Shadow shadow = shape.AddNewShadow(); shadow.on = NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t; shadow.color = "black"; shadow.obscured = NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t; shape.AddNewPath().connecttype = (ST_ConnectType.none); shape.AddNewTextbox().style = ("mso-direction-alt:auto"); CT_ClientData cldata = shape.AddNewClientData(); cldata.ObjectType = ST_ObjectType.Note; cldata.AddNewMoveWithCells(); cldata.AddNewSizeWithCells(); cldata.AddNewAnchor("1, 15, 0, 2, 3, 15, 3, 16"); cldata.AddNewAutoFill(ST_TrueFalseBlank.@false); cldata.AddNewRow(0); cldata.AddNewColumn(0); _items.Add(shape); return(shape); }
internal CT_Shape newCommentShape() { CT_Shape ctShape = new CT_Shape(); ctShape.id = "_x0000_s" + (object)++this._shapeId; ctShape.type = "#" + this._shapeTypeId; ctShape.style = "position:absolute; visibility:hidden"; ctShape.fillcolor = "#ffffe1"; ctShape.insetmode = ST_InsetMode.auto; ctShape.AddNewFill().color = "#ffffe1"; CT_Shadow ctShadow = ctShape.AddNewShadow(); ctShadow.on = ST_TrueFalse.t; ctShadow.color = "black"; ctShadow.obscured = ST_TrueFalse.t; ctShape.AddNewPath().connecttype = ST_ConnectType.none; ctShape.AddNewTextbox().style = "mso-direction-alt:auto"; CT_ClientData ctClientData = ctShape.AddNewClientData(); ctClientData.ObjectType = ST_ObjectType.Note; ctClientData.AddNewMoveWithCells(); ctClientData.AddNewSizeWithCells(); ctClientData.AddNewAnchor("1, 15, 0, 2, 3, 15, 3, 16"); ctClientData.AddNewAutoFill(ST_TrueFalseBlank.@false); ctClientData.AddNewRow(0); ctClientData.AddNewColumn(0); this._items.Add((object)ctShape); return(ctShape); }
public void TestNew() { XSSFVMLDrawing vml = new XSSFVMLDrawing(); ArrayList items = vml.GetItems(); Assert.AreEqual(2, items.Count); Assert.IsTrue(items[0] is CT_ShapeLayout); CT_ShapeLayout layout = (CT_ShapeLayout)items[0]; Assert.AreEqual(ST_Ext.edit, layout.ext); Assert.AreEqual(ST_Ext.edit, layout.idmap.ext); Assert.AreEqual("1", layout.idmap.data); Assert.IsTrue(items[1] is CT_Shapetype); CT_Shapetype type = (CT_Shapetype)items[1]; Assert.AreEqual("21600,21600", type.coordsize); Assert.AreEqual(202.0f, type.spt); Assert.AreEqual("m,l,21600r21600,l21600,xe", type.path2); Assert.AreEqual("_xssf_cell_comment", type.id); Assert.AreEqual(ST_TrueFalse.t, type.path.gradientshapeok); Assert.AreEqual(ST_ConnectType.rect, type.path.connecttype); CT_Shape shape = vml.newCommentShape(); Assert.AreEqual(3, items.Count); Assert.AreSame(items[2], shape); Assert.AreEqual("#_xssf_cell_comment", shape.type); Assert.AreEqual("position:absolute; visibility:hidden", shape.style); Assert.AreEqual("#ffffe1", shape.fillcolor); Assert.AreEqual(ST_InsetMode.auto, shape.insetmode); Assert.AreEqual("#ffffe1", shape.fill.color); CT_Shadow shadow = shape.shadow; Assert.AreEqual(ST_TrueFalse.t, shadow.on); Assert.AreEqual("black", shadow.color); Assert.AreEqual(ST_TrueFalse.t, shadow.obscured); Assert.AreEqual(ST_ConnectType.none, shape.path.connecttype); Assert.AreEqual("mso-direction-alt:auto", shape.textbox.style); CT_ClientData cldata = shape.GetClientDataArray(0); Assert.AreEqual(ST_ObjectType.Note, cldata.ObjectType); Assert.AreEqual(1, cldata.SizeOfMoveWithCellsArray()); Assert.AreEqual(1, cldata.SizeOfSizeWithCellsArray()); Assert.AreEqual("1, 15, 0, 2, 3, 15, 3, 16", cldata.anchor); Assert.AreEqual(ST_TrueFalseBlank.@false, cldata.autoFill); Assert.AreEqual(0, cldata.GetRowArray(0)); Assert.AreEqual(0, cldata.GetColumnArray(0)); //serialize and read again MemoryStream out1 = new MemoryStream(); vml.Write(out1); XSSFVMLDrawing vml2 = new XSSFVMLDrawing(); vml2.Read(new MemoryStream(out1.ToArray())); ArrayList items2 = vml2.GetItems(); Assert.AreEqual(3, items2.Count); Assert.IsTrue(items2[0] is CT_ShapeLayout); Assert.IsTrue(items2[1] is CT_Shapetype); Assert.IsTrue(items2[2] is CT_Shape); }
/** * Creates a new XSSFComment, associated with a given * low level comment object. */ public XSSFComment(CommentsTable comments, CT_Comment comment, CT_Shape vmlShape) { _comment = comment; _comments = comments; _vmlShape = vmlShape; // we potentially need to adjust the column/row information in the shape // the same way as we do in setRow()/setColumn() if (vmlShape != null && vmlShape.SizeOfClientDataArray() > 0) { CellReference ref1 = new CellReference(comment.@ref); CT_ClientData clientData = vmlShape.GetClientDataArray(0); clientData.SetRowArray(0, ref1.Row); clientData.SetColumnArray(0, ref1.Col); // There is a very odd xmlbeans bug when changing the row // arrays which can lead to corrupt pointer // This call seems to fix them again... See bug #50795 //vmlShape.GetClientDataList().ToString(); } }
/** * Find a shape with ClientData of type "NOTE" and the specified row and column * * @return the comment shape or <code>null</code> */ internal CT_Shape FindCommentShape(int row, int col) { foreach (object itm in _items) { if (itm is CT_Shape) { CT_Shape sh = (CT_Shape)itm; if (sh.sizeOfClientDataArray() > 0) { CT_ClientData cldata = sh.GetClientDataArray(0); if (cldata.ObjectType == ST_ObjectType.Note) { int crow = cldata.GetRowArray(0); int ccol = cldata.GetColumnArray(0); if (crow == row && ccol == col) { return(sh); } } } } } return(null); }
internal CT_Shape FindCommentShape(int row, int col) { foreach (object obj in this._items) { if (obj is CT_Shape) { CT_Shape ctShape = (CT_Shape)obj; if (ctShape.sizeOfClientDataArray() > 0) { CT_ClientData clientDataArray = ctShape.GetClientDataArray(0); if (clientDataArray.ObjectType == ST_ObjectType.Note) { int rowArray = clientDataArray.GetRowArray(0); int columnArray = clientDataArray.GetColumnArray(0); if (rowArray == row && columnArray == col) { return(ctShape); } } } } } return((CT_Shape)null); }
public void TestNew() { XSSFVMLDrawing vml = new XSSFVMLDrawing(); ArrayList items = vml.GetItems(); Assert.AreEqual(2, items.Count); Assert.IsTrue(items[0] is CT_ShapeLayout); CT_ShapeLayout layout = (CT_ShapeLayout)items[0]; Assert.AreEqual(ST_Ext.edit, layout.ext); Assert.AreEqual(ST_Ext.edit, layout.idmap.ext); Assert.AreEqual("1", layout.idmap.data); Assert.IsTrue(items[1] is CT_Shapetype); CT_Shapetype type = (CT_Shapetype)items[1]; Assert.AreEqual("21600,21600", type.coordsize); Assert.AreEqual(202.0f, type.spt); Assert.AreEqual("m,l,21600r21600,l21600,xe", type.path2); Assert.AreEqual("_x0000_t202", type.id); Assert.AreEqual(NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t, type.path.gradientshapeok); Assert.AreEqual(ST_ConnectType.rect, type.path.connecttype); CT_Shape shape = vml.newCommentShape(); Assert.AreEqual(3, items.Count); Assert.AreSame(items[2], shape); Assert.AreEqual("#_x0000_t202", shape.type); Assert.AreEqual("position:absolute; visibility:hidden", shape.style); Assert.AreEqual("#ffffe1", shape.fillcolor); Assert.AreEqual(ST_InsetMode.auto, shape.insetmode); Assert.AreEqual("#ffffe1", shape.fill.color); CT_Shadow shadow = shape.shadow; Assert.AreEqual(NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t, shadow.on); Assert.AreEqual("black", shadow.color); Assert.AreEqual(NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t, shadow.obscured); Assert.AreEqual(ST_ConnectType.none, shape.path.connecttype); Assert.AreEqual("mso-direction-alt:auto", shape.textbox.style); CT_ClientData cldata = shape.GetClientDataArray(0); Assert.AreEqual(ST_ObjectType.Note, cldata.ObjectType); Assert.AreEqual(1, cldata.SizeOfMoveWithCellsArray()); Assert.AreEqual(1, cldata.SizeOfSizeWithCellsArray()); Assert.AreEqual("1, 15, 0, 2, 3, 15, 3, 16", cldata.anchor); Assert.AreEqual(ST_TrueFalseBlank.@false, cldata.autoFill); Assert.AreEqual(0, cldata.GetRowArray(0)); Assert.AreEqual(0, cldata.GetColumnArray(0)); //each of the properties of CT_ClientData should occurs 0 or 1 times, and CT_ClientData has multiple properties. //Assert.AreEqual("[]", cldata.GetVisibleList().ToString()); Assert.AreEqual(ST_TrueFalseBlank.NONE, cldata.visible); cldata.visible = (ST_TrueFalseBlank)Enum.Parse(typeof(ST_TrueFalseBlank), "true"); Assert.AreEqual(ST_TrueFalseBlank.@true, cldata.visible); //serialize and read again MemoryStream out1 = new MemoryStream(); vml.Write(out1); XSSFVMLDrawing vml2 = new XSSFVMLDrawing(); vml2.Read(new MemoryStream(out1.ToArray())); ArrayList items2 = vml2.GetItems(); Assert.AreEqual(3, items2.Count); Assert.IsTrue(items2[0] is CT_ShapeLayout); Assert.IsTrue(items2[1] is CT_Shapetype); Assert.IsTrue(items2[2] is CT_Shape); }