View Issue Details

IDProjectCategoryView StatusLast Update
0015664ScribusLanguage Toolspublic2019-06-04 20:55
Reportermaximm Assigned Tojghali  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
Fixed in Version1.5.5.svn 
Summary0015664: Support Hebrew numbering system
DescriptionThe attached patch implements Hebrew numerals support for page numbers and numbered lists. (More info on this numbering system: https://en.wikipedia.org/wiki/Hebrew_numerals)

For the UI, a new item is added to the numbering type combobox in the text properties panel and in the section tab of the document setup dialog. The new item is listed before "*", as its label is much similar to the first ones in the list. Such position in the list requires adding the new value to the middle of the NumFormat enum (see scribus/numeration.h), given that values of this enum are casted internally to the indexes of the combobox.

However, this will break compatibility with existing documents that use numbered lists, as (unlike page numbers and notes) the enum value is written to the file. e.g. NumerationFormat="8" will be interpreted as asterisk before my patch, and as Hebrew after my patch. If such breakage is no longer appropriate at this stage of 1.5.x development, I can move the new value to the end of the enum, at the cost of a less-ideal UI. (And as a future consideration, it might make sense to use the same approach of writing a string representation of the type, like what is done for page numbers, instead of making the index inside a combobox part of the file format...)
Tagspatch
PatchYes

Activities

maximm

2019-04-29 08:00

reporter  

heb.patch (4,982 bytes)   
diff --git a/scribus/numeration.cpp b/scribus/numeration.cpp
index aabd3511b..234d411c0 100644
--- a/scribus/numeration.cpp
+++ b/scribus/numeration.cpp
@@ -29,6 +29,7 @@ QStringList getFormatList()
 	     << QString::fromLatin1("A, B, C, ...")
 	     << QString::fromUtf8("\xE2\x80\xADأ, ب, ت, ...\xE2\x80\xAC")
 	     << QString::fromUtf8("\xE2\x80\xADأ, ب, ج, ...\xE2\x80\xAC")
+	     << QString::fromUtf8("\xE2\x80\xADא, ב, ג, ...\xE2\x80\xAC")
 	     << QString::fromLatin1("*")
 	     << QString::fromLatin1("CJK");
 	return list;
diff --git a/scribus/numeration.h b/scribus/numeration.h
index 1957173ba..bf004bd26 100644
--- a/scribus/numeration.h
+++ b/scribus/numeration.h
@@ -15,6 +15,7 @@ typedef enum
 	Type_A_B_C,
 	Type_Alphabet_ar,
 	Type_Abjad_ar,
+	Type_Hebrew,
 	Type_asterix,
 	Type_CJK,
 	Type_None=99
diff --git a/scribus/plugins/fileloader/scribus150format/scribus150format.cpp b/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
index 3687229b5..1d6df6d85 100644
--- a/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
+++ b/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
@@ -3408,6 +3408,8 @@ bool Scribus150Format::readNotesStyles(ScribusDoc* doc, ScXmlStreamReader& reade
 				NS.setType(Type_Alphabet_ar);
 			else if (type == "Type_Abjad_ar")
 				NS.setType(Type_Abjad_ar);
+			else if (type == "Type_Hebrew")
+				NS.setType(Type_Hebrew);
 			else if (type == "Type_asterix")
 				NS.setType(Type_asterix);
 			else if (type == "Type_CJK")
@@ -3576,6 +3578,8 @@ bool Scribus150Format::readSections(ScribusDoc* doc, ScXmlStreamReader& reader)
 				newSection.type=Type_Alphabet_ar;
 			if (type == "Type_Abjad_ar")
 				newSection.type=Type_Abjad_ar;
+			if (type == "Type_Hebrew")
+				newSection.type=Type_Hebrew;
 			if (type == "Type_CJK")
 				newSection.type=Type_CJK;
 			if (type == "Type_None")
diff --git a/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp b/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
index 9dc03aeab..24f689ab9 100644
--- a/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
+++ b/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
@@ -1273,6 +1273,9 @@ void Scribus150Format::writeSections(ScXmlStreamWriter & docu)
 			case Type_Abjad_ar:
 				docu.writeAttribute("Type", "Type_Abjad_ar");
 				break;
+			case Type_Hebrew:
+				docu.writeAttribute("Type", "Type_Hebrew");
+				break;
 			case Type_asterix:
 				docu.writeAttribute("Type", "Type_asterix");
 				break;
@@ -1365,6 +1368,9 @@ void Scribus150Format::writeNotesStyles(ScXmlStreamWriter & docu)
 			case Type_Abjad_ar:
 				docu.writeAttribute("Type", "Type_Abjad_ar");
 				break;
+			case Type_Hebrew:
+				docu.writeAttribute("Type", "Type_Hebrew");
+				break;
 			case Type_asterix:
 				docu.writeAttribute("Type", "Type_asterix");
 				break;
diff --git a/scribus/util.cpp b/scribus/util.cpp
index f7a0163bb..f125033f8 100644
--- a/scribus/util.cpp
+++ b/scribus/util.cpp
@@ -553,6 +553,9 @@ const QString getStringFromSequence(NumFormat type, uint position, const QString
 		case Type_Abjad_ar:
 			retVal = numberToLetterSequence(abjad, position);
 			break;
+		case Type_Hebrew:
+			retVal = numberToHebrew(position);
+			break;
 		case Type_I_II_III:
 			retVal = numberToRoman(position);
 			break;
@@ -1173,6 +1176,45 @@ void getUniqueName(QString &name, const QStringList& list, const QString& separa
 	name = newName;
 }
 
+const QString numberToHebrew(uint i)
+{
+	const QString hebrew("אבגדהוזחטיכלמנסעפצקרשת");
+	QString result;
+
+	if (i > 999)
+	{
+		result.append(numberToHebrew(i / 1000));
+		result.append(QChar(0x05F3));
+		i %= 1000;
+	}
+
+	int hundreds = i / 100;
+	int tens = (i - hundreds * 100) / 10;
+	int ones = i % 10;
+
+	while (hundreds > 4)
+	{
+		result.append(hebrew.at(21));
+		hundreds -= 4;
+	}
+
+	if (hundreds)
+		result.append(hebrew.at(hundreds + 17));
+
+	if (tens == 1 && ones == 5)
+		result.append("טו");
+	else if (tens == 1 && ones == 6)
+		result.append("טז");
+	else
+	{
+		if (tens)
+			result.append(hebrew.at(tens + 8));
+		if (ones)
+			result.append(hebrew.at(ones - 1));
+	}
+
+	return result;
+}
 
 const QString numberToCJK(uint i)
 {
diff --git a/scribus/util.h b/scribus/util.h
index ef0a8278a..4a344b86b 100644
--- a/scribus/util.h
+++ b/scribus/util.h
@@ -128,6 +128,7 @@ QString SCRIBUS_API getFileNameByPage(ScribusDoc* currDoc, uint pageNo, const QS
 //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, const QString& asterix="*");
+const QString SCRIBUS_API numberToHebrew(uint i);
 const QString SCRIBUS_API numberToRoman(uint i);
 const QString SCRIBUS_API numberToCJK(uint i);
 QChar SCRIBUS_API cjkDigit(uint i);
heb.patch (4,982 bytes)   

jghali

2019-04-29 17:32

administrator   ~0046170

Thanks! I committed your patch which quite a few modifications.

>> However, this will break compatibility with existing documents that use numbered lists, as (unlike page numbers and notes) the enum value is written to the file. e.g. NumerationFormat="8" will be interpreted as asterisk before my patch, and as Hebrew after my patch. If such breakage is no longer appropriate at this stage of 1.5.x development, I can move the new value to the end of the enum, at the cost of a less-ideal UI.

Breaking existing docs now would not have been very nice. So I moved the new NumFormat value toward the end of the enumeration and adopted an approach which will give us more flexibility on the NumFormat values presentation. To do so I created new combo widgets which disconnect individual NumFormat values and their position in the combobox list. The presentation order is still determined by the getFormatList() function, however the order itself is now free and can be modified.

Issue History

Date Modified Username Field Change
2019-04-29 08:00 maximm New Issue
2019-04-29 08:00 maximm File Added: heb.patch
2019-04-29 08:50 ale Summary Support Hebrew numbering system => [PATCH] Support Hebrew numbering system
2019-04-29 08:51 ale Tag Attached: patch
2019-04-29 17:32 jghali Note Added: 0046170
2019-04-29 17:32 jghali Assigned To => jghali
2019-04-29 17:32 jghali Status new => resolved
2019-04-29 17:32 jghali Resolution open => fixed
2019-04-29 17:32 jghali Fixed in Version => 1.5.5.svn
2019-04-29 17:32 jghali Summary [PATCH] Support Hebrew numbering system => Support Hebrew numbering system
2019-06-04 20:55 cbradney Status resolved => closed