diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-19 13:49:01 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-19 15:31:49 +0100 |
commit | a8beb8c08886ac6eef7fcc6a8881a77156e05d4e (patch) | |
tree | 51b994606d191b65f5a9b45fff032e2302f22fdb /sw/source/filter/ww8/docxattributeoutput.cxx | |
parent | 32ae1ed7504d58f9216593cb87f25c480a0e623b (diff) |
sw: DOCX export: use list's indent if paragraph is not counted
Writer/ODF has a feature to have paragraphs in a list without having a
list label, but they do take the indent of the list level into account.
Word doesn't appear to have this feature, so the export forces such
paragraphs to refer to a non-existent numId 0, so they are not part of a
list.
Take the left indent from the list level and write it into the pPr.
Change-Id: I8ad56e51e2d4dfd691e3c38532f1a824f5276fd7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125555
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw/source/filter/ww8/docxattributeoutput.cxx')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 9dee5cbf5a5a..40656f6e3bf7 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -8962,16 +8962,39 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) } else { + SvxLRSpaceItem const* pLRSpace(&rLRSpace); + ::std::optional<SvxLRSpaceItem> oLRSpace; + if (dynamic_cast<SwContentNode const*>(GetExport().m_pOutFormatNode) != nullptr) + { + auto pTextNd(static_cast<SwTextNode const*>(GetExport().m_pOutFormatNode)); + // WW doesn't have a concept of a pararaph that's in a list but not + // counted in the list - see AttributeOutputBase::ParaNumRule() + // forcing non-existent numId="0" in this case. + // This means WW won't apply the indents from the numbering, + // so try to add them as paragraph properties here. + if (!pTextNd->IsCountedInList()) + { + SfxItemSetFixed<RES_LR_SPACE, RES_LR_SPACE> temp(m_rExport.m_rDoc.GetAttrPool()); + pTextNd->GetParaAttr(temp, 0, 0, false, true, true, nullptr); + if (auto *const pItem = temp.GetItem(RES_LR_SPACE)) + { + // but don't use first-line offset from list (should it be 0 or from node?) + oLRSpace.emplace(*pItem); + oLRSpace->SetTextFirstLineOffset(pLRSpace->GetTextFirstLineOffset()); + pLRSpace = &*oLRSpace; + } + } + } rtl::Reference<FastAttributeList> pLRSpaceAttrList = FastSerializerHelper::createAttrList(); - if((0 != rLRSpace.GetTextLeft()) || (rLRSpace.IsExplicitZeroMarginValLeft())) + if ((0 != pLRSpace->GetTextLeft()) || (pLRSpace->IsExplicitZeroMarginValLeft())) { - pLRSpaceAttrList->add( FSNS( XML_w, ( bEcma ? XML_left : XML_start ) ), OString::number( rLRSpace.GetTextLeft() ) ); + pLRSpaceAttrList->add( FSNS(XML_w, (bEcma ? XML_left : XML_start)), OString::number(pLRSpace->GetTextLeft()) ); } - if((0 != rLRSpace.GetRight()) || (rLRSpace.IsExplicitZeroMarginValRight())) + if ((0 != pLRSpace->GetRight()) || (pLRSpace->IsExplicitZeroMarginValRight())) { - pLRSpaceAttrList->add( FSNS( XML_w, ( bEcma ? XML_right : XML_end ) ), OString::number( rLRSpace.GetRight() ) ); + pLRSpaceAttrList->add( FSNS(XML_w, (bEcma ? XML_right : XML_end)), OString::number(pLRSpace->GetRight()) ); } - sal_Int32 nFirstLineAdjustment = rLRSpace.GetTextFirstLineOffset(); + sal_Int32 const nFirstLineAdjustment = pLRSpace->GetTextFirstLineOffset(); if (nFirstLineAdjustment > 0) pLRSpaceAttrList->add( FSNS( XML_w, XML_firstLine ), OString::number( nFirstLineAdjustment ) ); else |