public GraphWindow(Book book)
     : this()
 {
     var graphBuilder = new GraphBuilder();
     this.Graph = graphBuilder.CreateGraph(book.Chapters);
     this.DataContext = this;
 }
Beispiel #2
0
        /// <summary>
        /// parses a given Flat ODT file
        /// </summary>
        /// <param name="filename">the path to the FODT file</param>
        /// <returns>a book object containing the FODT's information</returns>
        public Book Parse(string filename)
        {
            XElement document = this.loadXML(filename);

            var styles = this.getStyles(document);

            var paragraphs = this.getParagraphs(document);

            var book = new Book();

            Chapter lastChapter = new Chapter() { Title = "DUMMY" };
            Chapter currentChapter = new Chapter() { Title = "DUMMY" };
            foreach (var paragraph in paragraphs)
            {
                paragraph.Style = this.getStyle(styles, paragraph);
                var styleType = paragraph.Style.StyleType;

                if (styleType == StyleType.Title)
                {
                    lastChapter = currentChapter;

                    currentChapter = new Chapter();
                    book.Chapters.Add(currentChapter);

                    currentChapter.PrecedingChapter = lastChapter;
                    lastChapter.SucceedingChapter = currentChapter;

                    currentChapter.Title = paragraph.Content;
                    currentChapter.RevisionStatus = this.getRevisionStatus(paragraph.Style);
                }
                else if (styleType == StyleType.Successor)
                {
                    currentChapter.SucceedingChapterReferences.Add(paragraph.Content);
                }
                else if (styleType == StyleType.Precessor)
                {
                    currentChapter.PrecedingChapterReferences.Add(paragraph.Content);
                }
                else if (styleType == StyleType.Summary)
                {
                    currentChapter.Summary.Add(paragraph.Content);
                }
                else if (styleType == StyleType.Comment)
                {
                    currentChapter.Comment.Add(paragraph.Content);
                }
                else if (styleType == StyleType.Content)
                {
                    currentChapter.Text.Add(paragraph.Content);
                }
                else
                {

                }
            }

            this.checkChaptersErrors(book.Chapters);

            return book;
        }