diff options
author | Daniel Bankston <daniel.e.bankston@gmail.com> | 2012-06-07 01:46:52 -0500 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-06-17 17:04:03 +0200 |
commit | 9e24ae6d3b8390c5e3576aca9490881290c01ce9 (patch) | |
tree | a12c76997b5d57f826919f0b0078be37b74216db /sc/qa | |
parent | b622286b8135a2a654ab12857cf2a619fbee39a9 (diff) |
Add ODS unittest that checks merged cells and their content on multiple sheets
Existing unit tests did not check if cells were merged correctly on more than
one sheet.
Change-Id: Ibd4d29abd7345afc95fede2a17c7e498d8cac3d9
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/data/contentCSV/merged1.csv | 16 | ||||
-rw-r--r-- | sc/qa/unit/data/contentCSV/merged2.csv | 4 | ||||
-rw-r--r-- | sc/qa/unit/data/ods/merged.ods | bin | 0 -> 7723 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 54 |
4 files changed, 74 insertions, 0 deletions
diff --git a/sc/qa/unit/data/contentCSV/merged1.csv b/sc/qa/unit/data/contentCSV/merged1.csv new file mode 100644 index 000000000000..708ab3a2a8f7 --- /dev/null +++ b/sc/qa/unit/data/contentCSV/merged1.csv @@ -0,0 +1,16 @@ +merged,,,,,,, +,,,,,,, +,,,,,,,another merged +,,,,,,, +,,,,,,, +,,,,,,, +,,,,,,, +,,,,,,, +,,,,,,, +,,,,,,, +,,,,,,, +,,,,,,, +,,,,,,, +,,,,,,, +,,,,,,, +,,,yet another merged,,,, diff --git a/sc/qa/unit/data/contentCSV/merged2.csv b/sc/qa/unit/data/contentCSV/merged2.csv new file mode 100644 index 000000000000..68eef287152c --- /dev/null +++ b/sc/qa/unit/data/contentCSV/merged2.csv @@ -0,0 +1,4 @@ +,,,, +,,,, +,,,, +,,,,merged on another sheet diff --git a/sc/qa/unit/data/ods/merged.ods b/sc/qa/unit/data/ods/merged.ods Binary files differnew file mode 100644 index 000000000000..247457132013 --- /dev/null +++ b/sc/qa/unit/data/ods/merged.ods diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 763383228503..c5fbb99daf46 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -114,6 +114,7 @@ public: void testBugFixesXLS(); void testBugFixesXLSX(); void testBrokenQuotesCSV(); + void testMergedCellsODS(); void testRepeatedColumnsODS(); //change this test file only in excel and not in calc @@ -142,6 +143,7 @@ public: CPPUNIT_TEST(testBugFixesODS); CPPUNIT_TEST(testBugFixesXLS); CPPUNIT_TEST(testBugFixesXLSX); + CPPUNIT_TEST(testMergedCellsODS); CPPUNIT_TEST(testRepeatedColumnsODS); #if 0 CPPUNIT_TEST(testBrokenQuotesCSV); @@ -676,6 +678,58 @@ void ScFiltersTest::testBugFixesXLSX() xDocSh->DoClose(); } +namespace { + +void checkMergedCells( ScDocument* pDoc, const ScAddress& rStartAddress, + const ScAddress& rExpectedEndAddress ) +{ + SCCOL nActualEndCol = rStartAddress.Col(); + SCROW nActualEndRow = rStartAddress.Row(); + pDoc->ExtendMerge( rStartAddress.Col(), rStartAddress.Row(), + nActualEndCol, nActualEndRow, rStartAddress.Tab(), false ); + rtl::OString sTab = rtl::OString::valueOf( static_cast<sal_Int32>(rStartAddress.Tab() + 1) ); + rtl::OString sExpectedEndCol = rtl::OString::valueOf( static_cast<sal_Int32>(rExpectedEndAddress.Col()) ); + rtl::OString sExpectedEndRow = rtl::OString::valueOf( static_cast<sal_Int32>(rExpectedEndAddress.Row()) ); + rtl::OString sActualEndCol = rtl::OString::valueOf( static_cast<sal_Int32>(nActualEndCol) ); + rtl::OString sActualEndRow = rtl::OString::valueOf( static_cast<sal_Int32>(nActualEndRow) ); + rtl::OString msg = "Merged cells are not correctly imported on sheet" + sTab + "\n" + + " Expected EndCol, EndRow: " + sExpectedEndCol + ", " + sExpectedEndRow + "\n" + + " Actual EndCol, EndRow: " + sActualEndCol + ", " + sActualEndRow; + CPPUNIT_ASSERT_MESSAGE( msg.pData->buffer, + nActualEndCol == rExpectedEndAddress.Col() && + nActualEndRow == rExpectedEndAddress.Row() ); +} + +} + +void ScFiltersTest::testMergedCellsODS() +{ + const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("merged.")); + ScDocShellRef xDocSh = loadDoc( aFileNameBase, 0); + + ScDocument* pDoc = xDocSh->GetDocument(); + + //check sheet1 content + rtl::OUString aCSVFileName1; + createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("merged1.")), aCSVFileName1); + testFile(aCSVFileName1, pDoc, 0); + + //check sheet1 merged cells + checkMergedCells( pDoc, ScAddress( 0, 0, 0 ), ScAddress( 5, 11, 0 ) ); + checkMergedCells( pDoc, ScAddress( 7, 2, 0 ), ScAddress( 9, 12, 0 ) ); + checkMergedCells( pDoc, ScAddress( 3, 15, 0 ), ScAddress( 7, 23, 0 ) ); + + //check sheet2 content + rtl::OUString aCSVFileName2; + createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("merged2.")), aCSVFileName2); + testFile(aCSVFileName2, pDoc, 1); + + //check sheet2 merged cells + checkMergedCells( pDoc, ScAddress( 4, 3, 1 ), ScAddress( 6, 15, 1 ) ); + + xDocSh->DoClose(); +} + void ScFiltersTest::testRepeatedColumnsODS() { const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("repeatedColumns.")); |