From 90af4f50e8673975e63c928aa47fbc18eb160046 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 13 Mar 2014 22:46:18 -0400 Subject: fdo#58307: Write export test for this to ensure it won't go away... Change-Id: I01ebdfab7d6098402e2911713b0eb51e2003047c --- sc/inc/document.hxx | 2 +- sc/qa/unit/data/xlsx/sheet-tab-color.xlsx | Bin 0 -> 8408 bytes sc/qa/unit/subsequent_export-test.cxx | 68 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 sc/qa/unit/data/xlsx/sheet-tab-color.xlsx (limited to 'sc') diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index d8b4d7cdf7c6..a6af9fb6295f 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -569,7 +569,7 @@ public: SC_DLLPUBLIC bool SetCodeName( SCTAB nTab, const OUString& rName ); SC_DLLPUBLIC bool GetTable( const OUString& rName, SCTAB& rTab ) const; - std::vector GetAllTableNames() const; + SC_DLLPUBLIC std::vector GetAllTableNames() const; OUString GetCopyTabName(SCTAB nTab) const; diff --git a/sc/qa/unit/data/xlsx/sheet-tab-color.xlsx b/sc/qa/unit/data/xlsx/sheet-tab-color.xlsx new file mode 100644 index 000000000000..896bc3b00782 Binary files /dev/null and b/sc/qa/unit/data/xlsx/sheet-tab-color.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 90da87cb7602..defacfbb0cff 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -87,6 +87,8 @@ public: void testCellBordersXLS(); void testCellBordersXLSX(); + void testSheetTabColorsXLSX(); + void testSharedFormulaExportXLS(); void testSharedFormulaExportXLSX(); void testSharedFormulaStringResultExportXLSX(); @@ -114,6 +116,7 @@ public: CPPUNIT_TEST(testSheetProtectionXLSX); CPPUNIT_TEST(testCellBordersXLS); CPPUNIT_TEST(testCellBordersXLSX); + CPPUNIT_TEST(testSheetTabColorsXLSX); CPPUNIT_TEST(testSharedFormulaExportXLS); CPPUNIT_TEST(testSharedFormulaExportXLSX); CPPUNIT_TEST(testSharedFormulaStringResultExportXLSX); @@ -1089,6 +1092,71 @@ void ScExportTest::testCellBordersXLSX() testExcelCellBorders(XLSX); } +void ScExportTest::testSheetTabColorsXLSX() +{ + struct + { + bool checkContent( ScDocument* pDoc ) + { + + std::vector aTabNames = pDoc->GetAllTableNames(); + + // green, red, blue, yellow (from left to right). + if (aTabNames.size() != 4) + { + cerr << "There should be exactly 4 sheets." << endl; + return false; + } + + const char* pNames[] = { "Green", "Red", "Blue", "Yellow" }; + for (size_t i = 0, n = SAL_N_ELEMENTS(pNames); i < n; ++i) + { + OUString aExpected = OUString::createFromAscii(pNames[i]); + if (aExpected != aTabNames[i]) + { + cerr << "incorrect sheet name: expected='" << aExpected <<"', actual='" << aTabNames[i] << "'" << endl; + return false; + } + } + + const ColorData aXclColors[] = + { + 0x0000B050, // green + 0x00FF0000, // red + 0x000070C0, // blue + 0x00FFFF00, // yellow + }; + + for (size_t i = 0, n = SAL_N_ELEMENTS(aXclColors); i < n; ++i) + { + if (aXclColors[i] != pDoc->GetTabBgColor(i).GetColor()) + { + cerr << "wrong sheet color for sheet " << i << endl; + return false; + } + } + + return true; + } + + } aTest; + + ScDocShellRef xDocSh = loadDoc("sheet-tab-color.", XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load file.", xDocSh.Is()); + ScDocument* pDoc = xDocSh->GetDocument(); + bool bRes = aTest.checkContent(pDoc); + CPPUNIT_ASSERT_MESSAGE("Failed on the initial content check.", bRes); + + ScDocShellRef xDocSh2 = saveAndReload(xDocSh, XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to reload file.", xDocSh2.Is()); + xDocSh->DoClose(); + pDoc = xDocSh2->GetDocument(); + bRes = aTest.checkContent(pDoc); + CPPUNIT_ASSERT_MESSAGE("Failed on the content check after reload.", bRes); + + xDocSh2->DoClose(); +} + void ScExportTest::testSharedFormulaExportXLS() { struct -- cgit v1.2.3