diff options
author | Justin Luth <justin_luth@sil.org> | 2022-03-12 11:11:01 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-03-25 13:48:12 +0100 |
commit | c4cb1d1dd581a5f120d9cf8b1d4274ec38f3eabe (patch) | |
tree | 084536944b7ae889d555077e4a3f71ed75bc863a /sw | |
parent | 1fdd27398006baa03c2e45b4ca2412b74ef7ee62 (diff) |
tdf#147861 writerfilter: use GetFieldResult, not current DocProperty
Import DOCX and RTF DocProperty fields as "fixed" if the displayed
text does not match the File - Properties - Custom variable's content.
Otherwise LO will automatically update the field and show the wrong
contents (because MS Word requires the user to manually refresh via F9).
Change-Id: Id5d3d0794e81b13465c5e824f1e994f563e62c1c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131415
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf147861_customField.docx | bin | 0 -> 6473 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 19 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 2 |
3 files changed, 20 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf147861_customField.docx b/sw/qa/extras/ooxmlexport/data/tdf147861_customField.docx Binary files differnew file mode 100644 index 000000000000..70071fa7e8a3 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf147861_customField.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index a33da51048b8..bbc5ec25da07 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -18,6 +18,7 @@ #include <queue> #include <swmodeltestbase.hxx> +#include <unotxdoc.hxx> constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/extras/ooxmlexport/data/"; @@ -48,6 +49,24 @@ DECLARE_OOXMLEXPORT_TEST(testTdf135164_cancelledNumbering, "tdf135164_cancelledN CPPUNIT_ASSERT_EQUAL(OUString("i"), getProperty<OUString>(xPara, "ListLabelString")); } +DECLARE_OOXMLEXPORT_TEST(testTdf147861_customField, "tdf147861_customField.docx") +{ + // These should each be specific values, not a shared DocProperty + getParagraph(1, "CustomEditedTitle"); // edited + // A couple of nulls at the end of the string thwarted all attemps at an "equals" comparison. + CPPUNIT_ASSERT(getParagraph(2)->getString().startsWith(" INSERT Custom Title here")); + getParagraph(3, "My Title"); // edited + + // 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()); + uno::Reference<text::XTextField> xField(xFields->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("CustomEditedTitle"), xField->getPresentation(false)); + // The " (fixed)" part is unnecessary, but it must be consistent across a round-trip + CPPUNIT_ASSERT_EQUAL(OUString("DocInformation:Title (fixed)"), xField->getPresentation(true)); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf135906) { loadAndReload("tdf135906.docx"); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index 3d0b23f9e71e..415138bc5e28 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -129,7 +129,7 @@ DECLARE_OOXMLEXPORT_TEST(testN751117, "n751117.docx") DECLARE_OOXMLEXPORT_TEST(testFdo74745, "fdo74745.docx") { uno::Reference<text::XTextRange > paragraph = getParagraph(3); - CPPUNIT_ASSERT_EQUAL(OUString("09/02/14"), paragraph->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("09/02/2014"), paragraph->getString()); } DECLARE_OOXMLEXPORT_TEST(testFdo81486, "fdo81486.docx") |