/// <summary> /// Проверка слова /// </summary> public string[] Suggest(string word) { object nothing = Missing.Value; // Проверяем bool spelledright = this.application.CheckSpelling(word, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing); if (spelledright) { return(null); } // получаем список слов для замены SpellingSuggestions suggestions = this.application.GetSpellingSuggestions(word, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing); // сохраняем список слов ArrayList words = new ArrayList(); foreach (SpellingSuggestion suggestion in suggestions) { words.Add(suggestion.Name); } suggestions = null; // возвращаем массив слов return((string[])words.ToArray(typeof(string))); }
static void Main(string[] args) { Application word = new Application(); word.Documents.Add(); SpellingSuggestions suggestions = word.GetSpellingSuggestions("placa"); foreach (SpellingSuggestion item in suggestions) { Console.WriteLine(item.Name); } }
public string AutoCorrectContextMenu_GetContent(Office.IRibbonControl control) { string word = GetCurrentWord(); if (word == null) { return(String.Empty); } SpellingSuggestions suggestions = GetSpellingSuggestions(word); return(BuildMenu(word, suggestions)); }
public static string Proof(string proofText, Document _wordDoc, Application _wordApp) { var language = _wordApp.Languages[WdLanguageID.wdSpanish]; SpellingSuggestions spellingSuggestions = _wordApp.GetSpellingSuggestions(proofText, IgnoreUppercase: true, MainDictionary: language.Name); foreach (SpellingSuggestion spellingSuggestion in spellingSuggestions) { proofText = spellingSuggestion.Name; break; } return(proofText.ToLower()); }
private string BuildMenu(string word, SpellingSuggestions suggestions) { StringBuilder sb = new StringBuilder(@"<menu xmlns=""http://schemas.microsoft.com/office/2006/01/customui"" >"); int index = 0; foreach (SpellingSuggestion suggestion in suggestions) { var correction = new SpellingCorrection(word, suggestion.Name); sb.Append($"<button id=\"AutoCorrectSuggestion{index}\" label=\"{suggestion.Name}\" onAction=\"AutoCorrectContextMenu_Correct\" tag=\"{SpellingCorrection.Encode(correction)}\" />"); index += 1; } sb.Append(@"<menuSeparator id=""AutoCorrectSeparator"" />"); sb.Append(@"<button idMso=""AutoCorrect"" />"); sb.Append(@"</menu>"); return(sb.ToString()); }
static void Main(string[] args) { Application word = new Application(); object missing = Missing.Value; word.Documents.Add(ref missing, ref missing, ref missing, ref missing); SpellingSuggestions suggestions = word.GetSpellingSuggestions("placa", ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); foreach (SpellingSuggestion item in suggestions) { Console.WriteLine(item.Name); } }
public string Proof(string proofText) { Range wRng = _wordDoc.Bookmarks.get_Item(ref _oEndOfDoc).Range; wRng.Text = proofText; ProofreadingErrors spellingErros = wRng.SpellingErrors; foreach (Range spellingError in spellingErros) { SpellingSuggestions spellingSuggestions = _wordApp.GetSpellingSuggestions(spellingError.Text, IgnoreUppercase: true); foreach (SpellingSuggestion spellingSuggestion in spellingSuggestions) { spellingError.Text = spellingSuggestion.Name; break; } } string str = wRng.Text; wRng.Text = ""; return(str); }
private string BuildMenu(string word, SpellingSuggestions suggestions) { StringBuilder sb = new StringBuilder(@"<menu xmlns=""http://schemas.microsoft.com/office/2006/01/customui"" >"); int index = 0; foreach (SpellingSuggestion suggestion in suggestions) { var correction = new SpellingCorrection(word, suggestion.Name); sb.Append($"<button id=\"AutoCorrectSuggestion{index}\" label=\"{suggestion.Name}\" onAction=\"AutoCorrectContextMenu_Correct\" tag=\"{SpellingCorrection.Encode(correction)}\" />"); index += 1; } sb.Append(@"<menuSeparator id=""AutoCorrectSeparator"" />"); sb.Append(@"<button idMso=""AutoCorrect"" />"); sb.Append(@"</menu>"); return sb.ToString(); }
public ActionResult GetWordSuggestions(string word) { SpellingSuggestions obj = SpellingSuggestions.Instance; return(Json(obj.GetSuggestionsForWord(word), JsonRequestBehavior.AllowGet)); }