2 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
3 * Copyright (C) 2008 Nuanti Ltd.
4 * Copyright (C) 2009 Diego Escalante Urrelo <diegoe@gnome.org>
5 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
6 * Copyright (C) 2009, 2010, 2011 Igalia S.L.
7 * Copyright (C) 2010, Martin Robinson <mrobinson@webkit.org>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "TextCheckerClientGtk.h"
28 #include "NotImplemented.h"
29 #include "webkitspellchecker.h"
30 #include "webkitwebsettingsprivate.h"
32 #include <wtf/text/CString.h>
34 using namespace WebCore;
38 TextCheckerClientGtk::TextCheckerClientGtk(WebKitSpellChecker* spellChecker)
39 : m_spellChecker(spellChecker)
43 TextCheckerClientGtk::~TextCheckerClientGtk()
47 void TextCheckerClientGtk::ignoreWordInSpellDocument(const String& text)
49 webkit_spell_checker_ignore_word(m_spellChecker.get(), text.utf8().data());
52 void TextCheckerClientGtk::learnWord(const String& text)
54 webkit_spell_checker_learn_word(m_spellChecker.get(), text.utf8().data());
57 void TextCheckerClientGtk::checkSpellingOfString(const UChar* text, int length, int* misspellingLocation, int* misspellingLength)
59 GOwnPtr<gchar> utf8Text(g_utf16_to_utf8(const_cast<gunichar2*>(text), length, 0, 0, 0));
60 webkit_spell_checker_check_spelling_of_string(m_spellChecker.get(), utf8Text.get(), misspellingLocation, misspellingLength);
63 String TextCheckerClientGtk::getAutoCorrectSuggestionForMisspelledWord(const String& inputWord)
65 return webkit_spell_checker_get_autocorrect_suggestions_for_misspelled_word(m_spellChecker.get(), inputWord.utf8().data());
68 void TextCheckerClientGtk::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*)
73 void TextCheckerClientGtk::getGuessesForWord(const String& word, const String& context, WTF::Vector<String>& guesses)
75 char** suggestions = webkit_spell_checker_get_guesses_for_word(m_spellChecker.get(), word.utf8().data(), context.utf8().data());
81 for (int i = 0; suggestions[i]; i++)
82 guesses.append(String::fromUTF8(suggestions[i]));
84 g_strfreev(suggestions);
87 void TextCheckerClientGtk::updateSpellCheckingLanguage(const char* spellCheckingLanguages)
89 webkit_spell_checker_update_spell_checking_languages(m_spellChecker.get(), spellCheckingLanguages);