summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/ww8par.cxx
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2021-06-25 14:49:13 +0200
committerJustin Luth <justin_luth@sil.org>2021-06-26 18:31:49 +0200
commitf5394ceda7e714b87050d78a0319dc3cfab9ac99 (patch)
tree16031181a4245c6a5addb68050a2615181de281c /sw/source/filter/ww8/ww8par.cxx
parentf877ded8654edc70e466e92de1f9c1dbe5d959de (diff)
tdf#104239 doc import: chose m_pChosenWW8OutlineStyle carefully
Chapter numbering is a horrendous invention of LibreOffice. It is not at all a part of MS Formats. If there is anything that potentially can cause problems by choosing one style to be the outline style, invalidate it. We won't totally ignore CN because it has some unique properties in LO, and so it is worthwhile trying to round-trip it (alwyas LFO 0?) or populate it with the expected Heading styles if compatible. (I tried looping through and re-setting the matching styles with the "Outline" numrule first, but lots of unit tests prove that doesn't work well.) I couldn't believe the incredibly good effect this had on my torture test example document. Hurray. Then again, completely preventing CN at all also passed all unit tests, so I added a preventative test earlier. Change-Id: Iafa0d3606e558a3f17e49c3f1f6cebb7b25de962 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117920 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw/source/filter/ww8/ww8par.cxx')
-rw-r--r--sw/source/filter/ww8/ww8par.cxx22
1 files changed, 22 insertions, 0 deletions
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())