public void SetBorderTop(Borders border) { CT_PBdr ctpBrd = this.GetCTPBrd(true); CT_Border ctBorder = ctpBrd == null || !ctpBrd.IsSetTop() ? ctpBrd.AddNewTop() : ctpBrd.top; if (border == Borders.NONE) { ctpBrd.UnsetTop(); } else { ctBorder.val = EnumConverter.ValueOf <ST_Border, Borders>(border); } }
public void TestSetBorderTop() { //new clean instance of paragraph XWPFDocument doc = new XWPFDocument(); XWPFParagraph p = doc.CreateParagraph(); Assert.AreEqual(ST_Border.none, EnumConverter.ValueOf <ST_Border, Borders>(p.BorderTop)); CT_P ctp = p.GetCTP(); CT_PPr ppr = ctp.pPr == null?ctp.AddNewPPr() : ctp.pPr; //bordi CT_PBdr bdr = ppr.AddNewPBdr(); CT_Border borderTop = bdr.AddNewTop(); borderTop.val = (ST_Border.@double); bdr.top = (borderTop); Assert.AreEqual(Borders.Double, p.BorderTop); p.BorderTop = (Borders.Single); Assert.AreEqual(ST_Border.single, borderTop.val); }