Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determines whether the specified paragraph hvo is in the root diff and needs to be
        /// highlighted (i.e. it is not the last paragraph in the diff).
        /// </summary>
        /// <param name="rootDiff">The root diff.</param>
        /// <param name="para">The current paragraph.</param>
        /// <returns><c>true</c> if paragraph hvo is referenced in a last subdifference;
        /// <c>false</c> otherwise</returns>
        /// ------------------------------------------------------------------------------------
        private bool ParaBreakNeedsHighlight(Difference rootDiff, IStTxtPara para)
        {
            Debug.Assert(rootDiff != null);
            if (rootDiff.HasParaSubDiffs)
            {
                for (int iSubDiff = 0; iSubDiff < rootDiff.SubDiffsForParas.Count; iSubDiff++)
                {
                    // If we found the current paragraph in the subdiffs . . .
                    if (rootDiff.SubDiffsForParas[iSubDiff].GetPara(m_fRev) == para)
                    {
                        // now determine if it is the last one. We don't highlight the paragraph
                        // in the last subdifference because the difference does not span the para break.
                        // We also don't highlight the paragraph break if it is the only paragraph
                        // in the Revision or Current (the last subdifference would have a
                        // paragraph hvo of 0 if it was the only paragraph).
                        return(iSubDiff < rootDiff.SubDiffsForParas.Count - 1 &&
                               rootDiff.SubDiffsForParas[rootDiff.SubDiffsForParas.Count - 1].GetPara(m_fRev) != null);
                    }
                }
            }
            else
            {
                //Check for StanzaBreakAdded/Missing in root diff
                if ((rootDiff.DiffType & DifferenceType.StanzaBreakAddedToCurrent) != 0 ||
                    (rootDiff.DiffType & DifferenceType.StanzaBreakMissingInCurrent) != 0)
                {
                    return(rootDiff.GetPara(m_fRev) == para);
                }
            }

            return(false);
        }
Example #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines whether the specified paragraph hvo is in the root diff and needs to be
		/// highlighted (i.e. it is not the last paragraph in the diff).
		/// </summary>
		/// <param name="rootDiff">The root diff.</param>
		/// <param name="para">The current paragraph.</param>
		/// <returns><c>true</c> if paragraph hvo is referenced in a last subdifference;
		/// <c>false</c> otherwise</returns>
		/// ------------------------------------------------------------------------------------
		private bool ParaBreakNeedsHighlight(Difference rootDiff, IStTxtPara para)
		{
			Debug.Assert(rootDiff != null);
			if (rootDiff.HasParaSubDiffs)
			{
				for (int iSubDiff = 0; iSubDiff < rootDiff.SubDiffsForParas.Count; iSubDiff++)
				{
					// If we found the current paragraph in the subdiffs . . .
					if (rootDiff.SubDiffsForParas[iSubDiff].GetPara(m_fRev) == para)
					{
						// now determine if it is the last one. We don't highlight the paragraph
						// in the last subdifference because the difference does not span the para break.
						// We also don't highlight the paragraph break if it is the only paragraph
						// in the Revision or Current (the last subdifference would have a
						// paragraph hvo of 0 if it was the only paragraph).
						return (iSubDiff < rootDiff.SubDiffsForParas.Count - 1 &&
							rootDiff.SubDiffsForParas[rootDiff.SubDiffsForParas.Count - 1].GetPara(m_fRev) != null);
					}
				}
			}
			else
			{
				//Check for StanzaBreakAdded/Missing in root diff
				if ((rootDiff.DiffType & DifferenceType.StanzaBreakAddedToCurrent) != 0 ||
					(rootDiff.DiffType & DifferenceType.StanzaBreakMissingInCurrent) != 0)
				{
					return rootDiff.GetPara(m_fRev) == para;
				}
			}

			return false;
		}
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;
            }
        }