r21448 by craig -

scribus-commit scribus-commit at lists.scribus.net
Sun Sep 18 16:18:50 UTC 2016


Author: craig
Date: Sun Sep 18 16:18:50 2016
New Revision: 21448

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21448
Log:
Bring in some non intrusive changes from CTL

Modified:
    trunk/Scribus/AUTHORS
    trunk/Scribus/scribus/numeration.cpp
    trunk/Scribus/scribus/numeration.h
    trunk/Scribus/scribus/undostate.h
    trunk/Scribus/scribus/util.cpp
    trunk/Scribus/scribus/util.h

Modified: trunk/Scribus/AUTHORS
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21448&path=/trunk/Scribus/AUTHORS
==============================================================================
--- trunk/Scribus/AUTHORS	(original)
+++ trunk/Scribus/AUTHORS	Sun Sep 18 16:18:50 2016
@@ -71,7 +71,7 @@
 Giovanni Mugnai musical777 at gmail.com
 
 
-Refactoring text layout code and the new boxes model, Oman House of Open Source Technology team:
+Refactoring text layout code, the new boxes model & CTL text layout, Oman House of Open Source Technology team:
 
 Anood Almuharbi anood.almuharbi at gmail.com
 Asma ALbahanta as.bahanta at gmail.com

Modified: trunk/Scribus/scribus/numeration.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21448&path=/trunk/Scribus/scribus/numeration.cpp
==============================================================================
--- trunk/Scribus/scribus/numeration.cpp	(original)
+++ trunk/Scribus/scribus/numeration.cpp	Sun Sep 18 16:18:50 2016
@@ -17,38 +17,20 @@
 	return str;
 }
 
-QString getFormatName(int format)
-{
-	QString name;
-	if (format == Type_1_2_3)
-		name = "1_2_3";
-	else if (format == Type_i_ii_iii)
-		name = "i_ii_iii";
-	else if (format == Type_I_II_III)
-		name = "I_II_III";
-	else if (format == Type_a_b_c)
-		name = "a_b_c";
-	else if (format == Type_A_B_C)
-		name = "A_B_C";
-	else if (format == Type_asterix)
-		name = "*";
-	else if (format == Type_CJK)
-		name = "CJK";
-	Q_ASSERT(!name.isEmpty());
-	return name;
-}
-
-QStringList getFormatList()
-{
-	QStringList list;
-	list << "1_2_3" << "i_ii_iii" << "I_II_III" << "a_b_c" << "A_B_C" << "*" << "CJK";
-	return list;
-}
-
 QStringList getFormatListTr()
 {
 	QStringList list;
-	list << QObject::tr("1, 2, 3, ...") << QObject::tr("i, ii, iii, ...") << QObject::tr("I, II, III, ...") << QObject::tr("a, b, c, ...") << QObject::tr("A, B, C, ...") << QObject::tr("*") << QObject::tr("CJK");
+	list << QObject::tr("1, 2, 3, ...")
+	     // U+202D...U+202C to force the string to be displayed LTR
+	     << QObject::trUtf8("\u202dÙ¡, Ù¢, Ù£, ...\u202c")
+	     << QObject::tr("i, ii, iii, ...")
+	     << QObject::tr("I, II, III, ...")
+	     << QObject::tr("a, b, c, ...")
+	     << QObject::tr("A, B, C, ...")
+	     << QObject::trUtf8("\u202dأ, ب, ت, ...\u202c")
+	     << QObject::trUtf8("\u202dأ, ب, ج, ...\u202c")
+	     << QObject::tr("*")
+	     << QObject::tr("CJK");
 	return list;
 }
 

Modified: trunk/Scribus/scribus/numeration.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21448&path=/trunk/Scribus/scribus/numeration.h
==============================================================================
--- trunk/Scribus/scribus/numeration.h	(original)
+++ trunk/Scribus/scribus/numeration.h	Sun Sep 18 16:18:50 2016
@@ -8,10 +8,13 @@
 typedef enum 
 {
 	Type_1_2_3,
+	Type_1_2_3_ar,
 	Type_i_ii_iii,
 	Type_I_II_III,
 	Type_a_b_c,
 	Type_A_B_C,
+	Type_Alphabet_ar,
+	Type_Abjad_ar,
 	Type_asterix,
 	Type_CJK,
 	Type_None=99

Modified: trunk/Scribus/scribus/undostate.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21448&path=/trunk/Scribus/scribus/undostate.h
==============================================================================
--- trunk/Scribus/scribus/undostate.h	(original)
+++ trunk/Scribus/scribus/undostate.h	Sun Sep 18 16:18:50 2016
@@ -316,7 +316,7 @@
 	: SimpleState(name, description, pixmap) {}
 	~ScItemsState() {}
 	void insertItem(QString itemname, void * item) { pointerMap.insert(itemname, item); }
-	void* getItem(QString itemname) const { if (pointerMap.contains(itemname)) return pointerMap.value(itemname); else return NULL;}
+	void* getItem(QString itemname) const { if (pointerMap.contains(itemname)) return pointerMap.value(itemname, NULL); else return NULL;}
 	QList< QPair<void*, int> > insertItemPos;
 private:
 	QMap<QString,void*> pointerMap;

Modified: trunk/Scribus/scribus/util.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21448&path=/trunk/Scribus/scribus/util.cpp
==============================================================================
--- trunk/Scribus/scribus/util.cpp	(original)
+++ trunk/Scribus/scribus/util.cpp	Sun Sep 18 16:18:50 2016
@@ -390,6 +390,8 @@
 			{
 				ww++;
 			}
+			if (b.isSurrogate())
+				++a;
 			cc++;
 			Dat = b;
 			first = false;
@@ -410,6 +412,8 @@
 			{
 				wwN++;
 			}
+			if (b.isSurrogate())
+				++a;
 			ccN++;
 			Dat = b;
 			first = false;
@@ -529,31 +533,45 @@
 const QString getStringFromSequence(NumFormat type, uint position, QString asterix)
 {
 	QString retVal("");
+
+	const QString english("abcdefghijklmnopqrstuvwxyz");
+	const QString arabic("أبتثجحخدذرزسشصضطظعغفقكلÙ
نهوي");
+	const QString abjad("أبجدهوزحطيكلÙ
نسعفصقرشتثخذضظغ");
+
 	switch( type )
 	{
 		case Type_1_2_3:
 			retVal=QString::number(position);
 			break;
+		case Type_1_2_3_ar:
+			retVal=QLocale("ar").toString(position);
+			break;
 		case Type_A_B_C:
-			retVal=numberToLetterSequence(position).toUpper();
+			retVal = numberToLetterSequence(english, position).toUpper();
 			break;
 		case Type_a_b_c:
-			retVal=numberToLetterSequence(position);
+			retVal = numberToLetterSequence(english, position);
+			break;
+		case Type_Alphabet_ar:
+			retVal = numberToLetterSequence(arabic, position);
+			break;
+		case Type_Abjad_ar:
+			retVal = numberToLetterSequence(abjad, position);
 			break;
 		case Type_I_II_III:
-			retVal=arabicToRoman(position);
+			retVal = numberToRoman(position);
 			break;
 		case Type_i_ii_iii:
 			//well, for lower case people will want that, even if its "wrong"
 			//ie, X=10, x=10000
-			retVal=arabicToRoman(position).toLower();
+			retVal = numberToRoman(position).toLower();
 			break;
 		case Type_asterix:
 			for (uint a=1; a <= position; ++a)
 				retVal.append(asterix);
 			break;
 		case Type_CJK:
-			retVal=arabicToCJK(position);
+			retVal = numberToCJK(position);
 		case Type_None:
 			break;
 		default:
@@ -562,24 +580,32 @@
 	return retVal;
 }
 
-const QString numberToLetterSequence(uint i)
+const QString numberToLetterSequence(const QString& letters, uint num)
 {
 	QString retVal("");
 	unsigned digits = 1;
 	unsigned offset = 0;
-	uint column=i-1;
-
-	if( column > 4058115285U ) return  QString("@");
-
-	for( unsigned limit = 26; column >= limit+offset; limit *= 26, digits++ )
+	uint column = num - 1;
+
+	// FIXME: what is the heck is this?
+	if (column > 4058115285U)
+		return  QString("@");
+
+	for (unsigned limit = 28; column >= limit+offset; limit *= letters.length(), digits++)
 		offset += limit;
 
-	for( unsigned c = column - offset; digits; --digits, c/=26 )
-		retVal.prepend( QChar( 'a' + (c%26) ) );
+	for (unsigned c = column - offset; digits; --digits, c /= letters.length())
+	{
+		uint i = c % letters.length();
+		if (i < static_cast<uint>(letters.length()))
+			retVal.prepend(letters.at(i));
+		else
+			retVal.prepend(QChar::Null);
+	}
 	return retVal;
 }
 
-const QString arabicToRoman(uint i)
+const QString numberToRoman(uint i)
 {
 	QString roman("");
 	int arabic = i;
@@ -772,6 +798,15 @@
 	int ind = box->findText(text);
 	if (ind > -1)
 		box->setCurrentIndex(ind);
+	box->blockSignals(sigBlocked);
+}
+
+void removeComboItem(QComboBox *box, QString text)
+{
+	bool sigBlocked = box->blockSignals(true);
+	int ind = box->findText(text);
+	if (ind > -1)
+		box->removeItem(ind);
 	box->blockSignals(sigBlocked);
 }
 
@@ -1133,7 +1168,7 @@
 }
 
 
-const QString arabicToCJK(uint i)
+const QString numberToCJK(uint i)
 {
 	QString result;
 	if (i<10)

Modified: trunk/Scribus/scribus/util.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21448&path=/trunk/Scribus/scribus/util.h
==============================================================================
--- trunk/Scribus/scribus/util.h	(original)
+++ trunk/Scribus/scribus/util.h	Sun Sep 18 16:18:50 2016
@@ -22,6 +22,7 @@
 #include <QString>
 #include <QStringList>
 #include <QVector>
+#include <QTransform>
 
 #include "pagestructs.h"
 #include "scribusapi.h"
@@ -124,14 +125,15 @@
 //asterix is QString used in numeration when number is presented as few chars, like *, **, *** etc
 //default is '*' but can be used any string
 const QString SCRIBUS_API getStringFromSequence(NumFormat type, uint position, QString asterix="*");
-const QString SCRIBUS_API arabicToRoman(uint i);
-const QString SCRIBUS_API arabicToCJK(uint i);
+const QString SCRIBUS_API numberToRoman(uint i);
+const QString SCRIBUS_API numberToCJK(uint i);
 QChar SCRIBUS_API cjkDigit(uint i);
-const QString SCRIBUS_API numberToLetterSequence(uint i);
+const QString SCRIBUS_API numberToLetterSequence(const QString& letters, uint num);
 void SCRIBUS_API parsePagesString(QString pages, std::vector<int>* pageNs, int sourcePageCount);
 
 QString SCRIBUS_API readLinefromDataStream(QDataStream &s);
 void SCRIBUS_API setCurrentComboItem(QComboBox *box, QString text);
+void SCRIBUS_API removeComboItem(QComboBox *box, QString text);
 
 QString SCRIBUS_API readAdobeUniCodeString(QDataStream &s);
 QString SCRIBUS_API readAdobeUniCodeString16(QDataStream &s);
@@ -153,4 +155,5 @@
  * if exist then seprator and numbers are pre/append to name while it will be unique
 */
 void SCRIBUS_API getUniqueName(QString &name, QStringList list, QString separator = "", bool prepend = false);
+
 #endif




More information about the scribus-commit mailing list