summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2022-12-07 13:44:01 -0500
committerMiklos Vajna <vmiklos@collabora.com>2022-12-21 07:56:12 +0000
commit529cf56d77c391ef6083808e383b171e3d70980e (patch)
treed6acf01c5bdbbceae216e892ec60d34641ded26f
parent0ba2610a19b032dfad7e1d7fda8350ed95832956 (diff)
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 <jluth@mail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144621 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport17.cxx6
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport3.cxx4
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx10
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx2
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx20
5 files changed, 37 insertions, 5 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 63fda18c23f3..bb7f3d9458b6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -496,6 +496,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148111, "tdf148111.docx")
// No more fields
CPPUNIT_ASSERT(!xFields->hasMoreElements());
+
+ if (!mbExported)
+ 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(testTdf81507, "tdf81507.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 2d1bc1035d5a..4e8f58f6294b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -1013,6 +1013,10 @@ CPPUNIT_TEST_FIXTURE(Test, testGlossaryWithEmail)
"and @Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink' "
"and @Target='mailto:emailgoeshere@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 f2aaefa22440..73d01152dfb5 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -623,6 +623,7 @@ void SdtBlockHelper::DeleteAndResetTheLists()
m_aPlaceHolderDocPart.clear();
if (!m_aColor.isEmpty())
m_aColor.clear();
+ m_bShowingPlaceHolder = false;
m_bHasId = false;
}
@@ -715,6 +716,10 @@ void SdtBlockHelper::WriteExtraParams(::sax_fastparser::FSHelperPtr& pSerializer
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);
@@ -827,6 +832,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 f61b4576a941..8191cfb523cf 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;
OUString m_aTag;
OUString m_aLock;
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 2dd9b0583445..d98b2d3491e3 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2794,11 +2794,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:
@@ -2810,12 +2805,19 @@ 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:
case NS_ooxml::LN_CT_SdtPr_lock:
{
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();
@@ -2899,6 +2901,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
case NS_ooxml::LN_CT_SdtPr_tag: sName = "ooxml:CT_SdtPr_tag"; break;
case NS_ooxml::LN_CT_SdtPr_lock: sName = "ooxml:CT_SdtPr_lock"; 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);
};
@@ -2927,6 +2930,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());