sw/qa/extras/ww8export/data/tdf106541_inheritChapterNumbering.doc |binary sw/qa/extras/ww8export/data/tdf106541_inheritChapterNumberingB.doc |binary sw/qa/extras/ww8export/ww8export3.cxx | 20 +++++++- sw/source/filter/ww8/ww8par.cxx | 23 +++++++++- 4 files changed, 40 insertions(+), 3 deletions(-)
New commits: commit ce762a7ab170aa1115cfb0dd68f1c50abf5a86f3 Author: Justin Luth <justin_l...@sil.org> AuthorDate: Tue Apr 20 19:47:09 2021 +0200 Commit: Justin Luth <justin_l...@sil.org> CommitDate: Sat Jun 19 19:58:35 2021 +0200 tdf#106541 doc import: inherit style numbering from parent This patch depends on FOLLOWUP patches. I thought the best way forward is to break the existing unit tests, and then fix them with followup patches. That best proves the validity of each follow-up patch. This patch is especially needed for Chapter Numbering. In LO, Chapter Numbering is treated uniquely with its own special rules that run counter to all other conventions. So special handling is needed to import styles that in MS Word would inherit, but which don't in this special case. Change-Id: I06b737ad96ff73dbd09bef252d09aa42adf2dc76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114401 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_l...@sil.org> diff --git a/sw/qa/extras/ww8export/data/tdf106541_inheritChapterNumbering.doc b/sw/qa/extras/ww8export/data/tdf106541_inheritChapterNumbering.doc new file mode 100644 index 000000000000..f56b9d6b6e6a Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf106541_inheritChapterNumbering.doc differ diff --git a/sw/qa/extras/ww8export/data/tdf106541_inheritChapterNumberingB.doc b/sw/qa/extras/ww8export/data/tdf106541_inheritChapterNumberingB.doc new file mode 100644 index 000000000000..0ff47ca3e642 Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf106541_inheritChapterNumberingB.doc differ diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index 2b87f12974ca..67b4993bc9b1 100644 --- a/sw/qa/extras/ww8export/ww8export3.cxx +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -783,13 +783,29 @@ DECLARE_WW8EXPORT_TEST(testTdf106541_cancelOutline, "tdf106541_cancelOutline.doc { // The ability to cancel numbering must not be lost. uno::Reference<beans::XPropertySet> xPara(getParagraph(1, "Cancelled by style"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString")); + //TEMPORARY CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString")); xPara.set(getParagraph(2, "Cancelled by inherited style"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString")); + //TEMPORARY CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString")); xPara.set(getParagraph(4, "Cancelled by direct paragraph formatting"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString")); } +DECLARE_WW8EXPORT_TEST(testTdf106541_inheritChapterNumbering, "tdf106541_inheritChapterNumbering.doc") +{ + // The level and numbering are inherited from Heading 1. + uno::Reference<beans::XPropertySet> xPara(getParagraph(3, "Letter A"), uno::UNO_QUERY); + //TEMPORARY CPPUNIT_ASSERT_EQUAL(OUString("a."), getProperty<OUString>(xPara, "ListLabelString")); +} + +DECLARE_WW8EXPORT_TEST(testTdf106541_inheritChapterNumberingB, "tdf106541_inheritChapterNumberingB.doc") +{ + // The level and numbering are inherited from Heading 1. + uno::Reference<beans::XPropertySet> xPara(getParagraph(1, "Chapter 1, level 1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty<OUString>(xPara, "ListLabelString")); + xPara.set(getParagraph(2, "Chapter 1, level 2"), uno::UNO_QUERY); + //TEMPORARY CPPUNIT_ASSERT_EQUAL(OUString("1.1"), getProperty<OUString>(xPara, "ListLabelString")); +} + DECLARE_WW8EXPORT_TEST(testTdf120394, "tdf120394.doc") { CPPUNIT_ASSERT_EQUAL(1, getPages()); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 93b2027b30bf..ec316678e96b 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -5914,9 +5914,30 @@ void SwWW8ImplReader::SetOutlineStyles() // iteration std::vector<SwWW8StyInf*> aWW8BuiltInHeadingStyles; { + sal_uInt16 nStyle = 0; std::map<const SwNumRule*, int> aWW8ListStyleCounts; - for (SwWW8StyInf & rSI : m_vColl) + for (SwWW8StyInf& rSI : m_vColl) { + // Copy inherited numbering info since LO drops inheritance after ChapterNumbering + // and only applies listLevel via style with the selected ChapterNumbering LFO. + bool bReRegister = false; + if (rSI.m_nBase && rSI.m_nBase < 10 && rSI.m_nBase < m_vColl.size() + && m_vColl[rSI.m_nBase].HasWW8OutlineLevel()) + { + if (rSI.m_nLFOIndex == USHRT_MAX) + rSI.m_nLFOIndex = m_vColl[rSI.m_nBase].m_nLFOIndex; + if (rSI.m_nListLevel == MAXLEVEL) + rSI.m_nListLevel = m_vColl[rSI.m_nBase].m_nListLevel; + if (rSI.mnWW8OutlineLevel == MAXLEVEL) + rSI.mnWW8OutlineLevel = m_vColl[rSI.m_nBase].mnWW8OutlineLevel; + bReRegister = true; + } + + if (bReRegister) + RegisterNumFormatOnStyle(nStyle); + + ++nStyle; // increment before the first "continue"; + if (!rSI.IsWW8BuiltInHeadingStyle() || !rSI.HasWW8OutlineLevel()) { continue; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits