summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-02-27 16:43:10 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-03-30 23:52:42 +0200
commit760ea70fca602386b2ab4fbf21cde3c0f0a27835 (patch)
tree7b3961749211095363dfacbc7df51c0f5285a542
parentb213492f09a52a283a05ebd774b804cc551070d3 (diff)
pivotcharts: set the correct number format for categories
Change-Id: I54980c3fbf37816c77fee549fe8b9728ae76ba28
-rw-r--r--sc/inc/PivotChartDataSequence.hxx6
-rw-r--r--sc/source/ui/unoobj/PivotChartDataProvider.cxx25
-rw-r--r--sc/source/ui/unoobj/PivotChartDataSequence.cxx13
3 files changed, 35 insertions, 9 deletions
diff --git a/sc/inc/PivotChartDataSequence.hxx b/sc/inc/PivotChartDataSequence.hxx
index c6655bbc3995..6f4cc7cb59b8 100644
--- a/sc/inc/PivotChartDataSequence.hxx
+++ b/sc/inc/PivotChartDataSequence.hxx
@@ -51,25 +51,29 @@ struct PivotChartItem
double m_fValue;
OUString m_aString;
bool m_bIsValue;
+ sal_uInt32 m_nNumberFormat;
explicit PivotChartItem()
: m_fValue(0.0)
, m_aString()
, m_bIsValue(true)
+ , m_nNumberFormat(0)
{
rtl::math::setNan(&m_fValue);
}
- explicit PivotChartItem(double fValue)
+ explicit PivotChartItem(double fValue, sal_uInt32 nNumberFormat)
: m_fValue(fValue)
, m_aString()
, m_bIsValue(true)
+ , m_nNumberFormat(nNumberFormat)
{}
explicit PivotChartItem(OUString const & rString)
: m_fValue(0.0)
, m_aString(rString)
, m_bIsValue(false)
+ , m_nNumberFormat(0)
{
rtl::math::setNan(&m_fValue);
}
diff --git a/sc/source/ui/unoobj/PivotChartDataProvider.cxx b/sc/source/ui/unoobj/PivotChartDataProvider.cxx
index c5b9e40a6929..520244c983c9 100644
--- a/sc/source/ui/unoobj/PivotChartDataProvider.cxx
+++ b/sc/source/ui/unoobj/PivotChartDataProvider.cxx
@@ -279,6 +279,7 @@ uno::Reference<chart2::data::XDataSource> PivotChartDataProvider::createPivotCha
sheet::DataPilotFieldOrientation_HIDDEN));
long nDimPos = ScUnoHelpFunctions::GetLongProperty(xDimProp, SC_UNO_DP_POSITION);
+ sal_Int32 nNumberFormat = ScUnoHelpFunctions::GetLongProperty(xDimProp, SC_UNO_DP_NUMBERFO);
if (eDimOrient != sheet::DataPilotFieldOrientation_HIDDEN)
{
@@ -337,17 +338,29 @@ uno::Reference<chart2::data::XDataSource> PivotChartDataProvider::createPivotCha
if (rMember.Flags & sheet::MemberResultFlags::HASMEMBER ||
rMember.Flags & sheet::MemberResultFlags::CONTINUE)
{
- OUString sValue;
- if (!(rMember.Flags & sheet::MemberResultFlags::CONTINUE))
- sValue = rMember.Caption;
+ std::unique_ptr<PivotChartItem> pItem;
+
+ double fValue = rMember.Value;
+
+ if (rtl::math::isNan(fValue))
+ {
+ OUString sValue;
+ if (!(rMember.Flags & sheet::MemberResultFlags::CONTINUE))
+ sValue = rMember.Caption;
+ pItem.reset(new PivotChartItem(sValue));
+ }
+ else
+ {
+ pItem.reset(new PivotChartItem(fValue, nNumberFormat));
+ }
if (size_t(nDimPos) >= m_aCategoriesColumnOrientation.size())
m_aCategoriesColumnOrientation.resize(nDimPos + 1);
- m_aCategoriesColumnOrientation[nDimPos].push_back(PivotChartItem(sValue));
+ m_aCategoriesColumnOrientation[nDimPos].push_back(*pItem);
if (size_t(nDimPos) >= m_aCategoriesRowOrientation[i].size())
m_aCategoriesRowOrientation[i].resize(nDimPos + 1);
- m_aCategoriesRowOrientation[i][nDimPos] = PivotChartItem(sValue);
+ m_aCategoriesRowOrientation[i][nDimPos] = *pItem;
i++;
}
@@ -393,7 +406,7 @@ uno::Reference<chart2::data::XDataSource> PivotChartDataProvider::createPivotCha
if (nIndex >= aDataRowVector.size())
aDataRowVector.resize(nIndex + 1);
- aDataRowVector[nIndex].push_back(PivotChartItem(rDataResult.Flags ? rDataResult.Value : fNan));
+ aDataRowVector[nIndex].push_back(PivotChartItem(rDataResult.Flags ? rDataResult.Value : fNan, 0));
}
nIndex++;
}
diff --git a/sc/source/ui/unoobj/PivotChartDataSequence.cxx b/sc/source/ui/unoobj/PivotChartDataSequence.cxx
index 477d1cbc0603..6d68db9b64d5 100644
--- a/sc/source/ui/unoobj/PivotChartDataSequence.cxx
+++ b/sc/source/ui/unoobj/PivotChartDataSequence.cxx
@@ -150,10 +150,19 @@ uno::Sequence<OUString> SAL_CALL PivotChartDataSequence::generateLabel(chart2::d
return aSeq;
}
-sal_Int32 SAL_CALL PivotChartDataSequence::getNumberFormatKeyByIndex(sal_Int32 /*nIndex*/)
+sal_Int32 SAL_CALL PivotChartDataSequence::getNumberFormatKeyByIndex(sal_Int32 nIndex)
{
SolarMutexGuard aGuard;
- return 0;
+ if (nIndex == -1 && !m_aData.empty())
+ {
+ return m_aData[0].m_nNumberFormat;
+ }
+ else if (nIndex < 0 && size_t(nIndex) >= m_aData.size())
+ {
+ SAL_WARN("sc.ui", "Passed invalid index to getNumberFormatKeyByIndex(). Will return default value '0'.");
+ return 0;
+ }
+ return m_aData[size_t(nIndex)].m_nNumberFormat;
}
// XCloneable ================================================================