internal void InitLvl() { List <CT_Lvl> list = new List <CT_Lvl>(); for (int i = 0; i < 9; i++) { CT_Lvl lvl = new CT_Lvl(); lvl.start.val = "1"; lvl.tentative = i == 0? ST_OnOff.on : ST_OnOff.off; lvl.ilvl = i.ToString(); lvl.lvlJc.val = ST_Jc.left; lvl.numFmt.val = ST_NumberFormat.bullet; lvl.lvlText.val = lvlText[i % 3].ToString(); CT_Ind ind = lvl.pPr.AddNewInd(); ind.left = (420 * (i + 1)).ToString(); ind.hanging = 420; CT_Fonts fonts = lvl.rPr.AddNewRFonts(); fonts.ascii = "Wingdings"; fonts.hAnsi = "Wingdings"; fonts.hint = ST_Hint.@default; list.Add(lvl); } ctAbstractNum.lvl = list; }
public int GetIndentationFirstLine() { CT_Ind ctInd = this.GetCTInd(false); if (ctInd == null || !ctInd.IsSetFirstLine()) { return(-1); } return((int)ctInd.firstLine); }
public int GetIndentationHanging() { CT_Ind ctInd = this.GetCTInd(false); if (ctInd == null || !ctInd.IsSetHanging()) { return(-1); } return((int)ctInd.hanging); }
public int GetIndentationRight() { CT_Ind ctInd = this.GetCTInd(false); if (ctInd == null || !ctInd.IsSetRight()) { return(-1); } return(int.Parse(ctInd.right)); }
/** * Get a <b>copy</b> of the currently used CTPInd, if none is used, return * a new instance. */ private CT_Ind GetCTInd(bool create) { CT_PPr pr = GetCTPPr(); CT_Ind ct = pr.ind == null ? null : pr.ind; if (create && ct == null) { ct = pr.AddNewInd(); } return(ct); }
private CT_Ind GetCTInd(bool create) { CT_PPr ctpPr = this.GetCTPPr(); CT_Ind ctInd = ctpPr.ind == null ? (CT_Ind)null : ctpPr.ind; if (create && ctInd == null) { ctInd = ctpPr.AddNewInd(); } return(ctInd); }
public void TestSetGetIndentation() { XWPFDocument doc = new XWPFDocument(); XWPFParagraph p = doc.CreateParagraph(); Assert.AreEqual(-1, p.IndentationLeft); CT_P ctp = p.GetCTP(); CT_PPr ppr = ctp.pPr == null?ctp.AddNewPPr() : ctp.pPr; Assert.AreEqual(-1, p.IndentationLeft); CT_Ind ind = ppr.AddNewInd(); ind.left = "10"; Assert.AreEqual(10, p.IndentationLeft); p.IndentationLeft = 100; Assert.AreEqual(100, int.Parse(ind.left)); }
internal void InitLvl() { List <CT_Lvl> ctLvlList = new List <CT_Lvl>(); for (int index = 0; index < 9; ++index) { CT_Lvl ctLvl = new CT_Lvl(); ctLvl.start.val = "1"; ctLvl.tentative = index == 0 ? ST_OnOff.Value0 : ST_OnOff.Value1; ctLvl.ilvl = index.ToString(); ctLvl.lvlJc.val = ST_Jc.left; ctLvl.numFmt.val = ST_NumberFormat.bullet; ctLvl.lvlText.val = this.lvlText[index % 3].ToString(); CT_Ind ctInd = ctLvl.pPr.AddNewInd(); ctInd.left = (420 * (index + 1)).ToString(); ctInd.hanging = 420UL; CT_Fonts ctFonts = ctLvl.rPr.AddNewRFonts(); ctFonts.ascii = "Wingdings"; ctFonts.hAnsi = "Wingdings"; ctFonts.hint = ST_Hint.@default; ctLvlList.Add(ctLvl); } this.ctAbstractNum.lvl = ctLvlList.ToArray(); }
private static void CopyParagraph(XWPFParagraph templateph, XWPFParagraph ph) { if (!String.IsNullOrEmpty(templateph.Style)) { ph.Style = templateph.Style; } ph.SetNumID(templateph.GetNumID(), templateph.GetNumIlvl()); ph.Alignment = templateph.Alignment; ph.BorderBetween = templateph.BorderBetween; ph.BorderBottom = templateph.BorderBottom; ph.BorderLeft = templateph.BorderLeft; ph.BorderRight = templateph.BorderRight; ph.BorderTop = templateph.BorderTop; ph.FillBackgroundColor = templateph.FillBackgroundColor; ph.FillPattern = templateph.FillPattern; ph.FirstLineIndent = templateph.FirstLineIndent; ph.FontAlignment = templateph.FontAlignment; //readonly FootnoteText = templateph.FootnoteText; ph.IndentationFirstLine = templateph.IndentationFirstLine; //ph.IndentationHanging = templateph.IndentationHanging; ph.IndentationLeft = templateph.IndentationLeft; ph.IndentationRight = templateph.IndentationRight; ph.IndentFromLeft = templateph.IndentFromLeft; ph.IndentFromRight = templateph.IndentFromRight; ph.IsPageBreak = templateph.IsPageBreak; ph.IsWordWrapped = templateph.IsWordWrapped; if (ph.SpacingAfter != templateph.SpacingAfter) { ph.SpacingAfter = templateph.SpacingAfter; } if (ph.SpacingAfterLines != templateph.SpacingAfterLines) { ph.SpacingAfterLines = templateph.SpacingAfterLines; } if (ph.SpacingBefore != templateph.SpacingBefore) { ph.SpacingBefore = templateph.SpacingBefore; } if (ph.SpacingBeforeLines != templateph.SpacingBeforeLines) { ph.SpacingBeforeLines = templateph.SpacingBeforeLines; } if (ph.SpacingLineRule != templateph.SpacingLineRule) { ph.SpacingLineRule = templateph.SpacingLineRule; } if (ph.VerticalAlignment != templateph.VerticalAlignment) { ph.VerticalAlignment = templateph.VerticalAlignment; } foreach (XWPFRun templaterun in templateph.Runs) { XWPFRun run = ph.CreateRun(); WordGenerator.CopyRun(templaterun, run); } //公开的API中缩进信息不全 MethodInfo method = templateph.GetType().GetMethod("GetCTInd", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public); if (method != null) { CT_Ind indTemplate = method.Invoke(templateph, new object[] { false }) as CT_Ind; CT_Ind indPh = method.Invoke(ph, new object[] { true }) as CT_Ind; if (indTemplate != null && indPh != null) { indPh.firstLine = indTemplate.firstLine; indPh.firstLineChars = indTemplate.firstLineChars; indPh.firstLineSpecified = indTemplate.firstLineSpecified; indPh.hanging = indTemplate.hanging; indPh.hangingChars = indTemplate.hangingChars; indPh.hangingSpecified = indTemplate.hangingSpecified; indPh.left = indTemplate.left; indPh.leftChars = indTemplate.leftChars; indPh.right = indTemplate.right; indPh.rightChars = indTemplate.rightChars; } } }