Exemplo n.º 1
0
 void parser_SetTotalNumberSteps(object sender, LiftIO.Parsing.LiftParser <LiftObject, LiftEntry, LiftSense, LiftExample> .StepsArgs e)
 {
     if (m_progressDlg != null)
     {
         m_progressDlg.SetRange(0, e.Steps);
     }
 }
Exemplo n.º 2
0
        private void OnDumperSetProgressMessage(object sender, XDumper.MessageArgs e)
        {
            Debug.Assert(m_progressDlg != null);
            string sMsg = xWorksStrings.ResourceManager.GetString(e.MessageId, xWorksStrings.Culture);

            if (!String.IsNullOrEmpty(sMsg))
            {
                m_progressDlg.Message = sMsg;
            }
            m_progressDlg.Position = 0;
            m_progressDlg.SetRange(0, e.Max);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Do the modifications/merging/whatever to the LIFT file given by the first (and only)
        /// parameter.
        /// </summary>
        /// <returns>the name of the modified file (may be the same as the input), or null if an error occurs.</returns>
        protected object ChorusMerge(IAdvInd4 progressDialog, params object[] parameters)
        {
            // TODO: implement this!
            if (m_progressDlg == null)
            {
                m_progressDlg = progressDialog;
            }
            progressDialog.Message = "Merging via Chorus";
            progressDialog.SetRange(0, 100);
            progressDialog.Position = 0;
            string outPath = parameters[0].ToString();

            progressDialog.Position = 100;
            return(outPath);
        }
Exemplo n.º 4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// If <paramref name="progressDlg"/> is not <c>null</c> we run the background task
 /// with that progress dialog (without creating a separate thread). Otherwise we display
 /// a new progress dialog as a modal dialog and start the background task in a separate
 /// thread.
 /// </summary>
 /// <param name="progressDlg">The existing progress dialog, or <c>null</c>.</param>
 /// <param name="fDisplayUi">set to <c>true</c> to display the progress dialog,
 /// <c>false</c> to run without UI.</param>
 /// <param name="backgroundTask">The background task.</param>
 /// <param name="parameters">The paramters that will be passed to the background task</param>
 /// <returns>The return value from the background thread.</returns>
 /// ------------------------------------------------------------------------------------
 public object RunTask(IAdvInd4 progressDlg, bool fDisplayUi,
                       BackgroundTaskInvoker backgroundTask, params object[] parameters)
 {
     if (progressDlg != null)
     {
         int nMin;
         int nMax = 0;
         progressDlg.GetRange(out nMin, out nMax);
         progressDlg.Position = nMin;
         object ret = backgroundTask(progressDlg, parameters);
         progressDlg.SetRange(nMin, nMax);
         progressDlg.Position = nMax;
         return(ret);
     }
     return(RunTask(fDisplayUi, backgroundTask, parameters));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Export the contents of the lexicon to the given file (first and only parameter).
 /// </summary>
 /// <returns>the name of the exported LIFT file if successful, or null if an error occurs.</returns>
 protected object ExportLexicon(IAdvInd4 progressDialog, params object[] parameters)
 {
     try
     {
         if (m_progressDlg == null)
         {
             m_progressDlg = progressDialog;
         }
         string outPath = (string)parameters[0];
         progressDialog.Message = String.Format(FlexChorusStrings.ksExportingEntries,
                                                m_cache.LangProject.LexDbOA.EntriesOC.Count);
         using (XDumper dumper = new XDumper(m_cache))
         {
             dumper.UpdateProgress     += new XDumper.ProgressHandler(OnDumperUpdateProgress);
             dumper.SetProgressMessage += new EventHandler <XDumper.MessageArgs>(OnDumperSetProgressMessage);
             // Don't bother writing out the range information in the export.
             dumper.SetTestVariable("SkipRanges", true);
             dumper.SkipAuxFileOutput = true;
             progressDialog.SetRange(0, dumper.GetProgressMaximum());
             progressDialog.Position = 0;
             // TODO: get better output/input filename?
             string p       = Path.Combine(DirectoryFinder.FWCodeDirectory, @"Language Explorer\Export Templates");
             string fxtPath = Path.Combine(p, "LIFT.fxt.xml");
             using (TextWriter w = new StreamWriter(outPath))
             {
                 dumper.ExportPicturesAndMedia = true;                           // useless without Pictures directory...
                 dumper.Go(m_cache.LangProject as CmObject, fxtPath, w);
             }
             // TODO: validate output?
             return(outPath);
         }
     }
     catch
     {
         return(null);
     }
 }
Exemplo n.º 6
0
		/// <summary>
		/// Import the modified LIFT file given by the first (and only) parameter.
		/// </summary>
		/// <returns>the name of the log file for the import, or null if a major error occurs.</returns>
		protected object ImportLexicon(IAdvInd4 progressDialog, params object[] parameters)
		{
			if (m_progressDlg == null)
				m_progressDlg = progressDialog;
			progressDialog.SetRange(0, 100);
			progressDialog.Position = 0;
			string inPath = parameters[0].ToString();
			string sLogFile = null;
			PropChangedHandling oldPropChg = m_cache.PropChangedHandling;
			try
			{
				m_cache.PropChangedHandling = PropChangedHandling.SuppressAll;
				string sFilename;
				bool fMigrationNeeded = LiftIO.Migration.Migrator.IsMigrationNeeded(inPath);
				if (fMigrationNeeded)
				{
					string sOldVersion = LiftIO.Validation.Validator.GetLiftVersion(inPath);
					progressDialog.Message = String.Format("Migrating from LIFT version {0} to version {1}",
						sOldVersion, LiftIO.Validation.Validator.LiftVersion);
					sFilename = LiftIO.Migration.Migrator.MigrateToLatestVersion(inPath);
				}
				else
				{
					sFilename = inPath;
				}
				// TODO: validate input file?
				progressDialog.Message = "Loading various lists for lookup during import";
				FlexLiftMerger flexImporter = new FlexLiftMerger(m_cache, FlexLiftMerger.MergeStyle.msKeepOnlyNew, true);
				LiftIO.Parsing.LiftParser<LiftObject, LiftEntry, LiftSense, LiftExample> parser =
					new LiftIO.Parsing.LiftParser<LiftObject, LiftEntry, LiftSense, LiftExample>(flexImporter);
				parser.SetTotalNumberSteps += new EventHandler<LiftIO.Parsing.LiftParser<LiftObject, LiftEntry, LiftSense, LiftExample>.StepsArgs>(parser_SetTotalNumberSteps);
				parser.SetStepsCompleted += new EventHandler<LiftIO.Parsing.LiftParser<LiftObject,LiftEntry,LiftSense,LiftExample>.ProgressEventArgs>(parser_SetStepsCompleted);
				parser.SetProgressMessage += new EventHandler<LiftIO.Parsing.LiftParser<LiftObject, LiftEntry, LiftSense, LiftExample>.MessageArgs>(parser_SetProgressMessage);
				flexImporter.LiftFile = inPath;

				int cEntries = parser.ReadLiftFile(sFilename);

				if (fMigrationNeeded)
				{
					// Try to move the migrated file to the temp directory, even if a copy of it
					// already exists there.
					string sTempMigrated = Path.Combine(Path.GetTempPath(),
						Path.ChangeExtension(Path.GetFileName(sFilename), "." + LiftIO.Validation.Validator.LiftVersion + ".lift"));
					if (File.Exists(sTempMigrated))
						File.Delete(sTempMigrated);
					File.Move(sFilename, sTempMigrated);
				}
				progressDialog.Message = "Fixing relation links between imported entries";
				flexImporter.ProcessPendingRelations();
				sLogFile = flexImporter.DisplayNewListItems(inPath, cEntries);
			}
			catch (Exception error)
			{
				string sMsg = String.Format("Something went wrong trying to import {0} while merging...",
					inPath, error.Message);
				try
				{
					StringBuilder bldr = new StringBuilder();
					// leave in English for programmer's sake...
					bldr.AppendFormat("Something went wrong while FieldWorks was attempting to import {0}.",
						inPath);
					bldr.AppendLine();
					bldr.AppendLine(error.Message);
					bldr.AppendLine();
					bldr.AppendLine(error.StackTrace);
					if (System.Threading.Thread.CurrentThread.GetApartmentState() == System.Threading.ApartmentState.STA)
						Clipboard.SetDataObject(bldr.ToString(), true);
				}
				catch
				{
				}
				MessageBox.Show(sMsg, "Problem Merging",
					MessageBoxButtons.OK, MessageBoxIcon.Warning);
			}
			finally
			{
				m_cache.PropChangedHandling = oldPropChg;
			}
			return sLogFile;
		}
Exemplo n.º 7
0
		/// <summary>
		/// Do the modifications/merging/whatever to the LIFT file given by the first (and only)
		/// parameter.
		/// </summary>
		/// <returns>the name of the modified file (may be the same as the input), or null if an error occurs.</returns>
		protected object ChorusMerge(IAdvInd4 progressDialog, params object[] parameters)
		{
			// TODO: implement this!
			if (m_progressDlg == null)
				m_progressDlg = progressDialog;
			progressDialog.Message = "Merging via Chorus";
			progressDialog.SetRange(0, 100);
			progressDialog.Position = 0;
			string outPath = parameters[0].ToString();
			progressDialog.Position = 100;
			return outPath;
		}
Exemplo n.º 8
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Create all of the ScrBookRef objects for each book of Scripture
		/// </summary>
		/// <param name="progressDlg">Progress dialog so the user can cancel</param>
		/// -------------------------------------------------------------------------------------
		protected void CreateScrBookRefs(IAdvInd4 progressDlg)
		{
			IScrRefSystem scr = m_cache.ScriptureReferenceSystem;

			// If there are books existing, then delete them first.
			for (int i = scr.BooksOS.Count - 1; i >= 0; i--)
				scr.BooksOS.RemoveAt(i);

			XmlDocument doc = new XmlDocument();
			doc.Load(DirectoryFinder.FWCodeDirectory + @"\Translation Editor\ScrBookRef.xml");
			ILgWritingSystemFactory wsf = m_cache.LanguageWritingSystemFactoryAccessor;

			//Select and display the value of all the ISBN attributes.
			XmlNodeList tagList = doc.SelectNodes("/ScrBookRef/writingsystem");
			progressDlg.SetRange(0, tagList.Count * ScrReference.LastBook);
			progressDlg.Position = 0;
			progressDlg.Title = TeResourceHelper.GetResourceString("kstidCreatingBookNames");

			foreach (XmlNode writingSystem in tagList)
			{
				XmlAttributeCollection attributes = writingSystem.Attributes;
				string sLocale = attributes.GetNamedItem("iculocale").Value;
				int ws = m_cache.LanguageEncodings.GetWsFromIcuLocale(sLocale);
				if (ws == 0)
				{
					// It is possible that the XML file contains more languages than the
					// database. If so, just ignore this writing system.
					continue;
				}

				short iBook = 0;
				XmlNodeList WSBooks = writingSystem.SelectNodes("book");
				foreach (XmlNode book in WSBooks)
				{
					XmlAttributeCollection bookAttributes = book.Attributes;
					string sSilBookId = bookAttributes.GetNamedItem("SILBookId").Value;
					Debug.Assert(sSilBookId != null);
					// Make sure books are coming in canonical order.
					Debug.Assert(ScrReference.BookToNumber(sSilBookId) == iBook + 1);

					string sName = bookAttributes.GetNamedItem("Name").Value;
					string sAbbrev = bookAttributes.GetNamedItem("Abbreviation").Value;
					string sAltName = bookAttributes.GetNamedItem("AlternateName").Value;
					progressDlg.Message = string.Format(
						TeResourceHelper.GetResourceString("kstidCreatingBookNamesStatusMsg"), sName);
					progressDlg.Step(0);

					// check for the book id
					ScrBookRef bookRef = null;
					if (scr.BooksOS.Count > iBook)
					{
						bookRef = (ScrBookRef)scr.BooksOS[iBook];
						Debug.Assert(bookRef != null);
					}
					else
					{
						// add this book to the list
						bookRef = new ScrBookRef();
						scr.BooksOS.Append(bookRef);
					}
					if (sName != null)
						bookRef.BookName.SetAlternative(sName, ws);
					if (sAbbrev != null)
						bookRef.BookAbbrev.SetAlternative(sAbbrev, ws);
					if (sAltName != null)
						bookRef.BookNameAlt.SetAlternative(sAltName, ws);
					iBook++;
				}
			}
		}
Exemplo n.º 9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Exports the configured doc view.
        /// </summary>
        /// <param name="progressDlg">The progress dialog.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>Always null.</returns>
        /// ------------------------------------------------------------------------------------
        private object ExportConfiguredDocView(IAdvInd4 progressDlg, params object[] parameters)
        {
            Debug.Assert(parameters.Length == 3);
            m_progressDlg = progressDlg;
            if (m_xvc == null)
            {
                return(null);
            }

            string  outPath = (string)parameters[0];
            string  fxtPath = (string)parameters[1];
            FxtType ft      = (FxtType)parameters[2];

            try
            {
                m_cache.EnableBulkLoadingIfPossible(true);

                using (TextWriter w = new StreamWriter(outPath))
                {
                    FileInfo outFile = new FileInfo(outPath);
#if DEBUG
                    string dirPath   = Path.GetTempPath();
                    int    copyCount = 1;
                    string s         = string.Format("Starting Configured Export at {0}",
                                                     System.DateTime.Now.ToLongTimeString());
                    Debug.WriteLine(s);
#endif
                    m_ce = new ConfiguredExport(null, m_cache.MainCacheAccessor, m_hvoRootObj);
                    m_ce.Initialize(m_cache, w, ft.m_sDataType, ft.m_sFormat, outPath);
                    m_ce.UpdateProgress += new SIL.FieldWorks.Common.Controls.ConfiguredExport.ProgressHandler(ce_UpdateProgress);
                    m_xvc.Display(m_ce, m_hvoRootObj, m_seqView.RootFrag);
                    m_ce.Finish(ft.m_sDataType);
                    w.Close();
#if DEBUG
                    s = string.Format("Finished Configured Export Dump at {0}",
                                      System.DateTime.Now.ToLongTimeString());
                    Debug.WriteLine(s);
#endif
                    if (ft.m_sXsltFiles != null && ft.m_sXsltFiles.Length != 0)
                    {
                        string[] rgsXslts = ft.m_sXsltFiles.Split(new char[] { ';' });
                        int      cXslts   = rgsXslts.GetLength(0);
                        progressDlg.Position = 0;
                        progressDlg.SetRange(0, cXslts);
                        progressDlg.Message =
                            xWorksStrings.ProcessingIntoFinalForm;
                        int idx = fxtPath.LastIndexOfAny(new char[] { '/', '\\' });
                        if (idx < 0)
                        {
                            idx = 0;
                        }
                        else
                        {
                            ++idx;
                        }
                        string basePath = fxtPath.Substring(0, idx);
                        for (int ix = 0; ix <= cXslts; ++ix)
                        {
#if DEBUG
                            File.Copy(outPath, Path.Combine(dirPath, "DebugOnlyExportStage" + copyCount + ".txt"), true);
                            copyCount++;
                            if (ix < cXslts)
                            {
                                s = String.Format("Starting Configured Export XSLT file {0} at {1}",
                                                  rgsXslts[ix], System.DateTime.Now.ToLongTimeString());
                            }
                            else
                            {
                                s = String.Format("Starting final postprocess phase at {0}",
                                                  System.DateTime.Now.ToLongTimeString());
                            }
                            Debug.WriteLine(s);
#endif
                            if (ix < cXslts)
                            {
                                string sXsltPath = basePath + rgsXslts[ix];
                                m_ce.PostProcess(sXsltPath, outPath, ix + 1);
                            }
                            else
                            {
                                m_ce.PostProcess(null, outPath, ix + 1);
                            }
                            progressDlg.Step(0);
                        }
                    }

                    if (ft.m_sFormat.ToLowerInvariant() == "xhtml")
                    {
                        IVwStylesheet vss = null;
                        if (m_seqView.RootBox != null)
                        {
                            vss = m_seqView.RootBox.Stylesheet;
                        }
                        m_ce.WriteCssFile(Path.ChangeExtension(outPath, ".css"), vss);
                    }
                    m_ce = null;
#if DEBUG
                    File.Copy(outPath, Path.Combine(dirPath, "DebugOnlyExportStage" + copyCount + ".txt"), true);
                    s = string.Format("Totally Finished Configured Export at {0}",
                                      System.DateTime.Now.ToLongTimeString());
                    Debug.WriteLine(s);
#endif
                }
            }
            finally
            {
                m_cache.EnableBulkLoadingIfPossible(false);
            }
            return(null);
        }
Exemplo n.º 10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Load the Scr notes categories from the given XML document
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected virtual void CreateScrNoteCategories()
        {
            // Save the previous categories for all of the notes.
            Dictionary <int, List <string> > notesToCategories = CreateNoteToCategoryMap();

            m_scr.NoteCategoriesOA            = new CmPossibilityList();
            m_scr.NoteCategoriesOA.ItemClsid  = CmPossibility.kClassId;
            m_scr.NoteCategoriesOA.WsSelector = LangProject.kwsAnals;
            m_scr.NoteCategoriesOA.Name.SetAlternative(
                TeResourceHelper.GetResourceString("kstidScrNoteCategoriesListName"),
                m_scr.Cache.DefaultUserWs);

            XmlNodeList scrNoteCategoriesList = m_categories.SelectNodes("category");

            string message = null;

            if (m_progressDlg != null)
            {
                m_progressDlg.Title    = TeResourceHelper.GetResourceString("kstidLoadingNoteCategoriesCaption");
                m_progressDlg.Message  = string.Empty;
                m_progressDlg.Position = 0;
                m_progressDlg.SetRange(0, scrNoteCategoriesList.Count);
                message = TeResourceHelper.GetResourceString("kstidLoadNoteCategoryInDBStatus");
            }

            string localeXpath         = "name[@iculocale='" + m_userLocale + "']";
            string fallbackLocaleXpath = "name[@iculocale='" + m_fallbackUserLocale + "']";

            // Load all of the categories from the XML document
            int index = 0;

            foreach (XmlNode noteCategoryNode in scrNoteCategoriesList)
            {
                // Update dialog message.
                if (m_progressDlg != null)
                {
                    XmlNode node = noteCategoryNode.SelectSingleNode(localeXpath);
                    if (node == null)
                    {
                        node = noteCategoryNode.SelectSingleNode(fallbackLocaleXpath);
                    }

                    if (node != null)
                    {
                        m_progressDlg.Message = string.Format(message, node.InnerText);
                    }
                }

                CreateNoteCategory(m_scr.NoteCategoriesOAHvo,
                                   (int)CmPossibilityList.CmPossibilityListTags.kflidPossibilities,
                                   index++, noteCategoryNode);

                if (m_progressDlg != null)
                {
                    m_progressDlg.Step(1);
                }
            }

            m_scr.NoteCategoriesOA.ListVersion =
                new Guid(m_categories.Attributes.GetNamedItem("version").Value);

            // Attempt to map the previous categories of any notes to the new categories.
            ConnectNotesToNewCategories(notesToCategories);
        }
Exemplo n.º 11
0
        /// -------------------------------------------------------------------------------------
        /// <summary>
        /// Create all of the ScrBookRef objects for each book of Scripture
        /// </summary>
        /// <param name="progressDlg">Progress dialog so the user can cancel</param>
        /// -------------------------------------------------------------------------------------
        protected void CreateScrBookRefs(IAdvInd4 progressDlg)
        {
            IScrRefSystem scr = m_cache.ScriptureReferenceSystem;

            // If there are books existing, then delete them first.
            for (int i = scr.BooksOS.Count - 1; i >= 0; i--)
            {
                scr.BooksOS.RemoveAt(i);
            }

            XmlDocument doc = new XmlDocument();

            doc.Load(DirectoryFinder.FWCodeDirectory + @"\Translation Editor\ScrBookRef.xml");
            ILgWritingSystemFactory wsf = m_cache.LanguageWritingSystemFactoryAccessor;

            //Select and display the value of all the ISBN attributes.
            XmlNodeList tagList = doc.SelectNodes("/ScrBookRef/writingsystem");

            progressDlg.SetRange(0, tagList.Count * ScrReference.LastBook);
            progressDlg.Position = 0;
            progressDlg.Title    = TeResourceHelper.GetResourceString("kstidCreatingBookNames");

            foreach (XmlNode writingSystem in tagList)
            {
                XmlAttributeCollection attributes = writingSystem.Attributes;
                string sLocale = attributes.GetNamedItem("iculocale").Value;
                int    ws      = m_cache.LanguageEncodings.GetWsFromIcuLocale(sLocale);
                if (ws == 0)
                {
                    // It is possible that the XML file contains more languages than the
                    // database. If so, just ignore this writing system.
                    continue;
                }

                short       iBook   = 0;
                XmlNodeList WSBooks = writingSystem.SelectNodes("book");
                foreach (XmlNode book in WSBooks)
                {
                    XmlAttributeCollection bookAttributes = book.Attributes;
                    string sSilBookId = bookAttributes.GetNamedItem("SILBookId").Value;
                    Debug.Assert(sSilBookId != null);
                    // Make sure books are coming in canonical order.
                    Debug.Assert(ScrReference.BookToNumber(sSilBookId) == iBook + 1);

                    string sName    = bookAttributes.GetNamedItem("Name").Value;
                    string sAbbrev  = bookAttributes.GetNamedItem("Abbreviation").Value;
                    string sAltName = bookAttributes.GetNamedItem("AlternateName").Value;
                    progressDlg.Message = string.Format(
                        TeResourceHelper.GetResourceString("kstidCreatingBookNamesStatusMsg"), sName);
                    progressDlg.Step(0);

                    // check for the book id
                    ScrBookRef bookRef = null;
                    if (scr.BooksOS.Count > iBook)
                    {
                        bookRef = (ScrBookRef)scr.BooksOS[iBook];
                        Debug.Assert(bookRef != null);
                    }
                    else
                    {
                        // add this book to the list
                        bookRef = new ScrBookRef();
                        scr.BooksOS.Append(bookRef);
                    }
                    if (sName != null)
                    {
                        bookRef.BookName.SetAlternative(sName, ws);
                    }
                    if (sAbbrev != null)
                    {
                        bookRef.BookAbbrev.SetAlternative(sAbbrev, ws);
                    }
                    if (sAltName != null)
                    {
                        bookRef.BookNameAlt.SetAlternative(sAltName, ws);
                    }
                    iBook++;
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Import the modified LIFT file given by the first (and only) parameter.
        /// </summary>
        /// <returns>the name of the log file for the import, or null if a major error occurs.</returns>
        protected object ImportLexicon(IAdvInd4 progressDialog, params object[] parameters)
        {
            if (m_progressDlg == null)
            {
                m_progressDlg = progressDialog;
            }
            progressDialog.SetRange(0, 100);
            progressDialog.Position = 0;
            string inPath   = parameters[0].ToString();
            string sLogFile = null;
            PropChangedHandling oldPropChg = m_cache.PropChangedHandling;

            try
            {
                m_cache.PropChangedHandling = PropChangedHandling.SuppressAll;
                string sFilename;
                bool   fMigrationNeeded = LiftIO.Migration.Migrator.IsMigrationNeeded(inPath);
                if (fMigrationNeeded)
                {
                    string sOldVersion = LiftIO.Validation.Validator.GetLiftVersion(inPath);
                    progressDialog.Message = String.Format("Migrating from LIFT version {0} to version {1}",
                                                           sOldVersion, LiftIO.Validation.Validator.LiftVersion);
                    sFilename = LiftIO.Migration.Migrator.MigrateToLatestVersion(inPath);
                }
                else
                {
                    sFilename = inPath;
                }
                // TODO: validate input file?
                progressDialog.Message = "Loading various lists for lookup during import";
                FlexLiftMerger flexImporter = new FlexLiftMerger(m_cache, FlexLiftMerger.MergeStyle.msKeepOnlyNew, true);
                LiftIO.Parsing.LiftParser <LiftObject, LiftEntry, LiftSense, LiftExample> parser =
                    new LiftIO.Parsing.LiftParser <LiftObject, LiftEntry, LiftSense, LiftExample>(flexImporter);
                parser.SetTotalNumberSteps += new EventHandler <LiftIO.Parsing.LiftParser <LiftObject, LiftEntry, LiftSense, LiftExample> .StepsArgs>(parser_SetTotalNumberSteps);
                parser.SetStepsCompleted   += new EventHandler <LiftIO.Parsing.LiftParser <LiftObject, LiftEntry, LiftSense, LiftExample> .ProgressEventArgs>(parser_SetStepsCompleted);
                parser.SetProgressMessage  += new EventHandler <LiftIO.Parsing.LiftParser <LiftObject, LiftEntry, LiftSense, LiftExample> .MessageArgs>(parser_SetProgressMessage);
                flexImporter.LiftFile       = inPath;

                int cEntries = parser.ReadLiftFile(sFilename);

                if (fMigrationNeeded)
                {
                    // Try to move the migrated file to the temp directory, even if a copy of it
                    // already exists there.
                    string sTempMigrated = Path.Combine(Path.GetTempPath(),
                                                        Path.ChangeExtension(Path.GetFileName(sFilename), "." + LiftIO.Validation.Validator.LiftVersion + ".lift"));
                    if (File.Exists(sTempMigrated))
                    {
                        File.Delete(sTempMigrated);
                    }
                    File.Move(sFilename, sTempMigrated);
                }
                progressDialog.Message = "Fixing relation links between imported entries";
                flexImporter.ProcessPendingRelations();
                sLogFile = flexImporter.DisplayNewListItems(inPath, cEntries);
            }
            catch (Exception error)
            {
                string sMsg = String.Format("Something went wrong trying to import {0} while merging...",
                                            inPath, error.Message);
                try
                {
                    StringBuilder bldr = new StringBuilder();
                    // leave in English for programmer's sake...
                    bldr.AppendFormat("Something went wrong while FieldWorks was attempting to import {0}.",
                                      inPath);
                    bldr.AppendLine();
                    bldr.AppendLine(error.Message);
                    bldr.AppendLine();
                    bldr.AppendLine(error.StackTrace);
                    if (System.Threading.Thread.CurrentThread.GetApartmentState() == System.Threading.ApartmentState.STA)
                    {
                        Clipboard.SetDataObject(bldr.ToString(), true);
                    }
                }
                catch
                {
                }
                MessageBox.Show(sMsg, "Problem Merging",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                m_cache.PropChangedHandling = oldPropChg;
            }
            return(sLogFile);
        }
Exemplo n.º 13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a new language project for the new language name
		/// </summary>
		/// <param name="progressDlg">The progress dialog.</param>
		/// <param name="parameters">The parameters: first parameter is resources, second is
		/// name of the project (string), analysis and vernacular writing system
		/// (NamedWritingSystem).</param>
		/// <returns>Always null.</returns>
		/// <remarks>Override DisplayUi to prevent progress dialog from showing.</remarks>
		/// ------------------------------------------------------------------------------------
		protected internal object CreateNewLangProj(IAdvInd4 progressDlg, params object[] parameters)
		{
			Debug.Assert(parameters.Length == 4);
			ResourceManager resources = (ResourceManager)parameters[0];
			string projectName = (string)parameters[1];
			m_analWrtSys = (NamedWritingSystem)parameters[2];
			m_vernWrtSys = (NamedWritingSystem)parameters[3];
			string dbFileName;
			string logFileName;

			// Loading the new language project (LoadNewLangProj) took 120 steps. To be safe
			// we calculate with 140. Loading newlangproj took 94% of the time, so the total is
			// 150.
			int nMax = 150;
			progressDlg.SetRange(0, nMax);
			if (resources != null)
				progressDlg.Message = resources.GetString("kstidCreatingDB");
			CreateNewDbFiles(projectName, out dbFileName, out logFileName);

			progressDlg.Step(0);
			m_dbName = AttachDatabase(dbFileName, logFileName);

			progressDlg.Step(0);
			if (resources != null)
				progressDlg.Message = resources.GetString("kstidInitializingDB");
			LoadNewLangProj(progressDlg);

			// Create the FDO cache and writing systems.
			progressDlg.Position = (int)(nMax * 0.95);
			if (resources != null)
				progressDlg.Message = resources.GetString("kstidCreatingWS");

			int hvoLp = 0;
			using (FdoCache cache = FdoCache.Create(m_dbName))
			{
				progressDlg.Step(0);
				CreateAnalysisWritingSystem(cache);
				progressDlg.Step(0);
				CreateVernacularWritingSystem(cache);

				// Fix sort methods that should use the vernacular writing system.
				progressDlg.Step(0);
				progressDlg.Step(0);
				FixVernacularWritingSystemReferences(cache);
				progressDlg.Step(0);

				// set defaults so can access them now
				cache.LangProject.CacheDefaultWritingSystems();
				progressDlg.Step(0);
				AssignVernacularWritingSystemToDefaultPhPhonemes(cache);
				progressDlg.Step(0);

				// Create a reversal index for the original default analysis writing system. (LT-4480)
				IReversalIndex newIdx = cache.LangProject.LexDbOA.ReversalIndexesOC.Add(
					new ReversalIndex());
				ILgWritingSystem wsAnalysis = cache.LangProject.CurAnalysisWssRS[0];
				newIdx.WritingSystemRA = wsAnalysis;
				newIdx.Name.AnalysisDefaultWritingSystem = wsAnalysis.Name.AnalysisDefaultWritingSystem;
				progressDlg.Step(0);

				// Give the language project a default name. Later this can be modified by the
				// user by changing it on the project properties dialog.
				cache.LangProject.Name.UserDefaultWritingSystem = projectName;
				hvoLp = cache.LangProject.Hvo;
				cache.Save();
				progressDlg.Position = nMax;
			}

			return new NewLangProjReturnData(hvoLp, m_serverName, m_dbName);
		}
Exemplo n.º 14
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Create publications and header/footer sets (in the DB) from the given XML document.
		/// </summary>
		/// <remarks>tests are able to call this method</remarks>
		/// <param name="progressDlg">Progress dialog</param>
		/// <param name="rootNode">The XmlNode from which to read the publication info</param>
		/// -------------------------------------------------------------------------------------
		protected void CreatePublicationInfo(IAdvInd4 progressDlg, XmlNode rootNode)
		{
			// init static stuff we may need
			m_dummyXmlDoc = new XmlDocument();
			m_dummyXmlDoc.LoadXml("<dummy/>");

			// Set up progress dialog
			progressDlg.Position = 0;
			progressDlg.Title = TeResourceHelper.GetResourceString("kstidCreatingPublicationsCaption");
			progressDlg.Message = TeResourceHelper.GetResourceString("kstidCreatingPublicationsStatusMsg");

			//Get all publications and header/footer set nodes.
			XmlNodeList publicationNodes = rootNode.SelectNodes("Publications/Publication");
			XmlNodeList hfSetNodes = HeaderFooterSetNodes(rootNode);

			//we require at least one publication be created
			if (publicationNodes.Count == 0)
			{
				string message;
#if DEBUG
				message = "Error reading TePublications.xml: Missing <Publications> or <Publication> node";
#else
				message = TeResourceHelper.GetResourceString("kstidInvalidInstallation");
#endif
				throw new Exception(message);
			}

			// now set the progress dialog max
			progressDlg.SetRange(0, publicationNodes.Count + hfSetNodes.Count);

			// Create the Publications from those nodes
			CreatePublications(progressDlg, publicationNodes, hfSetNodes);

			//Create the Header/Footer Sets from those nodes
			CreateHfSets(progressDlg, hfSetNodes);

			// Finally, update publications version in database.
			SetNewResourceVersion(GetVersion(rootNode));
		}
Exemplo n.º 15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Make sure all of the pages are laid out to and including the given page.
		/// </summary>
		/// <param name="pageIndex">page index to layout through</param>
		/// <param name="dpiX">The X dpi</param>
		/// <param name="dpiY">The Y dpi</param>
		/// <param name="dlg">Progress dialog to display the progress of the layout, null
		/// to not display one.</param>
		/// <returns>
		/// True if it did a layout of a page, false otherwise
		/// </returns>
		/// ------------------------------------------------------------------------------------
		protected bool LayoutToPageIfNeeded(int pageIndex, float dpiX, float dpiY, IAdvInd4 dlg)
		{
			lock (m_pages)
			{
				if (m_pages.Count == 0 || m_printerDpiX != dpiX || m_printerDpiY != dpiY)
				{
					m_printerDpiX = dpiX;
					m_printerDpiY = dpiY;
					CreatePages();
				}
			}

			// ENHANCE (TE-5651; EberhardB): right now we lay out everything up to the desired
			// page. This might take a loooong time if you have a large project. Now that we have
			// multiple divisions (and each book starting on a new page) it should be possible
			// to start with the page that starts the division that is on the desired page,
			// or go back through the divisions and start with the page that starts a
			// division that begins on a new page.
			bool fDidLayout = false;
			for (int iPage = 0; (iPage <= pageIndex) && (iPage < m_pages.Count); iPage++)
			{
				if (dlg != null)
				{
					dlg.SetRange(0, m_pages.Count);
					dlg.Message = string.Format(
						ResourceHelper.GetResourceString("kstidUpdatePageBreakPageCount"),
						iPage + 1, m_pages.Count);
				}

				// To be completely thread safe, we need to check the page count again
				// just in case the count changed while the lock was released.
				if (iPage < m_pages.Count && m_pages[iPage].LayOutIfNeeded())
				{
					if (dlg != null)
					{
						dlg.Position = iPage + 1;
						//Debug.WriteLine(string.Format("Page {0} of {1}", dlg.Value, dlg.Maximum));
						if (Cancel)
							break;
					}
					fDidLayout = true;
				}
			}

			return fDidLayout;
		}
Exemplo n.º 16
0
		/// <summary>
		/// Export the contents of the lexicon to the given file (first and only parameter).
		/// </summary>
		/// <returns>the name of the exported LIFT file if successful, or null if an error occurs.</returns>
		protected object ExportLexicon(IAdvInd4 progressDialog, params object[] parameters)
		{
			try
			{
				if (m_progressDlg == null)
					m_progressDlg = progressDialog;
				string outPath = (string)parameters[0];
				progressDialog.Message = String.Format(FlexChorusStrings.ksExportingEntries,
					m_cache.LangProject.LexDbOA.EntriesOC.Count);
				using (XDumper dumper = new XDumper(m_cache))
				{
					dumper.UpdateProgress += new XDumper.ProgressHandler(OnDumperUpdateProgress);
					dumper.SetProgressMessage += new EventHandler<XDumper.MessageArgs>(OnDumperSetProgressMessage);
					// Don't bother writing out the range information in the export.
					dumper.SetTestVariable("SkipRanges", true);
					dumper.SkipAuxFileOutput = true;
					progressDialog.SetRange(0, dumper.GetProgressMaximum());
					progressDialog.Position = 0;
					// TODO: get better output/input filename?
					string p = Path.Combine(DirectoryFinder.FWCodeDirectory, @"Language Explorer\Export Templates");
					string fxtPath = Path.Combine(p, "LIFT.fxt.xml");
					using (TextWriter w = new StreamWriter(outPath))
					{
						dumper.ExportPicturesAndMedia = true;	// useless without Pictures directory...
						dumper.Go(m_cache.LangProject as CmObject, fxtPath, w);
					}
					// TODO: validate output?
					return outPath;
				}
			}
			catch
			{
				return null;
			}
		}
Exemplo n.º 17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// If <paramref name="progressDlg"/> is not <c>null</c> we run the background task
		/// with that progress dialog (without creating a separate thread). Otherwise we display
		/// a new progress dialog as a modal dialog and start the background task in a separate
		/// thread.
		/// </summary>
		/// <param name="progressDlg">The existing progress dialog, or <c>null</c>.</param>
		/// <param name="fDisplayUi">set to <c>true</c> to display the progress dialog,
		/// <c>false</c> to run without UI.</param>
		/// <param name="backgroundTask">The background task.</param>
		/// <param name="parameters">The paramters that will be passed to the background task</param>
		/// <returns>The return value from the background thread.</returns>
		/// ------------------------------------------------------------------------------------
		public object RunTask(IAdvInd4 progressDlg, bool fDisplayUi,
			BackgroundTaskInvoker backgroundTask, params object[] parameters)
		{
			if (progressDlg != null)
			{
				int nMin;
				int nMax = 0;
				progressDlg.GetRange(out nMin, out nMax);
				progressDlg.Position = nMin;
				object ret = backgroundTask(progressDlg, parameters);
				progressDlg.SetRange(nMin, nMax);
				progressDlg.Position = nMax;
				return ret;
			}
			return RunTask(fDisplayUi, backgroundTask, parameters);
		}
Exemplo n.º 18
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates the key term equivalents.
		/// </summary>
		/// <param name="progressDlg">The progress dialog box.</param>
		/// <param name="parameters">Not used</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private object UpdateKeyTermEquivalents(IAdvInd4 progressDlg, params object[] parameters)
		{
			m_cache.EnableBulkLoadingIfPossible(true);
			List<InvalidRendering> invalidRenderings = new List<InvalidRendering>();
			try
			{
				// first build a map from verses to the keyterms that should have renderings.
				Set<int> chkTermIds = m_ktTree.ChkTermsWithRefs;
				if (progressDlg != null)
				{
					progressDlg.Message = TeResourceHelper.GetResourceString("kstidUpdateKeyTermEquivalentsProgressLoading");
					progressDlg.SetRange(0, chkTermIds.Count);
				}
				Dictionary<int, List<KeyTermRef>> bcvToChkRefs = new Dictionary<int, List<KeyTermRef>>();
				foreach (int keyTermHvo in chkTermIds)
				{
					AddChkRefsToBCVmap(keyTermHvo, ref bcvToChkRefs);
					if (progressDlg != null)
						progressDlg.Step(0);
				}
				// set progress bar to the number of verses to step through.
				if (progressDlg != null)
					progressDlg.SetRange(0, bcvToChkRefs.Count);
				// for each keyterm occurrences in each verse, make sure renderings are up to date.
				List<int> sortedKeys = new List<int>(bcvToChkRefs.Keys);
				sortedKeys.Sort();
				foreach (int bcv in sortedKeys)
				{
					// REVIEW (TE-6532): For now, all Key Term Refs in the DB use the Original
					// versisifcation. Should we support other versifications?
					ScrReference currentVerse = new ScrReference(bcv, Paratext.ScrVers.Original,
						m_scr.Versification);
					if (progressDlg != null)
					{
						progressDlg.Message = String.Format(TeResourceHelper.GetResourceString("kstidUpdateKeyTermEquivalentsProgressMessage"),
							currentVerse.AsString);
					}
					List<KeyTermRef> chkRefsForVerse = bcvToChkRefs[bcv];
					foreach (KeyTermRef chkRef in chkRefsForVerse)
					{
						Dictionary<int, bool> renderingActuallyExistsInVerse = new Dictionary<int, bool>();
						// skip doing anything about references that have been marked as "Ignore"
						if (chkRef.Status == KeyTermRenderingStatus.Ignored)
							continue;
						if (chkRef.RenderingRAHvo != 0)
						{
							if (CanFindTextInVerse(chkRef.RenderingRA, currentVerse))
							{
								if (chkRef.RenderingStatus == KeyTermRenderingStatus.Missing)
									chkRef.RenderingStatus = KeyTermRenderingStatus.Assigned;
								continue;
							}
						}
						// if an expected rendering is not found (or there was no previous assignment)
						// see if we can find an alternative rendering to AutoAssign.
						IChkTerm parentKeyTerm = chkRef.Owner as IChkTerm;
						bool fFound = false;
						foreach (IChkRendering rendering in parentKeyTerm.RenderingsOC)
						{
							if (rendering.SurfaceFormRA == null)
							{
								// We found a surface form that is not defined. Later we'll need to
								// remove this rendering, but for now we'll continue to the next one.
								invalidRenderings.Add(new InvalidRendering(parentKeyTerm, rendering));
								continue;
							}
							if (CanFindTextInVerse(rendering.SurfaceFormRA, currentVerse))
							{
								try
								{
									chkRef.RenderingRA = rendering.SurfaceFormRA;
									if (chkRef.RenderingStatus != KeyTermRenderingStatus.AutoAssigned)
										chkRef.RenderingStatus = KeyTermRenderingStatus.AutoAssigned;
									fFound = true;
									break;
								}
								catch
								{
									// Unable to set rendering because it is invalid.
									invalidRenderings.Add(new InvalidRendering(parentKeyTerm, rendering));
									continue;
								}
							}
						}
						if (!fFound)
						{
							if (chkRef.RenderingStatus == KeyTermRenderingStatus.Assigned)
							{
								// keep RenderingsRA info, so we know what is missing.
								chkRef.RenderingStatus = KeyTermRenderingStatus.Missing;
							}
							else
							{
								if (chkRef.RenderingRA != null)
									chkRef.RenderingRA = null;
								if (chkRef.RenderingStatus != KeyTermRenderingStatus.Unassigned)
									chkRef.RenderingStatus = KeyTermRenderingStatus.Unassigned;
							}
						}
					}
					if (progressDlg != null)
						progressDlg.Step(0);
				}
				return null;
			}
			finally
			{
				if (invalidRenderings.Count > 0)
				{
					// We found at least one invalid surface form, so we need to search through our
					// renderings and remove any that are invalid.
					foreach (InvalidRendering rendering in invalidRenderings)
						rendering.m_parentKeyTerm.RenderingsOC.Remove(rendering.m_rendering);
				}

				m_cache.EnableBulkLoadingIfPossible(false);
			}
		}
Exemplo n.º 19
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Exports the configured doc view.
		/// </summary>
		/// <param name="progressDlg">The progress dialog.</param>
		/// <param name="parameters">The parameters.</param>
		/// <returns>Always null.</returns>
		/// ------------------------------------------------------------------------------------
		private object ExportConfiguredDocView(IAdvInd4 progressDlg, params object[] parameters)
		{
			Debug.Assert(parameters.Length == 3);
			m_progressDlg = progressDlg;
			if (m_xvc == null)
				return null;

			string outPath = (string)parameters[0];
			string fxtPath = (string)parameters[1];
			FxtType ft = (FxtType)parameters[2];

			try
			{
				m_cache.EnableBulkLoadingIfPossible(true);

				using (TextWriter w = new StreamWriter(outPath))
				{
					FileInfo outFile = new FileInfo(outPath);
#if DEBUG
					string dirPath = Path.GetTempPath();
					int copyCount = 1;
					string s = string.Format("Starting Configured Export at {0}",
						System.DateTime.Now.ToLongTimeString());
					Debug.WriteLine(s);
#endif
					m_ce = new ConfiguredExport(null, m_cache.MainCacheAccessor, m_hvoRootObj);
					m_ce.Initialize(m_cache, w, ft.m_sDataType, ft.m_sFormat, outPath);
					m_ce.UpdateProgress += new SIL.FieldWorks.Common.Controls.ConfiguredExport.ProgressHandler(ce_UpdateProgress);
					m_xvc.Display(m_ce, m_hvoRootObj, m_seqView.RootFrag);
					m_ce.Finish(ft.m_sDataType);
					w.Close();
#if DEBUG
					s = string.Format("Finished Configured Export Dump at {0}",
						System.DateTime.Now.ToLongTimeString());
					Debug.WriteLine(s);
#endif
					if (ft.m_sXsltFiles != null && ft.m_sXsltFiles.Length != 0)
					{
						string[] rgsXslts = ft.m_sXsltFiles.Split(new char[] { ';' });
						int cXslts = rgsXslts.GetLength(0);
						progressDlg.Position = 0;
						progressDlg.SetRange(0, cXslts);
						progressDlg.Message =
							xWorksStrings.ProcessingIntoFinalForm;
						int idx = fxtPath.LastIndexOfAny(new char[] { '/', '\\' });
						if (idx < 0)
							idx = 0;
						else
							++idx;
						string basePath = fxtPath.Substring(0, idx);
						for (int ix = 0; ix <= cXslts; ++ix)
						{
#if DEBUG
							File.Copy(outPath, Path.Combine(dirPath, "DebugOnlyExportStage" + copyCount + ".txt"), true);
							copyCount++;
							if (ix < cXslts)
								s = String.Format("Starting Configured Export XSLT file {0} at {1}",
									rgsXslts[ix], System.DateTime.Now.ToLongTimeString());
							else
								s = String.Format("Starting final postprocess phase at {0}",
									System.DateTime.Now.ToLongTimeString());
							Debug.WriteLine(s);
#endif
							if (ix < cXslts)
							{
								string sXsltPath = basePath + rgsXslts[ix];
								m_ce.PostProcess(sXsltPath, outPath, ix + 1);
							}
							else
							{
								m_ce.PostProcess(null, outPath, ix + 1);
							}
							progressDlg.Step(0);
						}
					}

					if (ft.m_sFormat.ToLowerInvariant() == "xhtml")
					{
						IVwStylesheet vss = null;
						if (m_seqView.RootBox != null)
							vss = m_seqView.RootBox.Stylesheet;
						m_ce.WriteCssFile(Path.ChangeExtension(outPath, ".css"), vss);
					}
					m_ce = null;
#if DEBUG
					File.Copy(outPath, Path.Combine(dirPath, "DebugOnlyExportStage" + copyCount + ".txt"), true);
					s = string.Format("Totally Finished Configured Export at {0}",
						System.DateTime.Now.ToLongTimeString());
					Debug.WriteLine(s);
#endif
				}
			}
			finally
			{
				m_cache.EnableBulkLoadingIfPossible(false);
			}
			return null;
		}
Exemplo n.º 20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create a new language project for the new language name
        /// </summary>
        /// <param name="progressDlg">The progress dialog.</param>
        /// <param name="parameters">The parameters: first parameter is resources, second is
        /// name of the project (string), analysis and vernacular writing system
        /// (NamedWritingSystem).</param>
        /// <returns>Always null.</returns>
        /// <remarks>Override DisplayUi to prevent progress dialog from showing.</remarks>
        /// ------------------------------------------------------------------------------------
        protected internal object CreateNewLangProj(IAdvInd4 progressDlg, params object[] parameters)
        {
            Debug.Assert(parameters.Length == 4);
            ResourceManager resources   = (ResourceManager)parameters[0];
            string          projectName = (string)parameters[1];

            m_analWrtSys = (NamedWritingSystem)parameters[2];
            m_vernWrtSys = (NamedWritingSystem)parameters[3];
            string dbFileName;
            string logFileName;

            // Loading the new language project (LoadNewLangProj) took 120 steps. To be safe
            // we calculate with 140. Loading newlangproj took 94% of the time, so the total is
            // 150.
            int nMax = 150;

            progressDlg.SetRange(0, nMax);
            if (resources != null)
            {
                progressDlg.Message = resources.GetString("kstidCreatingDB");
            }
            CreateNewDbFiles(projectName, out dbFileName, out logFileName);

            progressDlg.Step(0);
            m_dbName = AttachDatabase(dbFileName, logFileName);

            progressDlg.Step(0);
            if (resources != null)
            {
                progressDlg.Message = resources.GetString("kstidInitializingDB");
            }
            LoadNewLangProj(progressDlg);

            // Create the FDO cache and writing systems.
            progressDlg.Position = (int)(nMax * 0.95);
            if (resources != null)
            {
                progressDlg.Message = resources.GetString("kstidCreatingWS");
            }

            int hvoLp = 0;

            using (FdoCache cache = FdoCache.Create(m_dbName))
            {
                progressDlg.Step(0);
                CreateAnalysisWritingSystem(cache);
                progressDlg.Step(0);
                CreateVernacularWritingSystem(cache);

                // Fix sort methods that should use the vernacular writing system.
                progressDlg.Step(0);
                progressDlg.Step(0);
                FixVernacularWritingSystemReferences(cache);
                progressDlg.Step(0);

                // set defaults so can access them now
                cache.LangProject.CacheDefaultWritingSystems();
                progressDlg.Step(0);
                AssignVernacularWritingSystemToDefaultPhPhonemes(cache);
                progressDlg.Step(0);

                // Create a reversal index for the original default analysis writing system. (LT-4480)
                IReversalIndex newIdx = cache.LangProject.LexDbOA.ReversalIndexesOC.Add(
                    new ReversalIndex());
                ILgWritingSystem wsAnalysis = cache.LangProject.CurAnalysisWssRS[0];
                newIdx.WritingSystemRA = wsAnalysis;
                newIdx.Name.AnalysisDefaultWritingSystem = wsAnalysis.Name.AnalysisDefaultWritingSystem;
                progressDlg.Step(0);

                // Give the language project a default name. Later this can be modified by the
                // user by changing it on the project properties dialog.
                cache.LangProject.Name.UserDefaultWritingSystem = projectName;
                hvoLp = cache.LangProject.Hvo;
                cache.Save();
                progressDlg.Position = nMax;
            }

            return(new NewLangProjReturnData(hvoLp, m_serverName, m_dbName));
        }