summaryrefslogtreecommitdiff
path: root/chart2/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-07-07 19:04:41 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-07-07 19:06:22 -0400
commitdc4355e51764d18b36f748e7a743abde53cf9b9f (patch)
tree5b65807e1fbcf9ea4e4d90caeedeb82e053e9fc6 /chart2/qa
parentb8c444a46b2f41dae673c6118d84276be0e6c87d (diff)
bnc#881025: Write test for this.
Change-Id: Ifb1f83bbe5f9bb9ecb7fca26f883d1331052f10d
Diffstat (limited to 'chart2/qa')
-rw-r--r--chart2/qa/extras/chart2export.cxx28
-rw-r--r--chart2/qa/extras/chart2import.cxx61
-rw-r--r--chart2/qa/extras/charttest.hxx36
-rwxr-xr-xchart2/qa/extras/data/pptx/stacked-non-stacked-mix-y-axis.pptxbin0 -> 86216 bytes
4 files changed, 98 insertions, 27 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 68f6091aa4bb..899ff107e14b 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -719,27 +719,17 @@ void Chart2ExportTest::testAxisNumberFormatODS()
{
void check( const Reference<chart2::XChartDocument>& xChartDoc )
{
- Reference<util::XNumberFormatsSupplier> xNFS(xChartDoc, UNO_QUERY_THROW);
- Reference<util::XNumberFormats> xNumberFormats = xNFS->getNumberFormats();
- CPPUNIT_ASSERT(xNumberFormats.is());
-
Reference<chart2::XAxis> xAxisX = getAxisFromDoc(xChartDoc, 0, 0, 0);
Reference<chart2::XTitled> xTitle(xAxisX, UNO_QUERY_THROW);
OUString aTitleText = getTitleString(xTitle);
CPPUNIT_ASSERT_EQUAL(OUString("Linked To Source"), aTitleText);
- Reference<beans::XPropertySet> xPS(xAxisX, UNO_QUERY_THROW);
-
- sal_Int32 nNumFmt = -1;
- xPS->getPropertyValue("NumberFormat") >>= nNumFmt;
- CPPUNIT_ASSERT_MESSAGE("Failed to get a number format value from X axis.", nNumFmt != -1);
- Reference<beans::XPropertySet> xNumPS = xNumberFormats->getByKey(nNumFmt);
- CPPUNIT_ASSERT(xNumPS.is());
- sal_Int16 nType = util::NumberFormat::UNDEFINED;
- xNumPS->getPropertyValue("Type") >>= nType;
+ sal_Int32 nNumFmt = getNumberFormatFromAxis(xAxisX);
+ sal_Int16 nType = getNumberFormatType(xChartDoc, nNumFmt);
CPPUNIT_ASSERT_MESSAGE("X axis should be percentage format.", (nType & util::NumberFormat::PERCENT));
bool bNumFmtLinked = false;
+ Reference<beans::XPropertySet> xPS(xAxisX, uno::UNO_QUERY_THROW);
xPS->getPropertyValue("LinkNumberFormatToSource") >>= bNumFmtLinked;
CPPUNIT_ASSERT_MESSAGE("X axis should have its number format linked to source.", bNumFmtLinked);
@@ -748,18 +738,12 @@ void Chart2ExportTest::testAxisNumberFormatODS()
aTitleText = getTitleString(xTitle);
CPPUNIT_ASSERT_EQUAL(OUString("Not Linked"), aTitleText);
- xPS.set(xAxisY, UNO_QUERY_THROW);
-
- nNumFmt = -1;
- xPS->getPropertyValue("NumberFormat") >>= nNumFmt;
- CPPUNIT_ASSERT_MESSAGE("Failed to get a number format value from Y axis.", nNumFmt != -1);
- xNumPS = xNumberFormats->getByKey(nNumFmt);
- CPPUNIT_ASSERT(xNumPS.is());
- nType = util::NumberFormat::UNDEFINED;
- xNumPS->getPropertyValue("Type") >>= nType;
+ nNumFmt = getNumberFormatFromAxis(xAxisY);
+ nType = getNumberFormatType(xChartDoc, nNumFmt);
CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType & util::NumberFormat::NUMBER));
bNumFmtLinked = true;
+ xPS.set(xAxisY, uno::UNO_QUERY_THROW);
xPS->getPropertyValue("LinkNumberFormatToSource") >>= bNumFmtLinked;
CPPUNIT_ASSERT_MESSAGE("Y axis should not have its number format linked to source.", !bNumFmtLinked);
}
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index e0728edae9cc..785129118043 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -40,6 +40,7 @@ public:
* hidden columns for internal data table yet).
*/
void testPPTXHiddenDataSeries();
+ void testPPTXStackedNonStackedYAxis();
void testPPTChartSeries();
void testODPChartSeries();
void testBnc864396();
@@ -70,6 +71,7 @@ public:
CPPUNIT_TEST(testPPTChartSeries);
CPPUNIT_TEST(testPPTXChartSeries);
CPPUNIT_TEST(testPPTXHiddenDataSeries);
+ CPPUNIT_TEST(testPPTXStackedNonStackedYAxis);
CPPUNIT_TEST(testODPChartSeries);
CPPUNIT_TEST(testBnc864396);
CPPUNIT_TEST(testBnc882383);
@@ -365,6 +367,65 @@ void Chart2ImportTest::testPPTXHiddenDataSeries()
CPPUNIT_ASSERT_EQUAL(OUString("Category 4"), aCategories[3][0]);
}
+void Chart2ImportTest::testPPTXStackedNonStackedYAxis()
+{
+ load("/chart2/qa/extras/data/pptx/", "stacked-non-stacked-mix-y-axis.pptx");
+
+ // 1st chart is a normal stacked column.
+ Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW);
+ OUString aTitle = getTitleString(xTitled);
+ CPPUNIT_ASSERT_EQUAL(OUString("Stacked"), aTitle);
+
+ // Get the Y-axis.
+ Reference<chart2::XAxis> xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
+ CPPUNIT_ASSERT(xYAxis.is());
+
+ sal_Int32 nNumberFormat = getNumberFormatFromAxis(xYAxis);
+ sal_Int16 nType = getNumberFormatType(xChartDoc, nNumberFormat);
+ CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType & util::NumberFormat::NUMBER));
+ CPPUNIT_ASSERT_MESSAGE("Y axis should NOT be a percent format.", !(nType & util::NumberFormat::PERCENT));
+
+ // 2nd chart is a percent-stacked column.
+ xChartDoc.set(getChartDocFromDrawImpress(1, 0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ xTitled.set(xChartDoc, uno::UNO_QUERY_THROW);
+ aTitle = getTitleString(xTitled);
+ CPPUNIT_ASSERT_EQUAL(OUString("100% Stacked"), aTitle);
+
+ // Get the Y-axis.
+ xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
+ CPPUNIT_ASSERT(xYAxis.is());
+
+ // Get the number format of the Y-axis.
+ nNumberFormat = getNumberFormatFromAxis(xYAxis);
+ nType = getNumberFormatType(xChartDoc, nNumberFormat);
+ CPPUNIT_ASSERT_MESSAGE("Y axis should be a percent format.", (nType & util::NumberFormat::PERCENT));
+
+ // 3rd chart is a mixture of normal-stacked column with a percent-stacked
+ // area chart series. Excel in this case sets the Y-axis to be
+ // non-percent axis and we should do the same for interoperability.
+ xChartDoc.set(getChartDocFromDrawImpress(2, 0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xChartDoc.is());
+
+ xTitled.set(xChartDoc, uno::UNO_QUERY_THROW);
+ aTitle = getTitleString(xTitled);
+ CPPUNIT_ASSERT_EQUAL(OUString("Stacked column mixed with 100% stacked area"), aTitle);
+
+ // Get the Y-axis.
+ xYAxis = getAxisFromDoc(xChartDoc, 0, 1, 0);
+ CPPUNIT_ASSERT(xYAxis.is());
+
+ // Get the number format of the Y-axis.
+ nNumberFormat = getNumberFormatFromAxis(xYAxis);
+ nType = getNumberFormatType(xChartDoc, nNumberFormat);
+ CPPUNIT_ASSERT_MESSAGE("Y axis should be a normal number format.", (nType & util::NumberFormat::NUMBER));
+ CPPUNIT_ASSERT_MESSAGE("Y axis should NOT be a percent format.", !(nType & util::NumberFormat::PERCENT));
+}
+
void Chart2ImportTest::testODPChartSeries()
{
//test chart series names for odp
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index f3d199179a49..318bac2c15d4 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -482,16 +482,42 @@ uno::Sequence < OUString > ChartTest::getImpressChartColumnDescriptions( const c
return seriesList;
}
-OUString getTitleString( const Reference<chart2::XTitled>& xTitled, sal_Int32 nIndex = 0 )
+OUString getTitleString( const Reference<chart2::XTitled>& xTitled )
{
uno::Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
CPPUNIT_ASSERT(xTitle.is());
uno::Sequence<uno::Reference<chart2::XFormattedString> > aFSSeq = xTitle->getText();
- CPPUNIT_ASSERT(aFSSeq.getLength() > nIndex);
- uno::Reference<chart2::XFormattedString> xFS = aFSSeq[nIndex];
- CPPUNIT_ASSERT(xFS.is());
+ OUString aText;
+ for (sal_Int32 i = 0; i < aFSSeq.getLength(); ++i)
+ aText += aFSSeq[i]->getString();
- return xFS->getString();
+ return aText;
+}
+
+sal_Int32 getNumberFormatFromAxis( const Reference<chart2::XAxis>& xAxis )
+{
+ Reference<beans::XPropertySet> xPS(xAxis, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xPS.is());
+ sal_Int32 nNumberFormat = -1;
+ bool bSuccess = xPS->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
+ CPPUNIT_ASSERT(bSuccess);
+
+ return nNumberFormat;
+}
+
+sal_Int16 getNumberFormatType( const Reference<chart2::XChartDocument>& xChartDoc, sal_Int32 nNumberFormat )
+{
+ Reference<util::XNumberFormatsSupplier> xNFS(xChartDoc, uno::UNO_QUERY_THROW);
+ Reference<util::XNumberFormats> xNumberFormats = xNFS->getNumberFormats();
+ CPPUNIT_ASSERT(xNumberFormats.is());
+
+ Reference<beans::XPropertySet> xNumPS = xNumberFormats->getByKey(nNumberFormat);
+ CPPUNIT_ASSERT(xNumPS.is());
+
+ sal_Int16 nType = util::NumberFormat::UNDEFINED;
+ xNumPS->getPropertyValue("Type") >>= nType;
+
+ return nType;
}
#endif // INCLUDED_CHART2_QA_EXTRAS_CHARTTEST_HXX
diff --git a/chart2/qa/extras/data/pptx/stacked-non-stacked-mix-y-axis.pptx b/chart2/qa/extras/data/pptx/stacked-non-stacked-mix-y-axis.pptx
new file mode 100755
index 000000000000..27d099d40f04
--- /dev/null
+++ b/chart2/qa/extras/data/pptx/stacked-non-stacked-mix-y-axis.pptx
Binary files differ