//Export a summary Presentation with all the pages present in a category //The summar is composed by an index (optional) and a slide for each page //the slide content will be detemined by the expDetail delegate public void ExportSummary(string expCat, string outFileName, string expIdxName, int expPaging, ExportProc expDetail, WikiMedia.ExportNotify expNotify) { Presentation pres = new Presentation(fTemplatePath); PageList pl = wiki.GetPages(expCat); if (expIdxName != null) { Index2Slide(pres, pl, expIdxName, expPaging); } foreach (Page page in pl) { string title = GetTitle(page); if (title == null) { continue; } if (expNotify != null) { expNotify(page.title); } page.LoadHTML(); Document doc = HTML2Model.Convert(page.text); expDetail(pres, doc, title); } pres.Save(fBasePath + outFileName); pres.Close(); }
//Export all the pages in a Wiki category into a index presentation, each page //will contain up to expPagining summaries. A summary will be composed up to //descSize characters taken from the first Header of the Page public void ExportIndex(string expCat, string outFileName, int expPaging, int descSize, WikiMedia.ExportNotify expNotify) { Microsoft.Office.Interop.PowerPoint.Slide slide = null; Microsoft.Office.Interop.PowerPoint.TextRange textRange = null; Presentation pres = new Presentation(fTemplatePath); PageList pl = wiki.GetPages(expCat); int cnt = 0; foreach (Page page in pl) { string title = GetTitle(page); if (title == null) { continue; } cnt++; if ((cnt % expPaging) == 1) { slide = pres.Add(Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText, GetTitleName(expCat)); textRange = slide.Shapes[2].TextFrame.TextRange; } if (expNotify != null) { expNotify(page.title); } page.LoadHTML(); Document doc = HTML2Model.Convert(page.text); AddFirstHeader(textRange, doc, page, title, descSize); } pres.Save(fBasePath + outFileName); pres.Close(); }
//Export a set of Wiki pages into several Power Point slides (saved into export directory) public void ExportPages(string[] pages, string expDir, WikiMedia.ExportNotify expNotify) { Page page; Document doc; Presentation pres; string outPath = BuildPath(expDir); foreach (string title in pages) { if (String.IsNullOrEmpty(title)) { continue; } if (expNotify != null) { expNotify(title); } page = wiki.GetPage(title); page.LoadHTML(); if (!String.IsNullOrEmpty(page.text)) { doc = HTML2Model.Convert(page.text); pres = new Presentation(fTemplatePath); Page2Slide(pres, doc, title, true); StringBuilder fileName = new StringBuilder(title.Length); for (int i = 0; i < title.Length; i++) { char c = title[i]; if ("\\:/".IndexOf(c) == -1) { fileName.Append(c); } } pres.Save(outPath + fileName.ToString() + ".ppt"); pres.Close(); } } }