diff options
-rw-r--r-- | offapi/com/sun/star/text/ContentControl.idl | 6 | ||||
-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 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx | 5 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx | bin | 4356 -> 4369 bytes | |||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 6 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 6 | ||||
-rw-r--r-- | writerfilter/source/dmapper/SdtHelper.cxx | 4 | ||||
-rw-r--r-- | writerfilter/source/dmapper/SdtHelper.hxx | 6 |
15 files changed, 82 insertions, 0 deletions
diff --git a/offapi/com/sun/star/text/ContentControl.idl b/offapi/com/sun/star/text/ContentControl.idl index af5be9ac251e..d07dbfc49256 100644 --- a/offapi/com/sun/star/text/ContentControl.idl +++ b/offapi/com/sun/star/text/ContentControl.idl @@ -99,6 +99,12 @@ service ContentControl @since LibreOffice 7.5 */ [optional, property] boolean ComboBox; + + /** The alias: just remembered. + + @since LibreOffice 7.5 + */ + [optional, property] string Alias; }; diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index 41d35fd10fb8..6462bf49cd06 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -166,6 +166,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; @@ -322,6 +325,10 @@ public: const 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 bb82bf3a1eef..850a789900df 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -890,6 +890,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 83efc0f9e5c2..23811a497566 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -624,6 +624,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: @@ -647,6 +648,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, testListIdState) diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index d6488db0326e..5246edc2a1e7 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -426,6 +426,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: @@ -447,6 +448,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"); } CPPUNIT_TEST_FIXTURE(Test, testNegativePageBorder) diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx index 89b12d9b7ea0..911cff5e7a58 100644 --- a/sw/source/core/txtnode/attrcontentcontrol.cxx +++ b/sw/source/core/txtnode/attrcontentcontrol.cxx @@ -408,6 +408,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 b63725fac2f9..7af0fd0638b2 100644 --- a/sw/source/core/unocore/unocontentcontrol.cxx +++ b/sw/source/core/unocore/unocontentcontrol.cxx @@ -174,6 +174,7 @@ public: OUString m_aDataBindingXpath; OUString m_aDataBindingStoreItemID; OUString m_aColor; + OUString m_aAlias; Impl(SwXContentControl& rThis, SwDoc& rDoc, SwContentControl* pContentControl, uno::Reference<text::XText> xParentText, std::unique_ptr<const TextRangeList_t> pPortions) @@ -482,6 +483,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 @@ -901,6 +903,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(); @@ -1112,6 +1129,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 0bf5a84a7aaa..ae9a718a57ee 100644 --- a/sw/source/core/unocore/unomap1.cxx +++ b/sw/source/core/unocore/unomap1.cxx @@ -1009,6 +1009,7 @@ o3tl::span<const SfxItemPropertyMapEntry> SwUnoPropertyMapProvider::GetContentCo { 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 }, }; return aContentControlMap_Impl; diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 16af1afc910a..7338bb697fc4 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2361,6 +2361,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); diff --git a/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx b/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx index 7b842e667104..f6f67327fad8 100644 --- a/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx +++ b/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx @@ -86,6 +86,11 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtRunRichText) xContent.set(xContentEnum->nextElement(), uno::UNO_QUERY); xContent->getPropertyValue("CharHeight") >>= fCharheight; CPPUNIT_ASSERT_EQUAL(24.f, fCharheight); + uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); + OUString aAlias; + xContentControlProps->getPropertyValue("Alias") >>= aAlias; + // This was empty. + CPPUNIT_ASSERT_EQUAL(OUString("myalias"), aAlias); } CPPUNIT_TEST_FIXTURE(Test, testSdtRunPlainText) diff --git a/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx b/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx Binary files differindex b945d0bb3b55..b3b25d8cc3ab 100644 --- a/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx +++ b/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 675a8b37e869..2682f78e1e91 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2827,6 +2827,12 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) break; } + if (nSprmId == NS_ooxml::LN_CT_SdtPr_alias) + { + m_pImpl->m_pSdtHelper->SetAlias(sStringValue); + break; + } + if (nSprmId == NS_ooxml::LN_CT_SdtPr_checkbox) { m_pImpl->m_pSdtHelper->setControlType(SdtControlType::checkBox); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 7b1811974713..d73b89a78de0 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -937,6 +937,12 @@ void DomainMapper_Impl::PopSdt() uno::Any(m_pSdtHelper->GetColor())); } + if (!m_pSdtHelper->GetAlias().isEmpty()) + { + xContentControlProps->setPropertyValue("Alias", + uno::Any(m_pSdtHelper->GetAlias())); + } + if (m_pSdtHelper->getControlType() == SdtControlType::checkBox) { xContentControlProps->setPropertyValue("Checkbox", uno::Any(true)); diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx index 8225a6a04bca..ebcea44ef863 100644 --- a/writerfilter/source/dmapper/SdtHelper.cxx +++ b/writerfilter/source/dmapper/SdtHelper.cxx @@ -511,6 +511,10 @@ void SdtHelper::SetColor(const OUString& rColor) { m_aColor = rColor; } const OUString& SdtHelper::GetColor() const { return m_aColor; } +void SdtHelper::SetAlias(const OUString& rAlias) { m_aAlias = rAlias; } + +const OUString& SdtHelper::GetAlias() const { return m_aAlias; } + } // namespace writerfilter::dmapper /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/SdtHelper.hxx b/writerfilter/source/dmapper/SdtHelper.hxx index 689c57503185..bdb95f3d7e13 100644 --- a/writerfilter/source/dmapper/SdtHelper.hxx +++ b/writerfilter/source/dmapper/SdtHelper.hxx @@ -126,6 +126,9 @@ class SdtHelper final : public virtual SvRefBase /// <w:sdtPr>'s <w15:color w:val="...">. OUString m_aColor; + /// <w:sdtPr>'s <w:alias w:val="...">. + OUString m_aAlias; + public: explicit SdtHelper(DomainMapper_Impl& rDM_Impl, css::uno::Reference<css::uno::XComponentContext> xContext); @@ -205,6 +208,9 @@ public: void SetColor(const OUString& rColor); const OUString& GetColor() const; + void SetAlias(const OUString& rAlias); + const OUString& GetAlias() const; + std::optional<OUString> getValueFromDataBinding(); }; |