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

Tibor Nagy (via logerrit) logerrit at kemper.freedesktop.org
Sat Oct 10 22:12:20 UTC 2020


 sc/qa/unit/data/ods/tdf126305.ods     |binary
 sc/qa/unit/subsequent_export-test.cxx |   22 +++++++++++++++++++++-
 sc/source/filter/excel/xecontent.cxx  |   13 ++++++++++++-
 3 files changed, 33 insertions(+), 2 deletions(-)

New commits:
commit fca525d570f4fada3db1a9bbee2e88a5a02839d9
Author:     Tibor Nagy <nagy.tibor2 at nisz.hu>
AuthorDate: Tue Oct 6 12:12:29 2020 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Sun Oct 11 00:11:35 2020 +0200

    tdf#126305 XLSX export: fix data validation Error Alert
    
    Excel supports three kinds of error messages: stop,
    warning and information, but LO only one of error
    message(stop) was exported.
    
    Co-authored-by: Attila Szűcs (NISZ)
    Change-Id: Iecf790c104bee39ee29629a13fe4af4d8b29d311
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104021
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/qa/unit/data/ods/tdf126305.ods b/sc/qa/unit/data/ods/tdf126305.ods
new file mode 100644
index 000000000000..fdff7d9568c3
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf126305.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 89a3659fe640..f22747996641 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -271,7 +271,7 @@ public:
     void testTdf133688_precedents();
     void testTdf91251_missingOverflowRoundtrip();
     void testTdf137000_handle_upright();
-
+    void testTdf126305_DataValidatyErrorAlert();
 
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
@@ -437,6 +437,7 @@ public:
     CPPUNIT_TEST(testTdf133688_precedents);
     CPPUNIT_TEST(testTdf91251_missingOverflowRoundtrip);
     CPPUNIT_TEST(testTdf137000_handle_upright);
+    CPPUNIT_TEST(testTdf126305_DataValidatyErrorAlert);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -5505,6 +5506,25 @@ void ScExportTest::testTdf137000_handle_upright()
                            "rot");
 }
 
+void ScExportTest::testTdf126305_DataValidatyErrorAlert()
+{
+    ScDocShellRef xShell = loadDoc("tdf126305.", FORMAT_ODS);
+    CPPUNIT_ASSERT(xShell.is());
+
+    ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX);
+    CPPUNIT_ASSERT(xDocSh.is());
+
+    std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX);
+    xmlDocUniquePtr pDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
+    CPPUNIT_ASSERT(pDoc);
+
+    assertXPath(pDoc, "/x:worksheet/x:dataValidations/x:dataValidation[1]", "errorStyle", "stop");
+    assertXPath(pDoc, "/x:worksheet/x:dataValidations/x:dataValidation[2]", "errorStyle", "warning");
+    assertXPath(pDoc, "/x:worksheet/x:dataValidations/x:dataValidation[3]", "errorStyle", "information");
+
+    xDocSh->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index eaa14d7e580e..a04c456fdeaa 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1637,6 +1637,17 @@ const char* lcl_GetOperatorType( sal_uInt32 nFlags )
     return nullptr;
 }
 
+const char* lcl_GetErrorType( sal_uInt32 nFlags )
+{
+    switch (nFlags & EXC_DV_ERROR_MASK)
+    {
+        case EXC_DV_ERROR_STOP:      return "stop";
+        case EXC_DV_ERROR_WARNING:   return "warning";
+        case EXC_DV_ERROR_INFO:      return "information";
+    }
+    return nullptr;
+}
+
 } // namespace
 
 XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong nScHandle ) :
@@ -1846,7 +1857,7 @@ void XclExpDV::SaveXml( XclExpXmlStream& rStrm )
     rWorksheet->startElement( XML_dataValidation,
             XML_allowBlank,         ToPsz( ::get_flag( mnFlags, EXC_DV_IGNOREBLANK ) ),
             XML_error,              XESTRING_TO_PSZ( maErrorText ),
-            // OOXTODO: XML_errorStyle,
+            XML_errorStyle,         lcl_GetErrorType(mnFlags),
             XML_errorTitle,         XESTRING_TO_PSZ( maErrorTitle ),
             // OOXTODO: XML_imeMode,
             XML_operator,           lcl_GetOperatorType( mnFlags ),


More information about the Libreoffice-commits mailing list