sc/qa/unit/data/xlsx/tdf81939.xlsx    |binary
 sc/qa/unit/subsequent_export-test.cxx |   29 +++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

New commits:
commit e364e52b9a551f78ff477939abbc555a47eb02ce
Author: Laurent Balland-Poirier <laurent.balland-poir...@laposte.net>
Date:   Sun Jul 3 10:45:53 2016 +0200

    tdf#81939 Add qa unit test
    
    Test removal or not of escape char in number format strings in XLSX
    
    Change-Id: I02a7e1bfd9df1ffd3bbad7dc072cfc85be68f949
    Reviewed-on: https://gerrit.libreoffice.org/26877
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com>

diff --git a/sc/qa/unit/data/xlsx/tdf81939.xlsx 
b/sc/qa/unit/data/xlsx/tdf81939.xlsx
new file mode 100644
index 0000000..6614a1e
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf81939.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 28e518d..131069b 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -171,6 +171,7 @@ public:
     void testHeaderImage();
 
     void testTdf88657();
+    void testEscapeCharInNumberFormatXLSX();
 
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
@@ -247,6 +248,7 @@ public:
     CPPUNIT_TEST(testHeaderImage);
 
     CPPUNIT_TEST(testTdf88657);
+    CPPUNIT_TEST(testEscapeCharInNumberFormatXLSX);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -3323,6 +3325,33 @@ void ScExportTest::testConditionalFormatRangeListXLSX()
     assertXPath(pDoc, "//x:conditionalFormatting", "sqref", "F4 F10");
 }
 
+void ScExportTest::testEscapeCharInNumberFormatXLSX()
+{
+    ScDocShellRef xDocSh = loadDoc("tdf81939.", FORMAT_XLSX);
+    CPPUNIT_ASSERT( xDocSh.Is() );
+    xDocSh = saveAndReload( &(*xDocSh), FORMAT_XLSX);
+    CPPUNIT_ASSERT( xDocSh.Is() );
+
+    xmlDocPtr pDoc = XPathHelper::parseExport(*xDocSh, m_xSFactory, 
"xl/styles.xml", FORMAT_XLSX);
+    CPPUNIT_ASSERT(pDoc);
+
+    const sal_Unicode cEuro (8364);  // € symbol
+    assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[2]", "formatCode", 
"00\\ 00\\ 00\\ 00\\ 00");
+    assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[3]", "formatCode", 
"00\\.00\\.00\\.000\\.0");   // tdf#81939
+    // "_-* #,##0\ _€_-;\-* #,##0\ _€_-;_-* "- "_€_-;_-@_-" // tdf#81222
+    OUString rFormatStrExpected ( "_-* #,##0\\ _" + OUString(cEuro) + "_-;\\-* 
#,##0\\ _" +
+            OUString(cEuro) + "_-;_-* \"- \"_" + OUString(cEuro) + "_-;_-@_-" 
);
+    assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[4]", "formatCode", 
rFormatStrExpected );
+    // "_-* #,##0" €"_-;\-* #,##0" €"_-;_-* "- €"_-;_-@_-");
+    rFormatStrExpected = "_-* #,##0\" " + OUString(cEuro) + "\"_-;\\-* #,##0\" 
" +
+            OUString(cEuro) + "\"_-;_-* \"- " + OUString(cEuro) + "\"_-;_-@_-";
+    assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[5]", "formatCode", 
rFormatStrExpected );
+    // remove escape char in fraction
+    assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[6]", "formatCode", "# 
?/?;[RED]\\-# #/#####");
+
+    xDocSh->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to