summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/rtfexport/rtfexport5.cxx16
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx12
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();
}