public void AddText(string text, OpenXmlRunPropertiesModel style) { if (string.IsNullOrEmpty(text)) { return; } StringBuilder stringBuilder = new StringBuilder(); bool flag = true; foreach (char c in text) { if (c != '\r') { if (c == '\n') { AddRun(stringBuilder, !flag, style); stringBuilder = new StringBuilder(); flag = false; } else if (c < ' ') { stringBuilder.Append(' '); } else { stringBuilder.Append(WordOpenXmlUtils.EscapeChar(c)); } } } AddRun(stringBuilder, !flag, style); }
private static string BeginInstructions(TextWriter writer, OpenXmlRunPropertiesModel properties) { StringBuilder stringBuilder = new StringBuilder(); using (StringWriter q = new StringWriter(stringBuilder, CultureInfo.InvariantCulture)) { properties.Write(q); } string text = stringBuilder.ToString(); writer.Write("<w:r>"); writer.Write(text); writer.Write("<w:fldChar w:fldCharType=\"begin\" w:fldLock=\"0\" w:dirty=\"0\"/></w:r><w:r>"); properties.NoProof = true; properties.Write(writer); properties.NoProof = false; return(text); }
public FieldWithCache(OpenXmlRunPropertiesModel properties, string instructions) { _properties = properties; _instructions = instructions; }
public static OpenXmlParagraphModel.IParagraphContent PageCountField(OpenXmlRunPropertiesModel textStyle) { return(new FieldWithCache(textStyle, "<w:instrText xml:space=\"preserve\"> NUMPAGES </w:instrText>")); }
public OpenXmlTextRunModel(string text, bool startsWithBreak, OpenXmlRunPropertiesModel properties) { _text = text; _properties = properties; _startsWithBreak = startsWithBreak; }
public void EndHyperlink(OpenXmlRunPropertiesModel textStyle) { _contents.Add(OpenXmlFieldGenerators.EndHyperlink()); }
public void StartHyperlink(string target, bool bookmarkLink, OpenXmlRunPropertiesModel textStyle) { _contents.Add(OpenXmlFieldGenerators.StartHyperlink(target, bookmarkLink)); }
public void AddLabel(string label, int level, OpenXmlRunPropertiesModel textStyle) { _contents.Add(OpenXmlFieldGenerators.TableOfContentsEntry(label, level)); }
public void AddPageCountField(OpenXmlRunPropertiesModel textStyle) { _contents.Add(OpenXmlFieldGenerators.PageCountField(textStyle)); }
private void AddRun(StringBuilder text, bool breakFirst, OpenXmlRunPropertiesModel style) { _contents.Add(new OpenXmlTextRunModel(text.ToString(), breakFirst, style)); }