[Libreoffice-commits] core.git: sw/qa sw/source
Justin Luth (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jul 5 04:06:03 UTC 2021
sw/qa/extras/ww8export/data/tdf104239_chapterNumberingLevels.doc |binary
sw/qa/extras/ww8export/data/tdf104239_numbering.doc |binary
sw/qa/extras/ww8export/ww8export3.cxx | 21 ++++++++
sw/source/filter/ww8/ww8par.cxx | 26 ++++------
4 files changed, 33 insertions(+), 14 deletions(-)
New commits:
commit 17bc5794d6acd38304653dc78b95f9f772893ca7
Author: Justin Luth <justin_luth at sil.org>
AuthorDate: Sat Jul 3 08:23:48 2021 +0200
Commit: Justin Luth <justin_luth at sil.org>
CommitDate: Mon Jul 5 06:05:29 2021 +0200
tdf#104239 doc import CN: don't skip no-style levels
The Chapter Numbering "Outline" style must copy
the entire range of levels, not just those that have
a paragraph style associated with them.
Change-Id: I25578129e9cdbd8eb3dab710a2b26dd2764752e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118343
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth at sil.org>
diff --git a/sw/qa/extras/ww8export/data/tdf104239_chapterNumberingLevels.doc b/sw/qa/extras/ww8export/data/tdf104239_chapterNumberingLevels.doc
new file mode 100644
index 000000000000..8a7583c3253c
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf104239_chapterNumberingLevels.doc differ
diff --git a/sw/qa/extras/ww8export/data/tdf104239_numbering.doc b/sw/qa/extras/ww8export/data/tdf104239_numbering.doc
new file mode 100644
index 000000000000..ee8ad09e4b14
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf104239_numbering.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index 58e226506ccf..797b7f103dd6 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -851,6 +851,27 @@ DECLARE_WW8EXPORT_TEST(testTdf75748_inheritChapterNumberingC, "tdf75748_inheritC
CPPUNIT_ASSERT_EQUAL(OUString("II.B.1."), getProperty<OUString>(xPara, "ListLabelString"));
}
+DECLARE_WW8EXPORT_TEST(testTdf104239_numbering, "tdf104239_numbering.doc")
+{
+ // The paragraph starts with "paraksta Pieņemšanas". [Roundtrip by Word 2016 avoids the problem.]
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(51), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("3.3.1."), getProperty<OUString>(xPara, "ListLabelString"));
+}
+
+DECLARE_WW8EXPORT_TEST(testTdf104239_chapterNumberingLevels, "tdf104239_chapterNumberingLevels.doc")
+{
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(1, "Heading 1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Article I."), getProperty<OUString>(xPara, "ListLabelString"));
+ xPara.set(getParagraph(2, "Heading 2"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("1"), getProperty<OUString>(xPara, "ListLabelString"));
+ xPara.set(getParagraph(3, "Heading 3"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("First"), getProperty<OUString>(xPara, "ListLabelString"));
+ xPara.set(getParagraph(4, "Heading 4"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
+ xPara.set(getParagraph(8, "Heading 9"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("1.1.1.1.1.1.1.1.1."), getProperty<OUString>(xPara, "ListLabelString"));
+}
+
DECLARE_WW8EXPORT_TEST(testTdf104239_chapterNumberTortureTest, "tdf104239_chapterNumberTortureTest.doc")
{
// There is no point in identifying what the wrong values where in this test,
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 8034adfa68ba..04b65f3e6eac 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -6018,7 +6018,17 @@ void SwWW8ImplReader::SetOutlineStyles()
// assigned directly and
// its default outline level is applied.
SwNumRule aOutlineRule(*m_rDoc.GetOutlineNumRule());
- bool bAppliedChangedOutlineStyle = false;
+ if (m_pChosenWW8OutlineStyle)
+ {
+ for (int i = 0; i < WW8ListManager::nMaxLevel; ++i)
+ {
+ // Don't clobber existing outline levels.
+ const sal_uInt16 nLevel = 1 << i;
+ if (!(nOutlineStyleListLevelWithAssignment & nLevel))
+ aOutlineRule.Set(i, m_pChosenWW8OutlineStyle->Get(i));
+ }
+ }
+
for (const SwWW8StyInf* pStyleInf : aWW8BuiltInHeadingStyles)
{
const sal_uInt16 nOutlineStyleListLevelOfWW8BuiltInHeadingStyle
@@ -6029,18 +6039,6 @@ void SwWW8ImplReader::SetOutlineStyles()
continue;
}
- const sal_uInt8 nLvl = pStyleInf->m_nListLevel == MAXLEVEL ? 0 : pStyleInf->m_nListLevel;
- if (m_pChosenWW8OutlineStyle != nullptr
- && pStyleInf->mnWW8OutlineLevel < WW8ListManager::nMaxLevel
- && pStyleInf->mnWW8OutlineLevel == nLvl)
- {
- // LibreOffice's Chapter Numbering only works when outlineLevel == listLevel
- const SwNumFormat& rRule
- = m_pChosenWW8OutlineStyle->Get(pStyleInf->mnWW8OutlineLevel);
- aOutlineRule.Set(pStyleInf->mnWW8OutlineLevel, rRule);
- bAppliedChangedOutlineStyle = true;
- }
-
// in case that there are more styles on this level ignore them
nOutlineStyleListLevelWithAssignment
|= nOutlineStyleListLevelOfWW8BuiltInHeadingStyle;
@@ -6075,7 +6073,7 @@ void SwWW8ImplReader::SetOutlineStyles()
}
}
- if (bAppliedChangedOutlineStyle)
+ if (m_pChosenWW8OutlineStyle)
{
m_rDoc.SetOutlineNumRule(aOutlineRule);
}
More information about the Libreoffice-commits
mailing list