/// <summary>
        /// Returns formatted OpenXmlElement[] representing given List instance
        /// </summary>
        /// <param name="list">List object</param>
        /// <returns></returns>
        public static IEnumerable<OpenXmlElement> GetFormattedElement(Model.List list)
        {
            List<OpenXmlElement> result = new List<OpenXmlElement>();

            int numStyleId = StyleCreator.AddNumberingStyle(list.Ordered, list.Label);

            foreach (Model.Element element in list.SubElements)
            {
                if (element.GetElementType() == Model.ElementType.ListItem)
                {
                    result.Add( GetListItem((Model.ListItem)element, numStyleId) );
                }
                else {
                    throw new InvalidSubFeatureException( list.GetElementType().ToString(), element.GetElementType().ToString());
                }
            }

            result.Add(new Paragraph());
            return result.AsEnumerable();
        }
        public static IEnumerable<OpenXmlElement> GetFormattedElement(Table table)
        {
            List<OpenXmlElement> result = new List<OpenXmlElement>();

            Word.Table wordTable = new Word.Table();

            wordTable.Append(GetTableProperties(table));

            //Add Headings
            if(table.Headings != null) wordTable.Append(GetFormattedTableRow(table.Headings));

            //Add Data Rows
            foreach (Element element in table.SubElements)
            {
                if (element.GetElementType() == ElementType.TableRow) wordTable.Append(GetFormattedTableRow((TableRow)element));
                else throw new InvalidSubFeatureException(table.GetElementType().ToString(), element.GetElementType().ToString());
            }

            result.Add(wordTable);
            result.Add(new Word.Paragraph());
            return result;
        }
        public static DocumentFormat.OpenXml.OpenXmlElement[] GetFormattedSection(MultiColumnSection section)
        {
            List<DocumentFormat.OpenXml.OpenXmlElement> formattedSection = new List<DocumentFormat.OpenXml.OpenXmlElement>();
            Element[] elements = section.SubElements;

            foreach (var element in elements)
            {
                formattedSection.AddRange(ElementFactory.GetElement(element));
            }

            Word.Columns cols = new Word.Columns()
            {
                ColumnCount = (Int16Value)section.NumberOfColumns
            };

            Word.SectionProperties secProps = new Word.SectionProperties(cols);
            Word.ParagraphProperties paraProp = new Word.ParagraphProperties(secProps);
            Word.Paragraph para = new Word.Paragraph(paraProp);

            formattedSection.Add(para);

            return formattedSection.ToArray();
        }
        public static DocumentFormat.OpenXml.OpenXmlElement[] GetFormattedSection(Section section)
        {
            List<DocumentFormat.OpenXml.OpenXmlElement> formattedSection = new List<DocumentFormat.OpenXml.OpenXmlElement>();
            Element[] elements = section.SubElements;

            foreach (var element in elements)
            {
                if (section.CanContain(element.GetElementType())) formattedSection.AddRange(ElementFactory.GetElement(element));
                else throw new InvalidSubFeatureException( section.GetElementType().ToString(), element.GetElementType().ToString() );
            }

            Word.Columns cols = new Word.Columns()
            {
                ColumnCount = (Int16Value)1
            };

            Word.SectionProperties secProps = new Word.SectionProperties(cols);
            Word.ParagraphProperties paraProp = new Word.ParagraphProperties(secProps);
            Word.Paragraph para = new Word.Paragraph(paraProp);

            formattedSection.Add(para);

            return formattedSection.ToArray();
        }
Beispiel #5
0
 public Font()
     : base()
 {
     Formats = new List<FontFormats>();
 }
 public Paragraph(Text[] parts)
 {
     contents = new List<Element>(parts);
 }
 public Paragraph()
     : base()
 {
     contents = new List<Element>();
     SetDefaultValues();
 }
Beispiel #8
0
 public Chapter()
     : base()
 {
     sections = new List<Element>();
 }
Beispiel #9
0
 public TableRow(TableCell[] cells)
 {
     this.cells = new List<Element>(cells);
 }
Beispiel #10
0
 public TableCell()
 {
     elements = new List<Element>();
 }
Beispiel #11
0
        private TableRow[] GetData()
        {
            List<TableRow> rows = new List<TableRow>();
            TableRow tmpRow;

            foreach (DataRow row in data.Rows)
            {
                tmpRow = new TableRow(GetCells(row));
                rows.Add(tmpRow);
            }

            return rows.ToArray();
        }
Beispiel #12
0
 private TableCell[] GetCells(DataRow row)
 {
     List<TableCell> cells = new List<TableCell>();
     for (int i = 0; i < data.Columns.Count; i++)
     {
         cells.Add( row[i] as TableCell);
     }
     return cells.ToArray();
 }
Beispiel #13
0
 public List()
     : base()
 {
     listItems = new List<Element>();
 }
Beispiel #14
0
 public Section()
     : base()
 {
     elementList = new List<Element>();
 }
        public static DocumentFormat.OpenXml.OpenXmlElement[] GetFormattedChapter(Chapter chapter)
        {
            if(!stylesAdded) StyleCreator.AddStylePart();

            List<OpenXmlElement> result = new List<OpenXmlElement>();

            //Setting up Heading style
            Word.ParagraphProperties paraProps = new Word.ParagraphProperties();
            Word.ParagraphStyleId style = new Word.ParagraphStyleId()
            {
                Val = "Heading1"
            };
            paraProps.Append(style);

            //Adding chapter title
            Word.Paragraph para = new Word.Paragraph();
            Word.Run run = new Word.Run();
            Word.Text text = new Word.Text()
            {
                Text = chapter.Title
            };

            run.Append(text);
            para.Append(paraProps);
            para.Append(run);

            result.Add(para);

            //Add all child elements
            foreach (Element element in chapter.SubElements)
            {
                if (element.GetElementType() == ElementType.MultiColumnSection)
                {
                    result.AddRange(MultiColumnSectionFormatter.GetFormattedSection((MultiColumnSection)element));
                }
                else if (element.GetElementType() == ElementType.Section) result.AddRange(SectionFormatter.GetFormattedSection((Section)element));

                else throw new InvalidSubFeatureException( chapter.GetElementType().ToString() , element.GetElementType().ToString());
            }

            return result.ToArray();
        }