summaryrefslogtreecommitdiff
path: root/sc/qa/unit/subsequent_filters-test.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/qa/unit/subsequent_filters-test.cxx')
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx80
1 files changed, 80 insertions, 0 deletions
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index b2133dbd591b..2206f42a087c 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -58,6 +58,7 @@
#include "stlsheet.hxx"
#include "docfunc.hxx"
#include "markdata.hxx"
+#include "colorscale.hxx"
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/drawing/XControlShape.hpp>
@@ -122,6 +123,7 @@ public:
void testDataValidityODS();
void testDataBarODS();
+ void testDataBarXLSX();
void testNewCondFormatXLSX();
//change this test file only in excel and not in calc
@@ -181,6 +183,7 @@ public:
CPPUNIT_TEST(testChartImportODS);
CPPUNIT_TEST(testDataBarODS);
+ CPPUNIT_TEST(testDataBarXLSX);
CPPUNIT_TEST(testNewCondFormatXLSX);
CPPUNIT_TEST(testNumberFormatHTML);
@@ -1724,8 +1727,85 @@ void ScFiltersTest::testRichTextContentODS()
xDocSh->DoClose();
}
+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;
+ 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);
+ CPPUNIT_ASSERT(xDocSh.Is());
+
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ testDataBar_Impl(pDoc);
+}
+
+void ScFiltersTest::testDataBarXLSX()
+{
+ ScDocShellRef xDocSh = loadDoc("databar.", XLSX);
+ CPPUNIT_ASSERT(xDocSh.Is());
+
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ testDataBar_Impl(pDoc);
}
void ScFiltersTest::testNewCondFormatXLSX()