protected object ExportTranslatedLists(IThreadedProgress progressDlg, object[] parameters) { string outPath = (string)parameters[0]; m_progressDlg = progressDlg; if (m_translatedLists.Count == 0 || m_translationWritingSystems.Count == 0) return null; TranslatedListsExporter exporter = new TranslatedListsExporter(m_translatedLists, m_translationWritingSystems, progressDlg); exporter.ExportLists(outPath); return null; }
/// <summary> /// Do the export of the semantic domains list to an HTML document (which is given extension .doc /// since it is mainly intended to be opened as a Word document, since Word understands the /// 'page break before' concept). /// The signature of this method is required by the way it is used as the task of the ProgressDialog. /// See the first few lines for the required parameters. /// </summary> /// <param name="progressDlg"></param> /// <param name="parameters"></param> /// <returns></returns> internal object ExportSemanticDomains(IThreadedProgress progressDlg, object[] parameters) { string outPath = (string) parameters[0]; var ft = (FxtType) parameters[1]; var fxtPath = (string) parameters[2]; bool allQuestions = (bool) parameters[3]; m_progressDlg = progressDlg; var lists = new List<ICmPossibilityList>(); lists.Add(m_cache.LangProject.SemanticDomainListOA); var exporter = new TranslatedListsExporter(lists, m_translationWritingSystems, progressDlg); exporter.ExportLists(outPath); FxtType ft1 = ft; #if DEBUG string dirPath = Path.GetTempPath(); #endif string xslt = ft1.m_sXsltFiles; progressDlg.Position = 0; progressDlg.Minimum = 0; progressDlg.Maximum = 1; progressDlg.Message = xWorksStrings.ProcessingIntoFinalForm; int idx = fxtPath.LastIndexOfAny(new[] {'/', '\\'}); if (idx < 0) idx = 0; else ++idx; string basePath = fxtPath.Substring(0, idx); string sXsltPath = basePath + xslt; string sIntermediateFile = ConfiguredExport.RenameOutputToPassN(outPath, 0); // The semantic domain xslt uses document('folderStart.xml') to retrieve the list of H1 topics. // This is not allowed by default so we must use a settings object to enable it. var settings = new XsltSettings(enableDocumentFunction: true, enableScript: false); XslCompiledTransform xsl = new XslCompiledTransform(); xsl.Load(sXsltPath, settings, new XmlUrlResolver()); var arguments = new XsltArgumentList(); // If we aren't outputting english we need to ignore it (except possibly for missing items) bool ignoreEn = m_translationWritingSystems[0] != m_cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr("en"); arguments.AddParam(@"ignoreLang", @"", (ignoreEn ? @"en" : @"")); arguments.AddParam(@"allQuestions", @"", (allQuestions ? @"1" : @"0")); using (var writer = FileUtils.OpenFileForWrite(outPath, Encoding.UTF8)) xsl.Transform(sIntermediateFile, arguments, writer); // Deleting them deals with LT-6345, // which asked that they be put in the temp folder. // But moving them to the temp directory is better for debugging errors. FileUtils.MoveFileToTempDirectory(sIntermediateFile, "FieldWorks-Export"); progressDlg.Step(0); #if DEBUG string s = string.Format("Totally Finished Export Semantic domains at {0}", DateTime.Now.ToLongTimeString()); Debug.WriteLine(s); #endif return null; // method signature is required by ProgressDialog }