internal void UpdateMorphBreaks(string sMorphs) { if (sMorphs != null && sMorphs.Trim().Length > 0) sMorphs = sMorphs.Trim(); else return; ISilDataAccess sda = m_caches.DataAccess; IVwCacheDa cda = (IVwCacheDa)m_caches.DataAccess; // Compare to the actual original form of the sandbox wordform var wf = m_sandbox.GetWordformOfAnalysis(); ITsString tssWordform = m_sandbox.FindAFullWordForm(wf); string wordform = StrFromTss(tssWordform); if (wordform == sMorphs) { // The only wordform choice in the list is the wordform of // some current analysis. We want to switch to that original wordform. // We do NOT want to look up the default, because that could well have an // existing morpheme breakdown, preventing us from getting back to the original // whole word. m_sandbox.SetWordform(tssWordform, false); return; } // We want to try to break this down into morphemes. // nb: use sda.Replace rather than cds.CachVecProp so that this registers as a change // in need of saving. int coldMorphs = sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); sda.Replace(m_hvoSbWord, ktagSbWordMorphs, 0, coldMorphs, new int[0], 0); sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, m_hvoSbWord, ktagSbWordMorphs, 0, 0, coldMorphs); MorphemeBreaker mb = new MorphemeBreaker(m_caches, sMorphs, m_hvoSbWord, m_wsVern, m_sandbox); mb.Run(); m_rootb.Reconstruct(); // Everything changed, more or less. // We've changed properties that the morph manager cares about, but we don't want it // to fire when we fix the selection. m_sandbox.m_editMonitor.NeedMorphemeUpdate = false; }
public override bool HandleReturnKey() { CheckDisposed(); IVwCacheDa cda = (IVwCacheDa)m_caches.DataAccess; ISilDataAccess sda = m_caches.DataAccess; int cmorphs = MorphCount; // JohnT: 0 is fine, that's what we see for a word which has no known analyses and // shows up as *** on the morphs line. //Debug.Assert(cmorphs != 0); for (int imorph = 0; imorph < cmorphs; ++imorph) { int hvoMbSec = MorphHvo(imorph); // Erase all the information. cda.CacheObjProp(hvoMbSec, ktagSbMorphForm, 0); cda.CacheObjProp(hvoMbSec, ktagSbMorphEntry, 0); cda.CacheObjProp(hvoMbSec, ktagSbMorphGloss, 0); cda.CacheObjProp(hvoMbSec, ktagSbMorphPos, 0); cda.CacheStringProp(hvoMbSec, ktagSbMorphPrefix, null); cda.CacheStringProp(hvoMbSec, ktagSbMorphPostfix, null); // Send notifiers for each of these deleted items. sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, hvoMbSec, ktagSbMorphForm, 0, 1, 1); sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, hvoMbSec, ktagSbMorphEntry, 0, 0, 1); sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, hvoMbSec, ktagSbMorphGloss, 0, 0, 1); sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, hvoMbSec, ktagSbMorphPos, 0, 0, 1); sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, hvoMbSec, ktagSbMorphPrefix, 0, 0, 1); sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, hvoMbSec, ktagSbMorphPostfix, 0, 0, 1); } // Now erase the morph bundles themselves. cda.CacheVecProp(m_hvoSbWord, ktagSbWordMorphs, new int[0], 0); sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, m_hvoSbWord, ktagSbWordMorphs, 0, 0, 1); MorphemeBreaker mb = new MorphemeBreaker(m_caches, ComboList.Text, m_hvoSbWord, m_wsVern, m_sandbox); mb.Run(); m_rootb.Reconstruct(); // Everything changed, more or less. // Todo: having called reconstruct, selection is invalid, may have to do // something special about making a new one. return true; }