sw/qa/extras/ooxmlexport/data/tdf133605.docx |binary sw/qa/extras/ooxmlexport/data/tdf133605_2.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 51 +++++++++++++++++++++++ writerfilter/source/dmapper/NumberingManager.cxx | 23 ++++------ writerfilter/source/dmapper/NumberingManager.hxx | 2 5 files changed, 63 insertions(+), 13 deletions(-)
New commits: commit c1d695d93125fbbd5999ee7f49a30a3360a90747 Author: Vasily Melenchuk <vasily.melenc...@cib.de> AuthorDate: Sun Jun 14 14:47:57 2020 +0300 Commit: Vasily Melenchuk <vasily.melenc...@cib.de> CommitDate: Wed Jun 17 09:21:53 2020 +0200 tdf#133605: docx import: use ilvl value for list level import Previous implementation was not aware about ilvl value which declares a level number it is defining. So LO was able correctly handle only lists were levels are defined in increasing order starting from zero. Same problem was also with override lists: if we just override only one some random level (for example ilvl=2 in bugdoc) it was applied to level 0. Change-Id: If1f466fcbae0c82a8601e5b638e541d75aab665c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96268 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> (cherry picked from commit 408f2a1c09a6563caf193384df8e1cac6e153fbb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96422 Reviewed-by: Vasily Melenchuk <vasily.melenc...@cib.de> diff --git a/sw/qa/extras/ooxmlexport/data/tdf133605.docx b/sw/qa/extras/ooxmlexport/data/tdf133605.docx new file mode 100644 index 000000000000..d248d5e1a93b Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf133605.docx differ diff --git a/sw/qa/extras/ooxmlexport/data/tdf133605_2.docx b/sw/qa/extras/ooxmlexport/data/tdf133605_2.docx new file mode 100644 index 000000000000..8d3c5acba609 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf133605_2.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index e2c5f0dbf9b6..99e1d29c93d8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -954,6 +954,57 @@ DECLARE_OOXMLEXPORT_TEST(testTdf120394, "tdf120394.docx") } } +DECLARE_OOXMLEXPORT_TEST(testTdf133605, "tdf133605.docx") +{ + CPPUNIT_ASSERT_EQUAL(1, getPages()); + { + uno::Reference<beans::XPropertySet> xPara(getParagraph(3), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), getProperty<sal_Int16>(xPara, "NumberingLevel")); + CPPUNIT_ASSERT_EQUAL(OUString(CHAR_ZWSP), getProperty<OUString>(xPara, "ListLabelString")); + } + { + uno::Reference<beans::XPropertySet> xPara(getParagraph(4), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), getProperty<sal_Int16>(xPara, "NumberingLevel")); + CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty<OUString>(xPara, "ListLabelString")); + } + { + uno::Reference<beans::XPropertySet> xPara(getParagraph(5), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2), getProperty<sal_Int16>(xPara, "NumberingLevel")); + CPPUNIT_ASSERT_EQUAL(OUString("1.1"), getProperty<OUString>(xPara, "ListLabelString")); + } + { + uno::Reference<beans::XPropertySet> xPara(getParagraph(6), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(3), getProperty<sal_Int16>(xPara, "NumberingLevel")); + CPPUNIT_ASSERT_EQUAL(OUString("(a)"), getProperty<OUString>(xPara, "ListLabelString")); + } +} + +DECLARE_OOXMLEXPORT_TEST(testTdf133605_2, "tdf133605_2.docx") +{ + // About the same document as tdf133605.docx, but number definition has level definitions in random order + CPPUNIT_ASSERT_EQUAL(1, getPages()); + { + uno::Reference<beans::XPropertySet> xPara(getParagraph(3), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), getProperty<sal_Int16>(xPara, "NumberingLevel")); + CPPUNIT_ASSERT_EQUAL(OUString(CHAR_ZWSP), getProperty<OUString>(xPara, "ListLabelString")); + } + { + uno::Reference<beans::XPropertySet> xPara(getParagraph(4), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), getProperty<sal_Int16>(xPara, "NumberingLevel")); + CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty<OUString>(xPara, "ListLabelString")); + } + { + uno::Reference<beans::XPropertySet> xPara(getParagraph(5), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2), getProperty<sal_Int16>(xPara, "NumberingLevel")); + CPPUNIT_ASSERT_EQUAL(OUString("1.1"), getProperty<OUString>(xPara, "ListLabelString")); + } + { + uno::Reference<beans::XPropertySet> xPara(getParagraph(6), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(3), getProperty<sal_Int16>(xPara, "NumberingLevel")); + CPPUNIT_ASSERT_EQUAL(OUString("(a)"), getProperty<OUString>(xPara, "ListLabelString")); + } +} + DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf123757, "tdf123757.docx") { xmlDocUniquePtr pXml = parseExport("word/document.xml"); diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx index 309ca8f46d80..23ea3ebefbb7 100644 --- a/writerfilter/source/dmapper/NumberingManager.cxx +++ b/writerfilter/source/dmapper/NumberingManager.cxx @@ -366,11 +366,14 @@ ListLevel::Pointer AbstractListDef::GetLevel( sal_uInt16 nLvl ) return pLevel; } -void AbstractListDef::AddLevel( ) +void AbstractListDef::AddLevel( sal_uInt16 nLvl ) { + if ( nLvl >= m_aLevels.size() ) + m_aLevels.resize( nLvl+1 ); + ListLevel::Pointer pLevel( new ListLevel ); m_pCurrentLevel = pLevel; - m_aLevels.push_back( pLevel ); + m_aLevels[nLvl] = pLevel; } uno::Sequence<uno::Sequence<beans::PropertyValue>> AbstractListDef::GetPropertyValues(bool bDefaults) @@ -381,7 +384,8 @@ uno::Sequence<uno::Sequence<beans::PropertyValue>> AbstractListDef::GetPropertyV int nLevels = m_aLevels.size( ); for ( int i = 0; i < nLevels; i++ ) { - aResult[i] = m_aLevels[i]->GetProperties(bDefaults); + if (m_aLevels[i]) + aResult[i] = m_aLevels[i]->GetProperties(bDefaults); } return result; @@ -700,14 +704,11 @@ void ListsManager::lcl_attribute( Id nName, Value& rVal ) AbstractListDef::SetValue( nName ); break; case NS_ooxml::LN_CT_NumLvl_ilvl: - { //add a new level to the level vector and make it the current one - m_pCurrentDefinition->AddLevel(); - - writerfilter::Reference<Properties>::Pointer_t pProperties = rVal.getProperties(); - if(pProperties) - pProperties->resolve(*this); - } + m_pCurrentDefinition->AddLevel(rVal.getString().toInt32()); + break; + case NS_ooxml::LN_CT_Lvl_ilvl: + m_pCurrentDefinition->AddLevel(rVal.getString().toInt32()); break; case NS_ooxml::LN_CT_AbstractNum_abstractNumId: { @@ -733,7 +734,6 @@ void ListsManager::lcl_attribute( Id nName, Value& rVal ) pCurrentLvl->Insert( PROP_FIRST_LINE_INDENT, uno::makeAny( ConversionHelper::convertTwipToMM100( nIntValue ) )); break; - case NS_ooxml::LN_CT_Lvl_ilvl: //overrides previous level - unsupported case NS_ooxml::LN_CT_Lvl_tplc: //template code - unsupported case NS_ooxml::LN_CT_Lvl_tentative: //marks level as unused in the document - unsupported break; @@ -895,7 +895,6 @@ void ListsManager::lcl_sprm( Sprm& rSprm ) break; case NS_ooxml::LN_CT_AbstractNum_lvl: { - m_pCurrentDefinition->AddLevel(); writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); if(pProperties) pProperties->resolve(*this); diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx index 6173f1431f0e..29f139082522 100644 --- a/writerfilter/source/dmapper/NumberingManager.hxx +++ b/writerfilter/source/dmapper/NumberingManager.hxx @@ -152,7 +152,7 @@ public: sal_Int16 Size( ) { return sal_Int16( m_aLevels.size( ) ); }; ListLevel::Pointer GetLevel( sal_uInt16 nLvl ); - void AddLevel( ); + void AddLevel( sal_uInt16 nLvl ); const ListLevel::Pointer& GetCurrentLevel( ) const { return m_pCurrentLevel; }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits