[Libreoffice-commits] .: sc/Module_sc.mk sc/qa

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Sun Jan 8 21:07:20 PST 2012


 sc/Module_sc.mk                                |    2 
 sc/qa/unit/data/contentCSV/rangeExp_Sheet2.csv |    5 +
 sc/qa/unit/data/ods/named-ranges-global.ods    |binary
 sc/qa/unit/data/xls/named-ranges-global.xls    |binary
 sc/qa/unit/data/xlsx/named-ranges-global.xlsx  |binary
 sc/qa/unit/filters-test.cxx                    |   24 +++--
 sc/qa/unit/helper/qahelper.hxx                 |  105 +++++++++++++++++++++++++
 sc/qa/unit/subsequent_filters-test.cxx         |   79 ++----------------
 8 files changed, 136 insertions(+), 79 deletions(-)

New commits:
commit cedfc2a67448692eb2c0028f18f77427a49a900b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Jan 9 00:31:06 2012 +0100

    add some tests related to fdo#42624
    
    see fdo#44587 for problems with range names in matrix formulas during xlsx
    import/export

diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index e57a433..cb3ae27 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -37,6 +37,7 @@ $(eval $(call gb_Module_add_targets,sc,\
 $(eval $(call gb_Module_add_check_targets,sc,\
     CppunitTest_sc_filters_test \
     CppunitTest_sc_ucalc \
+    CppunitTest_sc_subsequent_filters_test \
 ))
 
 $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
@@ -45,7 +46,6 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
     CppunitTest_sc_macros_test \
     CppunitTest_sc_namedrangeobj \
     CppunitTest_sc_spreadsheetobj \
-    CppunitTest_sc_subsequent_filters_test \
     CppunitTest_sc_tableautoformatfield \
     JunitTest_sc_complex \
     JunitTest_sc_unoapi \
diff --git a/sc/qa/unit/data/contentCSV/rangeExp_Sheet2.csv b/sc/qa/unit/data/contentCSV/rangeExp_Sheet2.csv
new file mode 100644
index 0000000..24778a9
--- /dev/null
+++ b/sc/qa/unit/data/contentCSV/rangeExp_Sheet2.csv
@@ -0,0 +1,5 @@
+6, 5
+7, 7
+0
+1, 2, 3
+4, 5, 6
diff --git a/sc/qa/unit/data/ods/named-ranges-global.ods b/sc/qa/unit/data/ods/named-ranges-global.ods
index 0c1af78..8a8bbe2 100644
Binary files a/sc/qa/unit/data/ods/named-ranges-global.ods and b/sc/qa/unit/data/ods/named-ranges-global.ods differ
diff --git a/sc/qa/unit/data/xls/named-ranges-global.xls b/sc/qa/unit/data/xls/named-ranges-global.xls
index ff2028e..993c8af 100644
Binary files a/sc/qa/unit/data/xls/named-ranges-global.xls and b/sc/qa/unit/data/xls/named-ranges-global.xls differ
diff --git a/sc/qa/unit/data/xlsx/named-ranges-global.xlsx b/sc/qa/unit/data/xlsx/named-ranges-global.xlsx
index a1ae8e7..e3fa9fb 100644
Binary files a/sc/qa/unit/data/xlsx/named-ranges-global.xlsx and b/sc/qa/unit/data/xlsx/named-ranges-global.xlsx differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 2326c73..2a0b3e2 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -31,6 +31,7 @@
 #include <sal/config.h>
 #include <unotest/filters-test.hxx>
 #include <test/bootstrapfixture.hxx>
+#include <rtl/strbuf.hxx>
 #include <osl/file.hxx>
 
 #include <sfx2/app.hxx>
@@ -42,10 +43,7 @@
 #define CALC_DEBUG_OUTPUT 0
 #define TEST_BUG_FILES 0
 
-#include "helper/debughelper.hxx"
-#include <fstream>
-#include <string>
-#include <sstream>
+#include "helper/qahelper.hxx"
 
 #include "docsh.hxx"
 #include "postit.hxx"
@@ -93,6 +91,7 @@ public:
         const rtl::OUString &rUserData, const rtl::OUString& rTypeName, sal_uLong nFormatType=0);
 
     void createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath);
+    void createCSVPath(const rtl::OUString& aFileBase, rtl::OUString& rFilePath);
 
     virtual void setUp();
     virtual void tearDown();
@@ -177,6 +176,14 @@ void ScFiltersTest::createFileURL(const rtl::OUString& aFileBase, const rtl::OUS
     rFilePath = aBuffer.makeStringAndClear();
 }
 
+void ScFiltersTest::createCSVPath(const rtl::OUString& aFileBase, rtl::OUString& rCSVPath)
+{
+    rtl::OUStringBuffer aBuffer(getSrcRootPath());
+    aBuffer.append(m_aBaseString).append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/contentCSV/")));
+    aBuffer.append(aFileBase).append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("csv")));
+    rCSVPath = aBuffer.makeStringAndClear();
+}
+
 void ScFiltersTest::testCVEs()
 {
     testDir(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Quattro Pro 6.0")),
@@ -260,8 +267,6 @@ void testRangeNameImpl(ScDocument* pDoc)
     CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 should reference Sheet1.A3", aValue == 3);
     pRangeData = pDoc->GetRangeName(1)->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL2")));
     CPPUNIT_ASSERT_MESSAGE("range name Sheet2.Local2 not found", pRangeData);
-    pDoc->GetValue(1,1,1,aValue);
-    CPPUNIT_ASSERT_MESSAGE("range name Sheet2.Local2 should reference Sheet2.A2", aValue == 7);
     //check for correct results for the remaining formulas
     pDoc->GetValue(1,1,0, aValue);
     CPPUNIT_ASSERT_MESSAGE("=global2 should be 2", aValue == 2);
@@ -269,8 +274,6 @@ void testRangeNameImpl(ScDocument* pDoc)
     CPPUNIT_ASSERT_MESSAGE("=local2 should be 4", aValue == 4);
     pDoc->GetValue(2,0,0, aValue);
     CPPUNIT_ASSERT_MESSAGE("=SUM(global3) should be 10", aValue == 10);
-    pDoc->GetValue(1,0,1,aValue);
-    CPPUNIT_ASSERT_MESSAGE("range name Sheet2.local1 should reference Sheet1.A5", aValue == 5);
 }
 
 }
@@ -293,6 +296,11 @@ void ScFiltersTest::testRangeName()
         CPPUNIT_ASSERT_MESSAGE("Failed to load named-ranges-globals.*", xDocSh.Is());
         ScDocument* pDoc = xDocSh->GetDocument();
         testRangeNameImpl(pDoc);
+
+        rtl::OUString aSheet2CSV(RTL_CONSTASCII_USTRINGPARAM("rangeExp_Sheet2."));
+        rtl::OUString aCSVPath;
+        createCSVPath( aSheet2CSV, aCSVPath );
+        testFile( aCSVPath, pDoc, 1);
         xDocSh->DoClose();
     }
 }
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
new file mode 100644
index 0000000..4c9ae91
--- /dev/null
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard at googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef SC_QA_HELPER_HXX
+#define SC_QA_HELPER_HXX
+
+#include "helper/csv_handler.hxx"
+#include "helper/debughelper.hxx"
+#include "orcus/csv_parser.hpp"
+#include <fstream>
+#include <string>
+#include <sstream>
+
+void loadFile(const rtl::OUString& aFileName, std::string& aContent)
+{
+    rtl::OString aOFileName = rtl::OUStringToOString(aFileName, RTL_TEXTENCODING_UTF8);
+    std::ifstream aFile(aOFileName.getStr());
+
+    rtl::OStringBuffer aErrorMsg("Could not open csv file: ");
+    aErrorMsg.append(aOFileName);
+    CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), aFile);
+    std::ostringstream aOStream;
+    aOStream << aFile.rdbuf();
+    aFile.close();
+    aContent = aOStream.str();
+}
+
+void testFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab, StringType aStringFormat = StringValue)
+{
+    csv_handler aHandler(pDoc, nTab, aStringFormat);
+    orcus::csv_parser_config aConfig;
+    aConfig.delimiters.push_back(',');
+    aConfig.delimiters.push_back(';');
+    aConfig.text_qualifier = '"';
+
+
+    std::string aContent;
+    loadFile(aFileName, aContent);
+    orcus::csv_parser<csv_handler> parser ( &aContent[0], aContent.size() , aHandler, aConfig);
+    try
+    {
+        parser.parse();
+    }
+    catch (const orcus::csv_parse_error& e)
+    {
+        std::cout << "reading csv content file failed: " << e.what() << std::endl;
+        rtl::OStringBuffer aErrorMsg("csv parser error: ");
+        aErrorMsg.append(e.what());
+        CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), false);
+    }
+}
+
+//need own handler because conditional formatting strings must be generated
+void testCondFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab)
+{
+    conditional_format_handler aHandler(pDoc, nTab);
+    orcus::csv_parser_config aConfig;
+    aConfig.delimiters.push_back(',');
+    aConfig.delimiters.push_back(';');
+    aConfig.text_qualifier = '"';
+    std::string aContent;
+    loadFile(aFileName, aContent);
+    orcus::csv_parser<conditional_format_handler> parser ( &aContent[0], aContent.size() , aHandler, aConfig);
+    try
+    {
+        parser.parse();
+    }
+    catch (const orcus::csv_parse_error& e)
+    {
+        std::cout << "reading csv content file failed: " << e.what() << std::endl;
+        rtl::OStringBuffer aErrorMsg("csv parser error: ");
+        aErrorMsg.append(e.what());
+        CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), false);
+    }
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 9916584..374041e 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -45,12 +45,7 @@
 #define CALC_DEBUG_OUTPUT 0
 #define TEST_BUG_FILES 0
 
-#include "helper/csv_handler.hxx"
-#include "helper/debughelper.hxx"
-#include "orcus/csv_parser.hpp"
-#include <fstream>
-#include <string>
-#include <sstream>
+#include "helper/qahelper.hxx"
 
 #define ODS_FORMAT_TYPE 50331943
 #define XLS_FORMAT_TYPE 318767171
@@ -75,70 +70,6 @@ FileFormat aFileFormats[] = {
     { "xlsx", "Calc MS Excel 2007 XML" , "MS Excel 2007 XML", XLSX_FORMAT_TYPE }
 };
 
-void loadFile(const rtl::OUString& aFileName, std::string& aContent)
-{
-    rtl::OString aOFileName = rtl::OUStringToOString(aFileName, RTL_TEXTENCODING_UTF8);
-    std::ifstream aFile(aOFileName.getStr());
-
-    rtl::OStringBuffer aErrorMsg("Could not open csv file: ");
-    aErrorMsg.append(aOFileName);
-    CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), aFile);
-    std::ostringstream aOStream;
-    aOStream << aFile.rdbuf();
-    aFile.close();
-    aContent = aOStream.str();
-}
-
-void testFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab, StringType aStringFormat = StringValue)
-{
-    csv_handler aHandler(pDoc, nTab, aStringFormat);
-    orcus::csv_parser_config aConfig;
-    aConfig.delimiters.push_back(',');
-    aConfig.delimiters.push_back(';');
-    aConfig.text_qualifier = '"';
-
-
-    std::string aContent;
-    loadFile(aFileName, aContent);
-    orcus::csv_parser<csv_handler> parser ( &aContent[0], aContent.size() , aHandler, aConfig);
-    try
-    {
-        parser.parse();
-    }
-    catch (const orcus::csv_parse_error& e)
-    {
-        std::cout << "reading csv content file failed: " << e.what() << std::endl;
-        rtl::OStringBuffer aErrorMsg("csv parser error: ");
-        aErrorMsg.append(e.what());
-        CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), false);
-    }
-}
-
-//need own handler because conditional formatting strings must be generated
-void testCondFile(rtl::OUString& aFileName, ScDocument* pDoc, SCTAB nTab)
-{
-    conditional_format_handler aHandler(pDoc, nTab);
-    orcus::csv_parser_config aConfig;
-    aConfig.delimiters.push_back(',');
-    aConfig.delimiters.push_back(';');
-    aConfig.text_qualifier = '"';
-    std::string aContent;
-    loadFile(aFileName, aContent);
-    orcus::csv_parser<conditional_format_handler> parser ( &aContent[0], aContent.size() , aHandler, aConfig);
-    try
-    {
-        parser.parse();
-    }
-    catch (const orcus::csv_parse_error& e)
-    {
-        std::cout << "reading csv content file failed: " << e.what() << std::endl;
-        rtl::OStringBuffer aErrorMsg("csv parser error: ");
-        aErrorMsg.append(e.what());
-        CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), false);
-    }
-
-}
-
 }
 
 /* Implementation of Filters test */
@@ -303,6 +234,14 @@ void ScFiltersTest::testRangeName()
         CPPUNIT_ASSERT_MESSAGE("Failed to load named-ranges-globals.*", xDocSh.Is());
         ScDocument* pDoc = xDocSh->GetDocument();
         testRangeNameImpl(pDoc);
+
+        rtl::OUString aSheet2CSV(RTL_CONSTASCII_USTRINGPARAM("rangeExp_Sheet2."));
+        rtl::OUString aCSVPath;
+        createCSVPath( aSheet2CSV, aCSVPath );
+        // fdo#44587
+        if (i != XLSX)
+            testFile( aCSVPath, pDoc, 1);
+
         xDocSh->DoClose();
     }
 }


More information about the Libreoffice-commits mailing list