/// ------------------------------------------------------------------------------------ /// <summary> /// Handle the File/Export/Xhtml menu command /// </summary> /// <param name="args"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ protected bool OnFileExportXhtml(object args) { using (ExportXmlDialog dlg = new ExportXmlDialog(m_cache, m_bookFilter, GetReferenceToCurrentBook().Book, m_StyleSheet, FileType.XHTML, m_app)) { if (dlg.ShowDialog() == DialogResult.OK) { // TODO/REVIEW: get the stylesheet overridden for printing. ExportXhtml export = new ExportXhtml(dlg.FileName, m_cache, m_bookFilter, dlg.ExportWhat, dlg.BookNumber, dlg.FirstSection, dlg.LastSection, dlg.Description, m_StyleSheet, CurrentPublication, m_app); export.Run(this); } } return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handle the File/Export/Open Office menu command /// </summary> /// ------------------------------------------------------------------------------------ protected bool OnFileExportPs(object args) { try { if (!PathwayUtils.IsPathwayForScrInstalled) { MessageBox.Show(this, ResourceHelper.GetResourceString("kstidInvalidPathwayInstallation"), m_app.ApplicationName, MessageBoxButtons.OK); return false; } // Show the Pathway dialog. string pathwayDir = PathwayUtils.PathwayInstallDirectory; string cssDllPath = Path.Combine(pathwayDir, "CssDialog.dll"); var dlg = ReflectionHelper.CreateObject(cssDllPath, "SIL.PublishingSolution.ScriptureContents", null); Debug.Assert(dlg != null, "missing CssDialog.dll from Pathway install"); ReflectionHelper.SetProperty(dlg, "DatabaseName", m_cache.ProjectId.Name); ReflectionHelper.SetProperty(dlg, "PublicationName", CurrentPublication.Name); DialogResult result = (DialogResult) ReflectionHelper.GetResult(dlg, "ShowDialog"); if (result != DialogResult.Cancel) { // Get the output location for the XHTML file. string outputLocationPath = (string) ReflectionHelper.GetProperty(dlg, "OutputLocationPath"); string fileName = Path.Combine(outputLocationPath, CurrentPublication.Name + ".xhtml"); if (result == DialogResult.Yes) { ExportXhtml export = new ExportXhtml(fileName, m_cache, m_bookFilter, ExportWhat.FilteredBooks, 1, 1, 1, "Pathway TranslationEditor Export", m_StyleSheet, CurrentPublication, m_app); export.Run(this); } else { string existingLocationPath = (string) ReflectionHelper.GetField(dlg, "ExistingLocationPath"); File.Copy(existingLocationPath, fileName); } // Export the XHTML file to the specified format. var exporter = ReflectionHelper.CreateObject(Path.Combine(pathwayDir, "PsExport.dll"), "SIL.PublishingSolution.PsExport", null); Debug.Assert(exporter != null); ReflectionHelper.SetProperty(exporter, "DataType", "Scripture"); ReflectionHelper.CallMethod(exporter, "Export", fileName); } } catch { MessageBox.Show(this, ResourceHelper.GetResourceString("kstidInvalidPathwayInstallation"), m_app.ApplicationName, MessageBoxButtons.OK); return false; } return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handle the File/Export/Open Office menu command /// </summary> /// <param name="args"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ protected bool OnFileExportPs(object args) { IScriptureContents dlg = DynamicLoader.CreateObject("CssDialog.dll", "SIL.PublishingSolution.ScriptureContents") as IScriptureContents; Debug.Assert(dlg != null, "missing CssDialog.dll from Pathway install"); dlg.DatabaseName = m_cache.DatabaseName; dlg.PublicationName = CurrentPublication.Name; System.Windows.Forms.DialogResult result = dlg.ShowDialog(); if (result != DialogResult.Cancel) { string fileName = Path.Combine(dlg.OutputLocationPath, dlg.PublicationName + ".xhtml"); if (result == DialogResult.Yes) { ExportXhtml export = new ExportXhtml(fileName, m_cache, m_bookFilter, ExportWhat.FilteredBooks, 1, 1, 1, "Pathway TranslationEditor Export", m_StyleSheet, CurrentPublication); export.Run(); } else File.Copy(dlg.ExistingLocationPath, fileName); object assembly = DynamicLoader.CreateObject("PsExport.dll", "SIL.PublishingSolution.PsExport"); IExporter exporter = assembly as IExporter; Debug.Assert(exporter != null); exporter.DataType = "Scripture"; exporter.Export(fileName); } return true; }