Ejemplo n.º 1
0
        private void WriteReversalLetterHeadIfNeeded(int hvoItem)
        {
            int hvoOwner  = m_cache.GetOwnerOfObject(hvoItem);
            int clidOwner = m_cache.GetClassOfObject(hvoOwner);

            if (clidOwner != ReversalIndex.kclsidReversalIndex)
            {
                return;                         // subentries shouldn't trigger letter head change!
            }
            int    ws     = m_cache.GetIntProperty(hvoOwner, (int)ReversalIndex.ReversalIndexTags.kflidWritingSystem);
            string sEntry = m_cache.GetMultiUnicodeAlt(hvoItem,
                                                       (int)ReversalIndexEntry.ReversalIndexEntryTags.kflidReversalForm,
                                                       ws,
                                                       "ReversalIndexEntry_ReversalForm");

            if (String.IsNullOrEmpty(sEntry))
            {
                return;
            }
            if (String.IsNullOrEmpty(m_sWsRevIdx))
            {
                m_sWsRevIdx = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(ws);
            }
            WriteLetterHeadIfNeeded(sEntry, m_sWsRevIdx);
        }
Ejemplo n.º 2
0
 private int GetCanonicalNumber(int hvo, FdoCache cache)
 {
     return(cache.GetIntProperty(hvo, (int)ScrBook.ScrBookTags.kflidCanonicalNum));
 }
Ejemplo n.º 3
0
        public int Compare(object x1, object y1)
        {
            ManyOnePathSortItem x = x1 as ManyOnePathSortItem;
            ManyOnePathSortItem y = y1 as ManyOnePathSortItem;
            int hvoX     = x.KeyObject;         // CmBaseAnnotations
            int hvoY     = y.KeyObject;
            int hvoParaX = m_cache.GetObjProperty(hvoX, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginObject);
            int hvoParaY = m_cache.GetObjProperty(hvoY, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginObject);

            if (hvoParaX == hvoParaY)
            {
                // Compare begin offsets and return
                int offsetX = m_cache.GetIntProperty(hvoX, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginOffset);
                int offsetY = m_cache.GetIntProperty(hvoY, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginOffset);
                return(offsetX - offsetY);
            }
            // Enhance: do something about picture captions??

            // While owning objects are the same type, get the owner of each, if they are the same,
            // compare their position in owner. Special case to put heading before body.
            // If owners are not the same type, do some trick that will make FLEx texts come before Scripture.
            int hvoObjX = hvoParaX;
            int hvoObjY = hvoParaY;

            do
            {
                int hvoOwnerX = m_cache.GetOwnerOfObject(hvoObjX);
                int hvoOwnerY = m_cache.GetOwnerOfObject(hvoObjY);
                if (hvoOwnerX == 0)
                {
                    if (hvoOwnerY == 0)
                    {
                        return(hvoY - hvoX);       // totally arbitrary but at least consistent
                    }
                    return(-1);                    // also arbitrary
                }
                if (hvoOwnerY == 0)
                {
                    return(1);                    // arbitrary, object with shorter chain comes first.
                }
                if (hvoOwnerX == hvoOwnerY)
                {
                    int flidX = m_cache.GetOwningFlidOfObject(hvoObjX);
                    int flidY = m_cache.GetOwningFlidOfObject(hvoObjY);
                    if (flidX != flidY)
                    {
                        return(flidX - flidY);                        // typically body and heading.
                    }
                    int indexX = m_cache.GetObjIndex(hvoOwnerX, flidX, hvoObjX);
                    int indexY = m_cache.GetObjIndex(hvoOwnerY, flidY, hvoObjY);
                    return(indexX - indexY);
                }
                int clsX = m_cache.GetClassOfObject(hvoOwnerX);
                int clsY = m_cache.GetClassOfObject(hvoOwnerY);
                if (clsX != clsY)
                {
                    // Typically one is in Scripture, the other in a Text.
                    // Arbitrarily order things by the kind of parent they're in.
                    // Enhance JohnT: this will need improvement if we go to hierarchical
                    // structures like nested sections or a folder organization of texts.
                    // We could loop all the way up, and then back down till we find a pair
                    // of owners that are different.
                    // (We reverse the usual X - Y in order to put Texts before Scripture
                    // in this list as in the Texts list in FLEx.)
                    return(clsY - clsX);
                }
                hvoObjX = hvoOwnerX;
                hvoObjY = hvoOwnerY;
            } while (true);             // We'll eventually reach the top of the ownership hierarchy.
        }
Ejemplo n.º 4
0
 /// ------------------------------------------------------------------------------------
 /// <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);
 }