diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
commit | f008adb5a77e094eaf6abf3fc0f36958e66896a5 (patch) | |
tree | 8e9244c4d4957c36be81e15b566b4aa5ea26c982 /lib/kotext/kohyphen/kohyphen.cpp | |
parent | 1210f27b660efb7b37ff43ec68763e85a403471f (diff) | |
download | koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.tar.gz koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.zip |
TQt4 port koffice
This should enable compilation under both Qt3 and Qt4; fixes for any missed components will be forthcoming
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238284 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lib/kotext/kohyphen/kohyphen.cpp')
-rw-r--r-- | lib/kotext/kohyphen/kohyphen.cpp | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/lib/kotext/kohyphen/kohyphen.cpp b/lib/kotext/kohyphen/kohyphen.cpp index 584fa247..29d13c37 100644 --- a/lib/kotext/kohyphen/kohyphen.cpp +++ b/lib/kotext/kohyphen/kohyphen.cpp @@ -19,10 +19,10 @@ * Boston, MA 02110-1301, USA. * ******************************************************************************/ -#include <qdom.h> -#include <qfile.h> -#include <qtextcodec.h> -#include <qstring.h> +#include <tqdom.h> +#include <tqfile.h> +#include <tqtextcodec.h> +#include <tqstring.h> #include <klocale.h> #include <kapplication.h> @@ -49,31 +49,31 @@ KoHyphenator::KoHyphenator() { /* Reading config for dictionary encodings from file...*/ - QString path = kapp->dirs()->findResource("data", "koffice/hyphdicts/dicts.xml"); + TQString path = kapp->dirs()->findResource("data", "koffice/hyphdicts/dicts.xml"); #ifdef DEBUG_HYPHENATOR kdDebug() << path << endl; #endif - QFile *f; + TQFile *f; if (!path.isNull()) - f = new QFile(path); + f = new TQFile(path); else throw KoHyphenatorException( "Could not create KoHyphenator instance." ); - QDomDocument config; - QDomNodeList records; + TQDomDocument config; + TQDomNodeList records; config.setContent(f); - for (QDomNode n = config.firstChild(); !n.isNull(); n = n.nextSibling()) + for (TQDomNode n = config.firstChild(); !n.isNull(); n = n.nextSibling()) if (n.nodeName() == "dicts") { records = n.childNodes(); for (uint i = 0; i < records.count(); i++) { - QDomNamedNodeMap attr = records.item(i).attributes(); - if (attr.contains("lang") && attr.contains("encoding")) { - QString lang = attr.namedItem("lang").nodeValue(); - QString encoding = attr.namedItem("encoding").nodeValue(); + TQDomNamedNodeMap attr = records.item(i).attributes(); + if (attr.tqcontains("lang") && attr.tqcontains("encoding")) { + TQString lang = attr.namedItem("lang").nodeValue(); + TQString encoding = attr.namedItem("encoding").nodeValue(); #ifdef DEBUG_HYPHENATOR kdDebug() << "KoHyphenator: found lang=" << lang << " encoding=" << encoding << endl; #endif @@ -88,19 +88,19 @@ KoHyphenator::KoHyphenator() KoHyphenator::~KoHyphenator() { - for (QMap<QString, HyphenDict*>::iterator it = dicts.begin(); it != dicts.end(); ++it) + for (TQMap<TQString, HyphenDict*>::iterator it = dicts.begin(); it != dicts.end(); ++it) { if ((*it) != 0) hnj_hyphen_free((*it)); } } -char *KoHyphenator::hyphens(const QString& str, const QString& lang) const +char *KoHyphenator::hyphens(const TQString& str, const TQString& lang) const { char *x = new char[str.length()+1]; try { - QTextCodec *codec = codecForLang(lang); + TQTextCodec *codec = codecForLang(lang); hnj_hyphen_hyphenate(dict(lang), (const char *)(codec->fromUnicode(str)), str.length(), x); } catch (KoHyphenatorException &e) @@ -115,13 +115,13 @@ char *KoHyphenator::hyphens(const QString& str, const QString& lang) const return x; } -QString KoHyphenator::hyphenate(const QString& str, const QString& lang) const +TQString KoHyphenator::hyphenate(const TQString& str, const TQString& lang) const { char* x = new char[str.length()+1]; - QString res = str; + TQString res = str; try { - QTextCodec *codec = codecForLang(lang); + TQTextCodec *codec = codecForLang(lang); hnj_hyphen_hyphenate(dict(lang), (const char *)(codec->fromUnicode(str)), str.length(), x); } catch (KoHyphenatorException &e) @@ -141,7 +141,7 @@ QString KoHyphenator::hyphenate(const QString& str, const QString& lang) const #endif if ((x[i] % 2) != 0) { - res.insert(j+1, QChar(0xad)); + res.insert(j+1, TQChar(0xad)); j++; } j++; @@ -150,7 +150,7 @@ QString KoHyphenator::hyphenate(const QString& str, const QString& lang) const return res; } -bool KoHyphenator::checkHyphenPos(const QString& str, int pos, const QString& lang) const +bool KoHyphenator::checkHyphenPos(const TQString& str, int pos, const TQString& lang) const { #ifdef DEBUG_HYPHENATOR kdDebug() << "string: " << str << endl; @@ -167,65 +167,65 @@ bool KoHyphenator::checkHyphenPos(const QString& str, int pos, const QString& la return ret; } -HyphenDict *KoHyphenator::dict(const QString &_lang) const +HyphenDict *KoHyphenator::dict(const TQString &_lang) const { - QString lang( _lang ); + TQString lang( _lang ); //only load dictionary when encoding info is present - if (encodings.find(lang) == encodings.end()) + if (encodings.tqfind(lang) == encodings.end()) { - int underscore = lang.find('_'); + int underscore = lang.tqfind('_'); if ( underscore > -1 ) { lang.truncate( underscore ); - if (encodings.find(lang) == encodings.end()) - throw KoHyphenatorException( QString("No dictionary for %1").arg(lang) ); + if (encodings.tqfind(lang) == encodings.end()) + throw KoHyphenatorException( TQString("No dictionary for %1").tqarg(lang) ); } else - throw KoHyphenatorException( QString("No dictionary for %1").arg(lang) ); + throw KoHyphenatorException( TQString("No dictionary for %1").tqarg(lang) ); } - if (dicts.find(lang) == dicts.end()) + if (dicts.tqfind(lang) == dicts.end()) { #ifdef DEBUG_HYPHENATOR kdDebug() << "Searching dictionary for '" << lang << "' language..." << endl; #endif - QString path = kapp->dirs()->findResource("data", "koffice/hyphdicts/hyph_" + lang + ".dic"); + TQString path = kapp->dirs()->findResource("data", "koffice/hyphdicts/hyph_" + lang + ".dic"); if (!path.isNull()) { #ifdef DEBUG_HYPHENATOR kdDebug() << "Loading dictionary for '" << lang << "' language: path = " << path << endl; #endif - const_cast<KoHyphenator*>(this)->dicts.insert( lang, hnj_hyphen_load(QFile::encodeName(path)) ); - if (dicts.find(lang) == dicts.end()) + const_cast<KoHyphenator*>(this)->dicts.insert( lang, hnj_hyphen_load(TQFile::encodeName(path)) ); + if (dicts.tqfind(lang) == dicts.end()) { #ifdef DEBUG_HYPHENATOR kdDebug() << "No dictionary loaded" << endl; #endif - throw(KoHyphenatorException( QString("Could not load dictionary for the language: %1").arg(lang) )); + throw(KoHyphenatorException( TQString("Could not load dictionary for the language: %1").tqarg(lang) )); } } else - throw(KoHyphenatorException( QString("Could not load dictionary for the language: %1").arg(lang) )); + throw(KoHyphenatorException( TQString("Could not load dictionary for the language: %1").tqarg(lang) )); } return dicts[lang]; } -QTextCodec* KoHyphenator::codecForLang(const QString& lang) const +TQTextCodec* KoHyphenator::codecForLang(const TQString& lang) const { - EncodingMap::Iterator it = encodings.find(lang); + EncodingMap::Iterator it = encodings.tqfind(lang); if (it == encodings.end()) { - int underscore = lang.find('_'); + int underscore = lang.tqfind('_'); if ( underscore > -1 ) { - QString _lang( lang ); + TQString _lang( lang ); _lang.truncate( underscore ); - it = encodings.find(_lang); + it = encodings.tqfind(_lang); } } if (it != encodings.end()) { if ( (*it).codec ) return (*it).codec; - (*it).codec = QTextCodec::codecForName((*it).encoding); + (*it).codec = TQTextCodec::codecForName((*it).encoding); return (*it).codec; } - return QTextCodec::codecForMib(106); // utf-8 + return TQTextCodec::codecForMib(106); // utf-8 } |