static internal int InsertObjectIntoVirtualBackref(FdoCache cache, Mediator mediator, IVwVirtualHandler vh, int hvoSlice, uint clidNewObj, uint clidOwner, uint flid) { if (vh != null) { int clidSlice = cache.GetClassOfObject(hvoSlice); if (clidNewObj == LexEntry.kclsidLexEntry && clidSlice == LexEntry.kclsidLexEntry && clidOwner == LexDb.kclsidLexDb) { if (vh.FieldName == "VariantFormEntryBackRefs") { using (InsertVariantDlg dlg = new InsertVariantDlg()) { ILexEntry entOld = LexEntry.CreateFromDBObject(cache, hvoSlice); dlg.SetHelpTopic("khtpInsertVariantDlg"); dlg.SetDlgInfo(cache, mediator, entOld as IVariantComponentLexeme); if (dlg.ShowDialog() == DialogResult.OK && dlg.NewlyCreatedVariantEntryRefResult) { int insertPos = cache.GetVectorSize(hvoSlice, (int)flid); cache.PropChanged(hvoSlice, (int)flid, insertPos, 1, 0); return insertPos; } // say we've handled this. return -2; } } } } return -1; }
// Make a string representing a WfiAnalysis, suitable for use in a combo box item. static internal ITsString MakeAnalysisStringRep(int hvoWa, FdoCache fdoCache, bool fUseStyleSheet, int wsVern) { // ITsTextProps boldItalicAnalysis = BoldItalicAnalysis(fdoCache); // ITsTextProps italicAnalysis = ItalicAnalysis(fdoCache, Sandbox.SandboxVc.krgbRed); ITsTextProps posTextProperties = PartOfSpeechTextProperties(fdoCache, true, fUseStyleSheet); ITsTextProps formTextProperties = FormTextProperties(fdoCache, fUseStyleSheet, wsVern); ITsTextProps glossTextProperties = GlossTextProperties(fdoCache, true, fUseStyleSheet); ITsStrBldr tsb = TsStrBldrClass.Create(); ISilDataAccess sda = fdoCache.MainCacheAccessor; int cmorph = fdoCache.GetVectorSize(hvoWa, (int)WfiAnalysis.WfiAnalysisTags.kflidMorphBundles); if (cmorph == 0) return fdoCache.MakeUserTss(ITextStrings.ksNoMorphemes); bool fRtl = fdoCache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(wsVern).RightToLeft; int start = 0; int lim = cmorph; int increment = 1; if (fRtl) { start = cmorph - 1; lim = -1; increment = -1; } for (int i = start; i != lim; i += increment) { int hvoMb = fdoCache.GetVectorItem(hvoWa, (int)WfiAnalysis.WfiAnalysisTags.kflidMorphBundles, i); int hvoMf = fdoCache.GetObjProperty(hvoMb, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph); ITsString tssForm = null; if (hvoMf != 0) { int hvoEntry = fdoCache.GetOwnerOfObject(hvoMf); int hvoLexemeForm = sda.get_ObjectProp(hvoEntry, (int) LexEntry.LexEntryTags.kflidLexemeForm); if (hvoLexemeForm != 0) { tssForm = sda.get_MultiStringAlt(hvoLexemeForm, (int) MoForm.MoFormTags.kflidForm, wsVern); } if (tssForm == null || tssForm.Length == 0) { tssForm = fdoCache.MainCacheAccessor.get_MultiStringAlt(hvoEntry, (int)LexEntry.LexEntryTags.kflidCitationForm, wsVern); } if (tssForm.Length == 0) { // If there isn't a lexeme form OR citation form use the form of the morph. tssForm = fdoCache.MainCacheAccessor.get_MultiStringAlt(hvoMf, (int)MoForm.MoFormTags.kflidForm, wsVern); } } else // no MoForm linked to this bundle, use its own form. { tssForm = fdoCache.MainCacheAccessor.get_MultiStringAlt(hvoMb, (int)WfiMorphBundle.WfiMorphBundleTags.kflidForm, wsVern); } int ichForm = tsb.Length; tsb.ReplaceTsString(ichForm, ichForm, tssForm); tsb.SetProperties(ichForm, tsb.Length,formTextProperties); // add category (part of speech) int hvoMsa = fdoCache.GetObjProperty(hvoMb, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMsa); tsb.Replace(tsb.Length, tsb.Length, " ", null); int ichMinMsa = tsb.Length; string interlinName = ksMissingString; if (hvoMsa != 0) { IMoMorphSynAnalysis msa = MoMorphSynAnalysis.CreateFromDBObject(fdoCache, hvoMsa); interlinName = msa.InterlinearAbbr; } tsb.Replace(ichMinMsa, ichMinMsa, interlinName, posTextProperties); //add sense int hvoSense = fdoCache.GetObjProperty(hvoMb, (int)WfiMorphBundle.WfiMorphBundleTags.kflidSense); tsb.Replace(tsb.Length, tsb.Length, " ", null); int ichMinSense = tsb.Length; if (hvoSense != 0) { ITsString tssGloss = fdoCache.MainCacheAccessor.get_MultiStringAlt(hvoSense, (int)LexSense.LexSenseTags.kflidGloss, fdoCache.DefaultAnalWs); tsb.Replace(ichMinSense, ichMinSense, tssGloss.Text, glossTextProperties); } else tsb.Replace(ichMinSense, ichMinSense, ksMissingString, glossTextProperties); // Enhance JohnT: use proper seps. tsb.Replace(tsb.Length, tsb.Length, ksPartSeparator, null); } // Delete the final separator. (Enhance JohnT: this needs to get smarter when we do // real seps.) int ichFrom = tsb.Length - ksPartSeparator.Length; if (ichFrom < 0) ichFrom = 0; tsb.Replace(ichFrom, tsb.Length, "", null); return tsb.GetString(); }