Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes the Scripture object, along with styles, book names and abbreviations.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void InitializeScriptureAndStyles(IProgress progressDlg)
        {
            m_scr = m_cache.LanguageProject.TranslatedScriptureOA = m_cache.ServiceLocator.GetInstance <IScriptureFactory>().Create();

            //Initialize factory styles
            TeStylesXmlAccessor.CreateFactoryScrStyles(progressDlg, m_scr);

            //Initialize Scripture Book Ref info
            TeScrBookRefsInit.SetNamesAndAbbreviations(progressDlg, m_cache);
        }
Ejemplo n.º 2
0
        /// -------------------------------------------------------------------------------------
        /// <summary>
        /// If the current stylesheet version in the Db doesn't match that of the current XML
        /// file, update the DB.
        /// </summary>
        /// <param name="lp">The language project</param>
        /// <param name="progressDlg">The progress dialog from the splash screen</param>
        /// -------------------------------------------------------------------------------------
        public static void EnsureCurrentStylesheet(ILangProject lp, IAdvInd4 progressDlg)
        {
            TeStylesXmlAccessor acc = new TeStylesXmlAccessor(lp.TranslatedScriptureOA);

            acc.EnsureCurrentResource(progressDlg);

            if (acc.UserModifiedStyles.Count > 0)
            {
                using (FwStylesModifiedDlg dlg = new FwStylesModifiedDlg(acc.UserModifiedStyles,
                                                                         lp.Cache.ProjectName(), FwApp.App))
                {
                    dlg.ShowDialog();
                }
            }
        }
Ejemplo n.º 3
0
        /// -------------------------------------------------------------------------------------
        /// <summary>
        /// If the current stylesheet version in the Db doesn't match that of the current XML
        /// file, update the DB.
        /// </summary>
        /// <param name="cache">The FDO cache</param>
        /// <param name="progressDlg">The progress dialog from the splash screen</param>
        /// <param name="helpTopicProvider">A Help topic provider that can serve up a help topic
        /// that only exists in TE Help.</param>
        /// -------------------------------------------------------------------------------------
        public static void EnsureCurrentStylesheet(FdoCache cache, IProgress progressDlg,
                                                   IHelpTopicProvider helpTopicProvider)
        {
            TeStylesXmlAccessor acc = new TeStylesXmlAccessor(cache.LangProject.TranslatedScriptureOA);

            acc.EnsureCurrentResource(progressDlg);

            if (acc.UserModifiedStyles.Count > 0)
            {
                using (FwStylesModifiedDlg dlg = new FwStylesModifiedDlg(acc.UserModifiedStyles,
                                                                         cache.ProjectId.UiName, helpTopicProvider))
                {
                    dlg.ShowDialog();
                }
            }
        }
Ejemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sanity check to ensure the scripture texts are valid.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected void EnsureScriptureTextsValid()
        {
            foreach (IScrBook book in m_scr.ScriptureBooksOS)
            {
                if (book.SectionsOS.Count == 0)
                {
                    continue;
                }

                ContextValues sectionContext;
                foreach (IScrSection section in book.SectionsOS)
                {
                    // Check the heading paragraphs.
                    if (section.HeadingOA == null)
                    {
                        section.HeadingOA = m_cache.ServiceLocator.GetInstance <IStTextFactory>().Create();
                    }

                    if (section.HeadingOA.ParagraphsOS.Count == 0)
                    {
                        IStTxtPara para = m_cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle(
                            section.HeadingOA, ScrStyleNames.SectionHead);
                        sectionContext = ContextValues.Text;
                    }
                    else
                    {
                        IStStyle style = m_scr.FindStyle(section.HeadingOA.ParagraphsOS[0].StyleRules);
                        // style could be null. set default context if possible
                        sectionContext = style == null ? ContextValues.Text : style.Context;
                    }

                    // Check the content paragraphs.
                    if (section.ContentOA == null)
                    {
                        section.ContentOA = m_cache.ServiceLocator.GetInstance <IStTextFactory>().Create();
                    }

                    if (section.ContentOA.ParagraphsOS.Count == 0)
                    {
                        IStTxtPara para = m_cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle(
                            section.ContentOA, TeStylesXmlAccessor.GetDefaultStyleForContext(sectionContext, false));
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets a help file URL or topic
        /// </summary>
        /// <param name="stid"></param>
        /// <returns>The requested string</returns>
        /// ------------------------------------------------------------------------------------
        public override string GetHelpString(string stid)
        {
            // First check if the stid starts with the marker that tells us the user is wanting
            // help on a particular style displayed in the styles combo box. If so, then find
            // the correct URL for the help topic of that style's example.
            const string kStylePrefix = "style:";

            if (stid.StartsWith(kStylePrefix))
            {
                return(TeStylesXmlAccessor.GetHelpTopicForStyle(stid.Substring(kStylePrefix.Length)));
            }
            if (stid.StartsWith("khtpScrChecks_"))
            {
                return(TeResourceHelper.GetHelpString(stid) ?? base.GetHelpString("khtpScrChecksUndocumented"));
            }

            return(TeResourceHelper.GetHelpString(stid) ?? base.GetHelpString(stid));
        }
Ejemplo n.º 6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Ensures all of the project components are valid.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="existingProgressDlg">The existing progress dialog.</param>
        /// ------------------------------------------------------------------------------------
        public static void EnsureProjectComponentsValid(FdoCache cache, IAdvInd4 existingProgressDlg)
        {
            EnsureProjectValid(cache, existingProgressDlg);

            // TE-8621: Don't try to upgrade the database unless we're the project server and no one is connected
            if (!MiscUtils.IsServerLocal(cache.ServerName) || cache.GetNumberOfRemoteClients() > 0)
            {
                return;
            }

            ILangProject lp = cache.LangProject;

            TePublicationsInit.EnsureFactoryPublications(lp, existingProgressDlg);
            TeStylesXmlAccessor.EnsureCurrentStylesheet(lp, existingProgressDlg);
            TeScrNoteCategoriesInit.EnsureCurrentScrNoteCategories(lp, existingProgressDlg);
            TeKeyTermsInit.EnsureCurrentKeyTerms(lp, existingProgressDlg);
            cache.Save();
        }
Ejemplo n.º 7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Performs minimal initialization of Scripture needed by FLEx for importing from
        /// Paratext.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public static void EnsureMinimalScriptureInitialization(FdoCache cache, IThreadedProgress progressDlg,
                                                                IHelpTopicProvider helpTopicProvider)
        {
            TeScrInitializer scrInitializer = new TeScrInitializer(cache);

            if (scrInitializer.m_scr == null)
            {
                progressDlg.RunTask((progDlg, args) =>
                {
                    scrInitializer.InitializeScriptureAndStyles(progDlg);
                    return(null);
                });
            }
            else
            {
                TeStylesXmlAccessor.EnsureCurrentStylesheet(cache, progressDlg, helpTopicProvider);
            }
        }
Ejemplo n.º 8
0
        /// -------------------------------------------------------------------------------------
        /// <summary>
        /// If the current stylesheet version in the Db doesn't match that of the current XML
        /// file, update the DB.
        /// </summary>
        /// <param name="cache">The FDO cache</param>
        /// <param name="progressDlg">The progress dialog from the splash screen</param>
        /// <param name="helpTopicProvider">A Help topic provider that can serve up a help topic
        /// that only exists in TE Help.</param>
        /// -------------------------------------------------------------------------------------
        public static void EnsureCurrentStylesheet(FdoCache cache, IThreadedProgress progressDlg,
                                                   IHelpTopicProvider helpTopicProvider)
        {
            TeStylesXmlAccessor acc = new TeStylesXmlAccessor(cache.LangProject.TranslatedScriptureOA);

            acc.EnsureCurrentResource(progressDlg);

            // This class is used specifically for TE styles; FLEx *should* use a different class,
            // but per LT-14704, that is not the case. So always checking for current styles, but
            // suppressing a potentially confusing dialog when TE is not installed.
            if (acc.UserModifiedStyles.Count > 0 && FwUtils.IsTEInstalled)
            {
                using (FwStylesModifiedDlg dlg = new FwStylesModifiedDlg(acc.UserModifiedStyles,
                                                                         cache.ProjectId.UiName, helpTopicProvider))
                {
                    dlg.ShowDialog();
                }
            }
        }
Ejemplo n.º 9
0
        /// --------------------------------------------------------------------------------
        /// <summary>
        /// Ensures all of the project components are valid.
        /// </summary>
        /// --------------------------------------------------------------------------------
        public static void EnsureProjectComponentsValid(FdoCache cache, FwApp app,
                                                        IThreadedProgress existingProgressDlg)
        {
            EnsureProjectValid(cache, app, existingProgressDlg);

            // TE-8621: Don't try to upgrade the database unless we're the project server and no one is connected
            if (!cache.ProjectId.IsLocal || cache.NumberOfRemoteClients > 0)
            {
                return;
            }

            ILangProject lp = cache.LangProject;

            TeScrBookRefsInit.EnsureFactoryScrBookRefs(cache, existingProgressDlg);
            TePublicationsInit.EnsureFactoryPublications(lp, existingProgressDlg);
            TeStylesXmlAccessor.EnsureCurrentStylesheet(cache, existingProgressDlg, app);
            TeScrNoteCategoriesInit.EnsureCurrentScrNoteCategories(lp, existingProgressDlg);
            TeKeyTermsInit.EnsureCurrentKeyTerms(lp, app, existingProgressDlg);
        }
Ejemplo n.º 10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Returns a help topic with an example of how to use the given style. If the given
        /// style is not a factory style, then a general topic about using user-defined styles
        /// is returned.
        /// </summary>
        /// <param name="styleName">The  style name</param>
        /// <returns>A help topic with an example of how to use the given style, or if the given
        /// style is not a factory style, then a general topic about using user-defined styles
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public static string GetHelpTopicForStyle(string styleName)
        {
            if (styleName == StyleUtils.DefaultParaCharsStyleName)
            {
                return(@"Redirect.htm#its:Using_Styles.chm::/Using_Styles/Styles_Grouped_by_Type/" +
                       "Special_Text_and_Character_Styles/Default_Paragraph_Characters_description.htm");
            }

            string  editedName = styleName.Replace(" ", "_");
            XmlNode teStyles   = new TeStylesXmlAccessor().LoadDoc();

            try
            {
                XmlNode help =
                    teStyles.SelectSingleNode("markup/tag[@id='" + editedName + "']/help");

                XmlNode category = null;
                if (help != null)                 // without this test it sometimes throws a nullref exception, which is annoying while debugging though caught below.
                {
                    category = help.Attributes.GetNamedItem("category");
                }
                if (category != null)
                {
                    return(@"Redirect.htm#its:Using_Styles.chm::/Using_Styles/Styles_Grouped_by_Type/" +
                           category.Value + "/" + editedName +
                           ((editedName == ScrStyleNames.Normal) ? "_description.htm" : "_example.htm"));
                }
                XmlNode topic = null;
                if (help != null)                 // without this test it sometimes throws a nullref exception, which is annoying while debugging though caught below.
                {
                    topic = help.Attributes.GetNamedItem("topic");
                }
                if (topic != null)
                {
                    return(topic.Value);
                }
            }
            catch
            {
            }
            return(@"Advanced_Tasks/Customizing_Styles/User-defined_style.htm");
        }
Ejemplo n.º 11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets a help file URL or topic
        /// </summary>
        /// <param name="stid"></param>
        /// <param name="iKey"></param>
        /// <returns>The requested string</returns>
        /// ------------------------------------------------------------------------------------
        public override string GetHelpString(string stid, int iKey)
        {
            CheckDisposed();

            // First check if the stid starts with the marker that tells us the user is wanting
            // help on a particular style displayed in the styles combo box. If so, then find
            // the correct URL for the help topic of that style's example.
            if (stid.StartsWith("style:"))
            {
                return(TeStylesXmlAccessor.GetHelpTopicForStyle(stid.Substring(6)));
            }

            string helpString = TeResourceHelper.GetHelpString(stid);

            if (helpString != null)
            {
                return(helpString);
            }

            return(base.GetHelpString(stid, iKey));
        }
Ejemplo n.º 12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Set the properties of a StyleInfo to the factory default settings
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public static void SetPropsToFactorySettings(StyleInfo styleInfo)
        {
            TeStylesXmlAccessor acc = new TeStylesXmlAccessor(styleInfo.Cache.LanguageProject.TranslatedScriptureOA);

            acc.ResetProps(styleInfo);
        }
Ejemplo n.º 13
0
        /// -------------------------------------------------------------------------------------
        /// <summary>
        /// Create factory styles from the TE Styles XML file.
        /// </summary>
        /// <param name="progressDlg">Progress dialog so the user can cancel</param>
        /// <param name="scr">The Scripture</param>
        /// -------------------------------------------------------------------------------------
        public static void CreateFactoryScrStyles(IProgress progressDlg, IScripture scr)
        {
            TeStylesXmlAccessor acc = new TeStylesXmlAccessor(scr);

            acc.CreateStyles(progressDlg, scr.StylesOC, acc.LoadDoc(), true);
        }
Ejemplo n.º 14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Returns a help topic with an example of how to use the given style. If the given
		/// style is not a factory style, then a general topic about using user-defined styles
		/// is returned.
		/// </summary>
		/// <param name="styleName">The  style name</param>
		/// <returns>A help topic with an example of how to use the given style, or if the given
		/// style is not a factory style, then a general topic about using user-defined styles
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static string GetHelpTopicForStyle(string styleName)
		{
			if (styleName == FdoResources.DefaultParaCharsStyleName)
			{
				return @"Redirect.htm#its:Using_Styles.chm::/Using_Styles/Styles_Grouped_by_Type/" +
					"Special_Text_and_Character_Styles/Default_Paragraph_Characters_description.htm";
			}

			string editedName = styleName.Replace(" ", "_");
			XmlNode teStyles = new TeStylesXmlAccessor().LoadDoc();
			try
			{
				XmlNode help =
					teStyles.SelectSingleNode("markup/tag[@id='" + editedName + "']/help");

				XmlNode category = null;
				if (help != null) // without this test it sometimes throws a nullref exception, which is annoying while debugging though caught below.
					category = help.Attributes.GetNamedItem("category");
				if (category != null)
				{
					return @"Redirect.htm#its:Using_Styles.chm::/Using_Styles/Styles_Grouped_by_Type/" +
						category.Value + "/" + editedName +
						((editedName == ScrStyleNames.Normal) ? "_description.htm" : "_example.htm");
				}
				XmlNode topic = null;
				if (help != null) // without this test it sometimes throws a nullref exception, which is annoying while debugging though caught below.
					topic = help.Attributes.GetNamedItem("topic");
				if (topic != null)
				{
					return topic.Value;
				}
			}
			catch
			{
			}
			return @"Advanced_Tasks/Customizing_Styles/User-defined_style.htm";
		}
Ejemplo n.º 15
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Create factory styles from the TE Styles XML file.
		/// </summary>
		/// <param name="progressDlg">Progress dialog so the user can cancel</param>
		/// <param name="scr">The Scripture</param>
		/// -------------------------------------------------------------------------------------
		public static void CreateFactoryScrStyles(IAdvInd4 progressDlg, IScripture scr)
		{
			TeStylesXmlAccessor acc = new TeStylesXmlAccessor(scr);
			acc.CreateStyles(progressDlg, scr.StylesOC, acc.LoadDoc());
		}
Ejemplo n.º 16
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// If the current stylesheet version in the Db doesn't match that of the current XML
		/// file, update the DB.
		/// </summary>
		/// <param name="lp">The language project</param>
		/// <param name="progressDlg">The progress dialog from the splash screen</param>
		/// -------------------------------------------------------------------------------------
		public static void EnsureCurrentStylesheet(ILangProject lp, IAdvInd4 progressDlg)
		{
			TeStylesXmlAccessor acc = new TeStylesXmlAccessor(lp.TranslatedScriptureOA);
			acc.EnsureCurrentResource(progressDlg);

			if (acc.UserModifiedStyles.Count > 0)
			{
				using (FwStylesModifiedDlg dlg = new FwStylesModifiedDlg(acc.UserModifiedStyles,
					lp.Cache.ProjectName(), FwApp.App))
				{
					dlg.ShowDialog();
				}
			}
		}
Ejemplo n.º 17
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Gets the style name that is the default style to use for the given context
 /// </summary>
 /// <param name="nContext">the context</param>
 /// <param name="fCharStyle">set to <c>true</c> for character styles; otherwise
 /// <c>false</c>.</param>
 /// <returns>
 /// Name of the style that is the default for the context
 /// </returns>
 /// ------------------------------------------------------------------------------------
 public override string GetDefaultStyleForContext(int nContext, bool fCharStyle)
 {
     return(TeStylesXmlAccessor.GetDefaultStyleForContext((ContextValues)nContext, fCharStyle));
 }
Ejemplo n.º 18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes the scripture project.
        /// </summary>
        /// <param name="progressDialog">The progress dialog.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        private object InitializeScriptureProject(IAdvInd4 progressDialog, params object[] parameters)
        {
            ILangProject lp = m_cache.LangProject;

            if (m_scr == null)
            {
                m_scr = lp.TranslatedScriptureOA = new Scripture();

                //Initialize factory styles
                TeStylesXmlAccessor.CreateFactoryScrStyles(progressDialog, m_scr);

                // Initialize the separator and bridge strings.
                m_scr.ChapterVerseSepr = ":";
                m_scr.Bridge           = "-";
                m_scr.RefSepr          = ";";
                m_scr.VerseSepr        = ",";

                //Initialize misc
                m_scr.RestartFootnoteSequence        = true;
                m_scr.CrossRefsCombinedWithFootnotes = false;

                m_scr.FootnoteMarkerType       = FootnoteMarkerTypes.AutoFootnoteMarker;
                m_scr.FootnoteMarkerSymbol     = Scripture.kDefaultFootnoteMarkerSymbol;
                m_scr.DisplayFootnoteReference = false;

                m_scr.CrossRefMarkerType       = FootnoteMarkerTypes.NoFootnoteMarker;
                m_scr.CrossRefMarkerSymbol     = Scripture.kDefaultFootnoteMarkerSymbol;
                m_scr.DisplayCrossRefReference = true;
            }

            // Initialize Scripture book annotations
            if (m_scr.BookAnnotationsOS.Count == 0)
            {
                CreateScrBookAnnotations();
            }

            //Initialize Scripture Book Ref info
            if (m_cache.ScriptureReferenceSystem.BooksOS.Count == 0)
            {
                CreateScrBookRefs(progressDialog);
            }

            //Initialize factory publications
            if (m_scr.PublicationsOC.Count == 0)
            {
                TePublicationsInit.CreatePublicationInfo(progressDialog, m_scr);
            }

            //Initialize the key terms
            ICmPossibilityList keyTermsList = lp.KeyTermsList;

            if (keyTermsList.PossibilitiesOS.Count < 1)
            {
                TeKeyTermsInit.CreateKeyTerms(progressDialog, keyTermsList);
            }

            //Initialize the note categories
            if (m_scr.NoteCategoriesOA == null || m_scr.NoteCategoriesOA.PossibilitiesOS.Count == 0)
            {
                TeScrNoteCategoriesInit.CreateFactoryScrNoteCategories(progressDialog, m_scr);
            }

            m_cache.Save();

            // For good measure, on the off-chance the user notices.
            int nMin, nMax;

            progressDialog.GetRange(out nMin, out nMax);
            progressDialog.Position = nMax;

            return(null);
        }
Ejemplo n.º 19
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// If the current stylesheet version in the Db doesn't match that of the current XML
		/// file, update the DB.
		/// </summary>
		/// <param name="cache">The FDO cache</param>
		/// <param name="progressDlg">The progress dialog from the splash screen</param>
		/// <param name="helpTopicProvider">A Help topic provider that can serve up a help topic
		/// that only exists in TE Help.</param>
		/// -------------------------------------------------------------------------------------
		public static void EnsureCurrentStylesheet(FdoCache cache, IThreadedProgress progressDlg,
			IHelpTopicProvider helpTopicProvider)
		{
			TeStylesXmlAccessor acc = new TeStylesXmlAccessor(cache.LangProject.TranslatedScriptureOA);
			acc.EnsureCurrentResource(progressDlg);

			// This class is used specifically for TE styles; FLEx *should* use a different class,
			// but per LT-14704, that is not the case. So always checking for current styles, but
			// suppressing a potentially confusing dialog when TE is not installed.
			if (acc.UserModifiedStyles.Count > 0 && FwUtils.IsTEInstalled)
			{
				using (FwStylesModifiedDlg dlg = new FwStylesModifiedDlg(acc.UserModifiedStyles,
					cache.ProjectId.UiName, helpTopicProvider))
				{
					dlg.ShowDialog();
				}
			}
		}
Ejemplo n.º 20
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set the properties of a StyleInfo to the factory default settings
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public static void SetPropsToFactorySettings(StyleInfo styleInfo)
		{
			TeStylesXmlAccessor acc = new TeStylesXmlAccessor(styleInfo.Cache.LanguageProject.TranslatedScriptureOA);
			acc.ResetProps(styleInfo);
		}