void ParagraphSettingsDialog::slotApply()
{
    if (!m_styleChanged) {
        return;
    }

    KoParagraphStyle chosenStyle;
    m_paragraphGeneral->save(&chosenStyle);

    QTextCharFormat cformat;
    QTextBlockFormat format;
    chosenStyle.KoCharacterStyle::applyStyle(cformat);
    chosenStyle.applyStyle(format);

    KoListLevelProperties llp;
    if (chosenStyle.listStyle()) {
        llp = chosenStyle.listStyle()->levelProperties(chosenStyle.listStyle()->listLevels().first());
    } else {
        llp.setStyle(KoListStyle::None);
    }

    m_editor->applyDirectFormatting(cformat, format, llp);

    m_styleChanged = false;
}
Esempio n. 2
0
void ParagraphSettingsDialog::slotApply()
{
    emit startMacro(i18n("Paragraph Settings\n"));
    KoParagraphStyle chosenStyle;
    m_paragraphGeneral->save(&chosenStyle);
    QTextBlockFormat format;
    chosenStyle.applyStyle(format);
    m_cursor->mergeBlockFormat(format);
    if (chosenStyle.listStyle()) {
        ChangeListCommand *cmd = new ChangeListCommand(*m_cursor, chosenStyle.listStyle(), 0, ChangeListCommand::MergeWithAdjacentList);
        m_tool->addCommand(cmd);
    } else {
        QTextList *list = m_cursor->block().textList();
        if (list) { // then remove it.
            list->remove(m_cursor->block());
        }
    }
    emit stopMacro();
}