Changeset View
Changeset View
Standalone View
Standalone View
core/textpage.cpp
Context not available. | |||||
1802 | } | 1802 | } | ||
---|---|---|---|---|---|
1803 | 1803 | | |||
1804 | /** | 1804 | /** | ||
1805 | * reoder RTL words to the correct order | ||||
1806 | */ | ||||
1807 | TextList reoderRTLWords (TextList origTxtOrder) | ||||
1808 | { | ||||
1809 | TextList tmp; | ||||
1810 | int i, j, k; | ||||
1811 | | ||||
1812 | i = 0; | ||||
1813 | while (i < origTxtOrder.length()) | ||||
1814 | { | ||||
1815 | // output a left-to-right section | ||||
1816 | for (j = i; j < origTxtOrder.length() && ! origTxtOrder.at(j)->text().isRightToLeft()/*unicodeTypeR(origTxtOrder.at(j)->text().toUInt())*/; ++j) ; | ||||
1817 | for (k = i; k < j; ++k) | ||||
1818 | { | ||||
1819 | tmp.append(origTxtOrder.at(k)); | ||||
1820 | } | ||||
1821 | i = j; | ||||
1822 | // output a right-to-left section | ||||
1823 | for(j = i; j < origTxtOrder.length() && (origTxtOrder.at(j)->text().isRightToLeft() || origTxtOrder.at(j)->text() == " ") /*!(unicodeTypeL(origTxtOrder.at(j)->text().toUInt()) || unicodeTypeNum(origTxtOrder.at(j)->text().toUInt())*/; ++j); | ||||
1824 | | ||||
1825 | if(j > i) | ||||
1826 | { | ||||
1827 | tmp.append(new TinyTextEntity(QChar(0x202b), NormalizedRect())); | ||||
1828 | for (k = j - 1; k >= i; --k) | ||||
1829 | { | ||||
1830 | // filp new line char to be first in RTL word. | ||||
1831 | if (origTxtOrder.at(k)->text().contains('\n')) | ||||
1832 | { | ||||
1833 | QString flipNewLine = origTxtOrder.at(k)->text(); | ||||
1834 | flipNewLine.remove('\n'); | ||||
1835 | flipNewLine.push_front('\n'); | ||||
1836 | tmp.append(new TinyTextEntity(flipNewLine, origTxtOrder.at(k)->area)); | ||||
1837 | } | ||||
1838 | else | ||||
1839 | tmp.append(origTxtOrder.at(k)); | ||||
1840 | } | ||||
1841 | tmp.append(new TinyTextEntity(QChar(0x202c), NormalizedRect())); | ||||
1842 | i = j; | ||||
1843 | } | ||||
1844 | } | ||||
1845 | return tmp; | ||||
1846 | } | ||||
1847 | | ||||
1848 | /** | ||||
1805 | * Add spaces in between words in a line. It reuses the pointers passed in tree and might add new ones. You will need to take care of deleting them if needed | 1849 | * Add spaces in between words in a line. It reuses the pointers passed in tree and might add new ones. You will need to take care of deleting them if needed | ||
1806 | */ | 1850 | */ | ||
1807 | WordsWithCharacters addNecessarySpace(RegionTextList tree, int pageWidth, int pageHeight) | 1851 | WordsWithCharacters addNecessarySpace(RegionTextList tree, int pageWidth, int pageHeight) | ||
Context not available. | |||||
1916 | delete word.word; | 1960 | delete word.word; | ||
1917 | listOfCharacters.append(word.characters); | 1961 | listOfCharacters.append(word.characters); | ||
1918 | } | 1962 | } | ||
1919 | setWordList(listOfCharacters); | 1963 | setWordList(reoderRTLWords(listOfCharacters)); | ||
1920 | } | 1964 | } | ||
1921 | 1965 | | |||
1922 | TextEntity::List TextPage::words(const RegularAreaRect *area, TextAreaInclusionBehaviour b) const | 1966 | TextEntity::List TextPage::words(const RegularAreaRect *area, TextAreaInclusionBehaviour b) const | ||
Context not available. |