summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-07-04 12:29:08 +0300
committerXisco Fauli <xiscofauli@libreoffice.org>2021-07-06 11:32:11 +0200
commitf51f0c023dc163e348e784fc1f846a76afb9bf80 (patch)
treea2a314a700ede578d304150c70b156de0fa07405 /sw
parent0381a6f556ab973d847a6f2b1d4fa83f9d6cc833 (diff)
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 <mike.kaganski@collabora.com> (cherry picked from commit cd0ab69d4afee0c77884ae17ab9410216695b58b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118413 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf142464_ampm.docxbin0 -> 15171 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx26
2 files changed, 26 insertions, 0 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf142464_ampm.docx
Binary files 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 <swmodeltestbase.hxx>
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
+#include <com/sun/star/text/XTextField.hpp>
#include <xmloff/odffields.hxx>
@@ -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<css::text::XTextFieldsSupplier> xTextFieldsSupplier(
+ mxComponent, css::uno::UNO_QUERY_THROW);
+ auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
+ auto xFields(xFieldsAccess->createEnumeration());
+ css::uno::Reference<css::text::XTextField> 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: */