diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-10-05 08:22:19 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-10-07 12:06:30 +0200 |
commit | 534d77ec3be57c52b475f649d3fc59f6b7f79ef3 (patch) | |
tree | 9102c169ece1d799efa5618688f08a35f799b753 /sw | |
parent | 424cfae160e21dbc1397c9672adfbc68be715a87 (diff) |
sw content controls: preserve alias
This is similar to <w15:color> to preserve <w:alias>.
Related to
<https://gerrit.libreoffice.org/c/core/+/137399/2#message-a5ba9f1e0dc9e586034758ee7c0a94e1533e8922>.
(cherry picked from commit 481a082469802ffce08cd8c110e715260015eb97)
Conflicts:
sw/source/core/unocore/unomap1.cxx
Change-Id: I774b7204c5ca02ec6db89f5cbd3a6de6f2bf82a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141024
Tested-by: Miklos Vajna <vmiklos@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/formatcontentcontrol.hxx | 7 | ||||
-rw-r--r-- | sw/inc/unoprnms.hxx | 1 | ||||
-rw-r--r-- | sw/qa/core/unocore/unocore.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/txtnode/attrcontentcontrol.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unocontentcontrol.cxx | 28 | ||||
-rw-r--r-- | sw/source/core/unocore/unomap1.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 6 |
8 files changed, 49 insertions, 0 deletions
diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index e5e1cf0de1e9..5806f0851db1 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -165,6 +165,9 @@ class SW_DLLPUBLIC SwContentControl : public sw::BroadcastingModify /// The color: just remembered. OUString m_aColor; + /// The alias: just remembered. + OUString m_aAlias; + /// Stores a list item index, in case the doc model is not yet updated. std::optional<size_t> m_oSelectedListItem; @@ -324,6 +327,10 @@ public: OUString GetColor() const { return m_aColor; } + void SetAlias(const OUString& rAlias) { m_aAlias = rAlias; } + + const OUString& GetAlias() const { return m_aAlias; } + void SetReadWrite(bool bReadWrite) { m_bReadWrite = bReadWrite; } bool GetReadWrite() const { return m_bReadWrite; } diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 115638ae4e3a..623960f13516 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -887,6 +887,7 @@ #define UNO_NAME_DATA_BINDING_XPATH "DataBindingXpath" #define UNO_NAME_DATA_BINDING_STORE_ITEM_ID "DataBindingStoreItemID" #define UNO_NAME_COLOR "Color" +#define UNO_NAME_ALIAS "Alias" #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 658d4f9bfa3f..13a10c2f03f1 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -572,6 +572,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDate) xContentControlProps->setPropertyValue( "DataBindingStoreItemID", uno::Any(OUString("{241A8A02-7FFD-488D-8827-63FBE74E8BC9}"))); xContentControlProps->setPropertyValue("Color", uno::Any(OUString("008000"))); + xContentControlProps->setPropertyValue("Alias", uno::Any(OUString("myalias"))); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // Then make sure that the specified properties are set: @@ -595,6 +596,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDate) CPPUNIT_ASSERT_EQUAL(OUString("{241A8A02-7FFD-488D-8827-63FBE74E8BC9}"), pContentControl->GetDataBindingStoreItemID()); CPPUNIT_ASSERT_EQUAL(OUString("008000"), pContentControl->GetColor()); + CPPUNIT_ASSERT_EQUAL(OUString("myalias"), pContentControl->GetAlias()); } CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlPlainText) diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 2414c1b2ad38..761155ad1dc9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -297,6 +297,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDateContentControlExport) xContentControlProps->setPropertyValue("DataBindingXpath", uno::Any(OUString("/ns0:employees[1]/ns0:employee[1]/ns0:hireDate[1]"))); xContentControlProps->setPropertyValue("DataBindingStoreItemID", uno::Any(OUString("{241A8A02-7FFD-488D-8827-63FBE74E8BC9}"))); xContentControlProps->setPropertyValue("Color", uno::Any(OUString("008000"))); + xContentControlProps->setPropertyValue("Alias", uno::Any(OUString("myalias"))); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to DOCX: @@ -318,6 +319,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDateContentControlExport) assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:dataBinding", "xpath", "/ns0:employees[1]/ns0:employee[1]/ns0:hireDate[1]"); assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:dataBinding", "storeItemID", "{241A8A02-7FFD-488D-8827-63FBE74E8BC9}"); assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w15:color", "val", "008000"); + assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:alias", "val", "myalias"); } DECLARE_OOXMLEXPORT_TEST(testTdf137466, "tdf137466.docx") diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx index 9d0bf82b1a4c..ebd0fe48d9db 100644 --- a/sw/source/core/txtnode/attrcontentcontrol.cxx +++ b/sw/source/core/txtnode/attrcontentcontrol.cxx @@ -402,6 +402,8 @@ void SwContentControl::dumpAsXml(xmlTextWriterPtr pWriter) const BAD_CAST(m_aDataBindingStoreItemID.toUtf8().getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("color"), BAD_CAST(m_aColor.toUtf8().getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("alias"), + BAD_CAST(m_aAlias.toUtf8().getStr())); if (!m_aListItems.empty()) { diff --git a/sw/source/core/unocore/unocontentcontrol.cxx b/sw/source/core/unocore/unocontentcontrol.cxx index ed4e6d854776..774cc0f7fbcf 100644 --- a/sw/source/core/unocore/unocontentcontrol.cxx +++ b/sw/source/core/unocore/unocontentcontrol.cxx @@ -173,6 +173,7 @@ public: OUString m_aDataBindingXpath; OUString m_aDataBindingStoreItemID; OUString m_aColor; + OUString m_aAlias; Impl(SwXContentControl& rThis, SwDoc& rDoc, SwContentControl* pContentControl, const uno::Reference<text::XText>& xParentText, @@ -545,6 +546,7 @@ void SwXContentControl::AttachImpl(const uno::Reference<text::XTextRange>& xText pContentControl->SetDataBindingXpath(m_pImpl->m_aDataBindingXpath); pContentControl->SetDataBindingStoreItemID(m_pImpl->m_aDataBindingStoreItemID); pContentControl->SetColor(m_pImpl->m_aColor); + pContentControl->SetAlias(m_pImpl->m_aAlias); SwFormatContentControl aContentControl(pContentControl, nWhich); bool bSuccess @@ -964,6 +966,21 @@ void SAL_CALL SwXContentControl::setPropertyValue(const OUString& rPropertyName, } } } + else if (rPropertyName == UNO_NAME_ALIAS) + { + OUString aValue; + if (rValue >>= aValue) + { + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_aAlias = aValue; + } + else + { + m_pImpl->m_pContentControl->SetAlias(aValue); + } + } + } else { throw beans::UnknownPropertyException(); @@ -1175,6 +1192,17 @@ uno::Any SAL_CALL SwXContentControl::getPropertyValue(const OUString& rPropertyN aRet <<= m_pImpl->m_pContentControl->GetColor(); } } + else if (rPropertyName == UNO_NAME_ALIAS) + { + if (m_pImpl->m_bIsDescriptor) + { + aRet <<= m_pImpl->m_aAlias; + } + else + { + aRet <<= m_pImpl->m_pContentControl->GetAlias(); + } + } else { throw beans::UnknownPropertyException(); diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx index 4235fd2ebc1c..158da137f1fe 100644 --- a/sw/source/core/unocore/unomap1.cxx +++ b/sw/source/core/unocore/unomap1.cxx @@ -1044,6 +1044,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetContentControlProper { u"" UNO_NAME_DATA_BINDING_XPATH, 0, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 }, { u"" UNO_NAME_DATA_BINDING_STORE_ITEM_ID, 0, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 }, { u"" UNO_NAME_COLOR, 0, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 }, + { u"" UNO_NAME_ALIAS, 0, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0 }, { u"", 0, css::uno::Type(), 0, 0 } }; diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 7862a57b8394..85c68a3e078d 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2363,6 +2363,12 @@ void DocxAttributeOutput::WriteContentControlStart() m_pContentControl->GetColor()); } + if (!m_pContentControl->GetAlias().isEmpty()) + { + m_pSerializer->singleElementNS(XML_w, XML_alias, FSNS(XML_w, XML_val), + m_pContentControl->GetAlias()); + } + if (m_pContentControl->GetShowingPlaceHolder()) { m_pSerializer->singleElementNS(XML_w, XML_showingPlcHdr); |