diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2022-09-12 13:39:40 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-09-13 13:43:02 +0200 |
commit | f2c4ecbd38a274ca36db21a61ef7712b3db8ca87 (patch) | |
tree | e38c2ae2e323aa63a1ea5bc34c471619fee06714 | |
parent | bump harfbuzz dependency to >= 2.1.0 (diff) | |
download | core-f2c4ecbd38a274ca36db21a61ef7712b3db8ca87.tar.gz core-f2c4ecbd38a274ca36db21a61ef7712b3db8ca87.zip |
tdf#150267 Import docvar value correctly
Change-Id: I388923e3f7bea35c1247f47812c158f5ab92fc0e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139793
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
(cherry picked from commit bae62d8792d1ce31408ae101eeb305c302037849)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139667
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport5.cxx | 16 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 12 |
2 files changed, 13 insertions, 15 deletions
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index 59390a6fb5e0..2b7f37fc1a8b 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/XTextContentAppend.hpp> #include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XDependentTextField.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/awt/FontSlant.hpp> @@ -840,18 +841,11 @@ DECLARE_RTFEXPORT_TEST(testTdf150267, "tdf150267.rtf") uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextFieldsSupplier> xSupplier(xModel, uno::UNO_QUERY); uno::Reference<container::XNameAccess> xTextFieldMasters = xSupplier->getTextFieldMasters(); - uno::Sequence<rtl::OUString> aMasterNames = xTextFieldMasters->getElementNames(); - bool bHasUnusedField = false; - for (const auto& rMasterName : std::as_const(aMasterNames)) - { - if (rMasterName == "com.sun.star.text.fieldmaster.User.Unused") - { - bHasUnusedField = true; - break; - } - } + CPPUNIT_ASSERT_EQUAL(sal_True, + xTextFieldMasters->hasByName("com.sun.star.text.fieldmaster.User.Unused")); - CPPUNIT_ASSERT_EQUAL(true, bHasUnusedField); + auto xFieldMaster = xTextFieldMasters->getByName("com.sun.star.text.fieldmaster.User.Unused"); + CPPUNIT_ASSERT_EQUAL(OUString("Hello World"), getProperty<OUString>(xFieldMaster, "Content")); } DECLARE_RTFEXPORT_TEST(testTdf108416, "tdf108416.rtf") diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 5effc8d81bbf..ffcef6178a89 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -17,6 +17,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> +#include <com/sun/star/text/XDependentTextField.hpp> #include <i18nlangtag/languagetag.hxx> #include <unotools/ucbstreamhelper.hxx> #include <unotools/streamwrap.hxx> @@ -3483,12 +3484,15 @@ void RTFDocumentImpl::afterPopState(RTFParserState& rState) } else { - uno::Reference<beans::XPropertySet> xMasterProperties( + uno::Reference<beans::XPropertySet> xMaster( m_xModelFactory->createInstance("com.sun.star.text.FieldMaster.User"), uno::UNO_QUERY_THROW); - xMasterProperties->setPropertyValue("Name", - uno::Any(m_aStates.top().getDocVarName())); - xMasterProperties->setPropertyValue("Value", uno::Any(docvar)); + xMaster->setPropertyValue("Name", uno::Any(m_aStates.top().getDocVarName())); + uno::Reference<text::XDependentTextField> xField( + m_xModelFactory->createInstance("com.sun.star.text.TextField.User"), + uno::UNO_QUERY); + xField->attachTextFieldMaster(xMaster); + xField->getTextFieldMaster()->setPropertyValue("Content", uno::Any(docvar)); m_aStates.top().clearDocVarName(); } |