sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx |   12 -----
 sw/source/filter/ww8/docxattributeoutput.cxx  |   58 +++++++++++++-------------
 2 files changed, 29 insertions(+), 41 deletions(-)

New commits:
commit 108e88a8956befe90c987d9634713fd707d8fc91
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Nov 28 14:15:22 2025 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Dec 1 17:57:31 2025 +0100

    officeotron: wrong ordering of elements under sdtPr
    
    Change-Id: Idf3fa8d64f93a1b59321b7d0303e33e39254180d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194783
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index 50b54cbdaff0..f5dab71e916b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -785,9 +785,6 @@ CPPUNIT_TEST_FIXTURE(Test, testfdo82492)
 
 CPPUNIT_TEST_FIXTURE(Test, testSdtHeader)
 {
-    // FIXME: validation error in OOXML export
-    skipValidation();
-
     createSwDoc("sdt-header.docx");
     saveAndReload(TestFilter::DOCX);
     // Problem was that w:sdt elements in headers were lost on import.
@@ -798,9 +795,6 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtHeader)
 
 CPPUNIT_TEST_FIXTURE(Test, testSdtCompanyMultipara)
 {
-    // FIXME: validation error in OOXML export
-    skipValidation();
-
     createSwDoc("sdt-company-multipara.docx");
     saveAndReload(TestFilter::DOCX);
     xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
@@ -883,9 +877,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf66401)
 
 CPPUNIT_TEST_FIXTURE(Test, testDateFieldInShape)
 {
-    // FIXME: validation error in OOXML export
-    skipValidation();
-
     auto verify = [this](bool bIsExport = false) {
     // This was crashed on export.
         if (bIsExport)
@@ -929,9 +920,6 @@ CPPUNIT_TEST_FIXTURE(Test, testDateFieldInShape)
 
 CPPUNIT_TEST_FIXTURE(Test, testDateFieldAtEndOfParagraph)
 {
-    // FIXME: validation error in OOXML export
-    skipValidation();
-
     auto verify = [this](bool bIsExport = false) {
         // Additional line end was added by import and it was crashed on export
         if (bIsExport)
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 612a1cae6b61..5ad3505b978e 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -826,20 +826,19 @@ void SdtBlockHelper::WriteSdtBlock(const 
::sax_fastparser::FSHelperPtr& pSeriali
 
 void SdtBlockHelper::WriteExtraParams(const ::sax_fastparser::FSHelperPtr& 
pSerializer)
 {
+    if (!m_aAlias.isEmpty())
+        pSerializer->singleElementNS(XML_w, XML_alias, FSNS(XML_w, XML_val), 
m_aAlias);
+
+    if (!m_aTag.isEmpty())
+        pSerializer->singleElementNS(XML_w, XML_tag, FSNS(XML_w, XML_val), 
m_aTag);
+
     if (m_nId)
     {
         pSerializer->singleElementNS(XML_w, XML_id, FSNS(XML_w, XML_val), 
OString::number(m_nId));
     }
 
-    if (m_pDataBindingAttrs.is())
-    {
-        pSerializer->singleElementNS(XML_w, XML_dataBinding, 
detachFrom(m_pDataBindingAttrs));
-    }
-
-    if (m_pTextAttrs.is())
-    {
-        pSerializer->singleElementNS(XML_w, XML_text, 
detachFrom(m_pTextAttrs));
-    }
+    if (!m_aLock.isEmpty())
+        pSerializer->singleElementNS(XML_w, XML_lock, FSNS(XML_w, XML_val), 
m_aLock);
 
     if (!m_aPlaceHolderDocPart.isEmpty())
     {
@@ -851,6 +850,15 @@ void SdtBlockHelper::WriteExtraParams(const 
::sax_fastparser::FSHelperPtr& pSeri
     if (m_bShowingPlaceHolder)
         pSerializer->singleElementNS(XML_w, XML_showingPlcHdr);
 
+    if (m_pDataBindingAttrs.is())
+    {
+        pSerializer->singleElementNS(XML_w, XML_dataBinding, 
detachFrom(m_pDataBindingAttrs));
+    }
+
+    if (m_nTabIndex)
+        pSerializer->singleElementNS(XML_w, XML_tabIndex, FSNS(XML_w, XML_val),
+                                     OString::number(m_nTabIndex));
+
     if (!m_aColor.isEmpty())
     {
         pSerializer->singleElementNS(XML_w15, XML_color, FSNS(XML_w, XML_val), 
m_aColor);
@@ -861,18 +869,10 @@ void SdtBlockHelper::WriteExtraParams(const 
::sax_fastparser::FSHelperPtr& pSeri
         pSerializer->singleElementNS(XML_w15, XML_appearance, FSNS(XML_w15, 
XML_val), m_aAppearance);
     }
 
-    if (!m_aAlias.isEmpty())
-        pSerializer->singleElementNS(XML_w, XML_alias, FSNS(XML_w, XML_val), 
m_aAlias);
-
-    if (!m_aTag.isEmpty())
-        pSerializer->singleElementNS(XML_w, XML_tag, FSNS(XML_w, XML_val), 
m_aTag);
-
-    if (m_nTabIndex)
-        pSerializer->singleElementNS(XML_w, XML_tabIndex, FSNS(XML_w, XML_val),
-                                     OString::number(m_nTabIndex));
-
-    if (!m_aLock.isEmpty())
-        pSerializer->singleElementNS(XML_w, XML_lock, FSNS(XML_w, XML_val), 
m_aLock);
+    if (m_pTextAttrs.is())
+    {
+        pSerializer->singleElementNS(XML_w, XML_text, 
detachFrom(m_pTextAttrs));
+    }
 }
 
 void SdtBlockHelper::EndSdtBlock(const ::sax_fastparser::FSHelperPtr& 
pSerializer)
@@ -2542,6 +2542,14 @@ void DocxAttributeOutput::WriteFormDateStart(const 
OUString& sFullDate, const OU
     m_pSerializer->startElementNS(XML_w, XML_sdt);
     m_pSerializer->startElementNS(XML_w, XML_sdtPr);
 
+    if (aGrabBagSdt.hasElements())
+    {
+        // There are some extra sdt parameters came from grab bag
+        SdtBlockHelper aSdtBlock;
+        aSdtBlock.GetSdtParamsFromGrabBag(aGrabBagSdt);
+        aSdtBlock.WriteExtraParams(m_pSerializer);
+    }
+
     if(!sFullDate.isEmpty())
         m_pSerializer->startElementNS(XML_w, XML_date, FSNS(XML_w, 
XML_fullDate), sFullDate);
     else
@@ -2559,14 +2567,6 @@ void DocxAttributeOutput::WriteFormDateStart(const 
OUString& sFullDate, const OU
                                    FSNS(XML_w, XML_val), "gregorian");
     m_pSerializer->endElementNS(XML_w, XML_date);
 
-    if (aGrabBagSdt.hasElements())
-    {
-        // There are some extra sdt parameters came from grab bag
-        SdtBlockHelper aSdtBlock;
-        aSdtBlock.GetSdtParamsFromGrabBag(aGrabBagSdt);
-        aSdtBlock.WriteExtraParams(m_pSerializer);
-    }
-
     m_pSerializer->endElementNS(XML_w, XML_sdtPr);
 
     m_pSerializer->startElementNS(XML_w, XML_sdtContent);

Reply via email to