Ejemplo n.º 1
0
        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>"));
 }
Ejemplo n.º 5
0
 public OpenXmlTextRunModel(string text, bool startsWithBreak, OpenXmlRunPropertiesModel properties)
 {
     _text            = text;
     _properties      = properties;
     _startsWithBreak = startsWithBreak;
 }
Ejemplo n.º 6
0
 public void EndHyperlink(OpenXmlRunPropertiesModel textStyle)
 {
     _contents.Add(OpenXmlFieldGenerators.EndHyperlink());
 }
Ejemplo n.º 7
0
 public void StartHyperlink(string target, bool bookmarkLink, OpenXmlRunPropertiesModel textStyle)
 {
     _contents.Add(OpenXmlFieldGenerators.StartHyperlink(target, bookmarkLink));
 }
Ejemplo n.º 8
0
 public void AddLabel(string label, int level, OpenXmlRunPropertiesModel textStyle)
 {
     _contents.Add(OpenXmlFieldGenerators.TableOfContentsEntry(label, level));
 }
Ejemplo n.º 9
0
 public void AddPageCountField(OpenXmlRunPropertiesModel textStyle)
 {
     _contents.Add(OpenXmlFieldGenerators.PageCountField(textStyle));
 }
Ejemplo n.º 10
0
 private void AddRun(StringBuilder text, bool breakFirst, OpenXmlRunPropertiesModel style)
 {
     _contents.Add(new OpenXmlTextRunModel(text.ToString(), breakFirst, style));
 }