Ejemplo n.º 1
0
 protected void ToDomString(DomElementList elements, StringBuilder stringBuilder, int level)
 {
     foreach (DomElement element in elements)
     {
         stringBuilder.Append(Environment.NewLine);
         stringBuilder.Append(new string(' ', level * 4));
         stringBuilder.Append(element);
         ToDomString(element.Elements, stringBuilder, level + 1);
     }
 }
Ejemplo n.º 2
0
 protected DomElement()
 {
     Elements = new DomElementList();
     Attributes = new AttributeList();
 }
Ejemplo n.º 3
0
 protected void ToDomString(DomElementList elements, StringBuilder stringBuilder, int level)
 {
     foreach (DomElement element in elements)
     {
         stringBuilder.Append(Environment.NewLine);
         stringBuilder.Append(new string(' ', level*4));
         stringBuilder.Append(element);
         ToDomString(element.Elements, stringBuilder, level + 1);
     }
 }
Ejemplo n.º 4
0
 protected DomElement()
 {
     Elements   = new DomElementList();
     Attributes = new AttributeList();
 }
Ejemplo n.º 5
0
        // ReSharper restore UnusedMember.Global
        /// <summary>
        /// Fixes invalid paragraphs
        /// </summary>
        // ReSharper disable UnusedMember.Global
        public void FixForParagraphs(DomElement parentElement)
        {
            DomParagraph lastParagraph = null;
            var list = new DomElementList();
            foreach (DomElement element in parentElement.Elements)
            {
                if (element is DomHeader
                    || element is DomFooter)
                {
                    FixForParagraphs(element);
                    lastParagraph = null;
                    list.Add(element);
                    continue;
                }

                if (element is DomParagraph
                    || element is DomTableRow
                    || element is DomTable
                    || element is DomTableCell)
                {
                    lastParagraph = null;
                    list.Add(element);
                    continue;
                }

                if (lastParagraph == null)
                {
                    lastParagraph = new DomParagraph();
                    list.Add(lastParagraph);
                    if (element is DomText)
                        lastParagraph.Format = ((DomText) element).Format.Clone();
                }

                lastParagraph.Elements.Add(element);
            }

            parentElement.Elements.Clear();

            foreach (DomElement element in list)
                parentElement.Elements.Add(element);
        }