当前位置: 首页>>代码示例>>C#>>正文


C# IScrBook.FindCurrentFootnote方法代码示例

本文整理汇总了C#中IScrBook.FindCurrentFootnote方法的典型用法代码示例。如果您正苦于以下问题:C# IScrBook.FindCurrentFootnote方法的具体用法?C# IScrBook.FindCurrentFootnote怎么用?C# IScrBook.FindCurrentFootnote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScrBook的用法示例。


在下文中一共展示了IScrBook.FindCurrentFootnote方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindFootnoteNearSelection

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Finds the nearest footnote before the given selection.
		/// </summary>
		/// <param name="helper">The selection helper.</param>
		/// <param name="book">The book that owns the footnote collection.</param>
		/// <param name="fSearchForward">True to also search forward within the current paragraph</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private IStFootnote FindFootnoteNearSelection(SelectionHelper helper, IScrBook book,
			bool fSearchForward)
		{
			CheckDisposed();

			if (helper == null)
				helper = CurrentSelection;
			if (helper == null || book == null)
				return null;

			SelLevInfo[] levels = helper.GetLevelInfo(SelectionHelper.SelLimitType.Anchor);

			int iParagraph = -1;
			int tag = 0;
			int ich = helper.IchAnchor;
			int paraLev = helper.GetLevelForTag(StTextTags.kflidParagraphs);
			int contentLev = helper.GetLevelForTag(StTxtParaTags.kflidContents);

			Debug.Assert(paraLev != -1, "Need a paragraph for this method");
			iParagraph = levels[paraLev].ihvo;

			int iSection = ((ITeView)Control).LocationTracker.GetSectionIndexInBook(
				helper, SelectionHelper.SelLimitType.Anchor);

			if (iSection < 0)
				tag = ScrBookTags.kflidTitle;
			else
			{
				tag = (helper.GetLevelForTag(ScrSectionTags.kflidContent) >= 0 ?
					ScrSectionTags.kflidContent : ScrSectionTags.kflidHeading);
			}

			// Special case: if we're in the caption of a picture, get the ich from
			// the first level instead of the anchor. (TE-4696)
			if (contentLev >= 0 && levels[contentLev].ihvo == -1)
				ich = levels[contentLev].ich;

			IScrFootnote prevFootnote = null;
			if (fSearchForward) // look first at our current position, if we are searching foward
				prevFootnote = book.FindCurrentFootnote(iSection, iParagraph, ich, (int)tag);

			if (prevFootnote == null)
			{
				IScrTxtPara para = m_repoScrTxtPara.GetObject(levels[paraLev].hvo);
				ITsString tss = para.Contents;
				if (ich != 0)
				{
					// look backwards in our current paragraph - skip the current run, except when
					// at the end of the text.
					prevFootnote = para.FindPrevFootnoteInContents(ref ich, ich < tss.Length);
				}
				else if (iParagraph > 0)
				{
					// look at the previous paragraph for a footnote at the end
					IStText text = m_repoStText.GetObject(levels[paraLev + 1].hvo);
					IScrTxtPara prevPara = (IScrTxtPara)text[iParagraph - 1];
					ITsString prevTss = prevPara.Contents;
					int ichTmp = -1;
					prevFootnote = prevPara.FindPrevFootnoteInContents(ref ichTmp, false);
					if (prevFootnote != null)
					{
						if (ichTmp == prevTss.Length - 1)
							ich = ichTmp;
						else
							prevFootnote = null;
					}
					// ENHANCE: Look across contexts.
				}
			}
			if (prevFootnote == null && fSearchForward)
			{
				// look ahead in the same paragraph
				IScrTxtPara para = m_repoScrTxtPara.GetObject(levels[paraLev].hvo);
				ITsString tss = para.Contents;
				prevFootnote = para.FindNextFootnoteInContents(ref ich, true);
			}
			if (prevFootnote == null)
			{
				// just go back until we find one
				prevFootnote = book.FindPrevFootnote(ref iSection, ref iParagraph, ref ich, ref tag);
			}

			return prevFootnote;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:93,代码来源:TeEditingHelper.cs


注:本文中的IScrBook.FindCurrentFootnote方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。