r25055 by craig - Add codec call back in

scribus-commit scribus-commit at lists.scribus.net
Thu Mar 24 21:06:10 UTC 2022


Author: craig
Date: Thu Mar 24 21:06:10 2022
New Revision: 25055

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=25055
Log:
Add codec call back in

Modified:
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldict.cpp
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h

Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldict.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25055&path=/trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldict.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldict.cpp	(original)
+++ trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldict.cpp	Thu Mar 24 21:06:10 2022
@@ -40,23 +40,19 @@
 int HunspellDict::spell(const QString& word)
 {
 	if (m_hunspell)
-		return m_hunspell->spell(word.toStdString());
+		return m_hunspell->spell(m_codec->fromUnicode(word).toStdString());
 	return -1;
 }
 
 QStringList HunspellDict::suggest(const QString& word)
 {
 	QStringList replacements;
-	std::vector<std::string> suggestions = m_hunspell->suggest(word.toStdString());
+	std::vector<std::string> suggestions = m_hunspell->suggest(m_codec->fromUnicode(word).toStdString());
 	replacements.reserve(suggestions.size());
 	for(size_t i = 0, l = suggestions.size(); i < l; ++i)
 		replacements << QString::fromStdString(suggestions[i]);
-
-	//	char **sugglist = nullptr;
-//	int suggCount = m_hunspell->suggest(&sugglist, m_codec->fromUnicode(word).constData());
-//	for (int j = 0; j < suggCount; ++j)
-//		replacements << m_codec->toUnicode(sugglist[j]);
-//	m_hunspell->free_list(&sugglist, suggCount);
+//	ugly but works
+//	std::transform(suggestions.begin(), suggestions.end(), std::back_inserter(replacements), [](const std::string& s) -> QString { return QString::fromStdString(s); });
 
 	return replacements;
 }

Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25055&path=/trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h	(original)
+++ trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h	Thu Mar 24 21:06:10 2022
@@ -4,7 +4,8 @@
 #include <QString>
 #include <QStringList>
 
-struct WordsFound {
+struct WordsFound
+{
 	int start;
 	int end;
 	QString w;




More information about the scribus-commit mailing list