diff options
-rw-r--r-- | sc/qa/unit/data/ods/database.ods | bin | 8193 -> 9155 bytes | |||
-rw-r--r-- | sc/qa/unit/data/xls/database.xls | bin | 0 -> 8704 bytes | |||
-rw-r--r-- | sc/qa/unit/data/xlsx/database.xlsx | bin | 0 -> 7823 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 71 |
4 files changed, 58 insertions, 13 deletions
diff --git a/sc/qa/unit/data/ods/database.ods b/sc/qa/unit/data/ods/database.ods Binary files differindex c8039f95ddbe..612919f21a59 100644 --- a/sc/qa/unit/data/ods/database.ods +++ b/sc/qa/unit/data/ods/database.ods diff --git a/sc/qa/unit/data/xls/database.xls b/sc/qa/unit/data/xls/database.xls Binary files differnew file mode 100644 index 000000000000..04f473c1206e --- /dev/null +++ b/sc/qa/unit/data/xls/database.xls diff --git a/sc/qa/unit/data/xlsx/database.xlsx b/sc/qa/unit/data/xlsx/database.xlsx Binary files differnew file mode 100644 index 000000000000..646b79dc1b3c --- /dev/null +++ b/sc/qa/unit/data/xlsx/database.xlsx diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 68b5bf087b7f..d293bd5b4114 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -101,6 +101,8 @@ public: void testRangeNameXLSX(); void testFunctionsODS(); void testDatabaseRangesODS(); + void testDatabaseRangesXLS(); + void testDatabaseRangesXLSX(); void testFormatsODS(); void testFormatsXLS(); void testFormatsXLSX(); @@ -127,6 +129,8 @@ public: CPPUNIT_TEST(testRangeNameXLSX); CPPUNIT_TEST(testFunctionsODS); CPPUNIT_TEST(testDatabaseRangesODS); + CPPUNIT_TEST(testDatabaseRangesXLS); + CPPUNIT_TEST(testDatabaseRangesXLSX); CPPUNIT_TEST(testFormatsODS); CPPUNIT_TEST(testFormatsXLS); CPPUNIT_TEST(testFormatsXLSX); @@ -318,13 +322,10 @@ void ScFiltersTest::testFunctionsODS() xDocSh->DoClose(); } -void ScFiltersTest::testDatabaseRangesODS() -{ - const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("database.")); - ScDocShellRef xDocSh = loadDoc(aFileNameBase, 0); - xDocSh->DoHardRecalc(true); +namespace { - ScDocument* pDoc = xDocSh->GetDocument(); +void testDBRanges_Impl(ScDocument* pDoc, sal_Int32 nFormat) +{ ScDBCollection* pDBCollection = pDoc->GetDBCollection(); CPPUNIT_ASSERT_MESSAGE("no database collection", pDBCollection); @@ -343,15 +344,59 @@ void ScFiltersTest::testDatabaseRangesODS() CPPUNIT_ASSERT_MESSAGE("Sheet1: row 4-5 should be hidden", bHidden && nRow1 == 4 && nRow2 == 5); bHidden = pDoc->RowHidden(6, 0, &nRow1, &nRow2); CPPUNIT_ASSERT_MESSAGE("Sheet1: row 6-end should be visible", !bHidden && nRow1 == 6 && nRow2 == MAXROW); + if(nFormat == ODS) //excel doesn't support named db ranges + { + double aValue; + pDoc->GetValue(0,10,1, aValue); + rtl::OUString aString; + CPPUNIT_ASSERT_MESSAGE("Sheet2: A11: formula result is incorrect", aValue == 4); + pDoc->GetValue(1, 10, 1, aValue); + CPPUNIT_ASSERT_MESSAGE("Sheet2: B11: formula result is incorrect", aValue == 2); + } double aValue; - pDoc->GetValue(0,10,1, aValue); + pDoc->GetValue(3,10,1, aValue); rtl::OUString aString; - pDoc->GetFormula(0,10,1,aString); - rtl::OString aOString; - aOString = rtl::OUStringToOString(aString, RTL_TEXTENCODING_UTF8); - CPPUNIT_ASSERT_MESSAGE("Sheet2: A11: formula result is incorrect", aValue == 4); - pDoc->GetValue(1, 10, 1, aValue); - CPPUNIT_ASSERT_MESSAGE("Sheet2: B11: formula result is incorrect", aValue == 2); + CPPUNIT_ASSERT_MESSAGE("Sheet2: D11: formula result is incorrect", aValue == 4); + pDoc->GetValue(4, 10, 1, aValue); + CPPUNIT_ASSERT_MESSAGE("Sheet2: E11: formula result is incorrect", aValue == 2); + +} + +} + +void ScFiltersTest::testDatabaseRangesODS() +{ + const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("database.")); + ScDocShellRef xDocSh = loadDoc(aFileNameBase, 0); + xDocSh->DoHardRecalc(true); + + ScDocument* pDoc = xDocSh->GetDocument(); + + testDBRanges_Impl(pDoc, ODS); + xDocSh->DoClose(); +} + +void ScFiltersTest::testDatabaseRangesXLS() +{ + const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("database.")); + ScDocShellRef xDocSh = loadDoc(aFileNameBase, 1); + xDocSh->DoHardRecalc(true); + + ScDocument* pDoc = xDocSh->GetDocument(); + + testDBRanges_Impl(pDoc, XLS); + xDocSh->DoClose(); +} + +void ScFiltersTest::testDatabaseRangesXLSX() +{ + const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("database.")); + ScDocShellRef xDocSh = loadDoc(aFileNameBase, 2); + xDocSh->DoHardRecalc(true); + + ScDocument* pDoc = xDocSh->GetDocument(); + + testDBRanges_Impl(pDoc, XLSX); xDocSh->DoClose(); } |