sw/qa/extras/ooxmlexport/ooxmlexport16.cxx | 9 +++-- writerfilter/source/dmapper/DomainMapper.cxx | 5 ++ writerfilter/source/dmapper/DomainMapper.hxx | 1 writerfilter/source/dmapper/DomainMapper_Impl.cxx | 38 ++++++++++++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.hxx | 1 writerfilter/source/dmapper/StyleSheetTable.cxx | 6 +++ 6 files changed, 57 insertions(+), 3 deletions(-)
New commits: commit 7c7dcdb5132b579485631e620c1a87cd9b3881e3 Author: Justin Luth <justin_l...@sil.org> AuthorDate: Mon May 24 07:35:42 2021 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Jul 14 09:06:53 2021 +0200 tdf#141964 writerfilter CN: only one style per outline level This really surprised me. On outline numbering, only one style can use the level of a numbering rule. Any other style that has it defined is ignored. First come first served. [All based on experimentation, no documentation found.] There are two ways the style can be attached. The highest priority is if the numbering style itself has a paragraph style defined (which obviously is exclusive). The second way is just to assign a list level along with a numbering rule in the para style. Surprisingly, this too creates an exclusive lock on the level. These are some existing unit tests that triggered. I forget which ones are important or valuable, but none of the contents were affected, only the UI use of the style didn't apply numbering in Word: Example1 -ooxmlexport6 fdo74605.docx RT pStyle not written out for numbering. List-number-2 gets ilvl0 before List-number-1, and loses pStyle for absLevel 1 [NOT REALLY A PROBLEM. That is also how Word sees it. These aren't chapter numbering, so the pStyle settings just get dropped.] Example 2 - ooxmlexport7 fdo76979.docx RT: Bullet gets the numbering, but not Bullet2 Example 3 - ooxmlexport11 tdf101122_noFillForCustomShape.odt RT: Heading 9 gets the numbering, but not Heading 10 [Typical LO-originating document.] Example 4 - ooxmlexport13 tdf95848.docx RT: Heading 1, so not Heading 2 Example 5 - ooxmlexport14 tdf136929_framesOfParagraph.odt RT: OOoNum123Start, so not the others (who inherit from start anyway) Change-Id: Ia27131ae6d31b6cff240477f3546ccf92ea69160 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118707 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_l...@sil.org> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx index 120c312969d2..504b2d3ea802 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx @@ -164,9 +164,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf141966_chapterNumberTortureTest, "tdf141966_chap xPara.set(getParagraph(3, "First numbered line"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("1st.i.a.1.I"), getProperty<OUString>(xPara, "ListLabelString")); + xPara.set(getParagraph(5, "Outline with listLvl 5"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString")); + xPara.set(getParagraph(7, "inheritOnly: inherit outlineLvl and listLvl."), uno::UNO_QUERY); - // 2nd.iii in MS Word 2003. 2nd.ii in MS Word 2010/2016 where para5 is not numbered. Why not? - CPPUNIT_ASSERT_EQUAL(OUString("2nd.iii"), getProperty<OUString>(xPara, "ListLabelString")); + // 2nd.iii in MS Word 2003. 2nd.ii in MS Word 2010/2016 where para5 is not numbered. + CPPUNIT_ASSERT_EQUAL(OUString("2nd.ii"), getProperty<OUString>(xPara, "ListLabelString")); CPPUNIT_ASSERT_EQUAL(sal_Int16(1), getProperty<sal_Int16>(xPara, "NumberingLevel")); // Level 2 xPara.set(getParagraph(9, "outline with Body listLvl(9)."), uno::UNO_QUERY); @@ -179,7 +182,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf141966_chapterNumberTortureTest, "tdf141966_chap CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString")); xPara.set(getParagraph(12, "direct numId, inherit listLvl."), uno::UNO_QUERY); - //CPPUNIT_ASSERT_EQUAL(OUString("2nd.ii.a.1.I"), getProperty<OUString>(xPara, "ListLabelString")); + CPPUNIT_ASSERT_EQUAL(OUString("2nd.ii.a.1.I"), getProperty<OUString>(xPara, "ListLabelString")); CPPUNIT_ASSERT_EQUAL(sal_Int16(4), getProperty<sal_Int16>(xPara, "NumberingLevel")); // Level 5 xPara.set(getParagraph(13, "Style numId0 cancels inherited numbering."), uno::UNO_QUERY); diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 39b118e108f0..5fecd67c07ca 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -4035,6 +4035,11 @@ OUString DomainMapper::GetListStyleName(sal_Int32 nListId) const return m_pImpl->GetListStyleName( nListId ); } +void DomainMapper::ValidateListLevel(const OUString& sStyleIdentifierD) +{ + m_pImpl->ValidateListLevel(sStyleIdentifierD); +} + void DomainMapper::SetDocDefaultsImport(bool bSet) { m_pImpl->SetDocDefaultsImport(bSet); diff --git a/writerfilter/source/dmapper/DomainMapper.hxx b/writerfilter/source/dmapper/DomainMapper.hxx index e76014737cf3..688f4c37edc0 100644 --- a/writerfilter/source/dmapper/DomainMapper.hxx +++ b/writerfilter/source/dmapper/DomainMapper.hxx @@ -95,6 +95,7 @@ public: void PushListProperties( const ::tools::SvRef<PropertyMap>& pListProperties ); void PopListProperties(); OUString GetListStyleName(sal_Int32 nListId) const; + void ValidateListLevel(const OUString& sStyleIdentifierD); bool IsOOXMLImport() const; bool IsRTFImport() const; diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 1ab11e0b149f..ae10911d5eaa 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1486,6 +1486,44 @@ sal_Int16 DomainMapper_Impl::GetListLevel(const StyleSheetEntryPtr& pEntry, return GetListLevel(pParent); } +void DomainMapper_Impl::ValidateListLevel(const OUString& sStyleIdentifierD) +{ + StyleSheetEntryPtr pMyStyle = GetStyleSheetTable()->FindStyleSheetByISTD(sStyleIdentifierD); + if (!pMyStyle) + return; + + sal_Int8 nListLevel = GetListLevel(pMyStyle); + if (nListLevel < 0 || nListLevel >= WW_OUTLINE_MAX) + return; + + bool bDummy = false; + sal_Int16 nListId = lcl_getListId(pMyStyle, GetStyleSheetTable(), bDummy); + if (nListId < 1) + return; + + auto const pList(GetListTable()->GetList(nListId)); + if (!pList) + return; + + auto pLevel = pList->GetLevel(nListLevel); + if (!pLevel && pList->GetAbstractDefinition()) + pLevel = pList->GetAbstractDefinition()->GetLevel(nListLevel); + if (!pLevel) + return; + + if (!pLevel->GetParaStyle()) + { + // First come, first served, and it hasn't been claimed yet, so claim it now. + pLevel->SetParaStyle(pMyStyle); + } + else if (pLevel->GetParaStyle() != pMyStyle) + { + // This level is already used by another style, so prevent numbering via this style + // by setting to body level (9). + pMyStyle->pProperties->SetListLevel(WW_OUTLINE_MAX); + } +} + void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, const bool bRemove, const bool bNoNumbering ) { if (m_bDiscardHeaderFooter) diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 88b3eb7d8332..9c3e25a6e072 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -1032,6 +1032,7 @@ public: css::uno::Reference<css::container::XIndexAccess> GetCurrentNumberingRules(sal_Int32* pListLevel); sal_Int16 GetListLevel(const StyleSheetEntryPtr& pEntry, const PropertyMapPtr& pParaContext = nullptr); + void ValidateListLevel(const OUString& sStyleIdentifierD); /** Used for attributes/sprms which cannot be evaluated immediately (e.g. they depend diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index ae9440be8381..8eb833410e1a 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -924,6 +924,12 @@ void StyleSheetTable::ApplyNumberingStyleNameToParaStyles() const OUString sNumberingStyleName = m_pImpl->m_rDMapper.GetListStyleName( pStyleSheetProperties->GetListId() ); if ( !sNumberingStyleName.isEmpty() || !pStyleSheetProperties->GetListId() ) xPropertySet->setPropertyValue( getPropertyName(PROP_NUMBERING_STYLE_NAME), uno::makeAny(sNumberingStyleName) ); + + // Word 2010+ (not Word 2003, and Word 2007 is completely broken) + // does something rather strange. It does not allow two paragraph styles + // to share the same listLevel on a numbering rule. + // Consider this style to just be body level if already used previously. + m_pImpl->m_rDMapper.ValidateListLevel(pEntry->sStyleIdentifierD); } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits