r19267 by craig - Prepare Arabic to Chinese number conversion for #11632, move AttributeValue from util.h to scribusstructs.h, clean up util.h includes

scribus-commit scribus-commit at lists.scribus.net
Sun Jun 22 21:49:08 UTC 2014


Author: craig
Date: Sun Jun 22 21:49:07 2014
New Revision: 19267

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19267
Log:
Prepare Arabic to Chinese number conversion for #11632, move AttributeValue from util.h to scribusstructs.h, clean up util.h includes

Modified:
    trunk/Scribus/scribus/gtaction.cpp
    trunk/Scribus/scribus/notesstyles.cpp
    trunk/Scribus/scribus/notesstyles.h
    trunk/Scribus/scribus/numeration.cpp
    trunk/Scribus/scribus/numeration.h
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem_noteframe.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
    trunk/Scribus/scribus/plugins/import/odg/importodg.cpp
    trunk/Scribus/scribus/plugins/import/odg/importodg.h
    trunk/Scribus/scribus/plugins/import/pages/importpages.cpp
    trunk/Scribus/scribus/plugins/import/pages/importpages.h
    trunk/Scribus/scribus/plugins/import/viva/importviva.cpp
    trunk/Scribus/scribus/plugins/import/viva/importviva.h
    trunk/Scribus/scribus/scribusstructs.h
    trunk/Scribus/scribus/ui/helpbrowser.cpp
    trunk/Scribus/scribus/ui/helpbrowser.h
    trunk/Scribus/scribus/ui/marksmanager.cpp
    trunk/Scribus/scribus/ui/notesstyleseditor.cpp
    trunk/Scribus/scribus/ui/prefs_documentsections.cpp
    trunk/Scribus/scribus/util.cpp
    trunk/Scribus/scribus/util.h

Modified: trunk/Scribus/scribus/gtaction.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/gtaction.cpp
==============================================================================
--- trunk/Scribus/scribus/gtaction.cpp (original)
+++ trunk/Scribus/scribus/gtaction.cpp Sun Jun 22 21:49:07 2014
@@ -48,7 +48,7 @@
 #include "scribusdoc.h"
 #include "scribus.h"
 #include "undomanager.h"
-
+#include "util.h"
 #include "util_icon.h"
 #include "util_text.h"
 #include "ui/propertiespalette.h"

Modified: trunk/Scribus/scribus/notesstyles.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/notesstyles.cpp
==============================================================================
--- trunk/Scribus/scribus/notesstyles.cpp (original)
+++ trunk/Scribus/scribus/notesstyles.cpp Sun Jun 22 21:49:07 2014
@@ -1,5 +1,6 @@
 #include "notesstyles.h"
 #include "marks.h"
+#include "util.h"
 
 void NotesStyle::setEndNotes(bool setendnotes)
 {
@@ -20,3 +21,9 @@
 			(marksCharStyle != n2.marksCharStyle) || (notesParaStyle != n2.notesParaStyle)
 			);
 }
+
+
+const QString TextNote::numString()
+{
+	return notesStyle()->numString(m_number);
+}

Modified: trunk/Scribus/scribus/notesstyles.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/notesstyles.h
==============================================================================
--- trunk/Scribus/scribus/notesstyles.h (original)
+++ trunk/Scribus/scribus/notesstyles.h Sun Jun 22 21:49:07 2014
@@ -11,7 +11,6 @@
 #include "styles/charstyle.h"
 #include "styles/paragraphstyle.h"
 #include "text/storytext.h"
-#include "util.h"
 
 class ScribusDoc;
 class PageItem_NoteFrame;
@@ -103,7 +102,7 @@
 	NotesStyle* notesStyle() { return m_notesStyle; }
 	const int num() { return  m_number; }
 	void setNum(const int i) { m_number = i; }
-	const QString numString() { return notesStyle()->numString(m_number); }
+	const QString numString();
 	Mark* masterMark() { return m_noteMasterMark; }
 	void setMasterMark(Mark* m) { m_noteMasterMark = m; }
 	Mark* noteMark() { return m_noteFrameMark; }

Modified: trunk/Scribus/scribus/numeration.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/numeration.cpp
==============================================================================
--- trunk/Scribus/scribus/numeration.cpp (original)
+++ trunk/Scribus/scribus/numeration.cpp Sun Jun 22 21:49:07 2014
@@ -32,6 +32,8 @@
 		name = "A_B_C";
 	else if (format == Type_asterix)
 		name = "*";
+	else if (format == Type_Chinese)
+		name = "Chinese";
 	Q_ASSERT(!name.isEmpty());
 	return name;
 }
@@ -39,7 +41,7 @@
 const QStringList getFormatList()
 {
 	QStringList list;
-	list << "1_2_3" << "i_ii_iii" << "I_II_III" << "a_b_c" << "A_B_C" << "*";
+	list << "1_2_3" << "i_ii_iii" << "I_II_III" << "a_b_c" << "A_B_C" << "*" << "Chinese";
 	return list;
 }
 

Modified: trunk/Scribus/scribus/numeration.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/numeration.h
==============================================================================
--- trunk/Scribus/scribus/numeration.h (original)
+++ trunk/Scribus/scribus/numeration.h Sun Jun 22 21:49:07 2014
@@ -13,6 +13,7 @@
 	Type_a_b_c,
 	Type_A_B_C,
 	Type_asterix,
+	Type_Chinese,
 	Type_None=99
 } NumFormat;
 

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Sun Jun 22 21:49:07 2014
@@ -2134,7 +2134,6 @@
 			//#12405 (isGroup()) &&
 			(!m_Doc->drawAsPreview))
 		{
-			qDebug()<<"DrawObj_Decoration layerMarkersShown";
 			p->setPen(Qt::black, 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 			p->setPenOpacity(1.0);
 			p->setBrush(m_Doc->layerMarker(LayerID));

Modified: trunk/Scribus/scribus/pageitem_noteframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/pageitem_noteframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_noteframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_noteframe.cpp Sun Jun 22 21:49:07 2014
@@ -7,6 +7,7 @@
 
 #include "scribusdoc.h"
 #include "undomanager.h"
+#include "util.h"
 #include "util_text.h"
 
 

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Sun Jun 22 21:49:07 2014
@@ -3305,6 +3305,8 @@
 				NS.setType(Type_A_B_C);
 			else if (type == "Type_asterix")
 				NS.setType(Type_asterix);
+			else if (type == "Type_Chinese")
+				NS.setType(Type_Chinese);
 			else //if (type == "Type_None")
 				NS.setType(Type_None);
 			NS.setRange((NumerationRange) attrs.valueAsInt("Range"));

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp Sun Jun 22 21:49:07 2014
@@ -1214,6 +1214,9 @@
 				break;
 			case Type_asterix:
 				docu.writeAttribute("Type", "Type_asterix");
+				break;
+			case Type_Chinese:
+				docu.writeAttribute("Type", "Type_Chinese");
 				break;
 			case Type_None:
 				docu.writeAttribute("Type", "Type_None");

Modified: trunk/Scribus/scribus/plugins/import/odg/importodg.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/plugins/import/odg/importodg.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/odg/importodg.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/odg/importodg.cpp Sun Jun 22 21:49:07 2014
@@ -64,6 +64,7 @@
 #include "ui/multiprogressdialog.h"
 #include "ui/propertiespalette.h"
 #include "undomanager.h"
+#include "util.h"
 #include "util_formats.h"
 #include "util_icon.h"
 #include "util_math.h"

Modified: trunk/Scribus/scribus/plugins/import/odg/importodg.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/plugins/import/odg/importodg.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/odg/importodg.h (original)
+++ trunk/Scribus/scribus/plugins/import/odg/importodg.h Sun Jun 22 21:49:07 2014
@@ -18,7 +18,7 @@
 #include "pageitem.h"
 #include "sccolor.h"
 #include "fpointarray.h"
-#include "util.h"
+#include "scribusstructs.h"
 #include <QList>
 #include <QTransform>
 #include <QMultiMap>

Modified: trunk/Scribus/scribus/plugins/import/pages/importpages.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/plugins/import/pages/importpages.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pages/importpages.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pages/importpages.cpp Sun Jun 22 21:49:07 2014
@@ -61,6 +61,7 @@
 #include "ui/multiprogressdialog.h"
 #include "ui/propertiespalette.h"
 #include "undomanager.h"
+#include "util.h"
 #include "util_formats.h"
 #include "util_icon.h"
 #include "util_math.h"

Modified: trunk/Scribus/scribus/plugins/import/pages/importpages.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/plugins/import/pages/importpages.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pages/importpages.h (original)
+++ trunk/Scribus/scribus/plugins/import/pages/importpages.h Sun Jun 22 21:49:07 2014
@@ -17,7 +17,7 @@
 #include "pageitem.h"
 #include "sccolor.h"
 #include "fpointarray.h"
-#include "util.h"
+#include "scribusstructs.h"
 #include <QList>
 #include <QTransform>
 #include <QMultiMap>

Modified: trunk/Scribus/scribus/plugins/import/viva/importviva.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/plugins/import/viva/importviva.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/viva/importviva.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/viva/importviva.cpp Sun Jun 22 21:49:07 2014
@@ -60,6 +60,7 @@
 #include "ui/multiprogressdialog.h"
 #include "ui/propertiespalette.h"
 #include "undomanager.h"
+#include "util.h"
 #include "util_formats.h"
 #include "util_icon.h"
 #include "util_math.h"

Modified: trunk/Scribus/scribus/plugins/import/viva/importviva.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/plugins/import/viva/importviva.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/viva/importviva.h (original)
+++ trunk/Scribus/scribus/plugins/import/viva/importviva.h Sun Jun 22 21:49:07 2014
@@ -19,7 +19,7 @@
 #include "sctextstruct.h"
 #include "text/storytext.h"
 #include "fpointarray.h"
-#include "util.h"
+#include "scribusstructs.h"
 #include <QList>
 #include <QTransform>
 #include <QMultiMap>

Modified: trunk/Scribus/scribus/scribusstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/scribusstructs.h
==============================================================================
--- trunk/Scribus/scribus/scribusstructs.h (original)
+++ trunk/Scribus/scribus/scribusstructs.h Sun Jun 22 21:49:07 2014
@@ -349,5 +349,28 @@
 	}
 };
 
+class AttributeValue
+{
+	public:
+		AttributeValue() : valid(false),  value("")
+		{
+		}
+		AttributeValue(QString val)
+		{
+			if (val.isEmpty() || (val == ""))
+			{
+				valid = false;
+				value = QString();
+			}
+			else
+			{
+				valid = true;
+				value = val;
+			}
+		}
+		bool valid;
+		QString value;
+};
+
 #endif
 

Modified: trunk/Scribus/scribus/ui/helpbrowser.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/ui/helpbrowser.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/helpbrowser.cpp (original)
+++ trunk/Scribus/scribus/ui/helpbrowser.cpp Sun Jun 22 21:49:07 2014
@@ -57,6 +57,7 @@
 
 #include "prefsmanager.h"
 #include "scribuscore.h"
+#include "util.h"
 #include "util_icon.h"
 
 /*! \brief XML parsef for documantation history.

Modified: trunk/Scribus/scribus/ui/helpbrowser.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/ui/helpbrowser.h
==============================================================================
--- trunk/Scribus/scribus/ui/helpbrowser.h (original)
+++ trunk/Scribus/scribus/ui/helpbrowser.h Sun Jun 22 21:49:07 2014
@@ -48,7 +48,6 @@
 
 #include "ui_helpbrowser.h"
 #include "scribusapi.h"
-#include "util.h"
 #include "scconfig.h"
 #include "scpaths.h"
 #include "prefsmanager.h"

Modified: trunk/Scribus/scribus/ui/marksmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/ui/marksmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/marksmanager.cpp (original)
+++ trunk/Scribus/scribus/ui/marksmanager.cpp Sun Jun 22 21:49:07 2014
@@ -5,6 +5,7 @@
 #include "scribus.h"
 #include "scribusdoc.h"
 #include "undomanager.h"
+#include "util.h"
 #include <QStandardItemModel>
 
 MarksManager::MarksManager(QWidget *parent, const char *name)

Modified: trunk/Scribus/scribus/ui/notesstyleseditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/ui/notesstyleseditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/notesstyleseditor.cpp (original)
+++ trunk/Scribus/scribus/ui/notesstyleseditor.cpp Sun Jun 22 21:49:07 2014
@@ -8,6 +8,7 @@
 
 #include "scribus.h"
 #include "undomanager.h"
+#include "util.h"
 
 NotesStylesEditor::NotesStylesEditor(QWidget *parent, const char *name)
 	: ScrPaletteBase(parent, name), m_Doc(NULL)

Modified: trunk/Scribus/scribus/ui/prefs_documentsections.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/ui/prefs_documentsections.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_documentsections.cpp (original)
+++ trunk/Scribus/scribus/ui/prefs_documentsections.cpp Sun Jun 22 21:49:07 2014
@@ -38,7 +38,7 @@
 	localSections=prefsData->docSectionMap;
 	m_maxpageindex=m_doc->DocPages.count()-1;
 	styles.clear();
-	styles << tr("1, 2, 3, ...") << tr("i, ii, iii, ...") << tr("I, II, III, ...") << tr("a, b, c, ...") << tr("A, B, C, ...") << CommonStrings::tr_None;
+	styles << tr("1, 2, 3, ...") << tr("i, ii, iii, ...") << tr("I, II, III, ...") << tr("a, b, c, ...") << tr("A, B, C, ...") << tr("*") << tr("Chinese") << CommonStrings::tr_None;
 
 	updateTable();
 }
@@ -108,7 +108,6 @@
 {
 	bool outOfRange=false;
 	uint newDocPageSpec;
-
 	switch (col)
 	{
 	case 0:
@@ -153,15 +152,15 @@
 					localSections[row].type=(NumFormat)index;
 				else
 					if (index==styles.count()-1)
-					localSections[row].type=Type_None;
+						localSections[row].type=Type_None;
 			}
 		}
 		break;
 	case 6:
-		localSections[row].sectionstartindex= sectionsTable->item(row, col)->text().toUInt();;
+		localSections[row].sectionstartindex = sectionsTable->item(row, col)->text().toUInt();;
 		break;
 	case 7:
-		localSections[row].pageNumberWidth=sectionsTable->item(row, col)->text().toInt();
+		localSections[row].pageNumberWidth = sectionsTable->item(row, col)->text().toInt();
 		break;
 	case 8:
 		{

Modified: trunk/Scribus/scribus/util.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/util.cpp
==============================================================================
--- trunk/Scribus/scribus/util.cpp (original)
+++ trunk/Scribus/scribus/util.cpp Sun Jun 22 21:49:07 2014
@@ -569,6 +569,8 @@
 			for (uint a=1; a <= position; ++a)
 				retVal.append(asterix);
 			break;
+		case Type_Chinese:
+			retVal=arabicToChinese(position);
 		case Type_None:
 			break;
 		default:
@@ -1196,3 +1198,95 @@
 	} while (list.contains(newName));
 	name = newName;
 }
+
+
+const QString arabicToChinese(uint i)
+{
+	QString result;
+	if (i<10)
+		result = QString(chineseDigit(i));
+
+	if (i>9 && i<=99)
+	{
+		int tens=i/10;
+		int ones=i%10;
+		if (tens!=1)
+			result.append(chineseDigit(tens));
+		result.append(chineseDigit(10));
+		if (ones!=0)
+			result.append(chineseDigit(ones));
+	}
+
+	if (i>99 && i<=999)
+	{
+		int hundreds=i/100;
+		int tens=(i-hundreds*100)/10;
+		int ones=i%10;
+		result.append(chineseDigit(hundreds));
+		result.append(chineseDigit(100));
+		if (tens!=0)
+		{
+			result.append(chineseDigit(tens));
+			result.append(chineseDigit(10));
+		}
+		else if (ones!=0)
+			result.append(chineseDigit(0));
+		if (ones!=0)
+			result.append(chineseDigit(ones));
+	}
+	return result;
+}
+
+
+QChar chineseDigit(uint i)
+{
+	switch (i)
+	{
+		case 0:
+			return QChar(0x96f6);
+			break;
+		case 1:
+			return QChar(0x4e00);
+			break;
+		case 2:
+			return QChar(0x4e8c);
+			break;
+		case 3:
+			return QChar(0x4e09);
+			break;
+		case 4:
+			return QChar(0x56db);
+			break;
+		case 5:
+			return QChar(0x4e94);
+			break;
+		case 6:
+			return QChar(0x516d);
+			break;
+		case 7:
+			return QChar(0x4e03);
+			break;
+		case 8:
+			return QChar(0x516b);
+			break;
+		case 9:
+			return QChar(0x4e5d);
+			break;
+		case 10:
+			return QChar(0x5341);
+			break;
+		case 100:
+			return QChar(0x767e);
+			break;
+		case 1000:
+			return QChar(0x5343);
+			break;
+		case 10000:
+			return QChar(0x842c);
+			break;
+		case 100000000:
+			return QChar(0x5104);
+			break;
+	}
+	return QChar::Null;
+}

Modified: trunk/Scribus/scribus/util.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19267&path=/trunk/Scribus/scribus/util.h
==============================================================================
--- trunk/Scribus/scribus/util.h (original)
+++ trunk/Scribus/scribus/util.h Sun Jun 22 21:49:07 2014
@@ -24,9 +24,6 @@
 #include <QVector>
 
 #include "pagestructs.h"
-// #include "style.h"
-// #include "styles/charstyle.h"
-// #include "styles/paragraphstyle.h"
 #include "scribusapi.h"
 
 class  QDomElement;
@@ -38,28 +35,7 @@
 class  ScStreamFilter;
 struct CopyPasteBuffer;
 
-class AttributeValue
-{
-	public:
-		AttributeValue() : valid(false),  value("")
-		{
-		}
-		AttributeValue(QString val)
-		{
-			if (val.isEmpty() || (val == ""))
-			{
-				valid = false;
-				value = QString();
-			}
-			else
-			{
-				valid = true;
-				value = val;
-			}
-		}
-		bool valid;
-		QString value;
-};
+
 
 // class Foi;
 
@@ -156,6 +132,8 @@
 //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 arabicToChinese(uint i);
+QChar SCRIBUS_API chineseDigit(uint i);
 const QString SCRIBUS_API numberToLetterSequence(uint i);
 void SCRIBUS_API parsePagesString(QString pages, std::vector<int>* pageNs, int sourcePageCount);
 




More information about the scribus-commit mailing list