/// <summary> /// /// </summary> /// <param name="morphBundle"></param> /// <param name="wsVern"></param> /// <returns></returns> static public ITsString GetLexEntryTss(IWfiMorphBundle morphBundle, int wsVern) { LcmCache cache = morphBundle.Cache; LexEntryVc vcEntry = new LexEntryVc(cache); vcEntry.WritingSystemCode = wsVern; TsStringCollectorEnv collector = new TsStringCollectorEnv(null, cache.MainCacheAccessor, morphBundle.Hvo); collector.RequestAppendSpaceForFirstWordInNewParagraph = false; vcEntry.Display(collector, morphBundle.Hvo, (int)LexEntryVc.kfragEntryAndVariant); return(collector.Result); }
/// <summary> /// /// </summary> /// <param name="cache"></param> /// <param name="hvoEntryToDisplay"></param> /// <param name="wsVern"></param> /// <param name="ler"></param> /// <returns></returns> static public ITsString GetLexEntryTss(LcmCache cache, int hvoEntryToDisplay, int wsVern, ILexEntryRef ler) { LexEntryVc vcEntry = new LexEntryVc(cache); vcEntry.WritingSystemCode = wsVern; TsStringCollectorEnv collector = new TsStringCollectorEnv(null, cache.MainCacheAccessor, hvoEntryToDisplay); collector.RequestAppendSpaceForFirstWordInNewParagraph = false; vcEntry.Display(collector, hvoEntryToDisplay, (int)VcFrags.kfragHeadWord); if (ler != null) { vcEntry.Display(collector, ler.Hvo, LexEntryVc.kfragVariantTypes); } return(collector.Result); }
/// <summary> /// Displays a MorphBundle, setting the colors of its parts. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo">WfiMorphBundle</param> private void DisplayMorphBundle(IVwEnv vwenv, int hvo) { IWfiMorphBundle wmb = null; if (hvo != 0) wmb = m_wmbRepository.GetObject(hvo); vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenInnerPile(); int first = m_lineChoices.FirstMorphemeIndex; int last = m_lineChoices.LastMorphemeIndex; IMoForm mf = null; if (wmb != null) mf = wmb.MorphRA; if (vwenv is CollectorEnv && mf != null) { // Collectors are given an extra initial chance to 'collect' the morph type, if any. vwenv.AddObjProp(WfiMorphBundleTags.kflidMorph, this, kfragMorphType); } for (int i = first; i <= last; i++) { InterlinLineSpec spec = m_lineChoices[i]; SetColor(vwenv, LabelRGBFor(spec)); switch (spec.Flid) { case InterlinLineChoices.kflidMorphemes: if (wmb == null) { vwenv.AddString(m_tssMissingMorph); } else if (mf == null) { // displaying morphemes should be int ws = 0; if (wmb.MorphRA != null) { Debug.Assert(spec.StringFlid == MoFormTags.kflidForm); ws = GetRealWsOrBestWsForContext(wmb.MorphRA.Hvo, spec); } // If no morph, use the form of the morph bundle (and the entry is of // course missing) if (ws == 0) { ws = WritingSystemServices.ActualWs(m_cache, spec.WritingSystem, wmb.Hvo, WfiMorphBundleTags.kflidForm); } vwenv.AddStringAltMember( WfiMorphBundleTags.kflidForm, ws, this); } else { // Got a morph, show it. vwenv.AddObjProp(WfiMorphBundleTags.kflidMorph, this, kfragMorphFormChoices + i); // And the LexEntry line. } break; case InterlinLineChoices.kflidLexEntries: if (mf == null) { if (hvo != 0) vwenv.NoteDependency(new int[] { hvo }, new int[] { WfiMorphBundleTags.kflidMorph }, 1); vwenv.AddString(m_tssMissingEntry); } else { int ws = GetRealWsOrBestWsForContext(mf.Hvo, spec); if (ws == 0) ws = spec.WritingSystem; LexEntryVc vcEntry = new LexEntryVc(m_cache); vcEntry.WritingSystemCode = ws; vwenv.AddObj(hvo, vcEntry, LexEntryVc.kfragEntryAndVariant); } break; case InterlinLineChoices.kflidLexGloss: int flid = 0; if (wmb != null) { vwenv.NoteDependency(new[] { wmb.Hvo }, new[] { WfiMorphBundleTags.kflidMorph }, 1); vwenv.NoteDependency(new[] { wmb.Hvo }, new[] { WfiMorphBundleTags.kflidInflType }, 1); vwenv.NoteDependency(new[] { hvo }, new[] { WfiMorphBundleTags.kflidSense }, 1); if (wmb.SenseRA == null) { if (ShowDefaultSense && wmb.DefaultSense != null && UsingGuess) { flid = wmb.Cache.MetaDataCacheAccessor.GetFieldId2(WfiMorphBundleTags.kClassId, "DefaultSense", false); } } else { flid = WfiMorphBundleTags.kflidSense; if (wmb.MorphRA != null && DisplayLexGlossWithInflType(vwenv, wmb.MorphRA.Owner as ILexEntry, wmb.SenseRA, spec, wmb.InflTypeRA)) { break; } } } if (flid == 0) vwenv.AddString(m_tssMissingSense); else vwenv.AddObjProp(flid, this, kfragLineChoices + i); break; case InterlinLineChoices.kflidLexPos: // LexPOS line: int hvoMsa = 0; if (wmb != null && wmb.MsaRA != null) hvoMsa = wmb.MsaRA.Hvo; if (hvoMsa == 0) { if (hvo != 0) vwenv.NoteDependency(new int[] { hvo }, new int[] { WfiMorphBundleTags.kflidMsa }, 1); vwenv.AddString(m_tssMissingMsa); } else { // Use a special view constructor that knows how to display the // interlinear view of whatever kind of MSA it is. // Enhance JohnT: ideally we would have one of these VCs for each writing system, // perhaps stored in the InterlinLineSpec. Currently displaying multiple Wss of LexPos // is not useful, though it is possible. // Enhancement RickM: we set the m_msaVc.DefaultWs to the selected writing system // of each LexPos line in interlinear. This is used extract the LexPos abbreviation // for the specific writing system. m_msaVc.DefaultWs = spec.WritingSystem; vwenv.AddObjProp(WfiMorphBundleTags.kflidMsa, m_msaVc, (int)VcFrags.kfragInterlinearAbbr); } break; } } vwenv.CloseInnerPile(); }
/// <summary> /// /// </summary> /// <param name="morphBundle"></param> /// <param name="wsVern"></param> /// <returns></returns> static public ITsString GetLexEntryTss(IWfiMorphBundle morphBundle, int wsVern) { FdoCache cache = morphBundle.Cache; LexEntryVc vcEntry = new LexEntryVc(cache); vcEntry.WritingSystemCode = wsVern; TsStringCollectorEnv collector = new TsStringCollectorEnv(null, cache.MainCacheAccessor, morphBundle.Hvo); collector.RequestAppendSpaceForFirstWordInNewParagraph = false; vcEntry.Display(collector, morphBundle.Hvo, (int)LexEntryVc.kfragEntryAndVariant); return collector.Result; }
/// <summary> /// /// </summary> /// <param name="cache"></param> /// <param name="hvoEntryToDisplay"></param> /// <param name="wsVern"></param> /// <param name="ler"></param> /// <returns></returns> static public ITsString GetLexEntryTss(FdoCache cache, int hvoEntryToDisplay, int wsVern, ILexEntryRef ler) { LexEntryVc vcEntry = new LexEntryVc(cache); vcEntry.WritingSystemCode = wsVern; TsStringCollectorEnv collector = new TsStringCollectorEnv(null, cache.MainCacheAccessor, hvoEntryToDisplay); collector.RequestAppendSpaceForFirstWordInNewParagraph = false; vcEntry.Display(collector, hvoEntryToDisplay, (int)VcFrags.kfragHeadWord); if (ler != null) vcEntry.Display(collector, ler.Hvo, LexEntryVc.kfragVariantTypes); return collector.Result; }
/// <summary> /// /// </summary> /// <param name="vwenv"></param> /// <param name="hvo">WfiMorphBundle</param> private void DisplayMorphBundle(IVwEnv vwenv, int hvo) { vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, 10000); vwenv.OpenInnerPile(); int first = m_lineChoices.FirstMorphemeIndex; int last = m_lineChoices.LastMorphemeIndex; int hvoMf = 0; if (hvo != 0) { hvoMf = m_cache.GetObjProperty(hvo, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph); } if (vwenv is CollectorEnv && hvoMf != 0) { // Collectors are given an extra initial chance to 'collect' the morph type, if any. vwenv.AddObjProp((int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph, this, kfragMorphType); } for (int i = first; i <= last; i++) { InterlinLineSpec spec = m_lineChoices[i]; int ws = 0; if (hvo != 0) { ws = GetRealWs(hvo, spec); } SetColor(vwenv, LabelRGBFor(spec)); switch (spec.Flid) { case InterlinLineChoices.kflidMorphemes: if (hvo == 0) { vwenv.AddString(m_tssMissingMorph); } else if (hvoMf == 0) { // If no morph, use the form of the morph bundle (and the entry is of // course missing) if (ws == 0) { ws = m_cache.LangProject.ActualWs(spec.WritingSystem, hvo, (int)WfiMorphBundle.WfiMorphBundleTags.kflidForm); } vwenv.AddStringAltMember( (int)WfiMorphBundle.WfiMorphBundleTags.kflidForm, ws, this); } else { // Got a morph, show it. vwenv.AddObjProp((int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph, this, kfragMorphFormChoices + i); // And the LexEntry line. } break; case InterlinLineChoices.kflidLexEntries: if (hvoMf == 0) { if (hvo != 0) vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph }, 1); vwenv.AddString(m_tssMissingEntry); } else { if (ws == 0) ws = spec.WritingSystem; LexEntryVc vcEntry = new LexEntryVc(m_cache); vcEntry.WritingSystemCode = ws; vwenv.AddObj(hvo, vcEntry, LexEntryVc.kfragEntryAndVariant); } break; case InterlinLineChoices.kflidLexGloss: int hvoSense = 0; if (hvo != 0) { hvoSense = m_cache.GetObjProperty(hvo, (int)WfiMorphBundle.WfiMorphBundleTags.kflidSense); } if (hvoSense == 0) { int virtFlid = 0; if (hvo != 0) { vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)WfiMorphBundle.WfiMorphBundleTags.kflidSense }, 1); virtFlid = BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiMorphBundle", "DefaultSense"); } if (hvo != 0 && ShowDefaultSense && m_cache.GetObjProperty(hvo, virtFlid) > 0) { // Switch values when using the default sense, rather than the missing row '***'. SetGuessing(vwenv, false); vwenv.AddObjProp(virtFlid, this, kfragLineChoices + i); } else { vwenv.AddProp(ktagBundleMissingSense, this, kfragBundleMissingSense); } } else { vwenv.AddObjProp((int)WfiMorphBundle.WfiMorphBundleTags.kflidSense, this, kfragLineChoices + i); } break; case InterlinLineChoices.kflidLexPos: // LexPOS line: int hvoMsa = 0; if (hvo != 0) hvoMsa = m_cache.GetObjProperty(hvo, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMsa); if (hvoMsa == 0) { if (hvo != 0) vwenv.NoteDependency(new int[] { hvo }, new int[] { (int)WfiMorphBundle.WfiMorphBundleTags.kflidMsa }, 1); vwenv.AddString(m_tssMissingMsa); } else { // Use a special view constructor that knows how to display the // interlinear view of whatever kind of MSA it is. // Enhance JohnT: ideally we would have one of these VCs for each writing system, // perhaps stored in the InterlinLineSpec. Currently displaying multiple Wss of LexPos // is not useful, though it is possible. // Enhancement RickM: we set the m_msaVc.WritingSystemCode to the selected writing system // of each LexPos line in interlinear. This is used extract the LexPos abbreviation // for the specific writing system. m_msaVc.WritingSystemCode = spec.WritingSystem; vwenv.AddObjProp((int)WfiMorphBundle.WfiMorphBundleTags.kflidMsa, m_msaVc, (int)VcFrags.kfragInterlinearAbbr); } break; } } vwenv.CloseInnerPile(); }