/// <summary> /// If hvoWordform is the hvo of a capitalized wordform which has no useful information, /// delete it. It is considered useless if /// - it has no occurrences /// - it has no anlyses /// - it doesn't have known incorrect spelling status. /// Note that the argument may be some other kind of object (typically a WfiAnalysis or WfiGloss). /// If so do nothing. /// </summary> public static void DeleteRedundantCapitalizedWordform(FdoCache cache, int hvoWordform) { if (cache.GetClassOfObject(hvoWordform) != WfiWordform.kclsidWfiWordform) return; if (cache.GetVectorProperty(hvoWordform, OccurrencesFlid(cache), true).Length != 0) return; if (cache.IsValidObject(hvoWordform)) { // If it's real it might have analyses etc. WfiWordform wf = (WfiWordform) CmObject.CreateFromDBObject(cache, hvoWordform); if (wf.AnalysesOC.Count > 0) return; // Arguably we should keep it for known correct spelling status. However, if it's ever been // confirmed as an analysis, even temporarily, it will have that. if (wf.SpellingStatus == (int)SpellingStatusStates.incorrect) return; } foreach (int ws in cache.LangProject.CurVernWssRS.HvoArray) { CaseFunctions cf = new CaseFunctions(cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(ws).IcuLocale); string text = cache.GetMultiStringAlt(hvoWordform, (int) WfiWordformTags.kflidForm, ws).Text; if (!String.IsNullOrEmpty(text) && cf.StringCase(text) == StringCaseStatus.allLower) return; } cache.DeleteObject(hvoWordform); }
internal static ITsString AnnotationTargetString(int hvoTarget, int flid, int ws, FdoCache cache) { ITsString tssValue; if (IsMultilingual(flid)) { tssValue = cache.GetMultiStringAlt(hvoTarget, flid, ws); } else { tssValue = cache.GetTsStringProperty(hvoTarget, flid); } return tssValue; }
internal static string[] AddStringFromOtherObj(XmlNode frag, int hvoTarget, FdoCache cache) { int flid = XmlVc.GetFlid(frag, hvoTarget, cache); ITsStrFactory tsf = TsStrFactoryClass.Create(); FieldType itype = cache.GetFieldType(flid); if ((itype == FieldType.kcptUnicode) || (itype == FieldType.kcptBigUnicode)) { return new string[] {cache.GetUnicodeProperty(hvoTarget, flid)}; } else if ((itype == FieldType.kcptString) || (itype == FieldType.kcptBigString)) { return new string[] { cache.GetTsStringProperty(hvoTarget, flid).Text }; } else // multistring of some type { int wsid = 0; string sep = ""; if (s_cwsMulti > 1) { string sLabelWs = XmlUtils.GetOptionalAttributeValue(frag, "ws"); if (sLabelWs != null && sLabelWs == "current") { sep = DisplayMultiSep(frag, cache) + DisplayWsLabel(s_qwsCurrent, cache); wsid = s_qwsCurrent.WritingSystem; } } if (wsid == 0) wsid = LangProject.GetWritingSystem(frag, cache, null, LangProject.kwsAnal); if ((itype == FieldType.kcptMultiUnicode) || (itype == FieldType.kcptMultiBigUnicode)) { return new string[] {sep, cache.GetMultiUnicodeAlt(hvoTarget, flid, wsid, null) }; } else { return new string[] {sep, cache.GetMultiStringAlt(hvoTarget, flid, wsid).Text }; } } }
private void SetupWritingSystemsForTitle(FdoCache cache) { m_ttpWsLabel = LgWritingSystem.AbbreviationTextProperties; m_writingSystems = new LgWritingSystem[2]; m_writingSystems[0] = new LgWritingSystem(cache, cache.DefaultVernWs); m_writingSystems[1] = new LgWritingSystem(cache, cache.DefaultAnalWs); m_WsLabels = new ITsString[m_writingSystems.Length]; int wsEn = cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr("en"); if (wsEn == 0) wsEn = cache.DefaultUserWs; if (wsEn == 0) wsEn = cache.FallbackUserWs; for (int i = 0; i < m_writingSystems.Length; i++) { //m_WsLabels[i] = LgWritingSystem.UserAbbr(cache, m_writingSystems[i].Hvo); // For now (August 2008), try English abbreviation before UI writing system. // (See LT-8185.) m_WsLabels[i] = cache.GetMultiStringAlt(m_writingSystems[i].Hvo, (int)LgWritingSystem.LgWritingSystemTags.kflidAbbr, wsEn); if (String.IsNullOrEmpty(m_WsLabels[i].Text)) m_WsLabels[i] = LgWritingSystem.UserAbbr(cache, m_writingSystems[i].Hvo); } }