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


C# Microsoft.Office.Interop.Word.GetCleanedText方法代码示例

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


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

示例1: AdjustRange

 private Word.Range AdjustRange(Word.Range range, Annotation annotation)
 {
     String initialText = range.GetCleanedText();
     bool match = IsMatch(range, annotation);
     String rangeText = "";
     int offset = Int32.MinValue;
     object rangeStart = range.Start;
     object rangeEnd = range.End;
     int rangeLength = (int)rangeEnd - (int)rangeStart - 1;
     object selectionStart = annotation.Selection[0];
     try
     {
         while (!match)
         {
             offset = range.Text.IndexOf((char)selectionStart);
             object start = range.Start + (int)offset;
             object end = range.Start + rangeLength + (int)offset;
             do
             {
                 //extend the range to the selection length
                 range = document.Range(ref start, ref end);
                 range.TextRetrievalMode.IncludeHiddenText = false;
                 rangeText = range.GetCleanedText();
                 end = (int)end + 1;
             } while (rangeText.Length != annotation.Selection.GetCleanedText().Length);
             if (IsMatch(range, annotation))
             {
                 match = true;
             }
             else if (offset < 0)
             {
                 //if not found return initial range
                 return document.Range(ref rangeStart, ref rangeEnd);
             }
             else if (offset == 0)
             {
                 start = (int)start + 1;
                 end = (int)start + 1;
                 range = document.Range(ref start, ref end);
             }
         }
     }
     catch (NullReferenceException nre)
     {
         Log.Exception(nre);
         return null;
     }
     return range;
 }
开发者ID:xwiki-contrib,项目名称:xwiki-office,代码行数:49,代码来源:AnnotationDisplay.cs

示例2: IsMatch

 /// <summary>
 /// Determines if a Word range is matching the selected text for an annotation
 /// </summary>
 /// <param name="range">The Word range to be verified.</param>
 /// <param name="annotation">The displayed annotation.</param>
 /// <returns>True if the range contains the annotated text and does not start with white spaces.</returns>
 private bool IsMatch(Word.Range range, Annotation annotation)
 {
     String rangeText = range.GetCleanedText();
     String selectedText =  annotation.Selection.GetCleanedText();
     bool match = (rangeText == selectedText) && (range.Text[0] == annotation.Selection[0]);
     match = match && (!range.Text[0].ToString().IsWhiteSpace());
     match = match && (!range.Text[range.Text.Length -1].ToString().IsWhiteSpace());
     return match;
 }
开发者ID:xwiki-contrib,项目名称:xwiki-office,代码行数:15,代码来源:AnnotationDisplay.cs


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