r17501 by craig - Port hunspell to trunk. Change hyphenation language storage to us the abbreviated version of the language. Rename en.xml from loremipsum to en_GB and hyph_en.dic hyph dict to hyph_en_GB.dic
scribus-commit
scribus-commit at lists.scribus.net
Wed May 9 20:05:22 UTC 2012
Author: craig
Date: Wed May 9 20:05:21 2012
New Revision: 17501
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17501
Log:
Port hunspell to trunk. Change hyphenation language storage to us the abbreviated version of the language. Rename en.xml from loremipsum to en_GB and hyph_en.dic hyph dict to hyph_en_GB.dic
Added:
trunk/Scribus/resources/dicts/hyph_en_GB.dic
- copied unchanged from r17495, trunk/Scribus/resources/dicts/hyph_en.dic
trunk/Scribus/resources/loremipsum/en_GB.xml
- copied, changed from r17495, trunk/Scribus/resources/loremipsum/en.xml
Modified:
trunk/Scribus/CMakeLists.txt
trunk/Scribus/resources/dicts/hyph_en.dic
trunk/Scribus/resources/loremipsum/en.xml
trunk/Scribus/scribus/hyphenator.cpp
trunk/Scribus/scribus/langmgr.cpp
trunk/Scribus/scribus/pluginmanager.cpp
trunk/Scribus/scribus/pluginmanager.h
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
trunk/Scribus/scribus/plugins/tools/CMakeLists.txt
trunk/Scribus/scribus/prefsmanager.cpp
trunk/Scribus/scribus/scpaths.cpp
trunk/Scribus/scribus/scpaths.h
trunk/Scribus/scribus/scplugin.cpp
trunk/Scribus/scribus/scplugin.h
trunk/Scribus/scribus/scraction.h
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/text/storytext.cpp
trunk/Scribus/scribus/text/storytext.h
trunk/Scribus/scribus/ui/prefs_hyphenator.cpp
trunk/Scribus/scribus/ui/storyeditor.cpp
trunk/Scribus/scribus/ui/storyeditor.h
Modified: trunk/Scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/CMakeLists.txt (original)
+++ trunk/Scribus/CMakeLists.txt Wed May 9 20:05:21 2012
@@ -712,6 +712,18 @@
ENDIF (WITH_ASPELL)
#>>ASPELL for Speelling support
+#<<HUNSPELL for Speelling support
+OPTION(WANT_HUNSPELL "Enable support for spell checking with hunspell" OFF)
+IF (WANT_HUNSPELL)
+ FIND_PACKAGE(HUNSPELL)
+ IF (HUNSPELL_FOUND)
+ MESSAGE("Hunspell Found OK")
+ SET(HAVE_HUNSPELL 1)
+ ELSE (HUNSPELL_FOUND)
+ MESSAGE("HunSpell or its developer libraries NOT found - Disabling support for spell checking")
+ ENDIF (HUNSPELL_FOUND)
+ENDIF (WANT_HUNSPELL)
+#>>HUNSPELL for Speelling support
#<<PoDoFo for AI PDF import
OPTION(WITH_PODOFO "Enable support for PDF embedded in AI" ON)
Modified: trunk/Scribus/scribus/hyphenator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/hyphenator.cpp
==============================================================================
--- trunk/Scribus/scribus/hyphenator.cpp (original)
+++ trunk/Scribus/scribus/hyphenator.cpp Wed May 9 20:05:21 2012
@@ -63,7 +63,7 @@
doc->setHyphLanguage(Language);
}
// pfad += ScCore->primaryMainWindow()->Sprachen[Language];
- pfad += lmgr->getHyphFilename( doc->hyphLanguage(), false );
+ pfad += lmgr->getHyphFilename( doc->hyphLanguage(), true );
QFile f(pfad);
if (f.open(QIODevice::ReadOnly))
{
Modified: trunk/Scribus/scribus/langmgr.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/langmgr.cpp
==============================================================================
--- trunk/Scribus/scribus/langmgr.cpp (original)
+++ trunk/Scribus/scribus/langmgr.cpp Wed May 9 20:05:21 2012
@@ -20,7 +20,7 @@
***************************************************************************/
#include <iostream>
-
+#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QMap>
@@ -74,8 +74,10 @@
langList.insert("nl", langPair("Dutch", QObject::tr( "Dutch" )) );
langList.insert("en", langPair("English", QObject::tr( "English" )) );
langList.insert("en_AU", langPair("English (Australian)",QObject::tr( "English (Australian)" )) );
+ langList.insert("en_CA", langPair("English (Canadian)", QObject::tr( "English (Canadian)" )) );
langList.insert("en_GB", langPair("English (British)", QObject::tr( "English (British)" )) );
langList.insert("en_US", langPair("English (American)", QObject::tr( "English (American)" )) );
+ langList.insert("en_ZA", langPair("English (South African)", QObject::tr( "English (South African)" )) );
langList.insert("eo", langPair("Esperanto", QObject::tr( "Esperanto" )) );
langList.insert("et", langPair("Estonian", QObject::tr( "Estonian" )) );
langList.insert("de", langPair("German", QObject::tr( "German" )) );
@@ -128,6 +130,7 @@
langList.insert("tr", langPair("Turkish", QObject::tr( "Turkish" )) );
langList.insert("tr_TR", langPair("Turkish", QObject::tr( "Turkish" )) );
langList.insert("uk", langPair("Ukranian", QObject::tr( "Ukranian" )) );
+ langList.insert("uk_UA", langPair("Ukranian", QObject::tr( "Ukranian" )) );
langList.insert("vi", langPair("Vietnamese", QObject::tr( "Vietnamese" )) );
langList.insert("cy", langPair("Welsh", QObject::tr( "Welsh" )) );
}
Modified: trunk/Scribus/scribus/pluginmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/pluginmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/pluginmanager.cpp (original)
+++ trunk/Scribus/scribus/pluginmanager.cpp Wed May 9 20:05:21 2012
@@ -26,6 +26,7 @@
#include "prefsfile.h"
#include "scpaths.h"
#include "commonstrings.h"
+#include "ui/storyeditor.h"
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
@@ -358,6 +359,66 @@
return true;
}
+bool PluginManager::setupPluginActions(StoryEditor *sew)
+{
+ Q_CHECK_PTR(sew);
+ ScActionPlugin* plugin = 0;
+
+ //sew->seMenuMgr->addMenuSeparator("Extras");
+ for (PluginMap::Iterator it = pluginMap.begin(); it != pluginMap.end(); ++it)
+ {
+ if (it.value().plugin->inherits("ScActionPlugin"))
+ {
+ //Add in ScrAction based plugin linkage
+ //Insert DLL Action into Dictionary with values from plugin interface
+ plugin = dynamic_cast<ScActionPlugin*>(it.value().plugin);
+ assert(plugin);
+ ScActionPlugin::ActionInfo ai(plugin->actionInfo());
+ if (ai.enabledForStoryEditor)
+ {
+ ScrAction* action = new ScrAction(ScrAction::ActionDLLSE, ai.icon1, ai.icon2, ai.text, ai.keySequence, sew);
+ Q_CHECK_PTR(action);
+ sew->seActions.insert(ai.name, action);
+
+ // then enable and connect up the action
+ sew->seActions[ai.name]->setEnabled(ai.enabledForStoryEditor);
+
+ // Connect action's activated signal with the plugin's run method
+ it.value().enabled = connect( sew->seActions[ai.name], SIGNAL(triggeredData(QWidget*, ScribusDoc*)),
+ plugin, SLOT(run(QWidget*, ScribusDoc*)) );
+ //Get the menu manager to add the DLL's menu item to the right menu, after the chosen existing item
+ if ( ai.menuAfterName.isEmpty() )
+ {
+ if (!ai.seMenu.isEmpty())
+ {
+ if ((!ai.subMenuName.isEmpty()) && (!ai.parentMenu.isEmpty()))
+ {
+ if (!sew->seMenuMgr->menuExists(ai.seMenu))
+ sew->seMenuMgr->createMenu(ai.seMenu, ai.subMenuName, ai.parentMenu);
+ }
+ sew->seMenuMgr->addMenuItem(sew->seActions[ai.name], ai.seMenu, true);
+ }
+ }
+ else
+ {
+ QString actionName(ai.seMenu.toLower()+ai.menuAfterName);
+ ScrAction* afterAction=0;
+ if (sew->seActions.contains(actionName))
+ afterAction=sew->seActions[actionName];
+ if ((!ai.subMenuName.isEmpty()) && (!ai.parentMenu.isEmpty()))
+ {
+ if (!sew->seMenuMgr->menuExists(ai.seMenu))
+ sew->seMenuMgr->createMenu(ai.seMenu, ai.subMenuName, ai.parentMenu);
+ }
+ sew->seMenuMgr->addMenuItemAfter(sew->seActions[ai.name], ai.seMenu, true, afterAction);
+ }
+ }
+ }
+ }
+ return true;
+}
+
+
void PluginManager::enableOnlyStartupPluginActions(ScribusMainWindow* mw)
{
Q_CHECK_PTR(mw);
Modified: trunk/Scribus/scribus/pluginmanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/pluginmanager.h
==============================================================================
--- trunk/Scribus/scribus/pluginmanager.h (original)
+++ trunk/Scribus/scribus/pluginmanager.h Wed May 9 20:05:21 2012
@@ -21,6 +21,7 @@
class ScActionPlugin;
class ScPersistentPlugin;
class PrefsContext;
+class StoryEditor;
/**
* \brief PluginManager handles plugin loading, unloading, and running.
@@ -62,6 +63,11 @@
* Run in main window startup
*/
bool setupPluginActions(ScribusMainWindow*);
+
+ /*! \brief Called at after initPlugs to hook the loaded plugin into the GUI.
+ * Run in SE startup
+ */
+ bool setupPluginActions(StoryEditor *sew);
/*! \brief Called when the last doc is closed
*/
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Wed May 9 20:05:21 2012
@@ -1923,7 +1923,7 @@
m_Doc->PageSpa = attrs.valueAsDouble("ABSTSPALTEN");
m_Doc->setUnitIndex( attrs.valueAsInt("UNITS", 0) );
- m_Doc->setHyphLanguage(attrs.valueAsString("LANGUAGE", ""));
+ m_Doc->setHyphLanguage(attrs.valueAsString("LANGUAGE", "en_US"));
m_Doc->setHyphMinimumWordLength(attrs.valueAsInt("MINWORDLEN", 3));
m_Doc->setHyphConsecutiveLines(attrs.valueAsInt("HYCOUNT", 2));
Modified: trunk/Scribus/scribus/plugins/tools/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/plugins/tools/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/plugins/tools/CMakeLists.txt Wed May 9 20:05:21 2012
@@ -13,3 +13,6 @@
if (HAVE_ASPELL)
ADD_SUBDIRECTORY(spellcheck)
endif (HAVE_ASPELL)
+if (HAVE_HUNSPELL)
+ ADD_SUBDIRECTORY(hunspellcheck)
+endif (HAVE_HUNSPELL)
Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp (original)
+++ trunk/Scribus/scribus/prefsmanager.cpp Wed May 9 20:05:21 2012
@@ -310,7 +310,7 @@
appPrefs.docSetupPrefs.bleeds.Bottom = 0;
appPrefs.hyphPrefs.MinWordLen = 3;
appPrefs.hyphPrefs.HyCount = 2;
- appPrefs.hyphPrefs.Language = "";
+ appPrefs.hyphPrefs.Language = "en_US";
appPrefs.hyphPrefs.specialWords.clear();
appPrefs.hyphPrefs.ignoredWords.clear();
appPrefs.hyphPrefs.Automatic = true;
@@ -2387,7 +2387,7 @@
}
if (dc.tagName()=="Hyphenator")
{
- appPrefs.hyphPrefs.Language = dc.attribute("Language","");
+ appPrefs.hyphPrefs.Language = dc.attribute("Language","en_US");
appPrefs.hyphPrefs.MinWordLen = dc.attribute("WordLength", "3").toInt();
appPrefs.hyphPrefs.HyCount = dc.attribute("HyphenCount", "2").toInt();
appPrefs.hyphPrefs.Automatic = static_cast<bool>(dc.attribute("Automatic", "1").toInt());
Modified: trunk/Scribus/scribus/scpaths.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/scpaths.cpp
==============================================================================
--- trunk/Scribus/scribus/scpaths.cpp (original)
+++ trunk/Scribus/scribus/scpaths.cpp Wed May 9 20:05:21 2012
@@ -222,6 +222,73 @@
return(m_shareDir + "dicts/");
}
+QStringList ScPaths::spellDirs() const
+{
+ //dictionaryPaths
+ QString macPortsPath("/opt/local/share/hunspell/");
+ QString finkPath("/sw/share/hunspell/");
+ QString osxLibreOfficePath("/Applications/LibreOffice.app/Contents/share/extensions");
+ QString osxUserLibreOfficePath(QDir::homePath()+"/Applications/LibreOffice.app/Contents/share/extensions");
+ QString linuxLocalPath("/usr/local/share/hunspell/");
+ QString linuxHunspellPath("/usr/share/hunspell/");
+ QString linuxMyspellPath("/usr/share/myspell/");
+ QString windowsLOPath("LibreOffice 3.5/share/extensions");
+ QDir d;
+ QStringList spellDirs;
+ spellDirs.append(m_shareDir + "dicts/spelling/");
+#ifdef Q_OS_MAC
+ d.setPath(macPortsPath);
+ if (d.exists())
+ spellDirs.append(macPortsPath);
+ d.setPath(finkPath);
+ if (d.exists())
+ spellDirs.append(finkPath);
+ d.setPath(osxLibreOfficePath);
+ if (d.exists())
+ {
+ QStringList dictDirFilters("dict-*");
+ QStringList dictDirList(d.entryList(dictDirFilters, QDir::Dirs, QDir::Name));
+ QString dir;
+ foreach (dir, dictDirList)
+ spellDirs.append(osxLibreOfficePath + "/" + dir + "/");
+ }
+ d.setPath(osxUserLibreOfficePath);
+ if (d.exists())
+ {
+ QStringList dictDirFilters("dict-*");
+ QStringList dictDirList(d.entryList(dictDirFilters, QDir::Dirs, QDir::Name));
+ QString dir;
+ foreach (dir, dictDirList)
+ spellDirs.append(osxUserLibreOfficePath + "/" + dir + "/");
+ }
+
+#elif defined(_WIN32)
+ QString progFiles = getSpecialDir(CSIDL_PROGRAM_FILES);
+ d.setPath(progFiles+windowsLOPath);
+ if (d.exists())
+ {
+ QStringList dictDirFilters("dict-*");
+ QStringList dictDirList(d.entryList(dictDirFilters, QDir::Dirs, QDir::Name));
+ QString dir;
+ foreach (dir, dictDirList)
+ spellDirs.append(progFiles+windowsLOPath + "/" + dir + "/");
+ }
+ if (d.exists())
+ spellDirs.append(progFiles+windowsLOPath + "/" + dir + "/");
+#elif defined(Q_WS_X11)
+ d.setPath(linuxHunspellPath);
+ if (d.exists())
+ spellDirs.append(linuxHunspellPath);
+ d.setPath(linuxMyspellPath);
+ if (d.exists())
+ spellDirs.append(linuxMyspellPath);
+ d.setPath(linuxLocalPath);
+ if (d.exists())
+ spellDirs.append(linuxLocalPath);
+#endif
+ return spellDirs;
+}
+
QStringList ScPaths::getSystemFontDirs(void)
{
QStringList fontDirs;
Modified: trunk/Scribus/scribus/scpaths.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/scpaths.h
==============================================================================
--- trunk/Scribus/scribus/scpaths.h (original)
+++ trunk/Scribus/scribus/scpaths.h Wed May 9 20:05:21 2012
@@ -53,6 +53,8 @@
QString translationDir() const;
/** @brief Return path to the dicts directory */
QString dictDir() const;
+ /** @brief Return path to the spelling dictionary directory */
+ QStringList spellDirs() const;
/** @brief Return paths to system font directories*/
static QStringList getSystemFontDirs(void);
Modified: trunk/Scribus/scribus/scplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/scplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/scplugin.cpp (original)
+++ trunk/Scribus/scribus/scplugin.cpp Wed May 9 20:05:21 2012
@@ -110,6 +110,10 @@
m_actionInfo.firstObjectType.clear();
m_actionInfo.secondObjectType.clear();
m_actionInfo.enabledOnStartup = false;
+ m_actionInfo.enabledForStoryEditor = false;
+ m_actionInfo.seMenu = "";
+ m_actionInfo.seParentMenu = "";
+ m_actionInfo.seKeySequence = "";
}
ScActionPlugin::~ScActionPlugin()
Modified: trunk/Scribus/scribus/scplugin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/scplugin.h
==============================================================================
--- trunk/Scribus/scribus/scplugin.h (original)
+++ trunk/Scribus/scribus/scplugin.h Wed May 9 20:05:21 2012
@@ -282,6 +282,10 @@
// -1 indicates that any kind of object is possible. Otherwise the selection must contain the 2 Object Types
// for the Plugin Action to be enabled
bool enabledOnStartup;
+ bool enabledForStoryEditor;
+ QString seMenu;
+ QString seParentMenu;
+ QString seKeySequence;
};
// Return an ActionInfo instance to the caller
@@ -499,7 +503,7 @@
//
// The API version is currently simply incremented with each incompatible
// change. Future versions may introduce a minor/major scheme if necessary.
-#define PLUGIN_API_VERSION 0x00000102
+#define PLUGIN_API_VERSION 0x00000103
#endif
Modified: trunk/Scribus/scribus/scraction.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/scraction.h
==============================================================================
--- trunk/Scribus/scribus/scraction.h (original)
+++ trunk/Scribus/scribus/scraction.h Wed May 9 20:05:21 2012
@@ -35,7 +35,7 @@
Q_OBJECT
public:
- typedef enum {Normal, DataInt, DataDouble, DataQString, RecentFile, DLL, Window, RecentScript, UnicodeChar, Layer, ActionDLL, RecentPaste } ActionType;
+ typedef enum {Normal, DataInt, DataDouble, DataQString, RecentFile, DLL, Window, RecentScript, UnicodeChar, Layer, ActionDLL, RecentPaste, ActionDLLSE } ActionType;
/*!
\author Craig Bradney
@@ -177,6 +177,7 @@
void triggeredData(double);
void triggeredData(QString);
void triggeredData(ScribusDoc*);
+ void triggeredData(QWidget*, ScribusDoc*);
void toggledData(bool, int);
void toggledData(bool, double);
void toggledData(bool, QString);
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Wed May 9 20:05:21 2012
@@ -380,7 +380,7 @@
ScCore->setSplashStatus( tr("Initializing Hyphenator") );
QString preLang(prefsManager->appPrefs.hyphPrefs.Language);
initHyphenator();
- if (!LanguageManager::instance()->getHyphFilename( preLang, false ).isEmpty() )
+ if (!LanguageManager::instance()->getHyphFilename( preLang, true ).isEmpty() )
prefsManager->appPrefs.hyphPrefs.Language = preLang;
if (primaryMainWindow)
ScCore->setSplashStatus( tr("Reading Scrapbook") );
@@ -9218,7 +9218,7 @@
//Grab the language abbreviation from it, get the full language text
//Insert the name as key and a new string list into the map
QString hyphDirName = QDir::toNativeSeparators(ScPaths::instance().dictDir());
- QDir hyphDir(hyphDirName, "*.dic", QDir::Name, QDir::Files | QDir::NoSymLinks);
+ QDir hyphDir(hyphDirName, "hyph*.dic", QDir::Name, QDir::Files | QDir::NoSymLinks);
if ((hyphDir.exists()) && (hyphDir.count() != 0))
{
// LanguageManager langmgr;
@@ -9228,8 +9228,11 @@
{
QFileInfo fi(hyphDir[dc]);
QString fileLangAbbrev=fi.baseName().section('_', 1);
- languageOfHyphFile = LanguageManager::instance()->getLangFromAbbrev(fileLangAbbrev, false);
- InstLang.insert(languageOfHyphFile, QStringList());
+ InstLang.insert(fileLangAbbrev, QStringList());
+//<<hunspell
+// languageOfHyphFile = LanguageManager::instance()->getLangFromAbbrev(fileLangAbbrev, false);
+// InstLang.insert(languageOfHyphFile, QStringList());
+//>>hunspell
}
}
@@ -9251,7 +9254,7 @@
for (QMap<QString, QStringList>::Iterator it=InstLang.begin(); it!=InstLang.end(); ++it)
{
translatedLang="";
- translatedLang = trans->translate("QObject", it.key().toLocal8Bit().data(), "");
+ translatedLang = trans->translate("QObject", LanguageManager::instance()->getLangFromAbbrev(it.key(), false).toLocal8Bit().data(), "");
if (!translatedLang.isEmpty())
it.value().append(translatedLang);
}
@@ -9262,7 +9265,7 @@
//For each hyphenation file, grab the strings and the hyphenation data.
QString lang = QString(QLocale::system().name()).left(2);
LangTransl.clear();
- prefsManager->appPrefs.hyphPrefs.Language = "English";
+ prefsManager->appPrefs.hyphPrefs.Language = "en_US";
if ((hyphDir.exists()) && (hyphDir.count() != 0))
{
LanguageManager *langmgr(LanguageManager::instance());
@@ -9279,10 +9282,10 @@
langmgr->addHyphLang(fileLangAbbrev, hyphDir[dc]);
// Sprachen.insert(datein, hyphDir[dc]);
if (fileLangAbbrev == lang)
- prefsManager->appPrefs.hyphPrefs.Language = datein;
+ prefsManager->appPrefs.hyphPrefs.Language = fileLangAbbrev;
}
if (datein.isEmpty())
- prefsManager->appPrefs.hyphPrefs.Language = "English";
+ prefsManager->appPrefs.hyphPrefs.Language = "en_US";
}
}
@@ -9292,7 +9295,7 @@
for (QMap<QString, QStringList>::Iterator itl = InstLang.begin(); itl != itlend; ++itl)
{
if (itl.value().contains(inLang))
- return itl.key();
+ return LanguageManager::instance()->getLangFromAbbrev(itl.key());
}
return inLang;
}
Modified: trunk/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/text/storytext.cpp
==============================================================================
--- trunk/Scribus/scribus/text/storytext.cpp (original)
+++ trunk/Scribus/scribus/text/storytext.cpp Wed May 9 20:05:21 2012
@@ -480,6 +480,42 @@
invalidate(pos, pos + 1);
}
+int StoryText::replaceWord(int pos, QString newWord)
+{
+ int eoWord=pos;
+ while(eoWord < length())
+ {
+ if (text(eoWord).isLetterOrNumber())
+ ++eoWord;
+ else
+ break;
+ }
+ QString word=text(pos,eoWord-pos);
+ int lengthDiff=newWord.length()-word.length();
+ if (lengthDiff==0)
+ {
+ for (int j = 0; j < word.length(); ++j)
+ replaceChar(pos+j, newWord[j]);
+ }
+ else
+ {
+ if (lengthDiff>0)
+ {
+ for (int j = 0; j < word.length(); ++j)
+ replaceChar(pos+j, newWord[j]);
+ for (int j = word.length(); j < newWord.length(); ++j)
+ insertChars(pos+j, newWord.mid(j,1), true);
+ }
+ else
+ {
+ for (int j = 0; j < newWord.length(); ++j)
+ replaceChar(pos+j, newWord[j]);
+ removeChars(pos+newWord.length(), -lengthDiff);
+ }
+ }
+ return lengthDiff;
+}
+
void StoryText::hyphenateWord(int pos, uint len, char* hyphens)
{
assert(pos >= 0);
@@ -565,6 +601,15 @@
}
return result;
+}
+
+QString StoryText::sentence(int pos, int &posn)
+{
+ int sentencePos=qMax(0, prevSentence(pos));
+ sentencePos=qMax(sentencePos, nextWord(sentencePos));
+ posn=sentencePos;
+ int nextSentencePos=qMin(length(), nextSentence(pos+1));
+ return text(sentencePos, nextSentencePos-sentencePos);
}
QString StoryText::textWithSoftHyphens(int pos, uint len) const
@@ -1097,9 +1142,21 @@
int StoryText::nextWord(int pos)
{
int len = length();
- pos = qMin(len, pos+1);
- while (pos < len && wordBoundaries.indexOf(text(pos)) < 0)
- ++pos;
+ if (text(pos).isLetter())
+ pos = qMin(len, pos+1);
+ else
+ pos = qMin(len, pos);
+
+ // while (pos < len && wordBoundaries.indexOf(text(pos)) < 0)
+ // ++pos;
+
+ while (pos < len)
+ {
+ if(text(pos).isLetter())
+ ++pos;
+ else
+ break;
+ }
return pos < len ? pos + 1 : pos;
}
int StoryText::prevWord(int pos)
@@ -1109,6 +1166,20 @@
--pos;
return wordBoundaries.indexOf(text(pos)) < 0 ? pos + 1 : pos;
}
+
+int StoryText::endOfWord(int pos) const
+{
+ int len = length();
+ while (pos < len)
+ {
+ if(text(pos).isLetter())
+ ++pos;
+ else
+ break;
+ }
+ return pos;
+}
+
int StoryText::nextSentence(int pos)
{
int len = length();
Modified: trunk/Scribus/scribus/text/storytext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/text/storytext.h
==============================================================================
--- trunk/Scribus/scribus/text/storytext.h (original)
+++ trunk/Scribus/scribus/text/storytext.h Wed May 9 20:05:21 2012
@@ -110,6 +110,8 @@
void clear();
StoryText copy() const;
+
+ // Add, change, replace
// Insert chars from another StoryText object at current cursor position
void insert(const StoryText& other, bool onlySelection = false);
// Insert chars from another StoryText object at specific position
@@ -127,6 +129,8 @@
// Insert object at specific position
void insertObject(int pos, int obj);
void replaceChar(int pos, QChar ch);
+ // Replaced a word, and return the difference in length between old and new
+ int replaceWord(int pos, QString newWord);
void replaceObject(int pos, int obj);
void hyphenateWord(int pos, uint len, char* hyphens);
@@ -138,6 +142,8 @@
QChar text(int pos) const;
// Get text with len chars at specific position
QString text(int pos, uint len) const;
+ //Get sentence at any position within it
+ QString sentence(int pos, int &posn);
// Get word at specific position
QString wordAt(int pos) const;
@@ -199,6 +205,7 @@
int prevChar(int pos);
int nextWord(int pos);
int prevWord(int pos);
+ int endOfWord(int pos) const;
int nextSentence(int pos);
int prevSentence(int pos);
int nextParagraph(int pos);
Modified: trunk/Scribus/scribus/ui/prefs_hyphenator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/ui/prefs_hyphenator.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_hyphenator.cpp (original)
+++ trunk/Scribus/scribus/ui/prefs_hyphenator.cpp Wed May 9 20:05:21 2012
@@ -6,6 +6,7 @@
*/
#include <QInputDialog>
#include <QListWidget>
+#include <QDebug>
#include "prefs_hyphenator.h"
#include "langmgr.h"
@@ -57,7 +58,7 @@
{
hyphSuggestionsCheckBox->setChecked(!prefsData->hyphPrefs.Automatic);
hyphAutoCheckBox->setChecked(prefsData->hyphPrefs.AutoCheck);
- setCurrentComboItem(hyphLanguageComboBox, LanguageManager::instance()->getTransLangFromLang(prefsData->hyphPrefs.Language));
+ setCurrentComboItem(hyphLanguageComboBox, LanguageManager::instance()->getLangFromAbbrev(prefsData->hyphPrefs.Language, true));
smallestWordSpinBox->setValue(prefsData->hyphPrefs.MinWordLen);
maxConsecutiveCountSpinBox->setValue(prefsData->hyphPrefs.HyCount);
ignoreListWidget->addItems(prefsData->hyphPrefs.ignoredWords.toList());
@@ -70,7 +71,8 @@
{
prefsData->hyphPrefs.MinWordLen = smallestWordSpinBox->value();
//FIXME: remove this ScCore call
- prefsData->hyphPrefs.Language = ScCore->primaryMainWindow()->GetLang(hyphLanguageComboBox->itemData(hyphLanguageComboBox->currentIndex()).toString());
+ QString langFromCombo(ScCore->primaryMainWindow()->GetLang(hyphLanguageComboBox->itemData(hyphLanguageComboBox->currentIndex()).toString()));
+ prefsData->hyphPrefs.Language = LanguageManager::instance()->getAbbrevFromLang(langFromCombo, true, false);
prefsData->hyphPrefs.Automatic = !hyphSuggestionsCheckBox->isChecked();
prefsData->hyphPrefs.AutoCheck = hyphAutoCheckBox->isChecked();
prefsData->hyphPrefs.HyCount = maxConsecutiveCountSpinBox->value();
Modified: trunk/Scribus/scribus/ui/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/ui/storyeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/storyeditor.cpp (original)
+++ trunk/Scribus/scribus/ui/storyeditor.cpp Wed May 9 20:05:21 2012
@@ -1541,6 +1541,7 @@
charSelect(NULL),
charSelectUsed(false)
{
+ m_spellActive=false;
prefsManager=PrefsManager::instance();
#ifdef Q_WS_MAC
noIcon = loadIcon("noicon.xpm");
@@ -1808,6 +1809,9 @@
seMenuMgr->addMenuToMenuBar("Edit");
seMenuMgr->addMenuToMenuBar("Insert");
seMenuMgr->addMenuToMenuBar("Settings");
+
+ PluginManager::instance().setupPluginActions(this);
+ PluginManager::instance().languageChange();
}
void StoryEditor::buildGUI()
@@ -2110,6 +2114,11 @@
seActions["editPaste"]->setEnabled(true);
}
+void StoryEditor::setSpellActive(bool ssa)
+{
+ m_spellActive=ssa;
+}
+
/** 10/12/2004 - pv - #1203: wrong selection on double click
Catch the double click signal - cut the wrong selection (with
whitespaces on the tail) - select only one word - return
@@ -2185,45 +2194,48 @@
bool StoryEditor::eventFilter( QObject* ob, QEvent* ev )
{
- if ( ev->type() == QEvent::WindowDeactivate )
- {
- if ((currItem!=NULL) && (!blockUpdate))
- updateTextFrame();
- activFromApp = false;
-// Editor->getCursorPosition(&CurrPara, &CurrChar);
- }
- if ( ev->type() == QEvent::WindowActivate )
- {
- if ((!activFromApp) && (!textChanged) && (!blockUpdate))
- {
- activFromApp = true;
- if (currItem!=NULL)
+ if (!m_spellActive)
+ {
+ if ( ev->type() == QEvent::WindowDeactivate )
+ {
+ if ((currItem!=NULL) && (!blockUpdate))
+ updateTextFrame();
+ activFromApp = false;
+ // Editor->getCursorPosition(&CurrPara, &CurrChar);
+ }
+ if ( ev->type() == QEvent::WindowActivate )
+ {
+ if ((!activFromApp) && (!textChanged) && (!blockUpdate))
{
- //set to false otherwise some dialog properties wont be set correctly
- if (currItem->itemText.length() == 0)
- firstSet = false;
- disconnectSignals();
- Editor->setUndoRedoEnabled(false);
- Editor->setUndoRedoEnabled(true);
- Editor->textCursor().setPosition(0);
- seActions["fileRevert"]->setEnabled(false);
- seActions["editCopy"]->setEnabled(false);
- seActions["editCut"]->setEnabled(false);
- seActions["editClear"]->setEnabled(false);
- textChanged = false;
- FontTools->Fonts->RebuildList(currDoc, currItem->isAnnotation());
- Editor->loadItemText(currItem);
-// Editor->getCursorPosition(&CurrPara, &CurrChar);
- updateStatus();
- textChanged = false;
- Editor->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
- Editor->repaint();
- EditorBar->offs = 0;
-// EditorBar->doMove(0, Editor->contentsY());
- EditorBar->setRepaint(true);
- EditorBar->doRepaint();
- updateProps(0, 0);
- connectSignals();
+ activFromApp = true;
+ if (currItem!=NULL)
+ {
+ //set to false otherwise some dialog properties wont be set correctly
+ if (currItem->itemText.length() == 0)
+ firstSet = false;
+ disconnectSignals();
+ Editor->setUndoRedoEnabled(false);
+ Editor->setUndoRedoEnabled(true);
+ Editor->textCursor().setPosition(0);
+ seActions["fileRevert"]->setEnabled(false);
+ seActions["editCopy"]->setEnabled(false);
+ seActions["editCut"]->setEnabled(false);
+ seActions["editClear"]->setEnabled(false);
+ textChanged = false;
+ FontTools->Fonts->RebuildList(currDoc, currItem->isAnnotation());
+ Editor->loadItemText(currItem);
+ // Editor->getCursorPosition(&CurrPara, &CurrChar);
+ updateStatus();
+ textChanged = false;
+ Editor->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
+ Editor->repaint();
+ EditorBar->offs = 0;
+ // EditorBar->doMove(0, Editor->contentsY());
+ EditorBar->setRepaint(true);
+ EditorBar->doRepaint();
+ updateProps(0, 0);
+ connectSignals();
+ }
}
}
}
Modified: trunk/Scribus/scribus/ui/storyeditor.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17501&path=/trunk/Scribus/scribus/ui/storyeditor.h
==============================================================================
--- trunk/Scribus/scribus/ui/storyeditor.h (original)
+++ trunk/Scribus/scribus/ui/storyeditor.h Wed May 9 20:05:21 2012
@@ -387,11 +387,14 @@
virtual void changeEvent(QEvent *e);
void setCurrentDocumentAndItem(ScribusDoc *doc=NULL, PageItem *item=NULL);
+ void setSpellActive(bool ssa);
ScribusDoc* currentDocument() const;
PageItem* currentItem() const;
SEditor* Editor;
bool activFromApp;
+ MenuManager* seMenuMgr;
+ QMap<QString, QPointer<ScrAction> > seActions;
public slots:
void newStyle(const QString&);
@@ -517,9 +520,7 @@
PrefsManager* prefsManager;
PrefsContext* prefs;
- QMap<QString, QPointer<ScrAction> > seActions;
QStringList unicodeCharActionNames;
- MenuManager* seMenuMgr;
QPixmap noIcon;
QToolBar* FileTools;
@@ -544,6 +545,8 @@
QLabel* WordC2;
QLabel* CharCT2;
QLabel* CharC2;
+
+ bool m_spellActive;
};
#endif
More information about the scribus-commit
mailing list