sw/source/filter/ww8/docxattributeoutput.cxx |   28 ++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

New commits:
commit 2ff0d15c1abb781fcddbc508d7067bd8007bc1d4
Author:     Noel Grandin <[email protected]>
AuthorDate: Tue Oct 28 21:53:00 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Sat Nov 1 19:06:17 2025 +0100

    mso-test: fix formatting of w:char attribute value
    
    When loading and then saving the document from forum-mso-en-14041.docx,
    we end up with a string like "1f" instead of "001f" for the hex value
    of the w:char attribute, which is incorrect.
    
    INFO - Validating part "/word/document.xml" using schema "29500T/wml.xsd" 
...
    ERROR      - (word/document.xml:2 col:9 575) cvc-length-valid:
                   Value '43' with length = '1' is not facet-valid with respect 
to length '2' for type 'ST_ShortHexNumber'.
    ERROR      - (word/document.xml:2 col:9 575) cvc-attribute.3:
                The value '43' of attribute 'w:char' on element 'w:sym' is not 
valid with respect to its type, 'ST_ShortHexNumber'.
    
    Change-Id: Iea72e0064f09f4aa9ceb28f61596743c5b6434f0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193122
    Reviewed-by: Michael Stahl <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    (cherry picked from commit 2c9293526e822a8ef39ca77eb6a1f6ede6de9a92)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193246
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index e9fd0033934a..dc0363a759e7 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -138,6 +138,7 @@
 #include <textcontentcontrol.hxx>
 #include <formatflysplit.hxx>
 
+#include <o3tl/sprintf.hxx>
 #include <o3tl/string_view.hxx>
 #include <o3tl/unit_conversion.hxx>
 #include <osl/file.hxx>
@@ -3828,9 +3829,11 @@ static bool impl_WriteRunText( FSHelperPtr const & 
pSerializer, sal_Int32 nTextT
     {
         for (char16_t aChar : aView)
         {
+            char pBuf[5];
+            o3tl::sprintf(pBuf, "%04x", aChar);
             pSerializer->singleElementNS(XML_w, XML_sym,
                 FSNS(XML_w, XML_font), rSymbolFont,
-                FSNS(XML_w, XML_char), OString::number(aChar, 16));
+                FSNS(XML_w, XML_char), pBuf);
         }
     }
     else
commit 605589997542a936e3123c5e97c4469923135d44
Author:     Noel Grandin <[email protected]>
AuthorDate: Tue Oct 28 21:22:31 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Sat Nov 1 19:06:08 2025 +0100

    mso-test: emit w:cnfStyle in correct order in document.xml
    
    When loading and then saving the document from forum-mso-en-18503.docx,
    we end up with incorrect ordering of w:cnfStyle under w:tcPr in document.xml
    
    INFO - Validating part "/word/document.xml" using schema "29500T/wml.xsd" 
...
    ERROR      - (word/document.xml:2 col:4 548) cvc-complex-type.2.4.a:
                 Invalid content was found starting with element 'w:cnfStyle'.
    
    Change-Id: Ib4aa3b47be3060b6a9c3e69dee7aadd29072f983
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193120
    Reviewed-by: Michael Stahl <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    (cherry picked from commit 661b597daf9e04d64feb9fbb1610aa5189167813)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193245
    Reviewed-by: Noel Grandin <[email protected]>
    Tested-by: Jenkins

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 87a4866f595b..e9fd0033934a 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4759,6 +4759,17 @@ void DocxAttributeOutput::TableCellProperties( 
ww8::WW8TableNodeInfoInner::Point
     // Output any table cell redlines if there are any attached to this 
specific cell
     TableCellRedline( pTableTextNodeInfoInner );
 
+    if (const SfxGrabBagItem* pItem = 
pTableBox->GetFrameFormat()->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG))
+    {
+        const std::map<OUString, uno::Any>& rGrabBag = pItem->GetGrabBag();
+        std::map<OUString, uno::Any>::const_iterator it = 
rGrabBag.find(u"CellCnfStyle"_ustr);
+        if (it != rGrabBag.end())
+        {
+            uno::Sequence<beans::PropertyValue> aAttributes = it->second.get< 
uno::Sequence<beans::PropertyValue> >();
+            m_pTableStyleExport->CnfStyle(aAttributes);
+        }
+    }
+
     // Cell preferred width
     SwTwips nWidth = GetGridCols( pTableTextNodeInfoInner )->at( nCell );
     if ( nCell )
@@ -4797,18 +4808,6 @@ void DocxAttributeOutput::TableCellProperties( 
ww8::WW8TableNodeInfoInner::Point
         m_pSerializer->singleElementNS(XML_w, XML_vMerge, FSNS(XML_w, 
XML_val), "continue");
     }
 
-    if (const SfxGrabBagItem* pItem = 
pTableBox->GetFrameFormat()->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG))
-    {
-        const std::map<OUString, uno::Any>& rGrabBag = pItem->GetGrabBag();
-        std::map<OUString, uno::Any>::const_iterator it = 
rGrabBag.find(u"CellCnfStyle"_ustr);
-        if (it != rGrabBag.end())
-        {
-            uno::Sequence<beans::PropertyValue> aAttributes = it->second.get< 
uno::Sequence<beans::PropertyValue> >();
-            m_pTableStyleExport->CnfStyle(aAttributes);
-        }
-    }
-
-
     const SvxBoxItem& rBox = pTableBox->GetFrameFormat( )->GetBox( );
     const SvxBoxItem& rDefaultBox = 
(*m_TableFirstCells.rbegin())->getTableBox( )->GetFrameFormat( )->GetBox( );
     {

Reply via email to