diff options
author | Justin Luth <justin_luth@sil.org> | 2021-05-14 09:52:01 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-05-18 16:06:59 +0200 |
commit | 2f9d909a01f90197c3029a446f8aac8135f53f48 (patch) | |
tree | c836364519555826af66ed6f69069ab97920c0e5 /sw/source/filter | |
parent | 46c71f04c9e1fa9d257c26dd8a8f5e99bbbb1575 (diff) |
tdf#76817 tdf#141966 ooxmlexport: write OutlineRule if not inherited
The previous LO 6.1 version of this patch was fine in practice,
but in theory the special "Outline" numbering style COULD be
applied directly to a paragraph - especially during import
since "Chapter Numbering" is a LO invention, not a DOCX spec.
So, ensure that both the listLevel and the numId match
what is inherited from the style before deciding that
writing out the numbering is not needed.
This patch will be needed for tdf#141966.
Change-Id: I9ec4477ed18f84c22a0b5941d0d218186ab6875b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115612
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source/filter')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index f0775d63f6b8..09772ab2ccb3 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -8645,20 +8645,29 @@ void DocxAttributeOutput::ParaNumRule_Impl( const SwTextNode* pTextNd, sal_Int32 if ( USHRT_MAX == nNumId ) return; + // LibreOffice is not very flexible with "Outline Numbering" (aka "Outline" numbering style). + // Only ONE numbering rule ("Outline") can be associated with a style-assigned-listLevel, + // and no other style is able to inherit these numId/nLvl settings - only text nodes can. + // So listLevel only exists in paragraph properties EXCEPT for up to ten styles that have been + // assigned to one of these special Chapter Numbering listlevels (by default Heading 1-10). const sal_Int32 nTableSize = m_rExport.m_pUsedNumTable ? m_rExport.m_pUsedNumTable->size() : 0; const SwNumRule* pRule = nNumId > 0 && nNumId <= nTableSize ? (*m_rExport.m_pUsedNumTable)[nNumId-1] : nullptr; - const bool bOutlineRule = pRule && pRule->IsOutlineRule(); - - // Do not export outline rules (Chapter Numbering) as paragraph properties, only as style properties. - if ( !pTextNd || !bOutlineRule ) - { - m_pSerializer->startElementNS(XML_w, XML_numPr); - m_pSerializer->singleElementNS(XML_w, XML_ilvl, - FSNS(XML_w, XML_val), OString::number(nLvl)); - m_pSerializer->singleElementNS(XML_w, XML_numId, - FSNS(XML_w, XML_val), OString::number(nNumId)); - m_pSerializer->endElementNS( XML_w, XML_numPr ); + const SwTextFormatColl* pColl = pTextNd ? pTextNd->GetTextColl() : nullptr; + // Do not duplicate numbering that is inherited from the (Chapter numbering) style + // (since on import we duplicate style numbering/listlevel to the paragraph). + if (pColl && pColl->IsAssignedToListLevelOfOutlineStyle() + && nLvl == pColl->GetAssignedOutlineStyleLevel() && pRule && pRule->IsOutlineRule()) + { + // By definition of how LO is implemented, assignToListLevel is only possible + // when the style is also using OutlineRule for numbering. Adjust logic if that changes. + assert(pRule->GetName() == pColl->GetNumRule(true).GetValue()); + return; } + + m_pSerializer->startElementNS(XML_w, XML_numPr); + m_pSerializer->singleElementNS(XML_w, XML_ilvl, FSNS(XML_w, XML_val), OString::number(nLvl)); + m_pSerializer->singleElementNS(XML_w, XML_numId, FSNS(XML_w, XML_val), OString::number(nNumId)); + m_pSerializer->endElementNS(XML_w, XML_numPr); } void DocxAttributeOutput::ParaScriptSpace( const SfxBoolItem& rScriptSpace ) |