[Libreoffice-commits] core.git: sc/qa

Laurent Balland-Poirier laurent.balland-poirier at laposte.net
Fri Nov 11 12:33:01 UTC 2016


 sc/qa/unit/data/ods/tdf36038_ExtendedLCID.ods |binary
 sc/qa/unit/subsequent_export-test.cxx         |   43 ++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

New commits:
commit 8d811eda74a6b2b249a44a9217328e8d2788ec3c
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date:   Sun Oct 23 11:46:19 2016 +0200

    tdf#36038 QA test export/import extended LCID to Excel
    
    Change-Id: I5c8a19f62f030913f7e6dcbc0274f5d0aa197056
    Reviewed-on: https://gerrit.libreoffice.org/30175
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/qa/unit/data/ods/tdf36038_ExtendedLCID.ods b/sc/qa/unit/data/ods/tdf36038_ExtendedLCID.ods
new file mode 100644
index 0000000..3abb946
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf36038_ExtendedLCID.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index b9bbc30..1a99a64 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -181,6 +181,7 @@ public:
     void testEscapeCharInNumberFormatXLSX();
     void testNatNumInNumberFormatXLSX();
     void testExponentWithoutSignFormatXLSX();
+    void testExtendedLCID();
 
     void testHiddenRepeatedRowsODS();
     void testHyperlinkTargetFrameODS();
@@ -267,6 +268,7 @@ public:
     CPPUNIT_TEST(testEscapeCharInNumberFormatXLSX);
     CPPUNIT_TEST(testNatNumInNumberFormatXLSX);
     CPPUNIT_TEST(testExponentWithoutSignFormatXLSX);
+    CPPUNIT_TEST(testExtendedLCID);
 
     CPPUNIT_TEST(testHiddenRepeatedRowsODS);
     CPPUNIT_TEST(testHyperlinkTargetFrameODS);
@@ -3723,6 +3725,47 @@ void ScExportTest::testExponentWithoutSignFormatXLSX()
     xDocSh->DoClose();
 }
 
+void ScExportTest::testExtendedLCID()
+{
+    ScDocShellRef xDocSh = loadDoc("tdf36038_ExtendedLCID.", FORMAT_ODS);
+    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);
+    // Check export
+    assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[2]", "formatCode", "[$-107041E]DD\\-MM\\-YYYY");
+    assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[3]", "formatCode", "[$-D07041E]DD\\-MM\\-YYYY");
+    assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[4]", "formatCode", "[$-1030411]DD\\-MM\\-EE");
+    assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[5]", "formatCode", "[$-1B030411]DD\\-MM\\-EE");
+    assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[6]", "formatCode", "[$-108040D]DD\\-MM\\-YYYY");
+    //assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[7]", "formatCode", "[$-108040D]DD\\-MM\\-YYYY");
+    assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[7]", "formatCode", "[$-1060401]DD\\-MM\\-YYYY");
+    assertXPath(pDoc, "/x:styleSheet/x:numFmts/x:numFmt[8]", "formatCode", "[$-2060401]DD\\-MM\\-YYYY");
+
+    // Check import
+    ScDocument& rDoc = xDocSh->GetDocument();
+    SvNumberFormatter* pNumFormatter = rDoc.GetFormatTable();
+    sal_uInt32 nNumberFormat;
+    const OUString aLang[4] = { "[$-41E]", "[$-411]", "[$-40D]", "[$-401]" };
+    const OUString aCalendar[4] = { "[~buddhist]DD-MM-YYYY", "[~gengou]DD-MM-EE", "[~jewish]DD-MM-YYYY", "[~hijri]DD-MM-YYYY" };
+    for ( sal_Int16 nCol = 1; nCol <= 2; nCol++ )
+    {
+        for ( sal_Int16 nRow = 1; nRow <= 4; nRow++ )
+        {
+            rDoc.GetNumberFormat(nCol, nRow, 0, nNumberFormat);
+            const SvNumberformat* pNumberFormat = pNumFormatter->GetEntry(nNumberFormat);
+            const OUString& rFormatStr = pNumberFormat->GetFormatstring();
+            const OUString aExpectedFormatStr = aLang[nRow-1] + ( (nCol==2 && nRow!=3) ? OUString("[NatNum1]") : OUString("") ) + aCalendar[nRow-1];
+
+            CPPUNIT_ASSERT_EQUAL_MESSAGE("Number format lost extended LCID during Excel export", aExpectedFormatStr, rFormatStr);
+        }
+    }
+
+    xDocSh->DoClose();
+}
+
 void ScExportTest::testHiddenRepeatedRowsODS()
 {
     ScDocShellRef xDocSh = loadDoc("empty.", FORMAT_ODS);


More information about the Libreoffice-commits mailing list