summaryrefslogtreecommitdiff
path: root/chart2/qa/extras/chart2import.cxx
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-09-11 08:56:22 +0200
committerMatúš Kukan <matus.kukan@collabora.com>2014-09-11 22:47:59 +0200
commitd22a4d945ccf1456fbdb2c39802d956afa583a2a (patch)
treed32a5c95434de267d8473f24413f80f106bc9a6a /chart2/qa/extras/chart2import.cxx
parent1387027aa9acf9e62f2d7bf50f71a5889626d194 (diff)
bnc#892610: OOXML import: Improve chart number formats.
If sourceLinked is used, do not set "PercentageNumberFormat" even if showPercent is true. The format string should be used for "NumberFormat". c8cc89ff802d86b1f3a69afe1b4835b7df7f70c7 unnecessarily disabled "LinkNumberFormatToSource". Use that for data labels but not for axis. Also, actually make attaching number format supplier work for Calc. Previously, non standard formats were added into wrong supplier, and they were thrown away later because it was attached too late. (See also ChartModel::attachNumberFormatsSupplier) Change-Id: Iaf9945abc3d82d0ac63d9f36b8888eb49f39ab57
Diffstat (limited to 'chart2/qa/extras/chart2import.cxx')
-rw-r--r--chart2/qa/extras/chart2import.cxx52
1 files changed, 52 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 73200f92c81c..302d2b5e0e70 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -53,6 +53,7 @@ public:
void testFdo78080();
void testFdo54361();
void testAutoBackgroundXLSX();
+ void testNumberFormatsXLSX();
CPPUNIT_TEST_SUITE(Chart2ImportTest);
CPPUNIT_TEST(Fdo60083);
@@ -85,6 +86,7 @@ public:
CPPUNIT_TEST(testFdo78080);
CPPUNIT_TEST(testFdo54361);
CPPUNIT_TEST(testAutoBackgroundXLSX);
+ CPPUNIT_TEST(testNumberFormatsXLSX);
CPPUNIT_TEST_SUITE_END();
private:
@@ -626,6 +628,56 @@ void Chart2ImportTest::testAutoBackgroundXLSX()
(nColor & 0x00FFFFFF) == 0x00FFFFFF); // highest 2 bytes are transparency which we ignore here.
}
+void Chart2ImportTest::testNumberFormatsXLSX()
+{
+ load("/chart2/qa/extras/data/xlsx/", "number-formats.xlsx");
+ Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+ CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
+
+ uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
+ CPPUNIT_ASSERT(xDataSeries.is());
+ uno::Reference<beans::XPropertySet> xPropertySet;
+ chart2::DataPointLabel aLabel;
+ sal_Int32 nNumberFormat;
+ bool bLinkNumberFormatToSource = false;
+ bool bSuccess = false;
+ const sal_Int32 nChartDataNumberFormat = getNumberFormat(
+ xChartDoc, "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"??_);_(@_)");
+
+ xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_QUERY_THROW);
+ xPropertySet->getPropertyValue("Label") >>= aLabel;
+ CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber);
+ CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
+ xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
+ CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat);
+ bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
+ CPPUNIT_ASSERT_EQUAL(false, bSuccess);
+ bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
+ CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource);
+
+ xPropertySet.set(xDataSeries->getDataPointByIndex(1), uno::UNO_QUERY_THROW);
+ xPropertySet->getPropertyValue("Label") >>= aLabel;
+ CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber);
+ CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumberInPercent);
+ xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
+ CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat);
+ bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
+ CPPUNIT_ASSERT_EQUAL(false, bSuccess);
+ bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
+ CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource);
+
+ xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_QUERY_THROW);
+ xPropertySet->getPropertyValue("Label") >>= aLabel;
+ CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumber);
+ CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent);
+ xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
+ CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat);
+ bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat;
+ CPPUNIT_ASSERT_EQUAL(false, bSuccess);
+ bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
+ CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();