From e15d415acbd426e58fb1e967eb331fe41488dfff Mon Sep 17 00:00:00 2001 From: Nils Jeisecke Date: Tue, 12 May 2009 14:47:49 +0200 Subject: Added QTextListFormat::ListUpperRoman and QTextListFormat::ListLowerRoman for roman numbering of lists as supported by HTML/ODF Reviewed-by: Olivier Goffart Merge-request: 681 --- demos/textedit/textedit.cpp | 8 ++++++ src/gui/text/qcssparser.cpp | 10 ++++--- src/gui/text/qcssparser_p.h | 2 ++ src/gui/text/qtextdocument.cpp | 7 ++++- src/gui/text/qtextdocumentlayout.cpp | 6 ++++- src/gui/text/qtextformat.cpp | 2 ++ src/gui/text/qtextformat.h | 2 ++ src/gui/text/qtexthtmlparser.cpp | 6 +++++ src/gui/text/qtextlist.cpp | 49 ++++++++++++++++++++++++++++++++++ src/gui/text/qtextodfwriter.cpp | 8 +++++- tests/auto/qtextlist/tst_qtextlist.cpp | 36 +++++++++++++++++++++++++ 11 files changed, 129 insertions(+), 7 deletions(-) diff --git a/demos/textedit/textedit.cpp b/demos/textedit/textedit.cpp index 17516b4..5eee855 100644 --- a/demos/textedit/textedit.cpp +++ b/demos/textedit/textedit.cpp @@ -336,6 +336,8 @@ void TextEdit::setupTextActions() comboStyle->addItem("Ordered List (Decimal)"); comboStyle->addItem("Ordered List (Alpha lower)"); comboStyle->addItem("Ordered List (Alpha upper)"); + comboStyle->addItem("Ordered List (Roman lower)"); + comboStyle->addItem("Ordered List (Roman upper)"); connect(comboStyle, SIGNAL(activated(int)), this, SLOT(textStyle(int))); @@ -573,6 +575,12 @@ void TextEdit::textStyle(int styleIndex) case 6: style = QTextListFormat::ListUpperAlpha; break; + case 7: + style = QTextListFormat::ListLowerRoman; + break; + case 8: + style = QTextListFormat::ListUpperRoman; + break; } cursor.beginEditBlock(); diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index ab69e5c..db5ed7c 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -199,6 +199,7 @@ static const QCssKnownValue values[NumKnownValues - 1] = { { "link", Value_Link }, { "link-visited", Value_LinkVisited }, { "lower-alpha", Value_LowerAlpha }, + { "lower-roman", Value_LowerRoman }, { "lowercase", Value_Lowercase }, { "medium", Value_Medium }, { "mid", Value_Mid }, @@ -230,6 +231,7 @@ static const QCssKnownValue values[NumKnownValues - 1] = { { "transparent", Value_Transparent }, { "underline", Value_Underline }, { "upper-alpha", Value_UpperAlpha }, + { "upper-roman", Value_UpperRoman }, { "uppercase", Value_Uppercase }, { "wave", Value_Wave }, { "window", Value_Window }, @@ -239,10 +241,10 @@ static const QCssKnownValue values[NumKnownValues - 1] = { }; //Map id to strings as they appears in the 'values' array above -static const short indexOfId[NumKnownValues] = { 0, 40, 47, 41, 48, 53, 34, 26, 68, 69, 25, 42, 5, 62, 46, - 29, 57, 58, 27, 50, 60, 6, 10, 38, 55, 19, 13, 17, 18, 20, 21, 49, 24, 45, 65, 36, 3, 2, 39, 61, 16, - 11, 56, 14, 32, 63, 54, 64, 33, 67, 8, 28, 37, 12, 35, 59, 7, 9, 4, 66, 52, 22, 23, 30, 31, 1, 15, 0, - 51, 44, 43 }; +static const short indexOfId[NumKnownValues] = { 0, 41, 48, 42, 49, 54, 35, 26, 70, 71, 25, 43, 5, 63, 47, + 29, 58, 59, 27, 51, 61, 6, 10, 39, 56, 19, 13, 17, 18, 20, 21, 50, 24, 46, 67, 37, 3, 2, 40, 62, 16, + 11, 57, 14, 32, 64, 33, 65, 55, 66, 34, 69, 8, 28, 38, 12, 36, 60, 7, 9, 4, 68, 53, 22, 23, 30, 31, + 1, 15, 0, 52, 45, 44 }; QString Value::toString() const { diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index 8056f4d..b07acd5 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -223,6 +223,8 @@ enum KnownValue { Value_Decimal, Value_LowerAlpha, Value_UpperAlpha, + Value_LowerRoman, + Value_UpperRoman, Value_SmallCaps, Value_Uppercase, Value_Lowercase, diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 3287f31..3531699 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2416,7 +2416,10 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment) static bool isOrderedList(int style) { return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha - || style == QTextListFormat::ListUpperAlpha; + || style == QTextListFormat::ListUpperAlpha + || style == QTextListFormat::ListUpperRoman + || style == QTextListFormat::ListLowerRoman + ; } void QTextHtmlExporter::emitBlockAttributes(const QTextBlock &block) @@ -2513,6 +2516,8 @@ void QTextHtmlExporter::emitBlock(const QTextBlock &block) case QTextListFormat::ListSquare: html += QLatin1String("