summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-03-13 22:46:18 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-03-13 22:49:20 -0400
commit90af4f50e8673975e63c928aa47fbc18eb160046 (patch)
treebc79db61720099e125162494a47fdb017d273af5 /sc
parent5063f31c248fd3c16115582a1e3aef182257a225 (diff)
fdo#58307: Write export test for this to ensure it won't go away...
Change-Id: I01ebdfab7d6098402e2911713b0eb51e2003047c
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/qa/unit/data/xlsx/sheet-tab-color.xlsxbin0 -> 8408 bytes
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx68
3 files changed, 69 insertions, 1 deletions
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<OUString> GetAllTableNames() const;
+ SC_DLLPUBLIC std::vector<OUString> 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
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/sheet-tab-color.xlsx
Binary files 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<OUString> 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