Kaydet (Commit) 92c1128f authored tarafından Tamás Zolnai's avatar Tamás Zolnai Kaydeden (comit) Tamás Zolnai

PivotMedian: ODS import / export of pivot table median

Change-Id: I3b018f5a76bb3d89bcb6cbc34e4cb2f2057248d5
üst 298ee506
......@@ -149,6 +149,7 @@ public:
void testPivotTableXLSX();
void testPivotTableTwoDataFieldsXLSX();
void testPivotTableMedian();
void testSwappedOutImageExport();
void testLinkedGraphicRT();
......@@ -238,6 +239,7 @@ public:
CPPUNIT_TEST(testSheetProtection);
CPPUNIT_TEST(testPivotTableXLSX);
CPPUNIT_TEST(testPivotTableTwoDataFieldsXLSX);
CPPUNIT_TEST(testPivotTableMedian);
#if !defined(_WIN32)
CPPUNIT_TEST(testSupBookVirtualPath);
#endif
......@@ -2936,6 +2938,41 @@ void ScExportTest::testPivotTableTwoDataFieldsXLSX()
xDocSh2->DoClose();
}
void ScExportTest::testPivotTableMedian()
{
ScDocShellRef xDocSh = loadDoc("pivot-table-median.", FORMAT_ODS);
CPPUNIT_ASSERT_MESSAGE("Failed to load test document.", xDocSh.Is());
// Export the document and import again for a check
ScDocShellRef xDocSh2 = saveAndReload(xDocSh.get(), FORMAT_ODS);
xDocSh->DoClose();
// Check sheet
ScDocument& rDoc = xDocSh2->GetDocument();
CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one sheet.", sal_Int16(1), rDoc.GetTableCount());
// Check pivot table
ScDPCollection* pDPs = rDoc.GetDPCollection();
CPPUNIT_ASSERT_MESSAGE("Failed to get a live ScDPCollection instance.", pDPs);
CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be one pivot table instance.", size_t(1), pDPs->GetCount());
const ScDPObject* pDPObj = &(*pDPs)[0];
CPPUNIT_ASSERT_MESSAGE("Failed to get pivot table object.", pDPObj);
const ScDPSaveData* pSaveData = pDPObj->GetSaveData();
CPPUNIT_ASSERT_MESSAGE("Failed to get ScDPSaveData instance.", pSaveData);
// Check the data field function.
std::vector<const ScDPSaveDimension*> aDims;
pSaveData->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_DATA, aDims);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"There should be exactly 1 data field.",
std::vector<ScDPSaveDimension const *>::size_type(1), aDims.size());
const ScDPSaveDimension* pDim = aDims.back();
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Function for the data field should be COUNT.",
sal_uInt16(sheet::GeneralFunction_MEDIAN), pDim->GetFunction());
}
void ScExportTest::testFunctionsExcel2010ODS()
{
//testFunctionsExcel2010(FORMAT_ODS);
......
......@@ -56,6 +56,8 @@ sheet::GeneralFunction ScXMLConverter::GetFunctionFromString( const OUString& sF
return sheet::GeneralFunction_PRODUCT;
if( IsXMLToken(sFunction, XML_AVERAGE ) )
return sheet::GeneralFunction_AVERAGE;
if( IsXMLToken(sFunction, XML_MEDIAN ) )
return sheet::GeneralFunction_MEDIAN;
if( IsXMLToken(sFunction, XML_MAX ) )
return sheet::GeneralFunction_MAX;
if( IsXMLToken(sFunction, XML_MIN ) )
......@@ -83,6 +85,8 @@ ScSubTotalFunc ScXMLConverter::GetSubTotalFuncFromString( const OUString& sFunct
return SUBTOTAL_FUNC_PROD;
if( IsXMLToken(sFunction, XML_AVERAGE ) )
return SUBTOTAL_FUNC_AVE;
if( IsXMLToken(sFunction, XML_MEDIAN ) )
return SUBTOTAL_FUNC_MED;
if( IsXMLToken(sFunction, XML_MAX ) )
return SUBTOTAL_FUNC_MAX;
if( IsXMLToken(sFunction, XML_MIN ) )
......@@ -107,6 +111,7 @@ void ScXMLConverter::GetStringFromFunction(
{
case sheet::GeneralFunction_AUTO: sFuncStr = GetXMLToken( XML_AUTO ); break;
case sheet::GeneralFunction_AVERAGE: sFuncStr = GetXMLToken( XML_AVERAGE ); break;
case sheet::GeneralFunction_MEDIAN: sFuncStr = GetXMLToken( XML_MEDIAN ); break;
case sheet::GeneralFunction_COUNT: sFuncStr = GetXMLToken( XML_COUNT ); break;
case sheet::GeneralFunction_COUNTNUMS: sFuncStr = GetXMLToken( XML_COUNTNUMS ); break;
case sheet::GeneralFunction_MAX: sFuncStr = GetXMLToken( XML_MAX ); break;
......@@ -120,7 +125,7 @@ void ScXMLConverter::GetStringFromFunction(
case sheet::GeneralFunction_VARP: sFuncStr = GetXMLToken( XML_VARP ); break;
default:
{
// added to avoid warnings
assert(false);
}
}
ScRangeStringConverter::AssignString( rString, sFuncStr, false );
......@@ -134,6 +139,7 @@ void ScXMLConverter::GetStringFromFunction(
switch( eFunction )
{
case SUBTOTAL_FUNC_AVE: sFuncStr = GetXMLToken( XML_AVERAGE ); break;
case SUBTOTAL_FUNC_MED: sFuncStr = GetXMLToken( XML_MEDIAN ); break;
case SUBTOTAL_FUNC_CNT: sFuncStr = GetXMLToken( XML_COUNT ); break;
case SUBTOTAL_FUNC_CNT2: sFuncStr = GetXMLToken( XML_COUNTNUMS ); break;
case SUBTOTAL_FUNC_MAX: sFuncStr = GetXMLToken( XML_MAX ); break;
......
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