sw/source/filter/ww8/docxattributeoutput.cxx |   27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

New commits:
commit 255652df7d5c3d54fde6f6d0d490672014fdf8f4
Author:     Andras Timar <andras.ti...@collabora.com>
AuthorDate: Sat Nov 16 17:41:45 2024 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Tue Nov 19 08:11:03 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/+/176681
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    (cherry picked from commit beaccac5cc9afbd5b358e0c296dc86a6ec68aa49)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176746
    Tested-by: Andras Timar <andras.ti...@collabora.com>
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 96ca17068552..b0026f53a4c0 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3525,21 +3525,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);
+    }
 }
 
 }

Reply via email to