Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds the overrides to highlight a footnote diff.
        /// </summary>
        /// <param name="para">The footnote paragraph.</param>
        /// ------------------------------------------------------------------------------------
        private void AddOverridesToHighlightFootnoteDiff(IScrTxtPara para)
        {
            Difference diff = FindSubDiffForFootnote(para);

            if (diff == null)
            {
                return;
            }

            if (!(para.Owner is IScrFootnote))
            {
                Debug.Fail("Non-footnote paragraph being displayed in footnote VC!");
                return;                 //continue on gracefully
            }

            MakeDispPropOverrides(para, diff.GetIchMin(m_fRev), diff.GetIchLim(m_fRev),
                                  delegate(ref DispPropOverride prop)
            {
                prop.chrp.clrBack = DiffViewVc.kHighlightColor;
            });
        }
Example #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds the overrides to highlight a footnote diff.
        /// </summary>
        /// <param name="hvo">The hvo of the footnote paragraph.</param>
        /// ------------------------------------------------------------------------------------
        private void AddOverridesToHighlightFootnoteDiff(int hvo)
        {
            Difference diff = FindSubDiffForFootnote(hvo);

            if (diff == null)
            {
                return;
            }

            StTxtPara para = new StTxtPara(Cache, hvo);

            // Get the footnote which contains the paragraph.
            int ownerHvo = para.OwnerHVO;

            Debug.Assert(m_cache.GetClassOfObject(ownerHvo) == StFootnote.kClassId);
            if (m_cache.GetClassOfObject(ownerHvo) != StFootnote.kClassId)
            {
                return;                 //don't override the props for this para; continue on gracefully
            }
            ScrFootnote footnote = new ScrFootnote(Cache, ownerHvo);

            // Only add offset to first paragraph in footnote (should only be one para)
            int offset = 0;

            if (footnote.ParagraphsOS[0].Hvo == hvo)
            {
                int refLength    = footnote.GetReference(m_wsDefault).Length;
                int markerLength = footnote.FootnoteMarker.Length;
                //add one for the space in between (added in StVc)
                offset = refLength + markerLength + 1;
            }

            const uint knNinch = 0x80000000;


            // Now add appropriate properties.
            // Need to add override properties for each run in the
            // range to be highlighted.
            int       ichOverrideMin = diff.GetIchMin(m_fRev);
            ITsString tss            = para.Contents.UnderlyingTsString;
            TsRunInfo runInfo;
            int       ichOverrideLim;
            int       prevLim = 0;

            do
            {
                tss.FetchRunInfoAt(ichOverrideMin, out runInfo);
                ichOverrideLim = Math.Min(diff.GetIchLim(m_fRev), runInfo.ichLim);
                // Prevent infinite loop in case of bad data in difference
                if (ichOverrideLim == prevLim)
                {
                    break;
                }
                prevLim = ichOverrideLim;
                DispPropOverride prop = new DispPropOverride();
                prop.chrp.clrBack    = DiffViewVc.kHighlightColor;
                prop.chrp.clrFore    = knNinch;
                prop.chrp.clrUnder   = knNinch;
                prop.chrp.dympOffset = -1;
                prop.chrp.ssv        = -1;
                prop.chrp.unt        = -1;
                prop.chrp.ttvBold    = -1;
                prop.chrp.ttvItalic  = -1;
                prop.chrp.dympHeight = -1;
                prop.chrp.szFaceName = null;
                prop.chrp.szFontVar  = null;
                prop.ichMin          = ichOverrideMin + offset;
                prop.ichLim          = ichOverrideLim + offset;
                m_DispPropOverrides.Add(prop);
                ichOverrideMin = ichOverrideLim;
            }while (ichOverrideLim < diff.GetIchLim(m_fRev));
        }
Example #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// This is the main interesting method of displaying objects and fragments of them.
        /// A Scripture is displayed by displaying its Books;
        /// and a Book is displayed by displaying its Title and Sections;
        /// and a Section is diplayed by displaying its Heading and Content;
        /// which are displayed by using the standard view constructor for StText.
        ///
        /// This override provides special difference highlighting for a paragraph.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            CheckDisposed();

            switch (frag)
            {
            case (int)StTextFrags.kfrPara:
            {
                // The hvo may refer to m_Differences.CurrentDifference, or to a subdiff,
                //  so find the correct one.
                IScrTxtPara para = Cache.ServiceLocator.GetInstance <IScrTxtParaRepository>().GetObject(hvo);
                Difference  diff = FindDiff(para);

                m_DispPropOverrides.Clear();

                // If the diff represents added sections, and this paragraph belongs to it,
                // we must highlight the whole para
                bool fDisplayMissingParaPlaceholderAfter = false;
                if (diff != null)
                {
                    bool highlightWholePara = diff.IncludesWholePara(para, m_fRev);

                    // If the given paragraph has differences to be highlighted,
                    //  add appropriate properties
                    if ((diff.GetPara(m_fRev) == para || highlightWholePara) && m_fNeedHighlight)
                    {
                        // Need to add override properties for each run in the
                        // range to be highlighted.
                        // Determine the range of the paragraph that we want to highlight.
                        int paraMinHighlight = highlightWholePara ? 0 : diff.GetIchMin(m_fRev);
                        int paraLimHighlight = highlightWholePara ?
                                               para.Contents.Length : diff.GetIchLim(m_fRev);
                        if (paraMinHighlight == paraLimHighlight &&
                            IsParagraphAdditionOrDeletion(diff.DiffType))
                        {
                            if (paraMinHighlight == 0)
                            {
                                InsertMissingContentPara(vwenv);
                            }
                            else
                            {
                                fDisplayMissingParaPlaceholderAfter = true;
                            }
                        }

                        MakeDispPropOverrides(para, paraMinHighlight, paraLimHighlight,
                                              delegate(ref DispPropOverride prop)
                            {
                                prop.chrp.clrBack = kHighlightColor;
                            });
                    }
                }

                // the base Display will do the actual displaying of the Para frag
                base.Display(vwenv, hvo, frag);
                if (fDisplayMissingParaPlaceholderAfter)
                {
                    InsertMissingContentPara(vwenv);
                }
                break;
            }

            default:
                // handle all other frags
                base.Display(vwenv, hvo, frag);
                break;
            }
        }