summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtextlist
diff options
context:
space:
mode:
authorNils Jeisecke <jeisecke@saltation.de>2010-08-31 13:39:43 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-08-31 13:39:43 (GMT)
commitaf1af7a14c7d89a34267d955ca75ddd7abf5a370 (patch)
tree6d4b1a0bea14c0a9b0902da10d4f6b2d08196f55 /tests/auto/qtextlist
parentaf2b8878ba7bd153876a5531a8119a4bdbc6b257 (diff)
downloadQt-af1af7a14c7d89a34267d955ca75ddd7abf5a370.zip
Qt-af1af7a14c7d89a34267d955ca75ddd7abf5a370.tar.gz
Qt-af1af7a14c7d89a34267d955ca75ddd7abf5a370.tar.bz2
Implemented suffix and prefix strings for the numbering in ordered lists as supported by ODF. Works also with HTML import/export by using Qt CSS properties extensions.
Merge-request: 1642 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'tests/auto/qtextlist')
-rw-r--r--tests/auto/qtextlist/tst_qtextlist.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/auto/qtextlist/tst_qtextlist.cpp b/tests/auto/qtextlist/tst_qtextlist.cpp
index 3e92836..8ad0898 100644
--- a/tests/auto/qtextlist/tst_qtextlist.cpp
+++ b/tests/auto/qtextlist/tst_qtextlist.cpp
@@ -67,6 +67,9 @@ private slots:
void item();
void autoNumbering();
void autoNumberingRTL();
+ void autoNumberingPrefixAndSuffix();
+ void autoNumberingPrefixAndSuffixRTL();
+ void autoNumberingPrefixAndSuffixHtmlExportImport();
void romanNumbering();
void romanNumberingLimit();
void formatChange();
@@ -128,6 +131,76 @@ void tst_QTextList::autoNumbering()
QVERIFY(cursor.currentList()->itemText(cursor.block()) == "ab.");
}
+void tst_QTextList::autoNumberingPrefixAndSuffix()
+{
+ QTextListFormat fmt;
+ fmt.setStyle(QTextListFormat::ListLowerAlpha);
+ fmt.setNumberPrefix("-");
+ fmt.setNumberSuffix(")");
+ QTextList *list = cursor.createList(fmt);
+ QVERIFY(list);
+
+ for (int i = 0; i < 27; ++i)
+ cursor.insertBlock();
+
+ QVERIFY(list->count() == 28);
+
+ QVERIFY(cursor.currentList());
+ QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 27);
+ QVERIFY(cursor.currentList()->itemText(cursor.block()) == "-ab)");
+}
+
+void tst_QTextList::autoNumberingPrefixAndSuffixRTL()
+{
+ QTextBlockFormat bfmt;
+ bfmt.setLayoutDirection(Qt::RightToLeft);
+ cursor.setBlockFormat(bfmt);
+
+ QTextListFormat fmt;
+ fmt.setStyle(QTextListFormat::ListUpperAlpha);
+ fmt.setNumberPrefix("-");
+ fmt.setNumberSuffix("*");
+ QTextList *list = cursor.createList(fmt);
+ QVERIFY(list);
+
+ cursor.insertBlock();
+
+ QVERIFY(list->count() == 2);
+
+ QVERIFY(cursor.currentList()->itemText(cursor.block()) == "*B-");
+}
+
+void tst_QTextList::autoNumberingPrefixAndSuffixHtmlExportImport()
+{
+ QTextListFormat fmt;
+ fmt.setStyle(QTextListFormat::ListLowerAlpha);
+ fmt.setNumberPrefix("\"");
+ fmt.setNumberSuffix("#");
+ fmt.setIndent(10);
+ // FIXME: Would like to test "'" but there's a problem in the css parser (Scanner::preprocess
+ // is called before the values are being parsed), so the quoting does not work.
+ QTextList *list = cursor.createList(fmt);
+ QVERIFY(list);
+
+ for (int i = 0; i < 27; ++i)
+ cursor.insertBlock();
+
+ QVERIFY(list->count() == 28);
+
+ QString htmlExport = doc->toHtml();
+ QTextDocument importDoc;
+ importDoc.setHtml(htmlExport);
+
+ QTextCursor importCursor(&importDoc);
+ for (int i = 0; i < 27; ++i)
+ importCursor.movePosition(QTextCursor::NextBlock);
+
+ QVERIFY(importCursor.currentList());
+ QVERIFY(importCursor.currentList()->itemNumber(importCursor.block()) == 27);
+ QVERIFY(importCursor.currentList()->itemText(importCursor.block()) == "\"ab#");
+ QVERIFY(importCursor.currentList()->format().indent() == 10);
+}
+
void tst_QTextList::autoNumberingRTL()
{
QTextBlockFormat bfmt;