Exemplo n.º 1
0
        public void TestGetBasedOnStyle()
        {
            IVwStylesheet stylesheet   = (IVwStylesheet) new TestFwStylesheet();
            int           hvoNewStyle1 = stylesheet.MakeNewStyle();

            stylesheet.PutStyle("FirstStyle", "bla", hvoNewStyle1, 0, 0, 0, false, false, null);
            int hvoNewStyle2 = stylesheet.MakeNewStyle();

            stylesheet.PutStyle("SecondStyle", "bla", hvoNewStyle2, hvoNewStyle1, 0, 0, false,
                                false, null);
            Assert.AreEqual("FirstStyle", stylesheet.GetBasedOn("SecondStyle"));
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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)
            {
                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);
            }
        }