コード例 #1
0
        /// <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)));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Tomerder/Csharp
        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);
            }
        }
コード例 #3
0
        public string AutoCorrectContextMenu_GetContent(Office.IRibbonControl control)
        {
            string word = GetCurrentWord();

            if (word == null)
            {
                return(String.Empty);
            }

            SpellingSuggestions suggestions = GetSpellingSuggestions(word);

            return(BuildMenu(word, suggestions));
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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());
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: Tomerder/Csharp
        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);
            }
        }
コード例 #7
0
    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);
    }
コード例 #8
0
        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();
        }
コード例 #9
0
        public ActionResult GetWordSuggestions(string word)
        {
            SpellingSuggestions obj = SpellingSuggestions.Instance;

            return(Json(obj.GetSuggestionsForWord(word), JsonRequestBehavior.AllowGet));
        }