void ChangeListLevelCommand::redo()
{
    if (!m_first) {
        KoTextCommandBase::redo();
        UndoRedoFinalizer finalizer(this);
        for (int i = 0; i < m_blocks.size(); ++i) {
            m_lists.value(i)->updateStoredList(m_blocks.at(i));
            QTextBlock currentBlock(m_blocks.at(i));
            KoTextBlockData userData(currentBlock);
            userData.setCounterWidth(-1.0);
        }
    }
    else {
        for (int i = 0; i < m_blocks.size() && m_lists.value(i); ++i) {
            if (!m_lists.value(i)->style()->hasLevelProperties(m_levels.value(i))) {
                KoListLevelProperties llp = m_lists.value(i)->style()->levelProperties(m_levels.value(i));
                KoListLevelProperties parentLlp = m_lists.value(i)->style()->levelProperties(m_levels.value(i)-1);
                if (llp.alignmentMode() == false) {
                    //old list mode, see KoListLevelProperties::alignmentMode() documentation
                    llp.setIndent((m_levels.value(i)-1) * 20); //TODO make this configurable
                } else {
                    llp.setTabStopPosition(parentLlp.tabStopPosition() + parentLlp.marginIncrease());
                    llp.setMargin(parentLlp.margin() + parentLlp.marginIncrease());
                    llp.setTextIndent(parentLlp.textIndent());
                }
                llp.setDisplayLevel(llp.displayLevel() + m_coefficient);
                llp.setLevel(m_levels.value(i));

                m_lists.value(i)->style()->setLevelProperties(llp);
            }
            m_lists.value(i)->add(m_blocks.at(i), m_levels.value(i));
        }
    }
    m_first = false;
}
void ParagraphBulletsNumbers::setDisplay(KoParagraphStyle *style, int level)
{
    KoListStyle *listStyle = style->listStyle();
    widget.listPropertiesPane->setEnabled(listStyle != 0);
    widget.customCharacter->setText("-");
    if (listStyle == 0) {
        widget.listTypes->setCurrentRow(0);
        return;
    }

    KoListLevelProperties llp = listStyle->levelProperties(level);
    m_previousLevel = llp.level();
    widget.prefix->setText(llp.listItemPrefix());
    widget.suffix->setText(llp.listItemSuffix());
    widget.letterSynchronization->setChecked(llp.letterSynchronization());
    KoListStyle::Style s = llp.style();
    foreach(int row, m_mapping.keys()) {
        if (m_mapping[row] == s) {
            widget.listTypes->setCurrentRow(row);
            break;
        }
    }
    int align;
    if (llp.alignment() == (Qt::AlignLeft | Qt::AlignAbsolute))
        align = 1;
    else if (llp.alignment() == (Qt::AlignRight | Qt::AlignAbsolute))
        align = 2;
    else if (llp.alignment() == Qt::AlignCenter)
        align = 3;
    else
        align = 0;

    widget.alignment->setCurrentIndex(align);
    widget.depth->setValue(llp.level());
    widget.levels->setValue(llp.displayLevel());
    widget.startValue->setValue(llp.startValue());
    if (s == KoListStyle::CustomCharItem)
        widget.customCharacter->setText(llp.bulletCharacter());

    if (s == KoListStyle::ImageItem) {
        m_data = llp.bulletImage();
        widget.imageHeight->setValue(llp.height());
        widget.imageWidth->setValue(llp.width());
    } else {
        m_data = 0;
        widget.imageHeight->setValue(0);
        widget.imageWidth->setValue(0);
    }

    if(llp.alignmentMode()==false) {//for list-level-position-and-space-mode=label-width-and-position disable the following options
        widget.label_8->setEnabled(false);
        widget.label_9->setEnabled(false);
        widget.label_10->setEnabled(false);
        widget.label_11->setEnabled(false);

        widget.labelFollowedBy->setEnabled(false);
        widget.doubleSpinBox->setEnabled(false);
        widget.doubleSpinBox_2->setEnabled(false);
        widget.doubleSpinBox_3->setEnabled(false);
    } else {
        m_alignmentMode=true;
        switch(llp.labelFollowedBy()) {
        case KoListStyle::ListTab:
            widget.doubleSpinBox->setEnabled(true);
            widget.labelFollowedBy->setCurrentIndex(0);
            widget.doubleSpinBox->setValue(KoUnit::toCentimeter(llp.tabStopPosition()));
            break;
        case KoListStyle::Space:
            widget.doubleSpinBox->setEnabled(false);
            widget.labelFollowedBy->setCurrentIndex(1);
            break;
        case KoListStyle::Nothing:
            widget.doubleSpinBox->setEnabled(false);
            widget.labelFollowedBy->setCurrentIndex(2);
            break;
        default:
            Q_ASSERT(false);
        }

        widget.doubleSpinBox_2->setValue(KoUnit::toCentimeter(llp.margin()));
        widget.doubleSpinBox_3->setValue(KoUnit::toCentimeter(llp.margin())+KoUnit::toCentimeter(llp.textIndent()));
    }

    // *** features not in GUI;
    // character style
    // relative bullet size (percent)
    // minimum label width
    recalcPreview();
}