sw/source/filter/ww8/docxattributeoutput.cxx |   39 +++++++++++++--------------
 1 file changed, 19 insertions(+), 20 deletions(-)

New commits:
commit 1871d8026cfd559642c7342aab54036cbf2830b6
Author:     Noel Grandin <[email protected]>
AuthorDate: Tue Oct 28 15:36:15 2025 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Nov 3 15:56:31 2025 +0100

    mso-test: emit w:numFmt in correct order in numbering xml
    
    officeotron says:
    
      INFO - Validating part "/word/numbering.xml" using schema 
"29500T/wml.xsd" ...
      ERROR      - (numbering.xml:2 col:536) cvc-complex-type.2.4.a:
                  Invalid content was found starting with element 'w:numFmt'. 
One of '{
    
    when loading and then saving the forum-mso-en4-401306.docx document.
    
    Change-Id: I2c07b360169180fb8dcbf6a932df8e9e3de4158e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193093
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>
    (cherry picked from commit ffd2c88ddedd28896cf546f3bb06a2a59253f25e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193238
    Reviewed-by: Noel Grandin <[email protected]>
    Tested-by: Jenkins
    Signed-off-by: Xisco Fauli <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193276

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 951e8e22d31a..9cd47cba413b 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7798,6 +7798,15 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 
nLevel,
                 FSNS( XML_w, XML_val ), OString::number(nStart) );
     }
 
+    // format
+    OString aCustomFormat;
+    OString aFormat(lcl_ConvertNumberingType(nNumberingType, pOutSet, 
aCustomFormat, "decimal"_ostr));
+
+    if (aCustomFormat.isEmpty())
+    {
+        m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, 
XML_val), aFormat);
+    }
+
     if (m_bExportingOutline)
     {
         sal_uInt16 nId = m_rExport.m_pStyles->GetHeadingParagraphStyleId( 
nLevel );
@@ -7809,29 +7818,19 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 
nLevel,
     if (isLegal)
         m_pSerializer->singleElementNS(XML_w, XML_isLgl);
 
-    // format
-    OString aCustomFormat;
-    OString aFormat(lcl_ConvertNumberingType(nNumberingType, pOutSet, 
aCustomFormat, "decimal"_ostr));
-
+    if (!aCustomFormat.isEmpty())
     {
-        if (aCustomFormat.isEmpty())
-        {
-            m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, 
XML_val), aFormat);
-        }
-        else
-        {
-            m_pSerializer->startElementNS(XML_mc, XML_AlternateContent);
-            m_pSerializer->startElementNS(XML_mc, XML_Choice, XML_Requires, 
"w14");
+        m_pSerializer->startElementNS(XML_mc, XML_AlternateContent);
+        m_pSerializer->startElementNS(XML_mc, XML_Choice, XML_Requires, "w14");
 
-            m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, 
XML_val), aFormat,
-                                           FSNS(XML_w, XML_format), 
aCustomFormat);
+        m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, 
XML_val), aFormat,
+                                       FSNS(XML_w, XML_format), aCustomFormat);
 
-            m_pSerializer->endElementNS(XML_mc, XML_Choice);
-            m_pSerializer->startElementNS(XML_mc, XML_Fallback);
-            m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, 
XML_val), "decimal");
-            m_pSerializer->endElementNS(XML_mc, XML_Fallback);
-            m_pSerializer->endElementNS(XML_mc, XML_AlternateContent);
-        }
+        m_pSerializer->endElementNS(XML_mc, XML_Choice);
+        m_pSerializer->startElementNS(XML_mc, XML_Fallback);
+        m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, 
XML_val), "decimal");
+        m_pSerializer->endElementNS(XML_mc, XML_Fallback);
+        m_pSerializer->endElementNS(XML_mc, XML_AlternateContent);
     }
 
     // suffix

Reply via email to