示例#1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Replaces all references to one paragraph in the footnote cache with another. Used to
		/// update the cache when a paragraph is being merged with another.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="oldParaHvo">id of paragraph being merged into another</param>
		/// <param name="newParaHvo">id of paragraph surviving the merge</param>
		/// ------------------------------------------------------------------------------------
		public static void ReplaceReferencesToParagraph(FdoCache cache, int oldParaHvo, int newParaHvo)
		{
			int bookHvo = cache.GetOwnerOfObjectOfClass(oldParaHvo, (int)ScrBook.kclsidScrBook);
			if (bookHvo <= 0)
			{
				Debug.Fail("Footnotes have to be contained in paragraphs owned by books.");
				return;
			}
			Guid bookGuid = cache.GetGuidFromId(bookHvo);

			Dictionary<int, FootnoteHashEntry> dict;
			// Don't bother on empty cache - it will be created when needed. Need to use HVO to get
			// GUID so we don't create the book and potentially cause the refresh routine to be called.
			if (!cache.TryGetHashtable<int, FootnoteHashEntry>(bookGuid, out dict) || dict.Count == 0)
				return;

			foreach (FootnoteHashEntry entry in dict.Values)
			{
				if (entry.HvoPara == oldParaHvo)
					entry.HvoPara = newParaHvo;
			}
		}
示例#2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Refreshes cache for all footnotes in the StText containing the paragraph.  We only
		/// use this method when verses of a paragraph are changed - this will only happen on
		/// content paragraphs of a ScrSection.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="hvoObj"></param>
		/// ------------------------------------------------------------------------------------
		internal static void RefreshCacheForParagraph(FdoCache cache, int hvoObj)
		{
			int hvoPara = hvoObj;
			if (cache.GetClassOfObject(hvoObj) == CmTranslation.kClassId)
				hvoPara = cache.GetOwnerOfObject(hvoObj);

			int hvoText = cache.GetOwnerOfObject(hvoPara);
			IStText text = new StText(cache, hvoText);
			ScrSection section = new ScrSection(cache, text.OwnerHVO);
			BCVRef verseRef = new BCVRef(section.VerseRefStart);

			Dictionary<int, FootnoteHashEntry> dict;
			// Don't bother on empty cache - it will be created when needed. Need to use HVO to get GUID so we
			// don't create the book and potentially cause the refresh routine to be called.
			Guid bookGuid = cache.GetGuidFromId(section.OwnerHVO);
			if (!cache.TryGetHashtable<int, FootnoteHashEntry>(bookGuid, out dict) ||
				dict.Count == 0)
			{
				return;
			}

			AddFootnoteRefsInText(text, dict, ref verseRef);
		}