/** * Initialize a new Speadsheet VML Drawing */ private void newDrawing() { CT_ShapeLayout layout = new CT_ShapeLayout(); layout.ext = (ST_Ext.edit); CT_IdMap idmap = layout.AddNewIdmap(); idmap.ext = (ST_Ext.edit); idmap.data = ("1"); _items.Add(layout); CT_Shapetype shapetype = new CT_Shapetype(); _shapeTypeId = COMMENT_SHAPE_TYPE_ID; shapetype.id = _shapeTypeId;// "_x0000_t" + _shapeTypeId; shapetype.coordsize = "21600,21600"; shapetype.spt = 202; //_shapeTypeId = 202; shapetype.path2 = ("m,l,21600r21600,l21600,xe"); shapetype.AddNewStroke().joinstyle = (ST_StrokeJoinStyle.miter); CT_Path path = shapetype.AddNewPath(); path.gradientshapeok = NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t; path.connecttype = (ST_ConnectType.rect); _items.Add(shapetype); }
internal void Read(Stream is1) { StreamReader sr = new StreamReader(is1); string data = sr.ReadToEnd().Replace("<br>", ""); XDocument doc = XDocument.Load(new StringReader(data)); //InflaterInputStream iis = (InflaterInputStream)is1; //Stream vmlsm = new EvilUnclosedBRFixingInputStream(is1); --TODO:: add later XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable()); nsmgr.AddNamespace("o", "urn:schemas-microsoft-com:office:office"); nsmgr.AddNamespace("x", "urn:schemas-microsoft-com:office:excel"); nsmgr.AddNamespace("v", "urn:schemas-microsoft-com:vml"); _items = new ArrayList(); var nodes = doc.XPathSelectElements("/xml/*", nsmgr); foreach (XElement nd in nodes) { string xmltext = nd.OuterXml(); if (nd.Name.LocalName == QNAME_SHAPE_LAYOUT.Name) { CT_ShapeLayout sl = CT_ShapeLayout.Parse(nd, nsmgr); _items.Add(sl); } else if (nd.Name.LocalName == QNAME_SHAPE_TYPE.Name) { CT_Shapetype st = CT_Shapetype.Parse(nd, nsmgr); String typeid = st.id; if (typeid != null) { MatchCollection m = ptrn_shapeTypeId.Matches(typeid); if (m.Count > 0) { _shapeTypeId = Math.Max(_shapeTypeId, int.Parse(m[0].Groups[1].Value)); } } _items.Add(st); } else if (nd.Name.LocalName == QNAME_SHAPE.Name) { CT_Shape shape = CT_Shape.Parse(nd, nsmgr); String id = shape.id; if (id != null) { MatchCollection m = ptrn_shapeId.Matches(id); if (m.Count > 0) { _shapeId = Math.Max(_shapeId, int.Parse(m[0].Groups[1].Value)); } } _items.Add(shape); } else { _items.Add(nd); } } }
/** * Initialize a new Speadsheet VML Drawing */ private void newDrawing() { CT_ShapeLayout layout = new CT_ShapeLayout(); layout.ext = (ST_Ext.edit); CT_IdMap idmap = layout.AddNewIdmap(); idmap.ext = (ST_Ext.edit); idmap.data = ("1"); _items.Add(layout); CT_Shapetype shapetype = new CT_Shapetype(); _shapeTypeId = "_xssf_cell_comment"; shapetype.id = _shapeTypeId; shapetype.coordsize = "21600,21600"; shapetype.spt = 202; shapetype.path2 = ("m,l,21600r21600,l21600,xe"); shapetype.AddNewStroke().joinstyle = (ST_StrokeJoinStyle.miter); CT_Path path = shapetype.AddNewPath(); path.gradientshapeok = ST_TrueFalse.t; path.connecttype = (ST_ConnectType.rect); _items.Add(shapetype); }
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); }
internal void Read(Stream is1) { XmlDocument xmlDocument = new XmlDocument(); string end = new StreamReader(is1).ReadToEnd(); xmlDocument.LoadXml(end.Replace("<br>", "")); XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable); nsmgr.AddNamespace("o", "urn:schemas-microsoft-com:office:office"); nsmgr.AddNamespace("x", "urn:schemas-microsoft-com:office:excel"); nsmgr.AddNamespace("v", "urn:schemas-microsoft-com:vml"); this._items = new ArrayList(); foreach (XmlNode selectNode in xmlDocument.SelectNodes("/xml/*", nsmgr)) { string outerXml = selectNode.OuterXml; if (selectNode.LocalName == XSSFVMLDrawing.QNAME_SHAPE_LAYOUT.Name) { this._items.Add((object)CT_ShapeLayout.Parse(outerXml)); } else if (selectNode.LocalName == XSSFVMLDrawing.QNAME_SHAPE_TYPE.Name) { CT_Shapetype ctShapetype = CT_Shapetype.Parse(outerXml); this._shapeTypeId = ctShapetype.id; this._items.Add((object)ctShapetype); } else if (selectNode.LocalName == XSSFVMLDrawing.QNAME_SHAPE.Name) { CT_Shape ctShape = CT_Shape.Parse(outerXml); string id = ctShape.id; if (id != null) { MatchCollection matchCollection = XSSFVMLDrawing.ptrn_shapeId.Matches(id); if (matchCollection.Count > 0) { this._shapeId = Math.Max(this._shapeId, int.Parse(matchCollection[0].Groups[1].Value)); } } this._items.Add((object)ctShape); } else { this._items.Add((object)selectNode); } } }
private void newDrawing() { CT_ShapeLayout ctShapeLayout = new CT_ShapeLayout(); ctShapeLayout.ext = ST_Ext.edit; CT_IdMap ctIdMap = ctShapeLayout.AddNewIdmap(); ctIdMap.ext = ST_Ext.edit; ctIdMap.data = "1"; this._items.Add((object)ctShapeLayout); CT_Shapetype ctShapetype = new CT_Shapetype(); this._shapeTypeId = "_xssf_cell_comment"; ctShapetype.id = this._shapeTypeId; ctShapetype.coordsize = "21600,21600"; ctShapetype.spt = 202f; ctShapetype.path2 = "m,l,21600r21600,l21600,xe"; ctShapetype.AddNewStroke().joinstyle = ST_StrokeJoinStyle.miter; CT_Path ctPath = ctShapetype.AddNewPath(); ctPath.gradientshapeok = ST_TrueFalse.t; ctPath.connecttype = ST_ConnectType.rect; this._items.Add((object)ctShapetype); }
private static void CreateWaterMark(XWPFDocument doc, string headerText, string imageUrl = null) { if (doc.Document.body.sectPr == null) { doc.Document.body.sectPr = new CT_SectPr(); } CT_SectPr m_SectPr = doc.Document.body.sectPr; CT_Hdr header = new CT_Hdr(); //header.AddNewP().AddNewR().AddNewT().Value = headerText; var paragraph = header.AddNewP(); var ppr = paragraph.AddNewPPr(); ppr.AddNewPStyle().val = "a3"; ppr.AddNewJc().val = ST_Jc.right; var r = paragraph.AddNewR(); r.AddNewRPr().AddNewNoProof(); CT_Picture pict = r.AddNewPict(); CT_Shapetype shapetype = new CT_Shapetype(); shapetype.id = ("_x0000_t136"); shapetype.coordsize = ("21600,21600"); shapetype.spt = (136); shapetype.adj = ("10800"); shapetype.path2 = ("m@7,0l@8,0m@5,21600l@6,21600e"); CT_Formulas formulas = shapetype.AddNewFormulas(); formulas.AddNewF().eqn = ("sum #0 0 10800"); formulas.AddNewF().eqn = ("prod #0 2 1"); formulas.AddNewF().eqn = ("sum 21600 0 @1"); formulas.AddNewF().eqn = ("sum 0 0 @2"); formulas.AddNewF().eqn = ("sum 21600 0 @3"); formulas.AddNewF().eqn = ("if @0 @3 0"); formulas.AddNewF().eqn = ("if @0 21600 @1"); formulas.AddNewF().eqn = ("if @0 0 @2"); formulas.AddNewF().eqn = ("if @0 @4 21600"); formulas.AddNewF().eqn = ("mid @5 @6"); formulas.AddNewF().eqn = ("mid @8 @5"); formulas.AddNewF().eqn = ("mid @7 @8"); formulas.AddNewF().eqn = ("mid @6 @7"); formulas.AddNewF().eqn = ("sum @6 0 @5"); CT_Path path = shapetype.AddNewPath(); path.textpathok = (NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t); path.connecttype = (NPOI.OpenXmlFormats.Vml.Office.ST_ConnectType.custom); path.connectlocs = ("@9,0;@10,10800;@11,21600;@12,10800"); path.connectangles = ("270,180,90,0"); CT_TextPath shapeTypeTextPath = shapetype.AddNewTextpath(); shapeTypeTextPath.on = (NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t); shapeTypeTextPath.fitshape = (NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t); CT_Handles handles = shapetype.AddNewHandles(); CT_H h = handles.AddNewH(); h.position = ("#0,bottomRight"); h.xrange = ("6629,14971"); NPOI.OpenXmlFormats.Vml.Office.CT_Lock lock1 = shapetype.AddNewLock(); lock1.ext = (ST_Ext.edit); lock1.text = NPOI.OpenXmlFormats.Vml.Office.ST_TrueFalse.t; lock1.shapetype = NPOI.OpenXmlFormats.Vml.Office.ST_TrueFalse.t; CT_Shape shape = new CT_Shape(); shape.id = ("PowerPlusWaterMarkObject" + "1109904797"); shape.spid = ("_x0000_s206" + (4 + "1")); shape.type = ("#_x0000_t136"); shape.style = ("position:absolute;margin-left:0;margin-top:0;width:415pt;height:207.5pt;z-index:-251654144;mso-wrap-edited:f;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin"); //shape.wrapcoords = ("616 5068 390 16297 39 16921 -39 17155 7265 17545 7186 17467 -39 17467 18904 17467 10507 17467 8710 17545 18904 17077 18787 16843 18358 16297 18279 12554 19178 12476 20701 11774 20779 11228 21131 10059 21248 8811 21248 7563 20975 6316 20935 5380 19490 5146 14022 5068 2616 5068"); shape.fillcolor = ("#ed7d31 [3205]"); shape.stroked = (NPOI.OpenXmlFormats.Vml.ST_TrueFalse.@false); shape.AddNewFill().opacity = ".5"; CT_TextPath shapeTextPath = shape.AddNewTextpath(); shapeTextPath.style = ("font-family:"Yu Gothic UI""); shapeTextPath.@string = ("吴润杰水印"); // pict.Items.Add(shapetype); //pict.Set(shapetype); pict.Set(shape); //pict.Set(group); XWPFRelation Hrelation = XWPFRelation.HEADER; XWPFHeader docHeader = (XWPFHeader)doc.CreateRelationship(Hrelation, XWPFFactory.GetInstance(), doc.HeaderList.Count); docHeader.SetXWPFDocument(doc); //设置页眉 docHeader.SetHeaderFooter(header); CT_HdrFtrRef m_HdrFtr2 = m_SectPr.AddNewHeaderReference(); m_HdrFtr2.type = ST_HdrFtr.@default; m_HdrFtr2.id = docHeader.GetPackageRelationship().Id; }
internal void Read(Stream is1) { XmlDocument doc = new XmlDocument(); //InflaterInputStream iis = (InflaterInputStream)is1; StreamReader sr = new StreamReader(is1); string data = sr.ReadToEnd(); //Stream vmlsm = new EvilUnclosedBRFixingInputStream(is1); --TODO:: add later doc.LoadXml( data.Replace("<br>", "") ); XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace("o", "urn:schemas-microsoft-com:office:office"); nsmgr.AddNamespace("x", "urn:schemas-microsoft-com:office:excel"); nsmgr.AddNamespace("v", "urn:schemas-microsoft-com:vml"); _items = new ArrayList(); XmlNodeList nodes = doc.SelectNodes("/xml/*", nsmgr); foreach (XmlNode nd in nodes) { string xmltext = nd.OuterXml; if (nd.LocalName == QNAME_SHAPE_LAYOUT.Name) { CT_ShapeLayout sl = CT_ShapeLayout.Parse(nd, nsmgr); _items.Add(sl); } else if (nd.LocalName == QNAME_SHAPE_TYPE.Name) { CT_Shapetype st = CT_Shapetype.Parse(nd, nsmgr); _items.Add(st); _shapeTypeId = st.id; } else if (nd.LocalName == QNAME_SHAPE.Name) { CT_Shape shape = CT_Shape.Parse(nd, nsmgr); String id = shape.id; if (id != null) { MatchCollection m = ptrn_shapeId.Matches(id); if (m.Count > 0) { _shapeId = Math.Max(_shapeId, int.Parse(m[0].Groups[1].Value)); } } _items.Add(shape); } else { /// How to port following java code?? //Document doc2; //try //{ // InputSource is2 = new InputSource(new StringReader(obj.xmlText())); // doc2 = DocumentHelper.readDocument(is2); //} //catch (SAXException e) //{ // throw new XmlException(e.getMessage(), e); //} _items.Add(nd); } } }
public void TestCommentShowsBox() { XSSFWorkbook wb = new XSSFWorkbook(); wb.CreateSheet(); XSSFSheet sheet = (XSSFSheet)wb.GetSheetAt(0); XSSFCell cell = (XSSFCell)sheet.CreateRow(0).CreateCell(0); XSSFDrawing drawing = (XSSFDrawing)sheet.CreateDrawingPatriarch(); XSSFCreationHelper factory = (XSSFCreationHelper)wb.GetCreationHelper(); XSSFClientAnchor anchor = (XSSFClientAnchor)factory.CreateClientAnchor(); anchor.Col1 = cell.ColumnIndex; anchor.Col2 = cell.ColumnIndex + 3; anchor.Row1 = cell.RowIndex; anchor.Row2 = cell.RowIndex + 5; XSSFComment comment = (XSSFComment)drawing.CreateCellComment(anchor); XSSFRichTextString str = (XSSFRichTextString)factory.CreateRichTextString("this is a comment"); comment.String = str; cell.CellComment = comment; XSSFVMLDrawing vml = sheet.GetVMLDrawing(false); CT_Shapetype shapetype = null; ArrayList items = vml.GetItems(); foreach (object o in items) { if (o is CT_Shapetype) { shapetype = (CT_Shapetype)o; } } Assert.AreEqual(NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t, shapetype.stroked); Assert.AreEqual(NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t, shapetype.filled); using (MemoryStream ws = new MemoryStream()) { wb.Write(ws); using (MemoryStream rs = new MemoryStream(ws.GetBuffer())) { wb = new XSSFWorkbook(rs); sheet = (XSSFSheet)wb.GetSheetAt(0); vml = sheet.GetVMLDrawing(false); shapetype = null; items = vml.GetItems(); foreach (object o in items) { if (o is CT_Shapetype) { shapetype = (CT_Shapetype)o; } } //wb.Write(new FileStream("comments.xlsx", FileMode.Create)); //using (MemoryStream ws2 = new MemoryStream()) //{ // vml.Write(ws2); // throw new System.Exception(System.Text.Encoding.UTF8.GetString(ws2.GetBuffer())); //} Assert.AreEqual(NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t, shapetype.stroked); Assert.AreEqual(NPOI.OpenXmlFormats.Vml.ST_TrueFalse.t, shapetype.filled); } } }
/** * Initialize a new Speadsheet VML Drawing */ private void newDrawing() { CT_ShapeLayout layout = new CT_ShapeLayout(); layout.ext = (ST_Ext.edit); CT_IdMap idmap = layout.AddNewIdmap(); idmap.ext = (ST_Ext.edit); idmap.data = ("1"); _items.Add(layout); CT_Shapetype shapetype = new CT_Shapetype(); shapetype.id= "_x0000_t" + _shapeTypeId; shapetype.coordsize="21600,21600"; shapetype.spt=202; shapetype.path2 = ("m,l,21600r21600,l21600,xe"); shapetype.AddNewStroke().joinstyle = (ST_StrokeJoinStyle.miter); CT_Path path = shapetype.AddNewPath(); path.gradientshapeok = ST_TrueFalse.t; path.connecttype=(ST_ConnectType.rect); _items.Add(shapetype); }
/* * This is the default Watermark paragraph; the only variable is the text message * TODO: manage all the other variables */ private XWPFParagraph GetWatermarkParagraph(String text, int idx) { CT_P p = new CT_P(); byte[] rsidr = doc.Document.body.GetPArray(0).rsidR; byte[] rsidrdefault = doc.Document.body.GetPArray(0).rsidRDefault; p.rsidP = (rsidr); p.rsidRDefault = (rsidrdefault); CT_PPr pPr = p.AddNewPPr(); pPr.AddNewPStyle().val = ("Header"); // start watermark paragraph Npoi.Core.OpenXmlFormats.Wordprocessing.CT_R r = p.AddNewR(); CT_RPr rPr = r.AddNewRPr(); rPr.AddNewNoProof(); CT_Picture pict = r.AddNewPict(); CT_Group group = new CT_Group(); CT_Shapetype shapetype = group.AddNewShapetype(); shapetype.id = ("_x0000_t136"); shapetype.coordsize = ("1600,21600"); shapetype.spt = (136); shapetype.adj = ("10800"); shapetype.path2 = ("m@7,0l@8,0m@5,21600l@6,21600e"); CT_Formulas formulas = shapetype.AddNewFormulas(); formulas.AddNewF().eqn = ("sum #0 0 10800"); formulas.AddNewF().eqn = ("prod #0 2 1"); formulas.AddNewF().eqn = ("sum 21600 0 @1"); formulas.AddNewF().eqn = ("sum 0 0 @2"); formulas.AddNewF().eqn = ("sum 21600 0 @3"); formulas.AddNewF().eqn = ("if @0 @3 0"); formulas.AddNewF().eqn = ("if @0 21600 @1"); formulas.AddNewF().eqn = ("if @0 0 @2"); formulas.AddNewF().eqn = ("if @0 @4 21600"); formulas.AddNewF().eqn = ("mid @5 @6"); formulas.AddNewF().eqn = ("mid @8 @5"); formulas.AddNewF().eqn = ("mid @7 @8"); formulas.AddNewF().eqn = ("mid @6 @7"); formulas.AddNewF().eqn = ("sum @6 0 @5"); CT_Path path = shapetype.AddNewPath(); path.textpathok = (Npoi.Core.OpenXmlFormats.Vml.ST_TrueFalse.t); path.connecttype = (ST_ConnectType.custom); path.connectlocs = ("@9,0;@10,10800;@11,21600;@12,10800"); path.connectangles = ("270,180,90,0"); CT_TextPath shapeTypeTextPath = shapetype.AddNewTextpath(); shapeTypeTextPath.on = (Npoi.Core.OpenXmlFormats.Vml.ST_TrueFalse.t); shapeTypeTextPath.fitshape = (Npoi.Core.OpenXmlFormats.Vml.ST_TrueFalse.t); CT_Handles handles = shapetype.AddNewHandles(); CT_H h = handles.AddNewH(); h.position = ("#0,bottomRight"); h.xrange = ("6629,14971"); Npoi.Core.OpenXmlFormats.Vml.Office.CT_Lock lock1 = shapetype.AddNewLock(); lock1.ext = (ST_Ext.edit); CT_Shape shape = group.AddNewShape(); shape.id = ("PowerPlusWaterMarkObject" + idx); shape.spid = ("_x0000_s102" + (4 + idx)); shape.type = ("#_x0000_t136"); shape.style = ("position:absolute;margin-left:0;margin-top:0;width:415pt;height:207.5pt;z-index:-251654144;mso-wrap-edited:f;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin"); shape.wrapcoords = ("616 5068 390 16297 39 16921 -39 17155 7265 17545 7186 17467 -39 17467 18904 17467 10507 17467 8710 17545 18904 17077 18787 16843 18358 16297 18279 12554 19178 12476 20701 11774 20779 11228 21131 10059 21248 8811 21248 7563 20975 6316 20935 5380 19490 5146 14022 5068 2616 5068"); shape.fillcolor = ("black"); shape.stroked = (Npoi.Core.OpenXmlFormats.Vml.ST_TrueFalse.@false); CT_TextPath shapeTextPath = shape.AddNewTextpath(); shapeTextPath.style = ("font-family:"Cambria";font-size:1pt"); shapeTextPath.@string = (text); pict.Set(group); // end watermark paragraph return(new XWPFParagraph(p, doc)); }
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); }
private XWPFParagraph GetWatermarkParagraph(string text, int idx) { CT_P prgrph = new CT_P(); byte[] rsidR = this.doc.Document.body.GetPArray(0).rsidR; byte[] rsidRdefault = this.doc.Document.body.GetPArray(0).rsidRDefault; prgrph.rsidP = rsidR; prgrph.rsidRDefault = rsidRdefault; prgrph.AddNewPPr().AddNewPStyle().val = "Header"; NPOI.OpenXmlFormats.Wordprocessing.CT_R ctR = prgrph.AddNewR(); ctR.AddNewRPr().AddNewNoProof(); CT_Picture ctPicture = ctR.AddNewPict(); CT_Group ctGroup = new CT_Group(); CT_Shapetype ctShapetype = ctGroup.AddNewShapetype(); ctShapetype.id = "_x0000_t136"; ctShapetype.coordsize = "1600,21600"; ctShapetype.spt = 136f; ctShapetype.adj = "10800"; ctShapetype.path2 = "m@7,0l@8,0m@5,21600l@6,21600e"; CT_Formulas ctFormulas = ctShapetype.AddNewFormulas(); ctFormulas.AddNewF().eqn = "sum #0 0 10800"; ctFormulas.AddNewF().eqn = "prod #0 2 1"; ctFormulas.AddNewF().eqn = "sum 21600 0 @1"; ctFormulas.AddNewF().eqn = "sum 0 0 @2"; ctFormulas.AddNewF().eqn = "sum 21600 0 @3"; ctFormulas.AddNewF().eqn = "if @0 @3 0"; ctFormulas.AddNewF().eqn = "if @0 21600 @1"; ctFormulas.AddNewF().eqn = "if @0 0 @2"; ctFormulas.AddNewF().eqn = "if @0 @4 21600"; ctFormulas.AddNewF().eqn = "mid @5 @6"; ctFormulas.AddNewF().eqn = "mid @8 @5"; ctFormulas.AddNewF().eqn = "mid @7 @8"; ctFormulas.AddNewF().eqn = "mid @6 @7"; ctFormulas.AddNewF().eqn = "sum @6 0 @5"; CT_Path ctPath = ctShapetype.AddNewPath(); ctPath.textpathok = ST_TrueFalse.t; ctPath.connecttype = ST_ConnectType.custom; ctPath.connectlocs = "@9,0;@10,10800;@11,21600;@12,10800"; ctPath.connectangles = "270,180,90,0"; CT_TextPath ctTextPath1 = ctShapetype.AddNewTextpath(); ctTextPath1.on = ST_TrueFalse.t; ctTextPath1.fitshape = ST_TrueFalse.t; CT_H ctH = ctShapetype.AddNewHandles().AddNewH(); ctH.position = "#0,bottomRight"; ctH.xrange = "6629,14971"; ctShapetype.AddNewLock().ext = ST_Ext.edit; CT_Shape ctShape = ctGroup.AddNewShape(); ctShape.id = "PowerPlusWaterMarkObject" + (object)idx; ctShape.spid = "_x0000_s102" + (object)(4 + idx); ctShape.type = "#_x0000_t136"; ctShape.style = "position:absolute;margin-left:0;margin-top:0;width:415pt;height:207.5pt;z-index:-251654144;mso-wrap-edited:f;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin"; ctShape.wrapcoords = "616 5068 390 16297 39 16921 -39 17155 7265 17545 7186 17467 -39 17467 18904 17467 10507 17467 8710 17545 18904 17077 18787 16843 18358 16297 18279 12554 19178 12476 20701 11774 20779 11228 21131 10059 21248 8811 21248 7563 20975 6316 20935 5380 19490 5146 14022 5068 2616 5068"; ctShape.fillcolor = "black"; ctShape.stroked = ST_TrueFalse.@false; CT_TextPath ctTextPath2 = ctShape.AddNewTextpath(); ctTextPath2.style = "font-family:"Cambria";font-size:1pt"; ctTextPath2.@string = text; ctPicture.Set((object)ctGroup); return(new XWPFParagraph(prgrph, (IBody)this.doc)); }