示例#1
0
        /// <summary>
        /// Gets a paragraph in ODF format.
        /// </summary>
        /// <param name="doc">The ODF Textdocument that is being created</param>
        /// <returns>List of paragraphs in ODF format.</returns>
        public virtual List <IContent> GetODFParagraph(AODL.Document.TextDocuments.TextDocument doc)
        {
            List <IContent> paragraphs = new List <IContent>();

            //Create the header, if there is any.
            if (_header != null)
            {
                paragraphs.Add(_header.GetODFParagraph(doc)[0]);
            }

            //Create the text part if there is any
            if (!string.IsNullOrEmpty(_text))
            {
                //Create the paragraph
                ODFParagraph paragraph = AODL.Document.Content.Text.ParagraphBuilder.CreateStandardTextParagraph(doc);
                //Add the formated text
                foreach (var formatedText in CommonDocumentFunctions.ParseParagraphForODF(doc, _text))
                {
                    paragraph.TextContent.Add(formatedText);
                }
                //Add the header properties
                paragraphs.Add(paragraph);
            }
            return(paragraphs);
        }
示例#2
0
        /// <summary>
        /// Creates sublists for nested lists.
        /// </summary>
        /// <param name="firstItem">The item to start the list with.</param>
        /// <param name="document">The document to which the sublist belongs.</param>
        /// <param name="currentIndex">The index of the item.</param>
        /// <returns>An ODF list</returns>
        protected AODL.Document.Content.Text.List GetODFSublist(ListItem firstItem, IDocument document, AODL.Document.Content.Text.List parentList, ref int currentIndex)
        {
            //Create a list
            AODL.Document.Content.Text.List list = new AODL.Document.Content.Text.List(document, parentList);

            //Set the level of the list
            int currentLevel = firstItem.Level;

            //Create a new list item
            AODL.Document.Content.Text.ListItem listItem = null;
            //Loop through the items
            while (currentIndex < Items.Count)
            {
                if (Items[currentIndex].Level > currentLevel)
                {
                    //Start a new list and append items.
                    listItem.Content.Add(GetODFSublist(Items[currentIndex], document, list, ref currentIndex));
                    continue;
                }
                if (Items[currentIndex].Level < currentLevel)
                {
                    //Stop this list.
                    break;
                }
                if (Items[currentIndex].Level == currentLevel)
                {
                    //Create a new list item
                    listItem = new AODL.Document.Content.Text.ListItem(document);
                    //Create a paragraph
                    var paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                    //Add the text
                    foreach (var formatedText in CommonDocumentFunctions.ParseParagraphForODF(document, Items[currentIndex].Text))
                    {
                        paragraph.TextContent.Add(formatedText);
                    }

                    //Add paragraph to the list item
                    listItem.Content.Add(paragraph);

                    //Add the list item
                    list.Content.Add(listItem);

                    currentIndex++;
                }
            }

            return(list);
        }
示例#3
0
 /// <summary>
 /// Creates a ODF table row.
 /// </summary>
 /// <param name="row">The row in the ODF document.</param>
 /// <returns>The filled ODF row.</returns>
 internal AODL.Document.Content.Tables.Row GetODF(AODL.Document.Content.Tables.Row row)
 {
     foreach (string s in _values)
     {
         //Create a standard paragraph
         var paragraph = ParagraphBuilder.CreateStandardTextParagraph(row.Document);
         //Add the text
         foreach (var formatedText in CommonDocumentFunctions.ParseParagraphForODF(row.Document, s))
         {
             paragraph.TextContent.Add(formatedText);
         }
         //Add the content to the cell
         //row.Cells[_values.IndexOf(s)].Content.Add(paragraph);
     }
     return(row);
 }
示例#4
0
        /// <summary>
        /// Gets a list in ODF format.
        /// </summary>
        /// <param name="document">The document to which the list belongs.</param>
        /// <returns>The list as an IContent document</returns>
        public override IContent GetODFList(IDocument document)
        {
            //Create a list
            AODL.Document.Content.Text.List list = new AODL.Document.Content.Text.List(document, "NL1", ListStyles.Number, "NL1P1");

            //Set the list level to 0 as this is the top of the list
            int currentLevel = 0;

            //Create a new list item
            AODL.Document.Content.Text.ListItem listItem = null;
            //Loop through the items
            for (int currentIndex = 0; currentIndex < Items.Count; currentIndex++)
            {
                if (Items[currentIndex].Level > currentLevel)
                {
                    //Start a new list and append items.
                    if (listItem == null)
                    {
                        listItem = new AODL.Document.Content.Text.ListItem(document);
                    }
                    listItem.Content.Add(GetODFSublist(Items[currentIndex], document, list, ref currentIndex));
                    currentIndex--;
                    //Skip the rest of the routine
                    continue;
                }
                if (Items[currentIndex].Level == currentLevel)
                {
                    //Create a new list item
                    listItem = new AODL.Document.Content.Text.ListItem(document);
                    //Create a paragraph
                    var paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
                    //Add the text
                    foreach (var formatedText in CommonDocumentFunctions.ParseParagraphForODF(document, Items[currentIndex].Text))
                    {
                        paragraph.TextContent.Add(formatedText);
                    }

                    //Add paragraph to the list item
                    listItem.Content.Add(paragraph);

                    //Add the list item
                    list.Content.Add(listItem);
                }
            }

            return(list);
        }
示例#5
0
        /// <summary>
        /// Gets a paragraph in ODF format.
        /// </summary>
        /// <param name="doc">The ODF Textdocument that is being created</param>
        /// <returns>List of paragraphs in ODF format.</returns>
        public override List <IContent> GetODFParagraph(AODL.Document.TextDocuments.TextDocument doc)
        {
            //Get the headings enum
            Headings headingEnum   = Headings.Heading;
            string   headingString = string.Format("Heading{0}{1}", _paragraphLevel > 0 ? "_20" : string.Empty, _paragraphLevel > 0 ? "_" + (_paragraphLevel).ToString() : string.Empty);

            if (Enum.IsDefined(typeof(Headings), headingString))
            {
                headingEnum = (Headings)Enum.Parse(typeof(Headings), headingString);
            }

            //Create the header
            AODL.Document.Content.Text.Header header = new AODL.Document.Content.Text.Header(doc, headingEnum);
            //Add the formated text
            foreach (var formatedText in CommonDocumentFunctions.ParseParagraphForODF(doc, _text))
            {
                header.TextContent.Add(formatedText);
            }
            //Add the header properties
            return(new List <IContent>()
            {
                header
            });
        }