diff --git a/filters/libmsooxml/MsooXmlUtils.h b/filters/libmsooxml/MsooXmlUtils.h --- a/filters/libmsooxml/MsooXmlUtils.h +++ b/filters/libmsooxml/MsooXmlUtils.h @@ -110,6 +110,8 @@ void setTextStyle(const KoGenStyle& textStyle); void setStartOverride(const bool startOverride); + + void setDisplayLevels(const QString& displayLevels); QString startValue() const; @@ -132,6 +134,8 @@ KoGenStyle textStyle() const; bool startOverride() const; + + QString displayLevels() const; void addInheritedValues(const ParagraphBulletProperties& properties); @@ -156,6 +160,7 @@ QString m_followingChar; QString m_bulletRelativeSize; QString m_bulletSize; + QString m_displayLevels; KoGenStyle m_textStyle; diff --git a/filters/libmsooxml/MsooXmlUtils.cpp b/filters/libmsooxml/MsooXmlUtils.cpp --- a/filters/libmsooxml/MsooXmlUtils.cpp +++ b/filters/libmsooxml/MsooXmlUtils.cpp @@ -1201,6 +1201,7 @@ m_bulletColor = UNUSED; m_followingChar = UNUSED; m_bulletRelativeSize = UNUSED; + m_displayLevels = UNUSED m_bulletSize = UNUSED; m_startOverride = false; } @@ -1224,6 +1225,11 @@ m_type = ParagraphBulletProperties::BulletType; } +void Utils::ParagraphBulletProperties::setDisplayLevels(const QString& displayLevels) +{ + m_displayLevels = displayLevels; +} + void Utils::ParagraphBulletProperties::setStartValue(const QString& value) { m_startValue = value; @@ -1327,6 +1333,11 @@ return m_startValue; } +QString Utils::ParagraphBulletProperties::displayLevels() const +{ + return m_displayLevels; +} + QString Utils::ParagraphBulletProperties::bulletColor() const { return m_bulletColor; @@ -1453,6 +1464,9 @@ if (m_suffix != UNUSED) { out.addAttribute("style:num-suffix", m_suffix); } + if (m_displayLevels != UNUSED) { + out.addAttribute("text:display-levels", m_displayLevels); + } out.addAttribute("text:start-value", m_startValue); } else if (m_type == ParagraphBulletProperties::PictureType) { diff --git a/filters/words/docx/import/DocxXmlNumberingReader.cpp b/filters/words/docx/import/DocxXmlNumberingReader.cpp --- a/filters/words/docx/import/DocxXmlNumberingReader.cpp +++ b/filters/words/docx/import/DocxXmlNumberingReader.cpp @@ -433,12 +433,15 @@ TRY_READ_ATTR(val) if (!val.isEmpty()) { if (!m_bulletStyle) { - if (val.at(0) == '%' && val.length() == 2) { + m_currentBulletProperties.setPrefix(val.left(qMax(0, val.indexOf('%')))); + QString searchSuffix = QString("%%1").arg(m_currentBulletProperties.m_level); + + if (val.lastIndexOf(searchSuffix) >= 0) + m_currentBulletProperties.setSuffix(val.mid(val.lastIndexOf(searchSuffix) + searchSuffix.length())); + else m_currentBulletProperties.setSuffix(""); - } - else { - m_currentBulletProperties.setSuffix(val.right(1)); - } + + m_currentBulletProperties.setDisplayLevels(QString::number(val.count('%'))); } else { m_bulletCharacter = val; diff --git a/libs/textlayout/ListItemsHelper.cpp b/libs/textlayout/ListItemsHelper.cpp --- a/libs/textlayout/ListItemsHelper.cpp +++ b/libs/textlayout/ListItemsHelper.cpp @@ -183,7 +183,7 @@ KoOdfNumberDefinition numberFormat; numberFormat.setFormatSpecification(static_cast(format.intProperty(KoListStyle::NumberFormat))); numberFormat.setLetterSynchronization(format.boolProperty(KoListStyle::LetterSynchronization)); - item = numberFormat.formattedNumber(index) + "." + item; // add missing counters. + item = numberFormat.formattedNumber(1) + "." + item; // add missing counters. } } bool calcWidth = true;