dev/null |binary sc/qa/unit/data/ods/colorscale.ods |binary sc/qa/unit/data/xlsx/colorscale.xlsx |binary sc/qa/unit/helper/qahelper.hxx | 1 sc/qa/unit/helper/shared_test_impl.hxx | 155 +++++++++++++++++++++++++++++++++ sc/qa/unit/subsequent_export-test.cxx | 68 +++++++++++++- sc/qa/unit/subsequent_filters-test.cxx | 88 +++++------------- 7 files changed, 248 insertions(+), 64 deletions(-)
New commits: commit 317a9b2e9463635b87f1c00fc11755dc9a4129f6 Author: Markus Mohrhard <[email protected]> Date: Fri Mar 22 08:52:11 2013 +0100 add databar export test Change-Id: I0770d20911307ddd9426417314bebbe569660b14 diff --git a/sc/qa/unit/helper/shared_test_impl.hxx b/sc/qa/unit/helper/shared_test_impl.hxx index 6874a48..04f0547 100644 --- a/sc/qa/unit/helper/shared_test_impl.hxx +++ b/sc/qa/unit/helper/shared_test_impl.hxx @@ -30,6 +30,46 @@ private: const ScRange& mrRange; }; +struct DataBarData +{ + ScRange aRange; + ScColorScaleEntryType eLowerLimitType; + ScColorScaleEntryType eUpperLimitType; + databar::ScAxisPostion eAxisPosition; +}; + +DataBarData aData[] = { + { ScRange(1,2,0,1,5,0), COLORSCALE_AUTO, COLORSCALE_AUTO, databar::AUTOMATIC }, + { ScRange(3,2,0,3,5,0), COLORSCALE_MIN, COLORSCALE_MAX, databar::AUTOMATIC }, + { ScRange(5,2,0,5,5,0), COLORSCALE_PERCENTILE, COLORSCALE_PERCENT, databar::AUTOMATIC }, + { ScRange(7,2,0,7,5,0), COLORSCALE_VALUE, COLORSCALE_FORMULA, databar::AUTOMATIC }, + { ScRange(1,9,0,1,12,0), COLORSCALE_AUTO, COLORSCALE_AUTO, databar::MIDDLE } +}; + +void testDataBar_Impl(ScDocument* pDoc) +{ + ScConditionalFormatList* pList = pDoc->GetCondFormList(0); + CPPUNIT_ASSERT(pList); + + for(size_t i = 0; i < SAL_N_ELEMENTS(aData); ++i) + { + ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), + pList->end(), FindCondFormatByEnclosingRange(aData[i].aRange)); + CPPUNIT_ASSERT(itr != pList->end()); + CPPUNIT_ASSERT_EQUAL(size_t(1), itr->size()); + + const ScFormatEntry* pFormatEntry = itr->GetEntry(0); + CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), condformat::DATABAR); + const ScDataBarFormat* pDataBar = static_cast<const ScDataBarFormat*>(pFormatEntry); + CPPUNIT_ASSERT(pDataBar); + const ScDataBarFormatData* pDataBarData = pDataBar->GetDataBarData(); + CPPUNIT_ASSERT_EQUAL(aData[i].eLowerLimitType, pDataBarData->mpLowerLimit->GetType()); + CPPUNIT_ASSERT_EQUAL(aData[i].eUpperLimitType, pDataBarData->mpUpperLimit->GetType()); + + CPPUNIT_ASSERT_EQUAL(aData[i].eAxisPosition, pDataBarData->meAxisPosition); + } +} + struct ColorScale2EntryData { ScRange aRange; diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index aa0c1ed..c73ba31 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -48,6 +48,8 @@ public: void testConditionalFormatExportXLSX(); void testColorScaleExportODS(); void testColorScaleExportXLSX(); + void testDataBarExportODS(); + void testDataBarExportXLSX(); void testMiscRowHeightExport(); CPPUNIT_TEST_SUITE(ScExportTest); @@ -192,6 +194,34 @@ void ScExportTest::testColorScaleExportXLSX() testColorScale3Entry_Impl(pDoc); } +void ScExportTest::testDataBarExportODS() +{ + ScDocShellRef xShell = loadDoc("databar.", ODS); + CPPUNIT_ASSERT(xShell.Is()); + + ScDocShellRef xDocSh = saveAndReload(xShell, ODS); + CPPUNIT_ASSERT(xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + testDataBar_Impl(pDoc); +} + +void ScExportTest::testDataBarExportXLSX() +{ + ScDocShellRef xShell = loadDoc("databar.", XLSX); + CPPUNIT_ASSERT(xShell.Is()); + + ScDocShellRef xDocSh = saveAndReload(xShell, XLSX); + CPPUNIT_ASSERT(xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + testDataBar_Impl(pDoc); +} + void ScExportTest::testMiscRowHeightExport() { TestParam::RowData DfltRowData[] = diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 5a417f8..bdb09fd 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -1732,50 +1732,6 @@ void ScFiltersTest::testRichTextContentODS() xDocSh->DoClose(); } -namespace { - -struct DataBarData -{ - ScRange aRange; - ScColorScaleEntryType eLowerLimitType; - ScColorScaleEntryType eUpperLimitType; - databar::ScAxisPostion eAxisPosition; -}; - -DataBarData aData[] = { - { ScRange(1,2,0,1,5,0), COLORSCALE_AUTO, COLORSCALE_AUTO, databar::AUTOMATIC }, - { ScRange(3,2,0,3,5,0), COLORSCALE_MIN, COLORSCALE_MAX, databar::AUTOMATIC }, - { ScRange(5,2,0,5,5,0), COLORSCALE_PERCENTILE, COLORSCALE_PERCENT, databar::AUTOMATIC }, - { ScRange(7,2,0,7,5,0), COLORSCALE_VALUE, COLORSCALE_FORMULA, databar::AUTOMATIC }, - { ScRange(1,9,0,1,12,0), COLORSCALE_AUTO, COLORSCALE_AUTO, databar::MIDDLE } -}; - -void testDataBar_Impl(ScDocument* pDoc) -{ - ScConditionalFormatList* pList = pDoc->GetCondFormList(0); - CPPUNIT_ASSERT(pList); - - for(size_t i = 0; i < SAL_N_ELEMENTS(aData); ++i) - { - ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), - pList->end(), FindCondFormatByEnclosingRange(aData[i].aRange)); - CPPUNIT_ASSERT(itr != pList->end()); - CPPUNIT_ASSERT_EQUAL(size_t(1), itr->size()); - - const ScFormatEntry* pFormatEntry = itr->GetEntry(0); - CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), condformat::DATABAR); - const ScDataBarFormat* pDataBar = static_cast<const ScDataBarFormat*>(pFormatEntry); - CPPUNIT_ASSERT(pDataBar); - const ScDataBarFormatData* pDataBarData = pDataBar->GetDataBarData(); - CPPUNIT_ASSERT_EQUAL(aData[i].eLowerLimitType, pDataBarData->mpLowerLimit->GetType()); - CPPUNIT_ASSERT_EQUAL(aData[i].eUpperLimitType, pDataBarData->mpUpperLimit->GetType()); - - CPPUNIT_ASSERT_EQUAL(aData[i].eAxisPosition, pDataBarData->meAxisPosition); - } -} - -} - void ScFiltersTest::testDataBarODS() { ScDocShellRef xDocSh = loadDoc("databar.", ODS); commit e05cbcccbaafd42410f347ebc8b4222f59bf88a3 Author: Markus Mohrhard <[email protected]> Date: Fri Mar 22 08:47:36 2013 +0100 add export test for color scales Change-Id: I68ff1309c2769866c0821f7857f13103b8752cb5 diff --git a/sc/qa/unit/helper/shared_test_impl.hxx b/sc/qa/unit/helper/shared_test_impl.hxx new file mode 100644 index 0000000..6874a48 --- /dev/null +++ b/sc/qa/unit/helper/shared_test_impl.hxx @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef SC_SHARED_TEST_IMPL_HXX +#define SC_SHARED_TEST_IMPL_HXX + +#include "colorscale.hxx" +#include "conditio.hxx" + +struct FindCondFormatByEnclosingRange +{ + FindCondFormatByEnclosingRange(const ScRange& rRange): + mrRange(rRange) {} + + bool operator()(const ScConditionalFormat& rFormat) + { + if(rFormat.GetRange().Combine() == mrRange) + return true; + + return false; + } + +private: + const ScRange& mrRange; +}; + +struct ColorScale2EntryData +{ + ScRange aRange; + ScColorScaleEntryType eLowerType; + ScColorScaleEntryType eUpperType; +}; + +ColorScale2EntryData aData2Entry[] = { + { ScRange(1,2,0,1,5,0), COLORSCALE_MIN, COLORSCALE_MAX }, + { ScRange(3,2,0,3,5,0), COLORSCALE_PERCENTILE, COLORSCALE_PERCENT }, + { ScRange(5,2,0,5,5,0), COLORSCALE_VALUE, COLORSCALE_FORMULA } +}; + +void testColorScale2Entry_Impl(ScDocument* pDoc) +{ + const ScConditionalFormatList* pList = pDoc->GetCondFormList(0); + CPPUNIT_ASSERT(pList); + + for(size_t i = 0; i < SAL_N_ELEMENTS(aData2Entry); ++i) + { + ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), + pList->end(), FindCondFormatByEnclosingRange(aData2Entry[i].aRange)); + CPPUNIT_ASSERT(itr != pList->end()); + CPPUNIT_ASSERT_EQUAL(size_t(1), itr->size()); + + const ScFormatEntry* pFormatEntry = itr->GetEntry(0); + CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), condformat::COLORSCALE); + const ScColorScaleFormat* pColFormat = static_cast<const ScColorScaleFormat*>(pFormatEntry); + CPPUNIT_ASSERT_EQUAL(size_t(2), pColFormat->size()); + + ScColorScaleFormat::const_iterator format_itr = pColFormat->begin(); + CPPUNIT_ASSERT_EQUAL(aData2Entry[i].eLowerType, format_itr->GetType()); + ++format_itr; + CPPUNIT_ASSERT(format_itr != pColFormat->end()); + CPPUNIT_ASSERT_EQUAL(aData2Entry[i].eUpperType, format_itr->GetType()); + } +} + +struct ColorScale3EntryData +{ + ScRange aRange; + ScColorScaleEntryType eLowerType; + ScColorScaleEntryType eMiddleType; + ScColorScaleEntryType eUpperType; +}; + +ColorScale3EntryData aData3Entry[] = { + { ScRange(1,1,1,1,6,1), COLORSCALE_MIN, COLORSCALE_PERCENTILE, COLORSCALE_MAX }, + { ScRange(3,1,1,3,6,1), COLORSCALE_PERCENTILE, COLORSCALE_VALUE, COLORSCALE_PERCENT }, + { ScRange(5,1,1,5,6,1), COLORSCALE_VALUE, COLORSCALE_VALUE, COLORSCALE_FORMULA } +}; + +void testColorScale3Entry_Impl(ScDocument* pDoc) +{ + ScConditionalFormatList* pList = pDoc->GetCondFormList(1); + CPPUNIT_ASSERT(pList); + + for(size_t i = 0; i < SAL_N_ELEMENTS(aData3Entry); ++i) + { + ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), + pList->end(), FindCondFormatByEnclosingRange(aData3Entry[i].aRange)); + CPPUNIT_ASSERT(itr != pList->end()); + CPPUNIT_ASSERT_EQUAL(size_t(1), itr->size()); + + const ScFormatEntry* pFormatEntry = itr->GetEntry(0); + CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), condformat::COLORSCALE); + const ScColorScaleFormat* pColFormat = static_cast<const ScColorScaleFormat*>(pFormatEntry); + CPPUNIT_ASSERT_EQUAL(size_t(3), pColFormat->size()); + + ScColorScaleFormat::const_iterator format_itr = pColFormat->begin(); + CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eLowerType, format_itr->GetType()); + ++format_itr; + CPPUNIT_ASSERT(format_itr != pColFormat->end()); + CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eMiddleType, format_itr->GetType()); + ++format_itr; + CPPUNIT_ASSERT(format_itr != pColFormat->end()); + CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eUpperType, format_itr->GetType()); + } +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 343aa24..aa0c1ed 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -21,6 +21,7 @@ #define CALC_DEBUG_OUTPUT 0 #include "helper/qahelper.hxx" +#include "helper/shared_test_impl.hxx" #include "docsh.hxx" #include "postit.hxx" @@ -45,6 +46,8 @@ public: void test(); void testPasswordExport(); void testConditionalFormatExportXLSX(); + void testColorScaleExportODS(); + void testColorScaleExportXLSX(); void testMiscRowHeightExport(); CPPUNIT_TEST_SUITE(ScExportTest); @@ -53,6 +56,8 @@ public: CPPUNIT_TEST(testPasswordExport); #endif CPPUNIT_TEST(testConditionalFormatExportXLSX); + CPPUNIT_TEST(testColorScaleExportODS); + CPPUNIT_TEST(testColorScaleExportXLSX); CPPUNIT_TEST(testMiscRowHeightExport); CPPUNIT_TEST_SUITE_END(); @@ -157,6 +162,36 @@ void ScExportTest::testConditionalFormatExportXLSX() testCondFile(aCSVPath, pDoc, 0); } +void ScExportTest::testColorScaleExportODS() +{ + ScDocShellRef xShell = loadDoc("colorscale.", ODS); + CPPUNIT_ASSERT(xShell.Is()); + + ScDocShellRef xDocSh = saveAndReload(xShell, ODS); + CPPUNIT_ASSERT(xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + testColorScale2Entry_Impl(pDoc); + testColorScale3Entry_Impl(pDoc); +} + +void ScExportTest::testColorScaleExportXLSX() +{ + ScDocShellRef xShell = loadDoc("colorscale.", XLSX); + CPPUNIT_ASSERT(xShell.Is()); + + ScDocShellRef xDocSh = saveAndReload(xShell, XLSX); + CPPUNIT_ASSERT(xDocSh.Is()); + + ScDocument* pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + testColorScale2Entry_Impl(pDoc); + testColorScale3Entry_Impl(pDoc); +} + void ScExportTest::testMiscRowHeightExport() { TestParam::RowData DfltRowData[] = diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index dea8c85..5a417f8 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -75,6 +75,7 @@ #define TEST_BUG_FILES 0 #include "helper/qahelper.hxx" +#include "helper/shared_test_impl.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -1733,23 +1734,6 @@ void ScFiltersTest::testRichTextContentODS() namespace { -struct FindCondFormatByEnclosingRange -{ - FindCondFormatByEnclosingRange(const ScRange& rRange): - mrRange(rRange) {} - - bool operator()(const ScConditionalFormat& rFormat) - { - if(rFormat.GetRange().Combine() == mrRange) - return true; - - return false; - } - -private: - const ScRange& mrRange; -}; - struct DataBarData { ScRange aRange; @@ -1812,90 +1796,6 @@ void ScFiltersTest::testDataBarXLSX() testDataBar_Impl(pDoc); } -namespace { - -struct ColorScale2EntryData -{ - ScRange aRange; - ScColorScaleEntryType eLowerType; - ScColorScaleEntryType eUpperType; -}; - -ColorScale2EntryData aData2Entry[] = { - { ScRange(1,2,0,1,5,0), COLORSCALE_MIN, COLORSCALE_MAX }, - { ScRange(3,2,0,3,5,0), COLORSCALE_PERCENTILE, COLORSCALE_PERCENT }, - { ScRange(5,2,0,5,5,0), COLORSCALE_VALUE, COLORSCALE_FORMULA } -}; - -void testColorScale2Entry_Impl(ScDocument* pDoc) -{ - const ScConditionalFormatList* pList = pDoc->GetCondFormList(0); - CPPUNIT_ASSERT(pList); - - for(size_t i = 0; i < SAL_N_ELEMENTS(aData2Entry); ++i) - { - ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), - pList->end(), FindCondFormatByEnclosingRange(aData2Entry[i].aRange)); - CPPUNIT_ASSERT(itr != pList->end()); - CPPUNIT_ASSERT_EQUAL(size_t(1), itr->size()); - - const ScFormatEntry* pFormatEntry = itr->GetEntry(0); - CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), condformat::COLORSCALE); - const ScColorScaleFormat* pColFormat = static_cast<const ScColorScaleFormat*>(pFormatEntry); - CPPUNIT_ASSERT_EQUAL(size_t(2), pColFormat->size()); - - ScColorScaleFormat::const_iterator format_itr = pColFormat->begin(); - CPPUNIT_ASSERT_EQUAL(aData2Entry[i].eLowerType, format_itr->GetType()); - ++format_itr; - CPPUNIT_ASSERT(format_itr != pColFormat->end()); - CPPUNIT_ASSERT_EQUAL(aData2Entry[i].eUpperType, format_itr->GetType()); - } -} - -struct ColorScale3EntryData -{ - ScRange aRange; - ScColorScaleEntryType eLowerType; - ScColorScaleEntryType eMiddleType; - ScColorScaleEntryType eUpperType; -}; - -ColorScale3EntryData aData3Entry[] = { - { ScRange(1,1,1,1,6,1), COLORSCALE_MIN, COLORSCALE_PERCENTILE, COLORSCALE_MAX }, - { ScRange(3,1,1,3,6,1), COLORSCALE_PERCENTILE, COLORSCALE_VALUE, COLORSCALE_PERCENT }, - { ScRange(5,1,1,5,6,1), COLORSCALE_VALUE, COLORSCALE_VALUE, COLORSCALE_FORMULA } -}; - -void testColorScale3Entry_Impl(ScDocument* pDoc) -{ - ScConditionalFormatList* pList = pDoc->GetCondFormList(1); - CPPUNIT_ASSERT(pList); - - for(size_t i = 0; i < SAL_N_ELEMENTS(aData3Entry); ++i) - { - ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), - pList->end(), FindCondFormatByEnclosingRange(aData3Entry[i].aRange)); - CPPUNIT_ASSERT(itr != pList->end()); - CPPUNIT_ASSERT_EQUAL(size_t(1), itr->size()); - - const ScFormatEntry* pFormatEntry = itr->GetEntry(0); - CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), condformat::COLORSCALE); - const ScColorScaleFormat* pColFormat = static_cast<const ScColorScaleFormat*>(pFormatEntry); - CPPUNIT_ASSERT_EQUAL(size_t(3), pColFormat->size()); - - ScColorScaleFormat::const_iterator format_itr = pColFormat->begin(); - CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eLowerType, format_itr->GetType()); - ++format_itr; - CPPUNIT_ASSERT(format_itr != pColFormat->end()); - CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eMiddleType, format_itr->GetType()); - ++format_itr; - CPPUNIT_ASSERT(format_itr != pColFormat->end()); - CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eUpperType, format_itr->GetType()); - } -} - -} - void ScFiltersTest::testColorScaleODS() { ScDocShellRef xDocSh = loadDoc("colorscale.", ODS); commit 6dbea1ccccc99280b066ba0313300aa84966963b Author: Markus Mohrhard <[email protected]> Date: Fri Mar 22 08:21:03 2013 +0100 move the include statement to the correct header file Change-Id: Ibed6ec565588dedb991037297c418e1a76235dbb diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx index 8261358..58f6f4b 100644 --- a/sc/qa/unit/helper/qahelper.hxx +++ b/sc/qa/unit/helper/qahelper.hxx @@ -29,6 +29,7 @@ #ifndef SC_QA_HELPER_HXX #define SC_QA_HELPER_HXX +#include <test/bootstrapfixture.hxx> #include "helper/csv_handler.hxx" #include "helper/debughelper.hxx" #include "orcus/csv_parser.hpp" diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index d7998a7..343aa24 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -8,8 +8,6 @@ */ #include <sal/config.h> -#include <unotest/filters-test.hxx> -#include <test/bootstrapfixture.hxx> #include <rtl/strbuf.hxx> #include <osl/file.hxx> @@ -21,7 +19,6 @@ #define CALC_DEBUG_OUTPUT 0 -#define TEST_BUG_FILES 0 #include "helper/qahelper.hxx" commit ad56219feea688caa5f5f744b9f94aa39548e865 Author: Markus Mohrhard <[email protected]> Date: Fri Mar 22 08:14:17 2013 +0100 remove two unused test files Change-Id: If7d4167424f5a80733bed9f58e488e6a2a44d12d diff --git a/sc/qa/unit/data/ods/colorScale.ods b/sc/qa/unit/data/ods/colorScale.ods deleted file mode 100644 index 1e1f457..0000000 Binary files a/sc/qa/unit/data/ods/colorScale.ods and /dev/null differ diff --git a/sc/qa/unit/data/xlsx/colorScale.xlsx b/sc/qa/unit/data/xlsx/colorScale.xlsx deleted file mode 100644 index 33234ee..0000000 Binary files a/sc/qa/unit/data/xlsx/colorScale.xlsx and /dev/null differ commit f40803fea0bec4d3b8f9446ca01b9623ebf95c21 Author: Markus Mohrhard <[email protected]> Date: Fri Mar 22 08:11:55 2013 +0100 add import test for color scales Change-Id: Ie85f8efd520aaf4e10b560c637a74fbd9e25530b diff --git a/sc/qa/unit/data/ods/colorscale.ods b/sc/qa/unit/data/ods/colorscale.ods new file mode 100644 index 0000000..6ea5b83 Binary files /dev/null and b/sc/qa/unit/data/ods/colorscale.ods differ diff --git a/sc/qa/unit/data/xlsx/colorscale.xlsx b/sc/qa/unit/data/xlsx/colorscale.xlsx new file mode 100644 index 0000000..c70a207 Binary files /dev/null and b/sc/qa/unit/data/xlsx/colorscale.xlsx differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 2206f42..dea8c85 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -124,6 +124,8 @@ public: void testDataBarODS(); void testDataBarXLSX(); + void testColorScaleODS(); + void testColorScaleXLSX(); void testNewCondFormatXLSX(); //change this test file only in excel and not in calc @@ -184,6 +186,8 @@ public: CPPUNIT_TEST(testDataBarODS); CPPUNIT_TEST(testDataBarXLSX); + CPPUNIT_TEST(testColorScaleODS); + CPPUNIT_TEST(testColorScaleXLSX); CPPUNIT_TEST(testNewCondFormatXLSX); CPPUNIT_TEST(testNumberFormatHTML); @@ -1808,6 +1812,112 @@ void ScFiltersTest::testDataBarXLSX() testDataBar_Impl(pDoc); } +namespace { + +struct ColorScale2EntryData +{ + ScRange aRange; + ScColorScaleEntryType eLowerType; + ScColorScaleEntryType eUpperType; +}; + +ColorScale2EntryData aData2Entry[] = { + { ScRange(1,2,0,1,5,0), COLORSCALE_MIN, COLORSCALE_MAX }, + { ScRange(3,2,0,3,5,0), COLORSCALE_PERCENTILE, COLORSCALE_PERCENT }, + { ScRange(5,2,0,5,5,0), COLORSCALE_VALUE, COLORSCALE_FORMULA } +}; + +void testColorScale2Entry_Impl(ScDocument* pDoc) +{ + const ScConditionalFormatList* pList = pDoc->GetCondFormList(0); + CPPUNIT_ASSERT(pList); + + for(size_t i = 0; i < SAL_N_ELEMENTS(aData2Entry); ++i) + { + ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), + pList->end(), FindCondFormatByEnclosingRange(aData2Entry[i].aRange)); + CPPUNIT_ASSERT(itr != pList->end()); + CPPUNIT_ASSERT_EQUAL(size_t(1), itr->size()); + + const ScFormatEntry* pFormatEntry = itr->GetEntry(0); + CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), condformat::COLORSCALE); + const ScColorScaleFormat* pColFormat = static_cast<const ScColorScaleFormat*>(pFormatEntry); + CPPUNIT_ASSERT_EQUAL(size_t(2), pColFormat->size()); + + ScColorScaleFormat::const_iterator format_itr = pColFormat->begin(); + CPPUNIT_ASSERT_EQUAL(aData2Entry[i].eLowerType, format_itr->GetType()); + ++format_itr; + CPPUNIT_ASSERT(format_itr != pColFormat->end()); + CPPUNIT_ASSERT_EQUAL(aData2Entry[i].eUpperType, format_itr->GetType()); + } +} + +struct ColorScale3EntryData +{ + ScRange aRange; + ScColorScaleEntryType eLowerType; + ScColorScaleEntryType eMiddleType; + ScColorScaleEntryType eUpperType; +}; + +ColorScale3EntryData aData3Entry[] = { + { ScRange(1,1,1,1,6,1), COLORSCALE_MIN, COLORSCALE_PERCENTILE, COLORSCALE_MAX }, + { ScRange(3,1,1,3,6,1), COLORSCALE_PERCENTILE, COLORSCALE_VALUE, COLORSCALE_PERCENT }, + { ScRange(5,1,1,5,6,1), COLORSCALE_VALUE, COLORSCALE_VALUE, COLORSCALE_FORMULA } +}; + +void testColorScale3Entry_Impl(ScDocument* pDoc) +{ + ScConditionalFormatList* pList = pDoc->GetCondFormList(1); + CPPUNIT_ASSERT(pList); + + for(size_t i = 0; i < SAL_N_ELEMENTS(aData3Entry); ++i) + { + ScConditionalFormatList::const_iterator itr = std::find_if(pList->begin(), + pList->end(), FindCondFormatByEnclosingRange(aData3Entry[i].aRange)); + CPPUNIT_ASSERT(itr != pList->end()); + CPPUNIT_ASSERT_EQUAL(size_t(1), itr->size()); + + const ScFormatEntry* pFormatEntry = itr->GetEntry(0); + CPPUNIT_ASSERT_EQUAL(pFormatEntry->GetType(), condformat::COLORSCALE); + const ScColorScaleFormat* pColFormat = static_cast<const ScColorScaleFormat*>(pFormatEntry); + CPPUNIT_ASSERT_EQUAL(size_t(3), pColFormat->size()); + + ScColorScaleFormat::const_iterator format_itr = pColFormat->begin(); + CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eLowerType, format_itr->GetType()); + ++format_itr; + CPPUNIT_ASSERT(format_itr != pColFormat->end()); + CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eMiddleType, format_itr->GetType()); + ++format_itr; + CPPUNIT_ASSERT(format_itr != pColFormat->end()); + CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eUpperType, format_itr->GetType()); + } +} + +} + +void ScFiltersTest::testColorScaleODS() +{ + ScDocShellRef xDocSh = loadDoc("colorscale.", ODS); + CPPUNIT_ASSERT(xDocSh.Is()); + ScDocument* pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + testColorScale2Entry_Impl(pDoc); + testColorScale3Entry_Impl(pDoc); +} + +void ScFiltersTest::testColorScaleXLSX() +{ + ScDocShellRef xDocSh = loadDoc("colorscale.", XLSX); + CPPUNIT_ASSERT(xDocSh.Is()); + ScDocument* pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + testColorScale2Entry_Impl(pDoc); + testColorScale3Entry_Impl(pDoc); +} + void ScFiltersTest::testNewCondFormatXLSX() { ScDocShellRef xDocSh = ScBootstrapFixture::loadDoc( "new_cond_format_test.", XLSX ); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
