~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to plugins/textshape/tests/TestLists.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
 
122
122
    // now to make sure the text is actually properly set.
123
123
    block = m_doc->begin().next();
124
 
    i = 0;
 
124
    i = 1;
125
125
    while (block.isValid() && i < 13) {
126
126
        KoTextBlockData *data = dynamic_cast<KoTextBlockData*>(block.userData());
127
127
        QVERIFY(data);
315
315
    block = m_doc->begin();
316
316
    QVERIFY(block.userData() == 0);
317
317
    block = block.next();
318
 
    static const char* texts[] = { "1", "1.1.", "1.1.1", "1.1.2", "1.2.", "2", "2.1.", "2.2.", "3", "3.0.1", "1.1" };
 
318
    static const char* texts[] = { "1", "1.1.", "1.1.1", "1.1.2", "1.2.", "2", "2.1.", "2.2.", "3", "3.1.1", "1.1" };
319
319
    int i = 0;
320
320
    qreal indent = 0.0;
321
321
    while (block.isValid()) {
334
334
    }
335
335
}
336
336
 
 
337
void TestDocumentLayout::testNestedPrefixedLists()
 
338
{
 
339
    /* A list with different prefix for each level should show only the prefix of that level
 
340
     * Specifically we should not concatenate the prefixes of the higher levels
 
341
     * Specifically we should not concatenate the suffixes of the higher levels
 
342
     * That is only the prefix and the suffix of the current level should be applied
 
343
     */
 
344
    initForNewTest("MMMM\nSSSS\n");
 
345
 
 
346
    KoParagraphStyle h1;
 
347
    m_styleManager->add(&h1);
 
348
    KoParagraphStyle h2;
 
349
    m_styleManager->add(&h2);
 
350
 
 
351
    KoListStyle listStyle;
 
352
    KoListLevelProperties llp1;
 
353
    llp1.setStartValue(1);
 
354
    llp1.setStyle(KoListStyle::DecimalItem);
 
355
    llp1.setListItemPrefix("Main");
 
356
    llp1.setListItemSuffix(":");
 
357
 
 
358
    listStyle.setLevelProperties(llp1);
 
359
 
 
360
    KoListLevelProperties llp2;
 
361
    llp2.setStartValue(1);
 
362
    llp2.setStyle(KoListStyle::DecimalItem);
 
363
    llp2.setLevel(2);
 
364
    llp2.setListItemPrefix("Sub");
 
365
    llp2.setListItemSuffix("*");
 
366
    llp2.setDisplayLevel(2);
 
367
    listStyle.setLevelProperties(llp2);
 
368
 
 
369
    h1.setListStyle(&listStyle);
 
370
    h2.setListLevel(2);
 
371
    h2.setListStyle(&listStyle);
 
372
    
 
373
    QVERIFY(listStyle.hasLevelProperties(1));
 
374
    QVERIFY(listStyle.hasLevelProperties(2));
 
375
    QVERIFY(!listStyle.hasLevelProperties(3));
 
376
 
 
377
    QTextBlock block = m_doc->begin().next();
 
378
    h1.applyStyle(block);
 
379
    block = block.next();
 
380
    QVERIFY(block.isValid());
 
381
    h2.applyStyle(block);
 
382
 
 
383
    m_layout->layout();
 
384
 
 
385
    block = m_doc->begin();
 
386
    QVERIFY(block.userData() == 0);
 
387
    block = block.next();
 
388
    static const char* texts[] = { "Main1:", "Sub1.1*"};
 
389
    int i = 0;
 
390
    while (block.isValid()) {
 
391
        KoTextBlockData *data = dynamic_cast<KoTextBlockData*>(block.userData());
 
392
        //qDebug() << "text: " << block.text();
 
393
        //qDebug() << "expected: " << texts[i];
 
394
        QVERIFY(data);
 
395
        //qDebug() << data->counterText();
 
396
        QCOMPARE(data->counterText(), QString(texts[i++]));
 
397
        block = block.next();
 
398
    }
 
399
}
 
400
 
337
401
void TestDocumentLayout::testAutoRestartList()
338
402
{
339
403
    initForNewTest("Humans\nGandhi\nEinstein\nInventions\nCar\nToilet\nLaboratory\n");
635
699
    KoTextBlockData *data = dynamic_cast<KoTextBlockData*>(block.userData());
636
700
    QCOMPARE(data->counterPosition().x(), 200 - padding - data->counterWidth());
637
701
}
 
702
 
 
703
void TestDocumentLayout::testMultiLevel()
 
704
{
 
705
    initForNewTest("ListItem1\n");
 
706
    KoListStyle listStyle;
 
707
    KoListLevelProperties llp;
 
708
    llp.setStyle(KoListStyle::DecimalItem);
 
709
    llp.setLevel(3);
 
710
    llp.setDisplayLevel(4); // we won't show a .0 at the end so this is truncated to 3
 
711
    listStyle.setLevelProperties(llp);
 
712
 
 
713
    QTextBlock block = m_doc->begin();
 
714
    QVERIFY(block.isValid());
 
715
    listStyle.applyStyle(block);
 
716
    QVERIFY(block.textList());
 
717
 
 
718
    m_layout->layout();
 
719
 
 
720
    KoTextBlockData *data = dynamic_cast<KoTextBlockData*> (block.userData());
 
721
    QVERIFY(data);
 
722
    QVERIFY(data->hasCounterData());
 
723
    QCOMPARE(data->counterText(), QString("1.1.1"));
 
724
}