From f51f0c023dc163e348e784fc1f846a76afb9bf80 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 4 Jul 2021 12:29:08 +0300 Subject: tdf#142464: do not escape '/' is AM/PM when importing DOCX. See also commit a2e964afc5187fc1e3b38720ec10ad9856b87020, doing the same for DOC. Change-Id: Ib0ddb36de8589f9264fe857b20a6ef2aa2607c52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118369 Tested-by: Jenkins Reviewed-by: Mike Kaganski (cherry picked from commit cd0ab69d4afee0c77884ae17ab9410216695b58b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118413 Reviewed-by: Xisco Fauli --- sw/qa/extras/ooxmlexport/data/tdf142464_ampm.docx | Bin 0 -> 15171 bytes sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 26 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 sw/qa/extras/ooxmlexport/data/tdf142464_ampm.docx (limited to 'sw') diff --git a/sw/qa/extras/ooxmlexport/data/tdf142464_ampm.docx b/sw/qa/extras/ooxmlexport/data/tdf142464_ampm.docx new file mode 100644 index 000000000000..d63398488858 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf142464_ampm.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index e828519ed4cf..d92c29fefbe7 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -10,6 +10,7 @@ #include #include +#include #include @@ -688,6 +689,31 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testConditionalText, "conditional-text.fodt" assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:instrText", OUString(aExpected)); } +DECLARE_OOXMLEXPORT_TEST(testTdf142464_ampm, "tdf142464_ampm.docx") +{ + css::uno::Reference xTextFieldsSupplier( + mxComponent, css::uno::UNO_QUERY_THROW); + auto xFieldsAccess(xTextFieldsSupplier->getTextFields()); + auto xFields(xFieldsAccess->createEnumeration()); + css::uno::Reference xField(xFields->nextElement(), + css::uno::UNO_QUERY_THROW); + + // Without the fix in place, this would have failed with: + // - Expected: 12:32 PM + // - Actual : 12:32 a12/p12 + CPPUNIT_ASSERT_EQUAL(OUString("12:32 PM"), xField->getPresentation(false)); + + if (xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml")) + { + // Without the fix in place, this would have failed with: + // - Expected: DATE \@"H:mm\ AM/PM" + // - Actual : DATE \@"H:mm' a'M'/p'M" + // i.e., the AM/PM would be treated as literal 'a' and 'p' followed by a month code + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:instrText", + " DATE \\@\"H:mm\\ AM/PM\" "); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3