diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-01-09 00:31:06 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-01-09 06:05:39 +0100 |
commit | cedfc2a67448692eb2c0028f18f77427a49a900b (patch) | |
tree | 12dca323a8a837546c6a0538b991fff7c8d54af3 /sc | |
parent | eee86d79d7b8ac44be44807e4d5974f4a2592e32 (diff) |
add some tests related to fdo#42624
see fdo#44587 for problems with range names in matrix formulas during xlsx
import/export
Diffstat (limited to 'sc')
-rw-r--r-- | sc/Module_sc.mk | 2 | ||||
-rw-r--r-- | sc/qa/unit/data/contentCSV/rangeExp_Sheet2.csv | 5 | ||||
-rw-r--r-- | sc/qa/unit/data/ods/named-ranges-global.ods | bin | 8166 -> 8379 bytes | |||
-rw-r--r-- | sc/qa/unit/data/xls/named-ranges-global.xls | bin | 6656 -> 7168 bytes | |||
-rw-r--r-- | sc/qa/unit/data/xlsx/named-ranges-global.xlsx | bin | 5470 -> 5631 bytes | |||
-rw-r--r-- | sc/qa/unit/filters-test.cxx | 24 | ||||
-rw-r--r-- | sc/qa/unit/helper/qahelper.hxx | 105 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 79 |
8 files changed, 136 insertions, 79 deletions
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index e57a43396a55..cb3ae270b651 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 000000000000..24778a9e8e5e --- /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 Binary files differindex 0c1af78a7fae..8a8bbe29c310 100644 --- a/sc/qa/unit/data/ods/named-ranges-global.ods +++ b/sc/qa/unit/data/ods/named-ranges-global.ods diff --git a/sc/qa/unit/data/xls/named-ranges-global.xls b/sc/qa/unit/data/xls/named-ranges-global.xls Binary files differindex ff2028ecda6c..993c8afad546 100644 --- a/sc/qa/unit/data/xls/named-ranges-global.xls +++ b/sc/qa/unit/data/xls/named-ranges-global.xls diff --git a/sc/qa/unit/data/xlsx/named-ranges-global.xlsx b/sc/qa/unit/data/xlsx/named-ranges-global.xlsx Binary files differindex a1ae8e7b28f3..e3fa9fb32378 100644 --- a/sc/qa/unit/data/xlsx/named-ranges-global.xlsx +++ b/sc/qa/unit/data/xlsx/named-ranges-global.xlsx diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index 2326c7345c44..2a0b3e2edd85 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 000000000000..4c9ae91d29c7 --- /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@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 99165849009e..374041e760b4 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(); } } |