sw/source/filter/ww8/docxattributeoutput.cxx |   13 +++++++------
 sw/source/filter/ww8/docxattributeoutput.hxx |    2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 968b4e657ada91b67ef2b7cd5e5e3df844bd5feb
Author:     Justin Luth <[email protected]>
AuthorDate: Thu Feb 5 10:56:44 2026 -0500
Commit:     Justin Luth <[email protected]>
CommitDate: Fri Feb 6 21:42:45 2026 +0100

    NFC docx export: m_nSdtPrToken is never negative, or w:id
    
    No Functional Change intended.
    
    m_nSdtPrToken is never set to w:id
    and never has AFAICS from git blame.
    I assume it was put there during development and never removed.
    
    It is also never set to w:date. Date is never grabbagged.
    
    It also is never assigned a negative value.
    
    Change-Id: Ib47bea2601183f7c78027181753f0ff90d0d98e7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198852
    Reviewed-by: Justin Luth <[email protected]>
    Tested-by: Jenkins

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index adf613699ff6..b288b1ec37f7 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -780,7 +780,7 @@ void SdtBlockHelper::DeleteAndResetTheLists()
 
 void SdtBlockHelper::WriteSdtBlock(const ::sax_fastparser::FSHelperPtr& 
pSerializer, bool bRunTextIsOn, bool bParagraphHasDrawing)
 {
-    if (m_nSdtPrToken <= 0 && !m_pDataBindingAttrs.is() && !m_nId)
+    if (!m_nSdtPrToken && !m_pDataBindingAttrs.is() && !m_nId)
         return;
 
     // sdt start mark
@@ -793,7 +793,7 @@ void SdtBlockHelper::WriteSdtBlock(const 
::sax_fastparser::FSHelperPtr& pSeriali
 
     WriteExtraParams(pSerializer);
 
-    if (m_nSdtPrToken > 0 && m_pTokenChildren.is())
+    if (m_nSdtPrToken && m_pTokenChildren.is())
     {
         if (!m_pTokenAttributes.is())
             pSerializer->startElement(m_nSdtPrToken);
@@ -802,7 +802,8 @@ void SdtBlockHelper::WriteSdtBlock(const 
::sax_fastparser::FSHelperPtr& pSeriali
             pSerializer->startElement(m_nSdtPrToken, 
detachFrom(m_pTokenAttributes));
         }
 
-        if (m_nSdtPrToken == FSNS(XML_w, XML_date) || m_nSdtPrToken == 
FSNS(XML_w, XML_docPartObj) || m_nSdtPrToken == FSNS(XML_w, XML_docPartList) || 
m_nSdtPrToken == FSNS(XML_w14, XML_checkbox)) {
+        assert(m_nSdtPrToken != FSNS(XML_w, XML_date) && "date is never 
grabbagged, so SdtPrToken is never set to date");
+        if (/*m_nSdtPrToken == FSNS(XML_w, XML_date) ||*/ m_nSdtPrToken == 
FSNS(XML_w, XML_docPartObj) || m_nSdtPrToken == FSNS(XML_w, XML_docPartList) || 
m_nSdtPrToken == FSNS(XML_w14, XML_checkbox)) {
             for (auto& it : *m_pTokenChildren)
             {
                 pSerializer->singleElement(it.getToken(), FSNS(XML_w, 
XML_val), it.toCString());
@@ -811,7 +812,7 @@ void SdtBlockHelper::WriteSdtBlock(const 
::sax_fastparser::FSHelperPtr& pSeriali
 
         pSerializer->endElement(m_nSdtPrToken);
     }
-    else if ((m_nSdtPrToken > 0) && m_nSdtPrToken != FSNS(XML_w, XML_id) && 
!(bRunTextIsOn && bParagraphHasDrawing))
+    else if (m_nSdtPrToken && !(bRunTextIsOn && bParagraphHasDrawing))
     {
         if (!m_pTokenAttributes.is())
             pSerializer->singleElement(m_nSdtPrToken);
@@ -1863,7 +1864,7 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, 
sal_Int32 nPos, sal_In
 
         // if another sdt starts in this run, then wait
         // as closing the sdt now, might cause nesting of sdts
-        if (m_aRunSdt.m_nSdtPrToken > 0)
+        if (m_aRunSdt.m_nSdtPrToken)
             bCloseEarlierSDT = true;
         else
             m_aRunSdt.EndSdtBlock(m_pSerializer);
@@ -2612,7 +2613,7 @@ void DocxAttributeOutput::WriteSdtPlainText(const 
OUString & sValue, const uno::
         aSdtBlock.GetSdtParamsFromGrabBag(aGrabBagSdt);
         aSdtBlock.WriteExtraParams(m_pSerializer);
 
-        if (aSdtBlock.m_nSdtPrToken && aSdtBlock.m_nSdtPrToken != FSNS(XML_w, 
XML_id))
+        if (aSdtBlock.m_nSdtPrToken)
         {
             // Write <w:text/> or whatsoever from grabbag
             m_pSerializer->singleElement(aSdtBlock.m_nSdtPrToken);
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index 98d28202a09c..a1e699efef92 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -183,7 +183,7 @@ public:
     OUString m_aTag;
     sal_Int32 m_nTabIndex;
     OUString m_aLock;
-    sal_Int32 m_nSdtPrToken;
+    sal_Int32 m_nSdtPrToken; // 0 means either not set, or richText
 
     void DeleteAndResetTheLists();
 

Reply via email to