From 479c73a576e091d6de96842e0683fd1274695b43 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Wed, 18 Jun 2025 10:19:24 -0700 Subject: [PATCH 1/5] Fix LT-21945: Different modes for parsing vs. analyzing --- .../Configuration/Words/areaConfiguration.xml | 12 +++- .../Interlinear/ChooseAnalysisHandler.cs | 9 ++- .../Interlinear/ITextStrings.Designer.cs | 11 ++- Src/LexText/Interlinear/ITextStrings.resx | 7 ++ .../Interlinear/InterlinDocRootSiteBase.cs | 1 + Src/LexText/Interlinear/InterlinMaster.cs | 45 ++++++++++++ Src/LexText/Interlinear/InterlinVc.cs | 68 ++++++++++++------- .../Interlinear/SandboxBase.ComboHandlers.cs | 4 +- 8 files changed, 125 insertions(+), 32 deletions(-) diff --git a/DistFiles/Language Explorer/Configuration/Words/areaConfiguration.xml b/DistFiles/Language Explorer/Configuration/Words/areaConfiguration.xml index 48287bafa4..7a6458af91 100644 --- a/DistFiles/Language Explorer/Configuration/Words/areaConfiguration.xml +++ b/DistFiles/Language Explorer/Configuration/Words/areaConfiguration.xml @@ -28,8 +28,14 @@ + + + + + + - + @@ -286,6 +292,10 @@ + + + + diff --git a/Src/LexText/Interlinear/ChooseAnalysisHandler.cs b/Src/LexText/Interlinear/ChooseAnalysisHandler.cs index ee48a376f3..ec9a56098c 100644 --- a/Src/LexText/Interlinear/ChooseAnalysisHandler.cs +++ b/Src/LexText/Interlinear/ChooseAnalysisHandler.cs @@ -282,7 +282,7 @@ public void SetupCombo() var wordform = m_owner.GetWordformOfAnalysis(); // Add the analyses, and recursively the other items. - var guess_services = new AnalysisGuessServices(m_cache); + var guess_services = new AnalysisGuessServices(m_cache, GetParsingMode()); var sorted_analyses = guess_services.GetSortedAnalysisGuesses(wordform, m_occurrence, false); foreach (var wa in sorted_analyses) { @@ -311,7 +311,7 @@ void AddAnalysisItems(IWfiAnalysis wa) { AddItem(wa, MakeAnalysisStringRep(wa, m_cache, StyleSheet != null, (m_owner as SandboxBase).RawWordformWs), true); - var guess_services = new AnalysisGuessServices(m_cache); + var guess_services = new AnalysisGuessServices(m_cache, GetParsingMode()); var sorted_glosses = guess_services.GetSortedGlossGuesses(wa, m_occurrence); foreach (var gloss in sorted_glosses) { @@ -323,6 +323,11 @@ void AddAnalysisItems(IWfiAnalysis wa) AddItem(wa, MakeSimpleString(ITextStrings.ksNewWordGloss), false, WfiGlossTags.kClassId); } + private bool GetParsingMode() + { + return Owner.InterlinDoc.GetMaster().GetParsingMode(); + } + protected ITsString MakeSimpleString(String str) { ITsStrBldr builder = TsStringUtils.MakeStrBldr(); diff --git a/Src/LexText/Interlinear/ITextStrings.Designer.cs b/Src/LexText/Interlinear/ITextStrings.Designer.cs index 73f2a291b5..a6fa54ab95 100644 --- a/Src/LexText/Interlinear/ITextStrings.Designer.cs +++ b/Src/LexText/Interlinear/ITextStrings.Designer.cs @@ -19,7 +19,7 @@ namespace SIL.FieldWorks.IText { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ITextStrings { @@ -1576,6 +1576,15 @@ internal static string ksParsing { } } + /// + /// Looks up a localized string similar to Parsing. + /// + internal static string ksParsingMode { + get { + return ResourceManager.GetString("ksParsingMode", resourceCulture); + } + } + /// /// Looks up a localized string similar to Ph{0} {1}. /// diff --git a/Src/LexText/Interlinear/ITextStrings.resx b/Src/LexText/Interlinear/ITextStrings.resx index 96a099fec3..0f730840c8 100644 --- a/Src/LexText/Interlinear/ITextStrings.resx +++ b/Src/LexText/Interlinear/ITextStrings.resx @@ -986,4 +986,11 @@ Click "Cancel" to abort this import. Export Concordance Results + + Results may be incomplete. + + + Parsing + alternate name for Analyze tab + \ No newline at end of file diff --git a/Src/LexText/Interlinear/InterlinDocRootSiteBase.cs b/Src/LexText/Interlinear/InterlinDocRootSiteBase.cs index 6c65d7da4e..d694321f3c 100644 --- a/Src/LexText/Interlinear/InterlinDocRootSiteBase.cs +++ b/Src/LexText/Interlinear/InterlinDocRootSiteBase.cs @@ -1013,6 +1013,7 @@ protected virtual void SetRootInternal(int hvo) NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor, () => InterlinMaster.LoadParagraphAnnotationsAndGenerateEntryGuessesIfNeeded(RootStText, true)); // Sync Guesses data before we redraw anything. + Vc.RootSite = this; UpdateGuessData(); } // FWR-191: we don't need to reconstruct the display if we didn't need to reload annotations diff --git a/Src/LexText/Interlinear/InterlinMaster.cs b/Src/LexText/Interlinear/InterlinMaster.cs index 87fd9523bb..abd9e3f33e 100644 --- a/Src/LexText/Interlinear/InterlinMaster.cs +++ b/Src/LexText/Interlinear/InterlinMaster.cs @@ -55,6 +55,8 @@ public partial class InterlinMaster : InterlinMasterBase, IFocusablePanePortion private string m_currentTool = ""; + private string m_analyzeTabName = ""; + public string CurrentTool { get { return m_currentTool; } @@ -87,6 +89,8 @@ public InterlinMaster() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); + // Save the Analyze tab name. + m_analyzeTabName = m_tpInterlinear.Text; } internal string BookmarkId @@ -721,6 +725,7 @@ public override void Init(Mediator mediator, PropertyTable propertyTable, XmlNod m_mediator = mediator; // InitBase will do this, but we need it in place before calling SetInitialTabPage(). m_propertyTable = propertyTable; + SetParsingMode(GetParsingMode()); // Making the tab control currently requires this first... if (!fHideTitlePane) @@ -1246,6 +1251,46 @@ public bool OnConfigureInterlinear(object argument) return true; // We handled this } + public bool OnDisplaySetParsingMode(object commandObject, + ref UIItemDisplayProperties display) + { + var cmd = (Command)commandObject; + bool value = cmd.GetParameter("value") == "true"; + display.Checked = GetParsingMode() == value; + return true; + } + + public bool OnSetParsingMode(object argument) + { + var cmd = (Command)argument; + string value = cmd.GetParameter("value"); + SetParsingMode(value == "true"); + // Refresh the display. + RootStText = null; + m_idcAnalyze.ResetAnalysisCache(); + Clerk.JumpToIndex(Clerk.CurrentIndex); + return true; // we handled this + } + + public void SetParsingMode(bool value) + { + m_propertyTable.SetProperty("ParsingMode", value, PropertyTable.SettingsGroup.LocalSettings, false); + if (value) + { + m_tpInterlinear.Text = ITextStrings.ksParsingMode; + } + else + { + // Restore Analyze tab name. + m_tpInterlinear.Text = m_analyzeTabName; + } + } + + public bool GetParsingMode() + { + return m_propertyTable.GetBoolProperty("ParsingMode", false, PropertyTable.SettingsGroup.LocalSettings); + } + /// /// Use this to determine whether the last selected tab page which was /// persisted in the PropertyTable, pertains to an interlinear document. diff --git a/Src/LexText/Interlinear/InterlinVc.cs b/Src/LexText/Interlinear/InterlinVc.cs index bc71a04bf1..39d13f1b69 100644 --- a/Src/LexText/Interlinear/InterlinVc.cs +++ b/Src/LexText/Interlinear/InterlinVc.cs @@ -373,17 +373,22 @@ public void ResetAnalysisCache() if (m_loader != null) { CheckDisposed(); - m_loader.ResetGuessCache(); + m_loader.ResetGuessCache(GetParsingMode()); } } + public bool GetParsingMode() + { + return RootSite.GetMaster().GetParsingMode(); + } + internal AnalysisGuessServices GuessServices { get { if (m_loader != null && m_loader.GuessServices != null) return m_loader.GuessServices; - return new AnalysisGuessServices(m_cache); + return new AnalysisGuessServices(m_cache, GetParsingMode()); } } @@ -541,10 +546,32 @@ private void SetGuessing(IVwEnv vwenv, int bgColor) UsingGuess = true; } - private void SetGuessing(IVwEnv vwenv) + private int GetGuessColor(ICmObject obj) { - SetGuessing(vwenv, ApprovedGuessColor); - UsingGuess = true; + IWfiAnalysis wa; + if (GetParsingMode()) + { + // Parser approval takes precedence over User approval. + wa = (obj is IWfiGloss) ? ((IWfiGloss)obj).Analysis : obj as IWfiAnalysis; + if (wa != null) + { + Opinions opinion = wa.GetAgentOpinion(wa.Cache.LangProject.DefaultParserAgent); + if (opinion == Opinions.approves) + return MachineGuessColor; + } + return ApprovedGuessColor; + } + // User approval takes precedence over Parser approval. + if (obj is IWfiGloss) + return ApprovedGuessColor; + wa = obj as IWfiAnalysis; + if (wa != null) + { + Opinions opinion = wa.GetAgentOpinion(wa.Cache.LangProject.DefaultUserAgent); + if (opinion == Opinions.approves) + return ApprovedGuessColor; + } + return MachineGuessColor; } public bool UsingGuess { get; set; } @@ -1822,11 +1849,7 @@ private void DisplayMorphemes() // Display the morpheme bundles. if (m_hvoDefault != m_hvoWordBundleAnalysis) { - // Real analysis isn't what we're displaying, so morph breakdown - // is a guess. Is it a human-approved guess? - bool isHumanGuess = m_this.GuessCache.get_IntProp(m_hvoDefault, InterlinViewDataCache.OpinionAgentFlid) != - (int) AnalysisGuessServices.OpinionAgent.Parser; - m_this.SetGuessing(m_vwenv, isHumanGuess ? ApprovedGuessColor : MachineGuessColor); + m_this.SetGuessing(m_vwenv, m_this.GetGuessColor(m_defaultObj)); // Let the exporter know that this is a guessed analysis. m_vwenv.set_StringProperty(ktagAnalysisStatus, "guess"); } @@ -1842,7 +1865,7 @@ private void DisplayMorphemes() if (m_hvoWordBundleAnalysis == m_hvoWordform) { // Real analysis is just word, one we're displaying is a default - m_this.SetGuessing(m_vwenv); + m_this.SetGuessing(m_vwenv, m_this.GetGuessColor(m_defaultObj)); // Let the exporter know that this is a guessed analysis. m_vwenv.set_StringProperty(ktagAnalysisStatus, "guess"); } @@ -1866,11 +1889,7 @@ private void DisplayWordGloss(InterlinLineSpec spec, int choiceIndex) case WfiAnalysisTags.kClassId: if (m_hvoDefault != m_hvoWordBundleAnalysis) { - // Real analysis isn't what we're displaying, so morph breakdown - // is a guess. Is it a human-approved guess? - bool isHumanGuess = m_this.GuessCache.get_IntProp(m_hvoDefault, InterlinViewDataCache.OpinionAgentFlid) != - (int)AnalysisGuessServices.OpinionAgent.Parser; - m_this.SetGuessing(m_vwenv, isHumanGuess ? ApprovedGuessColor : MachineGuessColor); + m_this.SetGuessing(m_vwenv, m_this.GetGuessColor(m_defaultObj)); } var wa = (IWfiAnalysis) m_defaultObj; if (wa.MeaningsOC.Count == 0) @@ -1899,7 +1918,7 @@ private void DisplayWordGloss(InterlinLineSpec spec, int choiceIndex) } else { - m_this.SetGuessing(m_vwenv); + m_this.SetGuessing(m_vwenv, m_this.GetGuessColor(m_defaultObj)); m_vwenv.AddObj(m_hvoDefault, m_this, kfragLineChoices + choiceIndex); } break; @@ -1919,18 +1938,14 @@ private void DisplayWordPOS(int choiceIndex) case WfiAnalysisTags.kClassId: if (m_hvoDefault != m_hvoWordBundleAnalysis) { - // Real analysis isn't what we're displaying, so POS is a guess. - bool isHumanApproved = m_this.GuessCache.get_IntProp(m_hvoDefault, InterlinViewDataCache.OpinionAgentFlid) - != (int)AnalysisGuessServices.OpinionAgent.Parser; - - m_this.SetGuessing(m_vwenv, isHumanApproved ? ApprovedGuessColor : MachineGuessColor); + m_this.SetGuessing(m_vwenv, m_this.GetGuessColor(m_defaultObj)); } m_this.AddAnalysisPos(m_vwenv, m_hvoDefault, m_hvoWordBundleAnalysis, choiceIndex); break; case WfiGlossTags.kClassId: m_hvoWfiAnalysis = m_defaultObj.Owner.Hvo; if (m_hvoWordBundleAnalysis == m_hvoWordform) // then our analysis is a guess - m_this.SetGuessing(m_vwenv); + m_this.SetGuessing(m_vwenv, m_this.GetGuessColor(m_defaultObj)); m_vwenv.AddObj(m_hvoWfiAnalysis, m_this, kfragAnalysisCategoryChoices + choiceIndex); break; default: @@ -2288,7 +2303,7 @@ private void EnsureLoader() internal virtual IParaDataLoader CreateParaLoader() { - return new InterlinViewCacheLoader(new AnalysisGuessServices(m_cache), GuessCache); + return new InterlinViewCacheLoader(new AnalysisGuessServices(m_cache, GetParsingMode()), GuessCache); } internal void RecordGuessIfNotKnown(AnalysisOccurrence selected) @@ -2409,7 +2424,7 @@ public interface IParaDataLoader { void LoadParaData(IStTxtPara para); void LoadSegmentData(ISegment seg); - void ResetGuessCache(); + void ResetGuessCache(bool parsingMode); bool UpdatingOccurrence(IAnalysis oldAnalysis, IAnalysis newAnalysis); void RecordGuessIfNotKnown(AnalysisOccurrence occurrence); IAnalysis GetGuessForWordform(IWfiWordform wf, int ws); @@ -2533,10 +2548,11 @@ protected virtual void SetInt(int hvo, int flid, int n) #region IParaDataLoader Members - public void ResetGuessCache() + public void ResetGuessCache(bool parsingMode) { // recreate the guess services, so they will use the latest FDO data. GuessServices.ClearGuessData(); + GuessServices.PrioritizeParser = parsingMode; // clear the cache for the guesses, so it won't have any stale data. m_guessCache.ClearPropFromCache(InterlinViewDataCache.AnalysisMostApprovedFlid); } diff --git a/Src/LexText/Interlinear/SandboxBase.ComboHandlers.cs b/Src/LexText/Interlinear/SandboxBase.ComboHandlers.cs index f1dbb5189e..a21f974d34 100644 --- a/Src/LexText/Interlinear/SandboxBase.ComboHandlers.cs +++ b/Src/LexText/Interlinear/SandboxBase.ComboHandlers.cs @@ -1125,7 +1125,7 @@ private void AddAnalysesOf(IWfiWordform wordform, bool fBaseWordIsPhrase) return; // no real wordform, can't have analyses. ITsStrBldr builder = TsStringUtils.MakeStrBldr(); ITsString space = TsStringUtils.MakeString(fBaseWordIsPhrase ? " " : " ", m_wsVern); - var guess_services = new AnalysisGuessServices(m_caches.MainCache); + var guess_services = new AnalysisGuessServices(m_caches.MainCache, m_sandbox.InterlinDoc.GetMaster().GetParsingMode()); var sorted_analyses = guess_services.GetSortedAnalysisGuesses(wordform, m_wsVern); foreach (IWfiAnalysis wa in sorted_analyses) { @@ -3201,7 +3201,7 @@ private void AddComboItems(ref int hvoEmptyGloss, ITsStrBldr tsb, IWfiAnalysis w { IList wsids = m_sandbox.m_choices.EnabledWritingSystemsForFlid(InterlinLineChoices.kflidWordGloss); - var guess_services = new AnalysisGuessServices(m_caches.MainCache); + var guess_services = new AnalysisGuessServices(m_caches.MainCache, m_sandbox.InterlinDoc.GetMaster().GetParsingMode()); var sorted_glosses = guess_services.GetSortedGlossGuesses(wa); foreach (IWfiGloss gloss in sorted_glosses) { From b76ce01396e727c8c8b3f5a454bbb5dd3ad98157 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Wed, 18 Jun 2025 11:04:40 -0700 Subject: [PATCH 2/5] Fix LT-21945: Rename menu items --- .../Configuration/Words/areaConfiguration.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DistFiles/Language Explorer/Configuration/Words/areaConfiguration.xml b/DistFiles/Language Explorer/Configuration/Words/areaConfiguration.xml index 7a6458af91..10fee39719 100644 --- a/DistFiles/Language Explorer/Configuration/Words/areaConfiguration.xml +++ b/DistFiles/Language Explorer/Configuration/Words/areaConfiguration.xml @@ -28,10 +28,10 @@ - + - + @@ -293,8 +293,8 @@ - - + + From 4892328732c824d186d3daee68a45a2fc23df59f Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Fri, 20 Jun 2025 08:13:02 -0700 Subject: [PATCH 3/5] Incorporate liblcm with related changes --- Build/mkall.targets | 2 +- Build/nuget-common/packages.config | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Build/mkall.targets b/Build/mkall.targets index e9f0dc10be..cd1ff51237 100644 --- a/Build/mkall.targets +++ b/Build/mkall.targets @@ -285,7 +285,7 @@ 5.2.0-beta0003 15.0.0-beta0117 9.4.0.1-beta - 11.0.0-beta0121 + 11.0.0-beta0124 70.1.123 3.6.1 1.1.1-beta0001 diff --git a/Build/nuget-common/packages.config b/Build/nuget-common/packages.config index d84860f035..c098de7ccf 100644 --- a/Build/nuget-common/packages.config +++ b/Build/nuget-common/packages.config @@ -51,15 +51,15 @@ - - - - - - - - - + + + + + + + + + From 6add113abb81e3347f494b3db0b8e749ccbf614d Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Fri, 20 Jun 2025 09:51:18 -0700 Subject: [PATCH 4/5] Fix unit tests --- Src/LexText/Interlinear/InterlinVc.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Src/LexText/Interlinear/InterlinVc.cs b/Src/LexText/Interlinear/InterlinVc.cs index 39d13f1b69..bc37c4ff5b 100644 --- a/Src/LexText/Interlinear/InterlinVc.cs +++ b/Src/LexText/Interlinear/InterlinVc.cs @@ -379,6 +379,8 @@ public void ResetAnalysisCache() public bool GetParsingMode() { + if (RootSite?.GetMaster() == null) + return false; return RootSite.GetMaster().GetParsingMode(); } From 5c2938915b25f89af47b998e296623e5f9f10ae2 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Mon, 23 Jun 2025 09:31:03 -0700 Subject: [PATCH 5/5] Fixed problems reported by Jason --- Src/LexText/Interlinear/ChooseAnalysisHandler.cs | 10 ++++++---- Src/LexText/Interlinear/InterlinMaster.cs | 6 +++--- Src/LexText/Interlinear/InterlinVc.cs | 12 ++++++------ .../Interlinear/SandboxBase.ComboHandlers.cs | 13 +++++++++++-- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Src/LexText/Interlinear/ChooseAnalysisHandler.cs b/Src/LexText/Interlinear/ChooseAnalysisHandler.cs index ec9a56098c..79d284bec3 100644 --- a/Src/LexText/Interlinear/ChooseAnalysisHandler.cs +++ b/Src/LexText/Interlinear/ChooseAnalysisHandler.cs @@ -282,7 +282,7 @@ public void SetupCombo() var wordform = m_owner.GetWordformOfAnalysis(); // Add the analyses, and recursively the other items. - var guess_services = new AnalysisGuessServices(m_cache, GetParsingMode()); + var guess_services = new AnalysisGuessServices(m_cache, IsParsingMode()); var sorted_analyses = guess_services.GetSortedAnalysisGuesses(wordform, m_occurrence, false); foreach (var wa in sorted_analyses) { @@ -311,7 +311,7 @@ void AddAnalysisItems(IWfiAnalysis wa) { AddItem(wa, MakeAnalysisStringRep(wa, m_cache, StyleSheet != null, (m_owner as SandboxBase).RawWordformWs), true); - var guess_services = new AnalysisGuessServices(m_cache, GetParsingMode()); + var guess_services = new AnalysisGuessServices(m_cache, IsParsingMode()); var sorted_glosses = guess_services.GetSortedGlossGuesses(wa, m_occurrence); foreach (var gloss in sorted_glosses) { @@ -323,9 +323,11 @@ void AddAnalysisItems(IWfiAnalysis wa) AddItem(wa, MakeSimpleString(ITextStrings.ksNewWordGloss), false, WfiGlossTags.kClassId); } - private bool GetParsingMode() + private bool IsParsingMode() { - return Owner.InterlinDoc.GetMaster().GetParsingMode(); + if (Owner?.InterlinDoc?.GetMaster() == null) + return false; + return Owner.InterlinDoc.GetMaster().IsParsingMode(); } protected ITsString MakeSimpleString(String str) diff --git a/Src/LexText/Interlinear/InterlinMaster.cs b/Src/LexText/Interlinear/InterlinMaster.cs index abd9e3f33e..e5aca1c26c 100644 --- a/Src/LexText/Interlinear/InterlinMaster.cs +++ b/Src/LexText/Interlinear/InterlinMaster.cs @@ -725,7 +725,7 @@ public override void Init(Mediator mediator, PropertyTable propertyTable, XmlNod m_mediator = mediator; // InitBase will do this, but we need it in place before calling SetInitialTabPage(). m_propertyTable = propertyTable; - SetParsingMode(GetParsingMode()); + SetParsingMode(IsParsingMode()); // Making the tab control currently requires this first... if (!fHideTitlePane) @@ -1256,7 +1256,7 @@ public bool OnDisplaySetParsingMode(object commandObject, { var cmd = (Command)commandObject; bool value = cmd.GetParameter("value") == "true"; - display.Checked = GetParsingMode() == value; + display.Checked = IsParsingMode() == value; return true; } @@ -1286,7 +1286,7 @@ public void SetParsingMode(bool value) } } - public bool GetParsingMode() + public bool IsParsingMode() { return m_propertyTable.GetBoolProperty("ParsingMode", false, PropertyTable.SettingsGroup.LocalSettings); } diff --git a/Src/LexText/Interlinear/InterlinVc.cs b/Src/LexText/Interlinear/InterlinVc.cs index bc37c4ff5b..83380f468b 100644 --- a/Src/LexText/Interlinear/InterlinVc.cs +++ b/Src/LexText/Interlinear/InterlinVc.cs @@ -373,15 +373,15 @@ public void ResetAnalysisCache() if (m_loader != null) { CheckDisposed(); - m_loader.ResetGuessCache(GetParsingMode()); + m_loader.ResetGuessCache(IsParsingMode()); } } - public bool GetParsingMode() + internal bool IsParsingMode() { if (RootSite?.GetMaster() == null) return false; - return RootSite.GetMaster().GetParsingMode(); + return RootSite.GetMaster().IsParsingMode(); } internal AnalysisGuessServices GuessServices @@ -390,7 +390,7 @@ internal AnalysisGuessServices GuessServices { if (m_loader != null && m_loader.GuessServices != null) return m_loader.GuessServices; - return new AnalysisGuessServices(m_cache, GetParsingMode()); + return new AnalysisGuessServices(m_cache, IsParsingMode()); } } @@ -551,7 +551,7 @@ private void SetGuessing(IVwEnv vwenv, int bgColor) private int GetGuessColor(ICmObject obj) { IWfiAnalysis wa; - if (GetParsingMode()) + if (IsParsingMode()) { // Parser approval takes precedence over User approval. wa = (obj is IWfiGloss) ? ((IWfiGloss)obj).Analysis : obj as IWfiAnalysis; @@ -2305,7 +2305,7 @@ private void EnsureLoader() internal virtual IParaDataLoader CreateParaLoader() { - return new InterlinViewCacheLoader(new AnalysisGuessServices(m_cache, GetParsingMode()), GuessCache); + return new InterlinViewCacheLoader(new AnalysisGuessServices(m_cache, IsParsingMode()), GuessCache); } internal void RecordGuessIfNotKnown(AnalysisOccurrence selected) diff --git a/Src/LexText/Interlinear/SandboxBase.ComboHandlers.cs b/Src/LexText/Interlinear/SandboxBase.ComboHandlers.cs index a21f974d34..a0fb2f2838 100644 --- a/Src/LexText/Interlinear/SandboxBase.ComboHandlers.cs +++ b/Src/LexText/Interlinear/SandboxBase.ComboHandlers.cs @@ -115,6 +115,15 @@ internal InterlinComboHandler(SandboxBase sandbox) m_rootb = sandbox.RootBox; } + internal bool IsParsingMode() + { + if (m_sandbox.InterlinDoc?.GetMaster() == null) + return false; + return m_sandbox.InterlinDoc.GetMaster().IsParsingMode(); + } + + + // only for testing internal void SetSandboxForTesting(SandboxBase sandbox) { @@ -1125,7 +1134,7 @@ private void AddAnalysesOf(IWfiWordform wordform, bool fBaseWordIsPhrase) return; // no real wordform, can't have analyses. ITsStrBldr builder = TsStringUtils.MakeStrBldr(); ITsString space = TsStringUtils.MakeString(fBaseWordIsPhrase ? " " : " ", m_wsVern); - var guess_services = new AnalysisGuessServices(m_caches.MainCache, m_sandbox.InterlinDoc.GetMaster().GetParsingMode()); + var guess_services = new AnalysisGuessServices(m_caches.MainCache, IsParsingMode()); var sorted_analyses = guess_services.GetSortedAnalysisGuesses(wordform, m_wsVern); foreach (IWfiAnalysis wa in sorted_analyses) { @@ -3201,7 +3210,7 @@ private void AddComboItems(ref int hvoEmptyGloss, ITsStrBldr tsb, IWfiAnalysis w { IList wsids = m_sandbox.m_choices.EnabledWritingSystemsForFlid(InterlinLineChoices.kflidWordGloss); - var guess_services = new AnalysisGuessServices(m_caches.MainCache, m_sandbox.InterlinDoc.GetMaster().GetParsingMode()); + var guess_services = new AnalysisGuessServices(m_caches.MainCache, IsParsingMode()); var sorted_glosses = guess_services.GetSortedGlossGuesses(wa); foreach (IWfiGloss gloss in sorted_glosses) {