00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KOHYPHEN_H
00023 #define KOHYPHEN_H
00024
00025 #include <QMap>
00026 #include <QString>
00027
00028 #include <QByteArray>
00029 #include "hyphen.h"
00030 #include <koffice_export.h>
00031
00032 class KoHyphenatorException{
00033 public:
00034 KoHyphenatorException(const QString& MessageText): messageText(MessageText) {}
00035 QString message() const { return messageText; }
00036 private:
00037 QString messageText;
00038 };
00039
00059 class KOTEXT_EXPORT KoHyphenator{
00060 public:
00066 static KoHyphenator* self();
00067
00068 ~KoHyphenator();
00069
00076 bool checkHyphenPos(const QString& str, int pos, const QString& lang) const;
00077
00094 char *hyphens(const QString& str, const QString& lang) const;
00095
00106 QString hyphenate(const QString& str, const QString& lang) const;
00107
00108 private:
00112 QTextCodec* codecForLang(const QString& lang) const;
00113
00114 KoHyphenator();
00115 HyphenDict *dict(const QString &lang) const;
00116
00117 QMap<QString, HyphenDict*> dicts;
00118 struct EncodingStruct {
00119 EncodingStruct()
00120 : encoding(), codec(0L) {}
00121 EncodingStruct(const QByteArray& _encoding)
00122 : encoding(_encoding), codec(0L) {}
00123 QByteArray encoding;
00124 QTextCodec* codec;
00125 };
00126 typedef QMap<QString, EncodingStruct> EncodingMap;
00127 mutable EncodingMap encodings;
00128
00129 static KoHyphenator* s_self;
00130 };
00131
00132 #endif