sw/qa/extras/ooxmlexport/data/tdf148380_createField.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 15 +++++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-)
New commits: commit 431a0399bb050e65dedb2e9280e744699a724227 Author: Justin Luth <justin_l...@sil.org> AuthorDate: Tue Apr 5 14:10:21 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Apr 11 12:23:14 2022 +0200 tdf#148380 writerfilter: Import AUTHOR as FIXEDFLD This patch depends on patches for tdf#147861 and will require a follow-up export patch that handles exporting this FIXEDFLD (instead of just dumping the name of the field). This was being imported as plain text because of exception writerfilter/source/dmapper/DomainMapper_Impl.cxx:6950: Exception in CloseFieldCommand() com.sun.star.beans.UnknownPropertyException message: "Unknown property: FullName at /persistent/git/libreoffice2/sw/source/core/unocore/unofield.cxx:2156" Additionally, similar to tdf#134592, the create author will always be constant, so mark that as fixed. (This helps because in MS Word, the user can modify the field contents to be anything he wants, and it is only updated when F9 is pressed on the selected field. Thus, we might NOT want to show the real DocInfo.CreateAuthor as the unit test demonstrates.) Change-Id: Ie014c273d491fa5bbd9b9ecedc69702d0ae8d60c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132661 Tested-by: Justin Luth <jl...@mail.com> Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/data/tdf148380_createField.docx b/sw/qa/extras/ooxmlexport/data/tdf148380_createField.docx new file mode 100644 index 000000000000..c31ed72141e4 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf148380_createField.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 00f54a17c561..77caab6f81ff 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -67,6 +67,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf147861_customField, "tdf147861_customField.docx" CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Title (fixed)"), xField->getPresentation(true)); } +DECLARE_OOXMLEXPORT_TEST(testTdf148380_createField, "tdf148380_createField.docx") +{ + // Verify that these are fields, and not just plain text + uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + auto xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); + if (mbExported) + return; + uno::Reference<text::XTextField> xField(xFields->nextElement(), uno::UNO_QUERY); + // This should NOT be "Lorenzo Chavez", or a real date since the user hand-modified the result. + CPPUNIT_ASSERT_EQUAL(OUString("Myself - that's who"), xField->getPresentation(false)); + xField.set(xFields->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("yesterday at noon"), xField->getPresentation(false)); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf135906) { loadAndReload("tdf135906.docx"); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 597549475936..311a0ffd4384 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -5451,11 +5451,11 @@ void DomainMapper_Impl::handleAuthor uno::Reference< beans::XPropertySet > const& xFieldProperties, FieldId eFieldId ) { - if ( eFieldId != FIELD_USERINITIALS ) + if (eFieldId == FIELD_USERNAME) xFieldProperties->setPropertyValue ( getPropertyName(PROP_FULL_NAME), uno::makeAny( true )); - if (!rFirstParam.empty()) + if (!rFirstParam.empty() || eFieldId == FIELD_AUTHOR) { xFieldProperties->setPropertyValue( getPropertyName( PROP_IS_FIXED ),