public void AddRow(int level, string title, int page, string bookmarkRef) { CT_P ctP = this.block.sdtContent.AddNewP(); byte[] bytes = Encoding.Unicode.GetBytes("00EF7E24"); ctP.rsidR = bytes; ctP.rsidRDefault = bytes; CT_PPr ctPpr = ctP.AddNewPPr(); ctPpr.AddNewPStyle().val = nameof(TOC) + (object)level; CT_TabStop ctTabStop = ctPpr.AddNewTabs().AddNewTab(); ctTabStop.val = ST_TabJc.right; ctTabStop.leader = ST_TabTlc.dot; ctTabStop.pos = "8290"; ctPpr.AddNewRPr().AddNewNoProof(); CT_R ctR1 = ctP.AddNewR(); ctR1.AddNewRPr().AddNewNoProof(); ctR1.AddNewT().Value = title; CT_R ctR2 = ctP.AddNewR(); ctR2.AddNewRPr().AddNewNoProof(); ctR2.AddNewTab(); CT_R ctR3 = ctP.AddNewR(); ctR3.AddNewRPr().AddNewNoProof(); ctR3.AddNewFldChar().fldCharType = ST_FldCharType.begin; CT_R ctR4 = ctP.AddNewR(); ctR4.AddNewRPr().AddNewNoProof(); CT_Text ctText = ctR4.AddNewInstrText(); ctText.space = "preserve"; ctText.Value = " PAGEREF _Toc" + bookmarkRef + " \\h "; ctP.AddNewR().AddNewRPr().AddNewNoProof(); CT_R ctR5 = ctP.AddNewR(); ctR5.AddNewRPr().AddNewNoProof(); ctR5.AddNewFldChar().fldCharType = ST_FldCharType.separate; CT_R ctR6 = ctP.AddNewR(); ctR6.AddNewRPr().AddNewNoProof(); ctR6.AddNewT().Value = page.ToString(); CT_R ctR7 = ctP.AddNewR(); ctR7.AddNewRPr().AddNewNoProof(); ctR7.AddNewFldChar().fldCharType = ST_FldCharType.end; }
public void AddRow(int level, String title, int page, String bookmarkRef) { CT_SdtContentBlock contentBlock = this.block.sdtContent; CT_P p = contentBlock.AddNewP(); byte[] b = Encoding.Unicode.GetBytes("00EF7E24"); p.rsidR = b; p.rsidRDefault = b; CT_PPr pPr = p.AddNewPPr(); pPr.AddNewPStyle().val = ("TOC" + level); CT_Tabs tabs = pPr.AddNewTabs(); CT_TabStop tab = tabs.AddNewTab(); tab.val = (ST_TabJc.right); tab.leader = (ST_TabTlc.dot); tab.pos = "8290"; //(new BigInteger("8290")); pPr.AddNewRPr().AddNewNoProof(); CT_R Run = p.AddNewR(); Run.AddNewRPr().AddNewNoProof(); Run.AddNewT().Value = (title); Run = p.AddNewR(); Run.AddNewRPr().AddNewNoProof(); Run.AddNewTab(); Run = p.AddNewR(); Run.AddNewRPr().AddNewNoProof(); Run.AddNewFldChar().fldCharType = (ST_FldCharType.begin); // pageref run Run = p.AddNewR(); Run.AddNewRPr().AddNewNoProof(); CT_Text text = Run.AddNewInstrText(); text.space = "preserve";// (Space.PRESERVE); // bookmark reference text.Value = (" PAGEREF _Toc" + bookmarkRef + " \\h "); p.AddNewR().AddNewRPr().AddNewNoProof(); Run = p.AddNewR(); Run.AddNewRPr().AddNewNoProof(); Run.AddNewFldChar().fldCharType = (ST_FldCharType.separate); // page number run Run = p.AddNewR(); Run.AddNewRPr().AddNewNoProof(); Run.AddNewT().Value = page.ToString(); Run = p.AddNewR(); Run.AddNewRPr().AddNewNoProof(); Run.AddNewFldChar().fldCharType = (ST_FldCharType.end); }
public void TestAddTabsAndLineBreaks() { ctRun.AddNewT().Value = ("TEST STRING"); ctRun.AddNewCr(); ctRun.AddNewT().Value = (/*setter*/ "TEST2 STRING"); ctRun.AddNewTab(); ctRun.AddNewT().Value = (/*setter*/ "TEST3 STRING"); Assert.AreEqual(1, ctRun.SizeOfCrArray()); Assert.AreEqual(1, ctRun.SizeOfTabArray()); XWPFRun run = new XWPFRun(new CT_R(), p); run.AppendText("T1"); run.AddCarriageReturn(); run.AppendText("T2"); run.AddTab(); run.AppendText("T3"); Assert.AreEqual(1, run.GetCTR().GetCrList().Count); Assert.AreEqual(1, run.GetCTR().GetTabList().Count); Assert.AreEqual("T1\nT2\tT3", run.ToString()); }
/** * Specifies that a tab shall be placed at the current location in * the run content. */ public void AddTab() { run.AddNewTab(); }