summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rwxr-xr-xsw/qa/extras/ww8export/data/tdf104239_chapterNumberTortureTest.docbin0 -> 24064 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export3.cxx28
-rw-r--r--sw/source/filter/ww8/ww8par.cxx22
3 files changed, 50 insertions, 0 deletions
diff --git a/sw/qa/extras/ww8export/data/tdf104239_chapterNumberTortureTest.doc b/sw/qa/extras/ww8export/data/tdf104239_chapterNumberTortureTest.doc
new file mode 100755
index 000000000000..dc8f65e76d40
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf104239_chapterNumberTortureTest.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index b9a2a847c986..1ca05650da55 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -822,6 +822,34 @@ DECLARE_WW8EXPORT_TEST(testTdf106541_inheritChapterNumberingB, "tdf106541_inheri
CPPUNIT_ASSERT_EQUAL(OUString("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,
+ //because EVERYTHING was wrong, and MANY different fixes are required to solve the problems.
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(1, "No numId in style or paragraph"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
+ xPara.set(getParagraph(2, "Paragraph cancels numbering(0)"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
+ 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(7, "inheritOnly: inherit outlineLvl and listLvl."), uno::UNO_QUERY);
+ 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);
+ if (!mbExported)
+ CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
+ xPara.set(getParagraph(10, "outline with Body listLvl(9) #2."), uno::UNO_QUERY);
+ if (!mbExported)
+ CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
+ xPara.set(getParagraph(11, "direct formatting - Body listLvl(9)."), uno::UNO_QUERY);
+ //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(sal_Int16(4), getProperty<sal_Int16>(xPara, "NumberingLevel")); // Level 5
+ xPara.set(getParagraph(13, "Style numId0 cancels inherited numbering."), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
+}
+
DECLARE_WW8EXPORT_TEST(testTdf106541_inheritOutlineNumbering, "tdf106541_inheritOutlineNumbering.doc")
{
// The level and numbering are inherited from Level2.
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index d4c2ddc62cd6..0f5257417dfb 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -5916,6 +5916,7 @@ void SwWW8ImplReader::SetOutlineStyles()
{
sal_uInt16 nStyle = 0;
std::map<const SwNumRule*, int> aWW8ListStyleCounts;
+ std::map<const SwNumRule*, bool> aPreventUseAsChapterNumbering;
for (SwWW8StyInf& rSI : m_vColl)
{
// Copy inherited numbering info since LO drops inheritance after ChapterNumbering
@@ -5925,7 +5926,18 @@ void SwWW8ImplReader::SetOutlineStyles()
&& m_vColl[rSI.m_nBase].HasWW8OutlineLevel())
{
if (rSI.m_nLFOIndex == USHRT_MAX)
+ {
rSI.m_nLFOIndex = m_vColl[rSI.m_nBase].m_nLFOIndex;
+
+ // When ANYTHING is wrong or strange, prohibit eligibility for ChapterNumbering.
+ // A style never inherits numbering from Chapter Numbering.
+ if (rSI.m_nLFOIndex != USHRT_MAX)
+ {
+ const SwNumRule* pNumRule = m_vColl[rSI.m_nBase].m_pOutlineNumrule;
+ if (pNumRule)
+ aPreventUseAsChapterNumbering[pNumRule] = true;
+ }
+ }
if (rSI.m_nListLevel == MAXLEVEL)
rSI.m_nListLevel = m_vColl[rSI.m_nBase].m_nListLevel;
if (rSI.mnWW8OutlineLevel == MAXLEVEL)
@@ -5943,6 +5955,13 @@ void SwWW8ImplReader::SetOutlineStyles()
if (bReRegister)
RegisterNumFormatOnStyle(nStyle);
+ // When ANYTHING is wrong or strange, prohibit eligibility for ChapterNumbering.
+ if (rSI.IsWW8BuiltInHeadingStyle() && rSI.m_nListLevel != rSI.mnWW8OutlineLevel
+ && rSI.IsOutlineNumbered())
+ {
+ aPreventUseAsChapterNumbering[rSI.m_pOutlineNumrule] = true;
+ }
+
++nStyle; // increment before the first "continue";
if (!rSI.IsWW8BuiltInHeadingStyle() || !rSI.HasWW8OutlineLevel())
@@ -5955,6 +5974,9 @@ void SwWW8ImplReader::SetOutlineStyles()
const SwNumRule* pWW8ListStyle = rSI.GetOutlineNumrule();
if (pWW8ListStyle != nullptr)
{
+ if (aPreventUseAsChapterNumbering[pWW8ListStyle])
+ continue;
+
std::map<const SwNumRule*, int>::iterator aCountIter
= aWW8ListStyleCounts.find(pWW8ListStyle);
if (aCountIter == aWW8ListStyleCounts.end())