From ce762a7ab170aa1115cfb0dd68f1c50abf5a86f3 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 20 Apr 2021 19:47:09 +0200 Subject: 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 --- sw/source/filter/ww8/ww8par.cxx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'sw/source/filter/ww8/ww8par.cxx') 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 aWW8BuiltInHeadingStyles; { + sal_uInt16 nStyle = 0; std::map 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; -- cgit v1.2.3