public void AddText(string text, OpenXmlRunPropertiesModel style)
 {
     if (!string.IsNullOrEmpty(text))
     {
         StringBuilder stringBuilder = new StringBuilder();
         bool          flag          = true;
         foreach (char c in text)
         {
             if (c != '\r')
             {
                 if (c == '\n')
                 {
                     this.AddRun(stringBuilder, !flag, style);
                     stringBuilder = new StringBuilder();
                     flag          = false;
                 }
                 else if (c < ' ')
                 {
                     stringBuilder.Append(' ');
                 }
                 else
                 {
                     stringBuilder.Append(WordOpenXmlUtils.EscapeChar(c));
                 }
             }
         }
         this.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)
 {
     this._properties   = properties;
     this._instructions = instructions;
 }
 public static OpenXmlParagraphModel.IParagraphContent PageCountField(OpenXmlRunPropertiesModel textStyle)
 {
     return(new FieldWithCache(textStyle, "<w:instrText xml:space=\"preserve\"> NUMPAGES </w:instrText>"));
 }
 public void StartHyperlink(string target, bool bookmarkLink, OpenXmlRunPropertiesModel textStyle)
 {
     this._contents.Add(OpenXmlFieldGenerators.StartHyperlink(target, bookmarkLink));
 }
 public void AddLabel(string label, int level, OpenXmlRunPropertiesModel textStyle)
 {
     this._contents.Add(OpenXmlFieldGenerators.TableOfContentsEntry(label, level));
 }
 public void AddPageCountField(OpenXmlRunPropertiesModel textStyle)
 {
     this._contents.Add(OpenXmlFieldGenerators.PageCountField(textStyle));
 }
 private void AddRun(StringBuilder text, bool breakFirst, OpenXmlRunPropertiesModel style)
 {
     this._contents.Add(new OpenXmlTextRunModel(text.ToString(), breakFirst, style));
 }
 public void EndHyperlink(OpenXmlRunPropertiesModel textStyle)
 {
     this._contents.Add(OpenXmlFieldGenerators.EndHyperlink());
 }
 public OpenXmlTextRunModel(string text, bool startsWithBreak, OpenXmlRunPropertiesModel properties)
 {
     this._text            = text;
     this._properties      = properties;
     this._startsWithBreak = startsWithBreak;
 }