sw/source/writerfilter/dmapper/DomainMapper.cxx |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

New commits:
commit b08a09082f61f7319da8280a453193bef1c8b49b
Author:     Justin Luth <[email protected]>
AuthorDate: Wed Jan 14 15:16:10 2026 -0500
Commit:     Miklos Vajna <[email protected]>
CommitDate: Mon Jan 19 09:49:25 2026 +0100

    tdf#170322 writerfilter: if dataBinding, then not richText
    
    When a content control is not defined,
    that means that it is a richText control.
    If it was plainText, it would have contained a <w:text/> entry.
    
    However, in practice, if there is a <w:dataBinding>
    then MS Word treats it as plainText.
    
    The biggest problem here is that we don't really support
    blockSdt richText very well.
    Although we round-trip it, we don't display it
    as a content control in the application.
    
    So I'm not about to change _unknown to _richText,
    but just add in the bits that I've learned.
    I was trying to prove that the change I made
    to avoid fields being inside a plainText field
    (because MS Word considers those documents to be corrupt).
    
    Change-Id: I7cd2d8240ca92589741e347dc54301dd221f400a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197485
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Justin Luth <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper.cxx
index 14cbf84eed35..1229a204b9b6 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx
@@ -1102,7 +1102,12 @@ void DomainMapper::lcl_attribute(Id nName, const Value & 
val)
 
             if (m_pImpl->m_pSdtHelper->getControlType() == 
SdtControlType::unknown)
             {
-                // Still not determined content type? and it is even not 
unsupported? Then it is plain text field
+                // If the SdtControlType is not defined, it really OUGHT to be 
richText
+                // (although the presense of dataBinding gets treated as 
plainText by MS Word).
+                // HOWEVER, richText blockSDT is not working as a content 
control yet,
+                // so here we just convert blockSDT richText into plainText 
instead.
+
+                // Most likely this will just be changed again elsewhere.
                 
m_pImpl->m_pSdtHelper->setControlType(SdtControlType::plainText);
             }
             if (nName == NS_ooxml::LN_CT_SdtRun_sdtContent)
@@ -3259,6 +3264,14 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
     case NS_ooxml::LN_CT_SdtPr_tabIndex:
     case NS_ooxml::LN_CT_SdtPr_lock:
     {
+        if (nSprmId == NS_ooxml::LN_CT_SdtPr_dataBinding)
+        {
+            // Although the absense of a <w:text/> element should mean that 
the control is richText,
+            // in practice, the presense of a dataBinding element makes it 
plainText
+            if (m_pImpl->m_pSdtHelper->getControlType() == 
SdtControlType::richText)
+                
m_pImpl->m_pSdtHelper->setControlType(SdtControlType::plainText);
+        }
+
         if (!m_pImpl->GetSdtStarts().empty())
         {
             if (nSprmId == NS_ooxml::LN_CT_SdtPr_showingPlcHdr)

Reply via email to