sw/source/filter/ww8/docxattributeoutput.cxx | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
New commits: commit 8f4fe65d16a52cacac25701b4ec10e47a510475e Author: Andras Timar <andras.ti...@collabora.com> AuthorDate: Sat Nov 16 17:41:45 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Nov 19 12:05:11 2024 +0100 docx: export empty GrabBag elements as self-closing xml tags Although <tag></tag> and <tag/> are syntactically equivalent, we got a report that some 3rd party tool could not process a docx file produced by LibreOffice. In styles.xml there was <w14:ligatures w14:val="standardContextual"></w14:ligatures> instead of <w14:ligatures w14:val="standardContextual"/> This patch is meant to fix this, to mimic what Word does anyway. Change-Id: Iea409981d2a2eac40c460bdae4d3dc7e8b0c33ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176680 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Jenkins (cherry picked from commit 6cb711645b8d8f3cee0d3454e193cc7bf1cad305) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176753 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index b543f7736a98..3bf3668deb96 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3523,21 +3523,28 @@ void lclProcessRecursiveGrabBag(sal_Int32 aElementId, const css::uno::Sequence<c pAttributes->add(*aSubElementId, aValue); } - pSerializer->startElement(aElementId, pAttributes); - - for (const auto& rElement : rElements) + if (rElements.size() == 0) + { + pSerializer->singleElement(aElementId, pAttributes); + } + else { - css::uno::Sequence<css::beans::PropertyValue> aSumElements; + pSerializer->startElement(aElementId, pAttributes); - std::optional<sal_Int32> aSubElementId = lclGetElementIdForName(rElement.Name); - if(aSubElementId) + for (const auto& rElement : rElements) { - rElement.Value >>= aSumElements; - lclProcessRecursiveGrabBag(*aSubElementId, aSumElements, pSerializer); + css::uno::Sequence<css::beans::PropertyValue> aSumElements; + + std::optional<sal_Int32> aSubElementId = lclGetElementIdForName(rElement.Name); + if(aSubElementId) + { + rElement.Value >>= aSumElements; + lclProcessRecursiveGrabBag(*aSubElementId, aSumElements, pSerializer); + } } - } - pSerializer->endElement(aElementId); + pSerializer->endElement(aElementId); + } } }