From 5885c89d6b30ca607f84794d0de6800f49dd327b Mon Sep 17 00:00:00 2001 From: ahoogol Date: Sun, 25 Jun 2017 12:02:35 +0430 Subject: Added support for RTL(right to left) languages like Arabic and Persian in HTML output --- .gitignore | 1 + qtools/qstring.cpp | 95 ++++++++++++++++----- qtools/qstring.h | 37 ++++++++- src/config.xml | 13 +++ src/docparser.cpp | 123 +++++++++++++++++++++++++++- src/docparser.h | 160 ++++++++++++++++++++---------------- src/dot.cpp | 32 ++++---- src/htmldocvisitor.cpp | 79 ++++++++++++------ src/htmlgen.cpp | 16 +++- src/htmlgen.h | 2 + src/index.cpp | 19 ++++- src/outputgen.h | 2 + src/outputlist.h | 4 + src/pagedef.cpp | 4 + src/util.cpp | 5 +- src/util.h | 3 +- templates/html/doxygen.css | 200 +++++++++++++++++++++++++++++++++++---------- 17 files changed, 609 insertions(+), 186 deletions(-) diff --git a/.gitignore b/.gitignore index 21ebe47..440769b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ /doxygen_docs /doxygen.tag +/build diff --git a/qtools/qstring.cpp b/qtools/qstring.cpp index d831cb1..698efcf 100644 --- a/qtools/qstring.cpp +++ b/qtools/qstring.cpp @@ -11614,32 +11614,83 @@ static inline bool is_neutral(unsigned short dir) { #endif /*! - This function returns the basic directionality of the string (QChar::DirR for - right to left and QChar::DirL for left to right). Useful to find the right - alignment. - */ -QChar::Direction QString::basicDirection() +This function returns the directionality of the string. + +\returns a value of DirLTR, DirRTL, DirMixed or DirNeutral that indicates +if the entire text represented by this text is unidirectional, +and which direction, or if it is mixed-directional or all characters are neutral. +*/ +QString::Direction QString::direction() const { #ifndef QT_NO_UNICODETABLES - // find base direction - unsigned int pos = 0; - while ((pos < length()) && - (at(pos) != RLE) && - (at(pos) != LRE) && - (at(pos) != RLO) && - (at(pos) != LRO) && - (at(pos).direction() > 1) && - (at(pos).direction() != QChar::DirAL)) // not R and not L - pos++; - - if ((at(pos).direction() == QChar::DirR) || - (at(pos).direction() == QChar::DirAL) || - (at(pos) == RLE) || - (at(pos) == RLO)) - return QChar::DirR; + // find direction + unsigned char resultDir = DirNeutral; + for (unsigned int pos = 0; pos < length(); pos++) + { + if ((at(pos) != RLE) && + (at(pos) != LRE) && + (at(pos) != RLO) && + (at(pos) != LRO) && + (at(pos).direction() > 1) && + (at(pos).direction() != QChar::DirAL)) // not R and not L + continue; + + if ((at(pos).direction() == QChar::DirR) || + (at(pos).direction() == QChar::DirAL) || + (at(pos) == RLE) || + (at(pos) == RLO)) + resultDir |= DirRTL; + else + resultDir |= DirLTR; + if (resultDir == DirMixed) + return DirMixed; + } + return static_cast(resultDir); +#else + return DirLTR; #endif +} + +/*! +This function returns the basic directionality of the string. Useful to find the right +alignment. - return QChar::DirL; +The base direction is derived from the first character in the string +with bidirectional character type L, R, or AL. +If the first such character has type L, DirLTR is returned. +If the first such character has type R or AL, DirRTL is returned. +If the string does not contain any character of these types, then DirNeutral is returned. +This is a lightweight function for use when only the base direction is needed and +no further bidi processing of the text is needed. + +\returns DirRTL, DirLTR or DirNeutral +*/ +QString::Direction QString::basicDirection() const +{ +#ifndef QT_NO_UNICODETABLES + // find base direction + unsigned int pos = 0; + while ((pos < length()) && + (at(pos) != RLE) && + (at(pos) != LRE) && + (at(pos) != RLO) && + (at(pos) != LRO) && + (at(pos).direction() > 1) && + (at(pos).direction() != QChar::DirAL)) // not R and not L + pos++; + + if (pos == length()) + return DirNeutral; + + if ((at(pos).direction() == QChar::DirR) || + (at(pos).direction() == QChar::DirAL) || + (at(pos) == RLE) || + (at(pos) == RLO)) + return DirRTL; + return DirLTR; +#else + return DirLTR; +#endif } #ifndef QT_NO_UNICODETABLES diff --git a/qtools/qstring.h b/qtools/qstring.h index df3873d..5fcff29 100644 --- a/qtools/qstring.h +++ b/qtools/qstring.h @@ -369,6 +369,38 @@ public: QString &operator=( QChar c ); QString &operator=( char c ); + enum Direction + { + /// No strongly directional text. + /*! + * As return value for direction() or baseDirection(), it means that the source string + * is missing or empty, or contains neither left-to-right nor right-to-left characters. + */ + DirNeutral = 0x0, + /// Left-to-right text. + /*! + * - As return value for direction(), it means that the source string + * contains no right-to-left characters. + * - As return value for basicDirection(), it means that the first strong character + * of the source string has a left-to-right direction. + */ + DirLTR = 0b01, + /// Right-to-left text. + /*! + * - As return value for direction(), it means that the source string + * contains no left-to-right characters. + * - As return value for basicDirection(), it means that the first strong character + * of the source string has a right-to-left direction. + */ + DirRTL = 0b10, + /// Mixed-directional text + /*! + * As return value for direction(), it means that the source string + * contains both left-to-right and right-to-left characters. + */ + DirMixed = 0b11 + }; + //QT_STATIC_CONST QString null; //bool isNull() const; @@ -535,8 +567,9 @@ public: #endif // new functions for BiDi void compose(); - QChar::Direction basicDirection(); - QString visual(int index = 0, int len = -1); + QString::Direction direction() const; + QString::Direction basicDirection() const; + QString visual(int index = 0, int len = -1); #ifndef QT_NO_COMPAT const char* data() const { return latin1(); } diff --git a/src/config.xml b/src/config.xml index 8bb6add..69b4464 100644 --- a/src/config.xml +++ b/src/config.xml @@ -343,6 +343,19 @@ Go to the next section or return to the +