sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |    6 ++++++
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx    |    4 ++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   10 ++++++++++
 sw/source/filter/ww8/docxattributeoutput.hxx |    2 ++
 writerfilter/source/dmapper/DomainMapper.cxx |   20 +++++++++++++++-----
 5 files changed, 37 insertions(+), 5 deletions(-)

New commits:
commit 79944dae026f8f1dbb77ce0ebd13b025e7cddc50
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Wed Dec 7 13:44:01 2022 -0500
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Dec 9 18:51:04 2022 +0000

    tdf#149240 docx content controls: round-trip showingPlcHdr better
    
    ShowingPlaceHolder causes all the text in the control to be
    selected when the control gains the focus. Otherwise, just a
    cursor is placed at the click point.
    
    While round-tripping this attribute worked for inline SDTs,
    it was lost for block SDTs. But BlockSDTs are very easy
    to create. The MS templates are full of them.
    
    Also, these are boolean, but it could have a val=0 specified,
    in which case it is off, but we were importing it as on.
    
    
    Change-Id: I167afa935311a63bba408ecd489ae819485a5cb7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143818
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    (cherry picked from commit 78b5195d8add0679263a5e08ba34be9b27637a65)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143855
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 87e7d0c68b21..d9d5802e0606 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -830,6 +830,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148111, "tdf148111.docx")
 
     // No more fields
     CPPUNIT_ASSERT(!xFields->hasMoreElements());
+
+    if (!isExported())
+        return;
+    xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+    // ShowingPlaceholder should be off for 0, false and "on". (This was 21 
before the fix)
+    assertXPath(pXmlDoc,"//w:p/w:sdt/w:sdtPr/w:showingPlcHdr", 12);
 }
 
 DECLARE_OOXMLEXPORT_TEST(TestTdf73499, "tdf73499.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 9930fa27b768..db2abe3513a7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -1000,6 +1000,10 @@ CPPUNIT_TEST_FIXTURE(Test, testGlossaryWithEmail)
         "and 
@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink'
 "
         "and @Target='mailto:emailgoesh...@example.com' "
         "and @TargetMode='External']");
+
+    // preserve the ShowingPlaceholder setting on both block SDTs.
+    pXmlDoc = parseExport("word/document.xml");
+    
assertXPath(pXmlDoc,"/w:document/w:body/w:p/w:sdt/w:sdtPr/w:showingPlcHdr", 2);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testFdo71785, "fdo71785.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 92b13f34823c..dcafe422a0e8 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -619,6 +619,7 @@ void SdtBlockHelper::DeleteAndResetTheLists()
         m_aPlaceHolderDocPart.clear();
     if (!m_aColor.isEmpty())
         m_aColor.clear();
+    m_bShowingPlaceHolder = false;
     m_bHasId = false;
 }
 
@@ -707,6 +708,10 @@ void SdtBlockHelper::WriteExtraParams(const 
::sax_fastparser::FSHelperPtr& pSeri
         pSerializer->singleElementNS(XML_w, XML_docPart, FSNS(XML_w, XML_val), 
m_aPlaceHolderDocPart);
         pSerializer->endElementNS(XML_w, XML_placeholder);
     }
+
+    if (m_bShowingPlaceHolder)
+        pSerializer->singleElementNS(XML_w, XML_showingPlcHdr);
+
     if (!m_aColor.isEmpty())
     {
         pSerializer->singleElementNS(XML_w15, XML_color, FSNS(XML_w, XML_val), 
m_aColor);
@@ -813,6 +818,11 @@ void SdtBlockHelper::GetSdtParamsFromGrabBag(const 
uno::Sequence<beans::Property
                     m_aColor = sValue;
             }
         }
+        else if (aPropertyValue.Name == "ooxml:CT_SdtPr_showingPlcHdr")
+        {
+            if (!(aPropertyValue.Value >>= m_bShowingPlaceHolder))
+                SAL_WARN("sw.ww8", "DocxAttributeOutput::GrabBag: unexpected 
sdt ShowingPlcHdr");
+        }
         else if (aPropertyValue.Name == "ooxml:CT_SdtPr_alias" && 
m_aAlias.isEmpty())
         {
             if (!(aPropertyValue.Value >>= m_aAlias))
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index fd14524f6e77..6e029cc9dfc4 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -130,6 +130,7 @@ public:
     SdtBlockHelper()
         : m_bHasId(false)
         , m_bStartedSdt(false)
+        , m_bShowingPlaceHolder(false)
         , m_nSdtPrToken(0)
     {}
 
@@ -141,6 +142,7 @@ public:
     rtl::Reference<sax_fastparser::FastAttributeList> m_pDataBindingAttrs;
     OUString m_aColor;
     OUString m_aPlaceHolderDocPart;
+    bool m_bShowingPlaceHolder;
     OUString m_aAlias;
     sal_Int32 m_nSdtPrToken;
 
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 93cb36cb8e55..4683ff445458 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2828,11 +2828,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
         m_pImpl->disableInteropGrabBag();
     }
     break;
-    case NS_ooxml::LN_CT_SdtPr_showingPlcHdr:
-    {
-        m_pImpl->m_pSdtHelper->SetShowingPlcHdr();
-    }
-    break;
     case NS_ooxml::LN_CT_SdtPr_dataBinding:
     case NS_ooxml::LN_CT_SdtPr_equation:
     case NS_ooxml::LN_CT_SdtPr_checkbox:
@@ -2844,11 +2839,18 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
     case NS_ooxml::LN_CT_SdtPr_id:
     case NS_ooxml::LN_CT_SdtPr_alias:
     case NS_ooxml::LN_CT_SdtPlaceholder_docPart:
+    case NS_ooxml::LN_CT_SdtPr_showingPlcHdr:
     case NS_ooxml::LN_CT_SdtPr_color:
     case NS_ooxml::LN_CT_SdtPr_tag:
     {
         if (!m_pImpl->GetSdtStarts().empty())
         {
+            if (nSprmId == NS_ooxml::LN_CT_SdtPr_showingPlcHdr)
+            {
+                if (nIntValue)
+                    m_pImpl->m_pSdtHelper->SetShowingPlcHdr();
+            }
+
             if (nSprmId == NS_ooxml::LN_CT_SdtPr_color)
             {
                 writerfilter::Reference<Properties>::Pointer_t pProperties = 
rSprm.getProps();
@@ -2932,6 +2934,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
             case NS_ooxml::LN_CT_SdtPr_id:          sName = 
"ooxml:CT_SdtPr_id"; break;
             case NS_ooxml::LN_CT_SdtPr_alias:       sName = 
"ooxml:CT_SdtPr_alias"; break;
             case NS_ooxml::LN_CT_SdtPlaceholder_docPart: sName = 
"ooxml:CT_SdtPlaceholder_docPart"; break;
+            case NS_ooxml::LN_CT_SdtPr_showingPlcHdr: sName = 
"ooxml:CT_SdtPr_showingPlcHdr"; break;
             case NS_ooxml::LN_CT_SdtPr_color:       sName = 
"ooxml:CT_SdtPr_color"; break;
             default: assert(false);
         };
@@ -2958,6 +2961,13 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
             aValue.Value <<= sStringValue;
             m_pImpl->m_pSdtHelper->appendToInteropGrabBag(aValue);
         }
+        else if (nSprmId == NS_ooxml::LN_CT_SdtPr_showingPlcHdr)
+        {
+            beans::PropertyValue aValue;
+            aValue.Name = sName;
+            aValue.Value <<= bool(nIntValue);
+            m_pImpl->m_pSdtHelper->appendToInteropGrabBag(aValue);
+        }
         else
             m_pImpl->m_pSdtHelper->appendToInteropGrabBag(getInteropGrabBag());
         
m_pImpl->m_pSdtHelper->setOutsideAParagraph(m_pImpl->IsOutsideAParagraph());

Reply via email to