sw/source/filter/ww8/docxsdrexport.cxx |   18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

New commits:
commit b2dd08c6af51996f9fd2988f060d5c0f08e247c6
Author:     Aron Budea <[email protected]>
AuthorDate: Thu Jan 15 16:01:53 2026 +1030
Commit:     Aron Budea <[email protected]>
CommitDate: Fri Jan 16 02:36:56 2026 +0100

    sw: fix order of attributes in wp:anchor on export
    
    To match original DOCX in eg. tdf#169802 bugdoc.
    
    Change-Id: Ife68c293508bfed4f2a2b1d130e310390513981e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197312
    Tested-by: Jenkins
    Reviewed-by: Aron Budea <[email protected]>

diff --git a/sw/source/filter/ww8/docxsdrexport.cxx 
b/sw/source/filter/ww8/docxsdrexport.cxx
index 4c84b825cb26..a6af45eec32f 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -847,7 +847,6 @@ void DocxSdrExport::startDMLAnchorInline(const 
SwFrameFormat* pFrameFormat, cons
                       && pObj->GetLayer() != 
iDocumentDrawModelAccess.GetHeaderFooterHellId()
                       && pObj->GetLayer() != 
iDocumentDrawModelAccess.GetInvisibleHellId();
         }
-        attrList->add(XML_behindDoc, bOpaque ? "0" : "1");
 
         attrList->add(XML_distT, OString::number(TwipsToEMU(nDistT)));
         attrList->add(XML_distB, OString::number(TwipsToEMU(nDistB)));
@@ -855,6 +854,11 @@ void DocxSdrExport::startDMLAnchorInline(const 
SwFrameFormat* pFrameFormat, cons
         attrList->add(XML_distR, OString::number(TwipsToEMU(nDistR)));
 
         attrList->add(XML_simplePos, "0");
+
+        // It seems 0 and 1 have special meaning: just start counting from 2 
to avoid issues with that.
+        // Mandatory attribute, write 0 if pObj is null.
+        attrList->add(XML_relativeHeight, pObj ? 
OString::number(pObj->GetOrdNum() + 2) : "0"_ostr);
+        attrList->add(XML_behindDoc, bOpaque ? "0" : "1");
         attrList->add(XML_locked, "0");
 
         bool bLclInTabCell = true;
@@ -876,21 +880,11 @@ void DocxSdrExport::startDMLAnchorInline(const 
SwFrameFormat* pFrameFormat, cons
             bLclInTabCell = true;
         }
 
-        if (bLclInTabCell)
-            attrList->add(XML_layoutInCell, "1");
-        else
-            attrList->add(XML_layoutInCell, "0");
+        attrList->add(XML_layoutInCell, bLclInTabCell ? "1" : "0");
 
         bool bAllowOverlap = 
pFrameFormat->GetWrapInfluenceOnObjPos().GetAllowOverlap();
         attrList->add(XML_allowOverlap, bAllowOverlap ? "1" : "0");
 
-        if (pObj)
-            // It seems 0 and 1 have special meaning: just start counting from 
2 to avoid issues with that.
-            attrList->add(XML_relativeHeight, 
OString::number(pObj->GetOrdNum() + 2));
-        else
-            // relativeHeight is mandatory attribute, if value is not present, 
we must write default value
-            attrList->add(XML_relativeHeight, "0");
-
         if (pObj)
         {
             OUString sAnchorId = lclGetAnchorIdFromGrabBag(pObj);

Reply via email to