Kaydet (Commit) 9263095c authored tarafından Markus Mohrhard's avatar Markus Mohrhard

add import test for data bars

Change-Id: Ida98e51a7f9970c7d4c845f5a6ac1566cbed9e3a
üst b979429f
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include "stlsheet.hxx" #include "stlsheet.hxx"
#include "docfunc.hxx" #include "docfunc.hxx"
#include "markdata.hxx" #include "markdata.hxx"
#include "colorscale.hxx"
#include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/drawing/XControlShape.hpp>
...@@ -122,6 +123,7 @@ public: ...@@ -122,6 +123,7 @@ public:
void testDataValidityODS(); void testDataValidityODS();
void testDataBarODS(); void testDataBarODS();
void testDataBarXLSX();
void testNewCondFormatXLSX(); void testNewCondFormatXLSX();
//change this test file only in excel and not in calc //change this test file only in excel and not in calc
...@@ -181,6 +183,7 @@ public: ...@@ -181,6 +183,7 @@ public:
CPPUNIT_TEST(testChartImportODS); CPPUNIT_TEST(testChartImportODS);
CPPUNIT_TEST(testDataBarODS); CPPUNIT_TEST(testDataBarODS);
CPPUNIT_TEST(testDataBarXLSX);
CPPUNIT_TEST(testNewCondFormatXLSX); CPPUNIT_TEST(testNewCondFormatXLSX);
CPPUNIT_TEST(testNumberFormatHTML); CPPUNIT_TEST(testNumberFormatHTML);
...@@ -1724,8 +1727,85 @@ void ScFiltersTest::testRichTextContentODS() ...@@ -1724,8 +1727,85 @@ void ScFiltersTest::testRichTextContentODS()
xDocSh->DoClose(); 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() 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() void ScFiltersTest::testNewCondFormatXLSX()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment