private void SaveInODF() { using (AODL.Document.TextDocuments.TextDocument doc = new AODL.Document.TextDocuments.TextDocument()) { if (_isNew) { doc.New(); } else { doc.Load(Filename); } try { int imageCount = 1; //This is a counter for setting the image number. foreach (KeyValuePair <int, Paragraph> paragraph in Paragraphs) { //If this is an image we also need to pass the MainpArt as this is needed to generate the image part Picture img = paragraph.Value as Picture; Table table = paragraph.Value as Table; List list = paragraph.Value as List; if (img != null) { foreach (var p in img.GetODFParagraph(doc, paragraph.Key, ref imageCount)) { doc.Content.Add(p); } } else if (table != null) { //Add table to the document doc.Content.Add(table.GetODFTable(doc)); } else if (list != null) { //Add the list. doc.Content.Add(list.GetODFList(doc)); } else { //Add the text paragraph(s) foreach (var p in paragraph.Value.GetODFParagraph(doc)) { doc.Content.Add(p); } } } /* Save the results and close */ doc.SaveTo(Filename); } catch (Exception ex) { throw new FileLoadException("An error occured when saving the document: " + ex.Message, Filename, ex); } } }
public AODL.Document.TextDocuments.TextDocument Convert(FlowDocument flowdoc) { AODL.Document.TextDocuments.TextDocument textdoc = new AODL.Document.TextDocuments.TextDocument(); textdoc.New(); foreach (Paragraph p in flowdoc.Blocks) { AODL.Document.Content.Text.Paragraph par = new AODL.Document.Content.Text.Paragraph(textdoc); TextRange t = new TextRange(p.ElementStart, p.ElementEnd); par.TextContent.Add(new AODL.Document.Content.Text.SimpleText(textdoc, t.Text)); } return(textdoc); }