Exemplo n.º 1
0
        /// <summary>Handle possible homograph number changes:
        /// 1. Possibly remove homograph from original citation form.
        /// 2. Possibly add homograph for new citation form.
        /// </summary>
        public void Fixup(bool fRefreshList)
        {
            CheckDisposed();

            Debug.Assert(m_le != null);
            if (m_le.IsValidObject())
            {
                string currentHomographForm = m_le.HomographForm;
                int    currentMorphType     = m_le.MorphType;
                if (currentHomographForm == m_originalHomographForm &&
                    currentMorphType == m_originalMorphType)
                {
                    // No relevant changes, so do nothing.
                    return;
                }

                List <ILexEntry> ieAllEntries = new List <ILexEntry>(m_le.Cache.LangProject.LexDbOA.EntriesOC.ToArray());
                // Reset any homograph numbers associated with the old form.
                // This version of CollectHomographs will exclude m_le,
                // which means all the old homographs of the entry will be renumbered.
                List <ILexEntry> homographs = LexEntry.CollectHomographs(m_originalHomographForm,
                                                                         0, // Collect all of them.
                                                                         ieAllEntries,
                                                                         m_originalMorphType);
                LexEntry.ValidateExistingHomographs(homographs);
                // Set any homograph numbers associated with the new form,
                // and include m_le in the renumbering.
                homographs = LexEntry.CollectHomographs(currentHomographForm,
                                                        0, // Collect all of them.
                                                        ieAllEntries,
                                                        currentMorphType);
                LexEntry.ValidateExistingHomographs(homographs);

                // Fix it so that another call will do the right thing.
                m_originalHomographForm = currentHomographForm;
                m_originalMorphType     = currentMorphType;
            }
            else
            {
                // If our old entry isn't even valid any more, something has deleted it,
                // and whatever did so should have fixed up the list. We really don't want
                // to reload the whole thing if we don't need to (takes ages in a big lexicon),
                // so do nothing...JohnT
                return;
            }
            if (fRefreshList && m_rlu != null)
            {
                m_rlu.UpdateList(false);
            }
        }