コード例 #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Inserts the smushed footnotes.
        /// </summary>
        /// <param name="vwenv">The vwenv.</param>
        /// <param name="hvo">The hvo.</param>
        /// <param name="tag">The tag.</param>
        /// ------------------------------------------------------------------------------------
        private void InsertSmushedFootnotes(IVwEnv vwenv, int hvo, int tag)
        {
            ISilDataAccess sda  = vwenv.DataAccess;
            int            chvo = sda.get_VecSize(hvo, tag);

            if (chvo == 0 || m_startingFootnoteIndex < 0 || m_endingFootnoteIndex < 0)
            {
                return;
            }
            List <int> notes = new List <int>(chvo);

            for (int ihvo = m_startingFootnoteIndex; ihvo < chvo && ihvo <= m_endingFootnoteIndex; ihvo++)
            {
                int footnoteHvo = sda.get_VecItem(hvo, tag, ihvo);
                if (sda.get_IsValidObject(footnoteHvo))
                {
                    notes.Add(footnoteHvo);
                }
            }

            // TE-6185: Undo can cause the only footnote on the page to no longer be a valid object.
            if (notes.Count == 0)
            {
                return;
            }

            // Footnotes are owned by books which are owned by Scripture.
            ICmObject  obj = m_cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(notes[0]);
            IScripture scr = obj.Owner.Owner as IScripture;

            if (scr.CrossRefsCombinedWithFootnotes)
            {
                CreateNotesParagraph(vwenv, notes, NoteGeneralParagraphStyle);
            }
            else
            {
                List <int> generalNotes = new List <int>(notes.Count);
                List <int> crNotes      = new List <int>(notes.Count);
                foreach (int hvoNote in notes)
                {
                    int cPara = sda.get_VecSize(hvoNote, StTextTags.kflidParagraphs);
                    if (cPara != 0)
                    {
                        int          hvoFirstPara = sda.get_VecItem(hvoNote, StTextTags.kflidParagraphs, 0);
                        ITsTextProps paraStyle    = (ITsTextProps)m_cache.DomainDataByFlid.get_UnknownProp(
                            hvoFirstPara, StParaTags.kflidStyleRules);
                        if (paraStyle != null)
                        {
                            string styleName = paraStyle.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
                            while (!string.IsNullOrEmpty(styleName) &&
                                   styleName != ScrStyleNames.CrossRefFootnoteParagraph && m_stylesheet != null)
                            {
                                styleName = m_stylesheet.GetBasedOn(styleName);
                            }
                            if (styleName == ScrStyleNames.CrossRefFootnoteParagraph)
                            {
                                crNotes.Add(hvoNote);
                                continue;
                            }
                        }
                    }
                    generalNotes.Add(hvoNote);
                }
                CreateNotesParagraph(vwenv, generalNotes, NoteGeneralParagraphStyle);
                CreateNotesParagraph(vwenv, crNotes, NoteCrossRefParaStyle);
            }
        }
コード例 #2
0
ファイル: FootnoteVc.cs プロジェクト: sillsdev/WorldPad
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Inserts the smushed footnotes.
        /// </summary>
        /// <param name="vwenv">The vwenv.</param>
        /// <param name="hvo">The hvo.</param>
        /// <param name="tag">The tag.</param>
        /// ------------------------------------------------------------------------------------
        private void InsertSmushedFootnotes(IVwEnv vwenv, int hvo, int tag)
        {
            ISilDataAccess sda  = vwenv.DataAccess;
            int            chvo = sda.get_VecSize(hvo, tag);

            if (chvo == 0)
            {
                return;
            }
            List <int> notes = new List <int>(chvo);

            for (int ihvo = 0; ihvo < chvo; ihvo++)
            {
                int footnoteHvo = sda.get_VecItem(hvo, tag, ihvo);
                if (sda.get_IsValidObject(footnoteHvo))
                {
                    notes.Add(footnoteHvo);
                }
            }

            // TE-6185: Undo can cause the only footnote on the page to no longer be a valid object.
            if (notes.Count == 0)
            {
                return;
            }

            // Footnotes are owned by books which are owned by Scripture.
            int hvoScripture = m_cache.GetOwnerOfObject(m_cache.GetOwnerOfObject(notes[0]));
            int combine      = m_cache.GetIntProperty(hvoScripture, (int)Scripture.ScriptureTags.kflidCrossRefsCombinedWithFootnotes);

            if (combine != 0)
            {
                CreateNotesParagraph(vwenv, notes, NoteGeneralParagraphStyle);
            }
            else
            {
                List <int> generalNotes = new List <int>(notes.Count);
                List <int> crNotes      = new List <int>(notes.Count);
                foreach (int hvoNote in notes)
                {
                    int cPara = sda.get_VecSize(hvoNote, (int)StText.StTextTags.kflidParagraphs);
                    if (cPara != 0)
                    {
                        int          hvoFirstPara = sda.get_VecItem(hvoNote, (int)StText.StTextTags.kflidParagraphs, 0);
                        ITsTextProps paraStyle    = (ITsTextProps)m_cache.GetUnknown(hvoFirstPara, (int)StPara.StParaTags.kflidStyleRules);
                        if (paraStyle != null)
                        {
                            string styleName = paraStyle.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
                            while (styleName != null && styleName != "" && styleName != kstrNoteCrossRefStyleName && m_stylesheet != null)
                            {
                                styleName = m_stylesheet.GetBasedOn(styleName);
                            }
                            if (styleName == kstrNoteCrossRefStyleName)
                            {
                                crNotes.Add(hvoNote);
                                continue;
                            }
                        }
                    }
                    generalNotes.Add(hvoNote);
                }
                CreateNotesParagraph(vwenv, generalNotes, NoteGeneralParagraphStyle);
                CreateNotesParagraph(vwenv, crNotes, NoteCrossRefParaStyle);
            }
        }
コード例 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="hvo"></param>
 /// <returns></returns>
 public bool get_IsValidObject(int hvo)
 {
     return(m_sda.get_IsValidObject(hvo));
 }
コード例 #4
0
 /// <summary>
 /// Test whether an HVO represents a valid object. For the DB-less cache,
 /// the object must be in the m_extantObjectsByHvo data member.
 ///</summary>
 /// <param name='hvo'> </param>
 /// <returns></returns>
 public virtual bool get_IsValidObject(int hvo)
 {
     return(m_baseSda.get_IsValidObject(hvo));
 }