/// <summary>
        /// If a reference is removed from the ComponentLexeme list, it must also be removed
        /// from the PrimaryLexeme list (if it exists there as well).
        /// </summary>
        /// <param name="hvo"></param>
        /// <param name="tag"></param>
        /// <param name="ivMin"></param>
        /// <param name="cvIns"></param>
        /// <param name="cvDel"></param>
        public void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
        {
            if (hvo != m_obj.Hvo ||
                m_obj.ClassID != LexEntryRef.kclsidLexEntryRef ||
                tag != (int)LexEntryRef.LexEntryRefTags.kflidComponentLexemes)
            {
                return;
            }
            ILexEntryRef ler = m_obj as ILexEntryRef;
            FdoReferenceSequence <ICmObject> rgobjComponent = ler.ComponentLexemesRS;

            if (cvDel > cvIns)
            {
                int[] rghvoPrimary = ler.PrimaryLexemesRS.HvoArray;
                for (int i = 0; i < rghvoPrimary.Length; ++i)
                {
                    if (!rgobjComponent.Contains(rghvoPrimary[i]))
                    {
                        ler.PrimaryLexemesRS.Remove(rghvoPrimary[i]);
                    }
                }
            }
            else if (cvIns > cvDel && ler.ComponentLexemesRS.Count == 1 && ler.PrimaryLexemesRS.Count == 0)
            {
                ler.PrimaryLexemesRS.Append(ler.ComponentLexemesRS[0]);
            }
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Writes this category to the the specified annotation, creating a new category if
        /// needed.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal void WriteToCache(IScrScriptureNote ann)
        {
            int ws = (string.IsNullOrEmpty(IcuLocale) ? ann.Cache.DefaultAnalWs :
                      ScrNoteImportManager.GetWsForLocale(IcuLocale));

            int hvo;

            if (CategoryPath.IndexOf(StringUtils.kchObject) != -1)
            {
                // The category specified the full path of the category possibility.
                hvo = ann.Cache.LangProject.TranslatedScriptureOA.NoteCategoriesOA.FindOrCreatePossibility(
                    CategoryPath, ws);
            }
            else
            {
                // The category does not contain a delimiter, so we may need to search
                // the entire possibility tree for a matching category in case it is a
                // sub-possibility.
                hvo = ann.Cache.LangProject.TranslatedScriptureOA.NoteCategoriesOA.FindOrCreatePossibility(
                    CategoryPath, ws, false);
            }

            FdoReferenceSequence <ICmPossibility> categoryList = ann.CategoriesRS;

            if (!categoryList.Contains(hvo))
            {
                categoryList.Append(hvo);
            }
        }