public void ExportUSFM_ParatextVernacular() { string fileName = Path.Combine(Path.GetTempPath(), "~usfmfile~.txt"); FilteredScrBooks filter = FilteredScrBooks.GetFilterInstance(Cache, 1); while (filter.BookCount > 0) filter.Remove(0); // add the book of James to the book filter filter.Add(Cache.LangProject.TranslatedScriptureOA.ScriptureBooksOS[1]); // perform Paratext vernacular export try { ExportUsfm export = new ExportUsfm(Cache, filter, fileName); export.MarkupSystem = MarkupType.Paratext; export.Run(); VerifyFile("SIL.FieldWorks.AcceptanceTests.TE.ExportJasParatext.ptx", fileName); } finally { try { File.Delete(fileName); } catch {} } }
protected bool OnFileExportUsfmParatext(object args) { AdjustScriptureAnnotations(); ScrText assocProj = ParatextHelper.GetAssociatedProject(Cache.ProjectId); if (assocProj != null) { MessageBox.Show(this, String.Format(TeResourceHelper.GetResourceString("kstidParatextExportNotAvailable"), assocProj.JoinedNameAndFullName), FwUtils.ksTeAppName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return true; } using (ExportPtxDialog dlg = new ExportPtxDialog(m_cache, m_bookFilter, m_app.ProjectSpecificSettingsKey, m_app, m_app)) { if (dlg.ShowDialog() == DialogResult.OK) { using (ExportUsfm exporter = new ExportUsfm(m_cache, m_bookFilter, dlg.OutputSpec, m_app, dlg.FileNameFormat)) { exporter.OverwriteWithoutAsking = dlg.OverwriteConfirmed; exporter.MarkupSystem = MarkupType.Paratext; exporter.ExportScriptureDomain = dlg.ExportScriptureDomain; exporter.ExportBackTranslationDomain = dlg.ExportBackTranslationDomain; if (exporter.ExportBackTranslationDomain) exporter.RequestedAnalysisWss = dlg.RequestedAnalWs; exporter.ExportNotesDomain = dlg.ExportNotesDomain; exporter.ParatextProjectShortName = dlg.ShortName; exporter.ParatextProjectFolder = dlg.ParatextProjectFolder; exporter.Run(this); } } } return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handle the File/Export/Usfm Toolbox menu command /// </summary> /// <param name="args"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ protected bool OnFileExportUsfmToolbox(object args) { AdjustScriptureAnnotations(); using (ExportTbxDialog dlg = new ExportTbxDialog(m_cache, m_bookFilter, SettingsKeyEx)) { if (dlg.ShowDialog() == DialogResult.OK) { ExportUsfm exporter = null; try { if (!dlg.ExportSplitByBook) { exporter = new ExportUsfm(m_cache, m_bookFilter, dlg.OutputSpec); } else { exporter = new ExportUsfm(m_cache, m_bookFilter, dlg.OutputSpec, dlg.FileNameFormat); } exporter.MarkupSystem = MarkupType.Toolbox; exporter.ExportScriptureDomain = dlg.ExportScriptureDomain; exporter.ExportBackTranslationDomain = dlg.ExportBackTranslationDomain; exporter.ExportNotesDomain = dlg.ExportNotesDomain; exporter.RequestedAnalysisWss = dlg.RequestedAnalWs; Application.DoEvents(); exporter.Run(); } finally { if (exporter != null) { exporter.Dispose(); exporter = null; } } } } return true; }
public void ExportToMultipleFiles() { CheckDisposed(); string tempPath = Path.GetTempPath(); FilteredScrBooks filter = new FilteredScrBooks(m_fdoCache, 123); filter.ShowAllBooks(); try { using (ExportUsfm exporter = new ExportUsfm(m_fdoCache, filter, tempPath, new FileNameFormat(string.Empty, FileNameFormat.SchemeFormat.NNBBB, "dummy", "sfm"))) { exporter.RequestedAnalysisWss = new int[] { m_fdoCache.DefaultAnalWs }; exporter.MarkupSystem = MarkupType.Toolbox; // Toolbox has a different numbering scheme than ParaText. exporter.Run(); } Assert.IsTrue(File.Exists(Path.Combine(tempPath, "57PHMdummy.sfm"))); Assert.IsTrue(File.Exists(Path.Combine(tempPath, "59JASdummy.sfm"))); Assert.IsTrue(File.Exists(Path.Combine(tempPath, "65JUDdummy.sfm"))); } finally { DeleteFile(Path.Combine(tempPath, "57PHMdummy.sfm")); DeleteFile(Path.Combine(tempPath, "59JASdummy.sfm")); DeleteFile(Path.Combine(tempPath, "65JUDdummy.sfm")); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handle the File/Export/Usfm Paratext menu command /// </summary> /// <param name="args"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ protected bool OnFileExportUsfmParatext(object args) { AdjustScriptureAnnotations(); using (ExportPtxDialog dlg = new ExportPtxDialog(m_cache, m_bookFilter, SettingsKeyEx)) { if (dlg.ShowDialog() == DialogResult.OK) { using (ExportUsfm exporter = new ExportUsfm(m_cache, m_bookFilter, dlg.OutputSpec, dlg.FileNameFormat)) { exporter.OverwriteWithoutAsking = dlg.OverwriteConfirmed; exporter.MarkupSystem = MarkupType.Paratext; exporter.ExportScriptureDomain = dlg.ExportScriptureDomain; exporter.ExportBackTranslationDomain = dlg.ExportBackTranslationDomain; if (exporter.ExportBackTranslationDomain) exporter.RequestedAnalysisWss = dlg.RequestedAnalWs; exporter.ExportNotesDomain = dlg.ExportNotesDomain; exporter.ParatextProjectShortName = dlg.ShortName; exporter.ParatextProjectFolder = dlg.ParatextProjectFolder; exporter.Run(); } } } return true; }