/// ------------------------------------------------------------------------------------ /// <summary> /// Returns true if the given reference is recognized as that of an introduction section. /// (provides a static equivalent of this.IsIntro). /// </summary> /// <param name="cache">The FDO cache.</param> /// <param name="hvoSection">The hvo of the section.</param> /// <remarks> /// This method exists strictly as a performance enhancement and can be replaced by a /// direct call to IsIntro when the cache is ported and it is inexpensive to access the /// real ScrSection object. /// We come here a lot (gets called from Update handler), so we don't want to construct /// a ScrSection object here but get the value we're interested in directly from the /// cache. Creating a ScrSection object checks if the HVO is valid. In doing so it does /// a query on the database (select Class$ from CmObject...) This happens only in Debug, /// but getting the interesting value directly from the cache makes it easier to do SQL /// profiling. /// </remarks> /// ------------------------------------------------------------------------------------ public static bool IsIntroSection(FdoCache cache, int hvoSection) { return BCVRef.GetVerseFromBcv(cache.GetIntProperty(hvoSection, (int)ScrSection.ScrSectionTags.kflidVerseRefEnd)) == 0; }
/// <summary> /// Sort the changes (by beginOffset) /// </summary> public void SortChanges(FdoCache cache) { m_changes.Sort( delegate(int left, int right) { return cache.GetIntProperty(left, kflidBeginOffset).CompareTo( cache.GetIntProperty(right, kflidBeginOffset)); }); }
/// <summary> /// get the ws at the twfic's BeginOffset in its paragraph. /// </summary> /// <param name="cache">The cache.</param> /// <param name="hvoTwfic">The hvo twfic.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public static int GetTwficWs(FdoCache cache, int hvoTwfic) { Debug.Assert(cache.IsValidObject(hvoTwfic, CmBaseAnnotation.kClassId), String.Format("expected valid hvo({0}).", hvoTwfic)); if (hvoTwfic <= 0 && !cache.IsDummyObject(hvoTwfic)) throw new ArgumentException(String.Format("expected valid hvo({0}).", hvoTwfic)); int hvoPara = cache.GetObjProperty(hvoTwfic, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginObject); int ichBeginOffset = cache.GetIntProperty(hvoTwfic, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginOffset); int ws = GetWsAtParaOffset(cache, hvoPara, ichBeginOffset); return ws; }
/// <summary> /// Figure what the new contents needs to be. (Also sets OldContents.) /// </summary> /// <param name="cache"></param> public void MakeNewContents(FdoCache cache, string oldSpelling, string newSpelling, RespellUndoAction action) { m_oldContents = RespellUndoAction.AnnotationTargetString(m_hvoTarget, m_flid, m_ws, cache); ITsStrBldr bldr = m_oldContents.GetBldr(); SortChanges(cache); for (int i = m_changes.Count - 1; i >= 0; i--) { int ichMin = cache.GetIntProperty(m_changes[i], (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginOffset); int ichLim = cache.GetIntProperty(m_changes[i], (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidEndOffset); string replacement = action.Replacement(action.OldOccurrence(m_changes[i])); bldr.Replace(ichMin, ichLim, replacement, null); } m_newContents = bldr.GetString(); }