Exemplo n.º 1
0
 public override ITsString get_StringProp(int hvo, int tag)
 {
     if (tag == m_headwordFlid)
     {
         int hn;
         if (m_homographNumbers.TryGetValue(hvo, out hn))
         {
             var entry = m_entryRepo.GetObject(hvo);
             return(StringServices.HeadWordForWsAndHn(entry, Cache.DefaultVernWs, hn));
         }
         // In case it's one we somehow don't know about, we'll let the base method try to get the real HN.
     }
     else if (tag == m_senseOutlineFlid)
     {
         var sense = m_senseRepo.GetObject(hvo);
         return(GetSenseNumberTss(sense));
     }
     return(base.get_StringProp(hvo, tag));
 }
Exemplo n.º 2
0
            /// <summary>
            /// Put the sandbox info into the real WfiAnalysis (based on the m_hvoWfiAnalysis id).
            /// </summary>
            /// <returns>'true', if anything changed, otherwise 'false'.</returns>
            internal bool UpdateRealAnalysis()
            {
                var isDirty = false;

                BuildMorphLists();

                /* Sets these three variables up.
                 * m_analysisMorphs = new int[m_cmorphs];
                 * m_analysisMsas = new int[m_cmorphs];
                 * m_analysisSenses = new int[m_cmorphs];
                 */
                m_sdaMain.BeginUndoTask(MEStrings.ksUndoEditAnalysis, MEStrings.ksRedoEditAnalysis);

                try
                {
                    Debug.Assert(m_anal.MorphBundlesOS.Count == m_cmorphs);                     // Better be the same.
                    for (var imorph = 0; imorph < m_cmorphs; imorph++)
                    {
                        var mb = m_anal.MorphBundlesOS[imorph];

                        // Process Morph.
                        var oldHvo = mb.MorphRA == null ? 0 : mb.MorphRA.Hvo;
                        var newHvo = m_analysisMorphs[imorph];
                        if (oldHvo != newHvo)
                        {
                            if (newHvo == 0 && oldHvo != 0)
                            {
                                // Change to 'unknown'. Will no longer be able to use the morph property to get
                                // at the actual form, so reinstate it in the bundle.
                                foreach (IWritingSystem ws in mb.Cache.ServiceLocator.WritingSystems.VernacularWritingSystems)
                                {
                                    mb.Form.set_String(ws.Handle, mb.Cache.MainCacheAccessor.get_MultiStringAlt(oldHvo, MoFormTags.kflidForm, ws.Handle));
                                }
                            }
                            mb.MorphRA = m_moFormRepos.GetObject(newHvo);
                            isDirty    = true;
                        }

                        // Process Sense.
                        oldHvo = mb.SenseRA == null ? 0 : mb.SenseRA.Hvo;
                        newHvo = m_analysisSenses[imorph];
                        if (oldHvo != newHvo)
                        {
                            mb.SenseRA = m_senseRepos.GetObject(newHvo);
                            isDirty    = true;
                        }

                        // Process MSA.
                        oldHvo = mb.MsaRA == null ? 0 : mb.MsaRA.Hvo;
                        newHvo = m_analysisMsas[imorph];
                        if (oldHvo == newHvo)
                        {
                            continue;
                        }
                        mb.MsaRA = m_msaRepos.GetObject(newHvo);
                        isDirty  = true;
                    }
                }
                finally
                {
                    if (isDirty)
                    {
                        m_sdaMain.EndUndoTask();
                    }
                    else
                    {
                        m_sdaMain.Rollback();
                    }
                }
                return(isDirty);
            }