summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2019-12-10 12:53:08 +0100
committerLászló Németh <nemeth@numbertext.org>2019-12-16 08:58:25 +0100
commite57d90cd4e51a1353eafc87bb29cfe6076704a7c (patch)
treebdadf54a91203dcd32bd02a30d2187160c278d79
parentc5f593d68b7f6d8a2f2adc75d5bcb795822efeac (diff)
tdf#129173 tdf#129175 Fix number format of data labels
Show the real value (cell value) of datapoints instead of the recalculated value in case of Percent Stacked Area chart. Also fix: tdf#95425 Do not reset number format of data labels when open dialog of 'Format data series' and close dialog. Note: Inherits the data series/point label format from the cell format and not the axis format, if we set the 'link to source data' option to true. Change-Id: I04e9968034a67c6bc6b92941df61d945b4292d79 Reviewed-on: https://gerrit.libreoffice.org/84819 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--chart2/source/inc/ChartTypeHelper.hxx3
-rw-r--r--chart2/source/tools/ChartTypeHelper.cxx9
-rw-r--r--chart2/source/view/charttypes/AreaChart.cxx3
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx5
-rw-r--r--chart2/source/view/inc/VDataSeries.hxx1
-rw-r--r--chart2/source/view/main/ChartView.cxx28
-rw-r--r--chart2/source/view/main/VDataSeries.cxx16
-rw-r--r--sw/qa/extras/layout/data/testAreaChartNumberFormat.docxbin0 -> 26115 bytes
-rw-r--r--sw/qa/extras/layout/layout.cxx16
9 files changed, 33 insertions, 48 deletions
diff --git a/chart2/source/inc/ChartTypeHelper.hxx b/chart2/source/inc/ChartTypeHelper.hxx
index c570a15163bd..b4af58240460 100644
--- a/chart2/source/inc/ChartTypeHelper.hxx
+++ b/chart2/source/inc/ChartTypeHelper.hxx
@@ -79,9 +79,6 @@ public:
static OUString getRoleOfSequenceForDataLabelNumberFormatDetection( const css::uno::Reference<
css::chart2::XChartType >& xChartType );
- static bool shouldLabelNumberFormatKeyBeDetectedFromYAxis( const css::uno::Reference<
- css::chart2::XChartType >& xChartType );
-
static bool isSupportingOnlyDeepStackingFor3D( const css::uno::Reference< css::chart2::XChartType >& xChartType );
};
diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx
index 92974f5c5585..ebd2af04ab45 100644
--- a/chart2/source/tools/ChartTypeHelper.cxx
+++ b/chart2/source/tools/ChartTypeHelper.cxx
@@ -668,15 +668,6 @@ OUString ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( co
return aRet;
}
-bool ChartTypeHelper::shouldLabelNumberFormatKeyBeDetectedFromYAxis( const uno::Reference< XChartType >& xChartType )
-{
- bool bRet = true;
- OUString aChartTypeName = xChartType->getChartType();
- if( aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE) )
- bRet = false;
- return bRet;
-}
-
bool ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( const uno::Reference< XChartType >& xChartType )
{
bool bRet = false;
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index ca2218087a43..6d67d0b6a94c 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -722,6 +722,7 @@ void AreaChart::createShapes()
if( m_nDimension==3 && m_bArea && rXSlot.m_aSeriesVector.size()!=1 )
fLogicY = fabs( fLogicY );
+ double fLogicValueForLabeDisplay = fLogicY;
std::map< sal_Int32, double >& rLogicYSumMap = aLogicYSumMapByX[nIndex];
if (rPosHelper.isPercentY() && rLogicYSumMap[nAttachedAxisIndex] != 0.0)
{
@@ -749,8 +750,6 @@ void AreaChart::createShapes()
if( rLogicYForNextSeriesMap.find(nAttachedAxisIndex) == rLogicYForNextSeriesMap.end() )
rLogicYForNextSeriesMap[nAttachedAxisIndex] = 0.0;
- double fLogicValueForLabeDisplay = fLogicY;
-
fLogicY += rLogicYForNextSeriesMap[nAttachedAxisIndex];
rLogicYForNextSeriesMap[nAttachedAxisIndex] = fLogicY;
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 33424056d720..2a814e2fd73a 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -367,10 +367,7 @@ OUString VSeriesPlotter::getLabelTextForValue( VDataSeries const & rDataSeries
}
else
{
- if( rDataSeries.shouldLabelNumberFormatKeyBeDetectedFromYAxis() && m_aAxesNumberFormats.hasFormat(1,rDataSeries.getAttachedAxisIndex()) ) //y-axis
- nNumberFormatKey = m_aAxesNumberFormats.getFormat(1,rDataSeries.getAttachedAxisIndex());
- else
- nNumberFormatKey = rDataSeries.detectNumberFormatKey( nPointIndex );
+ nNumberFormatKey = rDataSeries.detectNumberFormatKey( nPointIndex );
}
if(nNumberFormatKey<0)
nNumberFormatKey=0;
diff --git a/chart2/source/view/inc/VDataSeries.hxx b/chart2/source/view/inc/VDataSeries.hxx
index 4a20eb79bfea..b65ea66f1009 100644
--- a/chart2/source/view/inc/VDataSeries.hxx
+++ b/chart2/source/view/inc/VDataSeries.hxx
@@ -102,7 +102,6 @@ public:
bool hasExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const;
sal_Int32 getExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const;
sal_Int32 detectNumberFormatKey( sal_Int32 nPointIndex ) const;
- bool shouldLabelNumberFormatKeyBeDetectedFromYAxis() const;
sal_Int32 getLabelPlacement(
sal_Int32 nPointIndex, const css::uno::Reference<css::chart2::XChartType>& xChartType,
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index e541d2509674..7e8f470d458b 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1897,26 +1897,16 @@ sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
{
uno::Reference< chart2::XChartType > xChartType( DataSeriesHelper::getChartTypeOfSeries( xSeries, xDiagram ) );
- bool bFormatFound = false;
- if( ChartTypeHelper::shouldLabelNumberFormatKeyBeDetectedFromYAxis( xChartType ) )
- {
- uno::Reference< beans::XPropertySet > xAttachedAxisProps( DiagramHelper::getAttachedAxis( xSeries, xDiagram ), uno::UNO_QUERY );
- if (xAttachedAxisProps.is() && (xAttachedAxisProps->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nFormat))
- bFormatFound = true;
- }
- if( !bFormatFound )
- {
- Reference< chart2::data::XDataSource > xSeriesSource( xSeries, uno::UNO_QUERY );
- OUString aRole( ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( xChartType ) );
+ Reference< chart2::data::XDataSource > xSeriesSource( xSeries, uno::UNO_QUERY );
+ OUString aRole( ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( xChartType ) );
- Reference< data::XLabeledDataSequence > xLabeledSequence(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, aRole ));
- if( xLabeledSequence.is() )
- {
- Reference< data::XDataSequence > xValues( xLabeledSequence->getValues() );
- if( xValues.is() )
- nFormat = xValues->getNumberFormatKeyByIndex( nPointIndex );
- }
+ Reference< data::XLabeledDataSequence > xLabeledSequence(
+ DataSeriesHelper::getDataSequenceByRole( xSeriesSource, aRole ));
+ if( xLabeledSequence.is() )
+ {
+ Reference< data::XDataSequence > xValues( xLabeledSequence->getValues() );
+ if( xValues.is() )
+ nFormat = xValues->getNumberFormatKeyByIndex( nPointIndex );
}
if (nFormat >= 0 && nOldFormat != nFormat)
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index 1b6f23121570..867eb56dee11 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -550,10 +550,14 @@ bool VDataSeries::hasExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPerce
{
OUString aPropName = bForPercentage ? OUString("PercentageNumberFormat") : OUString(CHART_UNONAME_NUMFMT);
bool bHasNumberFormat = false;
+ bool bLinkToSource = true;
uno::Reference< beans::XPropertySet > xPointProp( getPropertiesOfPoint( nPointIndex ));
sal_Int32 nNumberFormat = -1;
- if( xPointProp.is() && (xPointProp->getPropertyValue(aPropName) >>= nNumberFormat) )
- bHasNumberFormat = true;
+ if( xPointProp.is() && (xPointProp->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkToSource))
+ {
+ if( !bLinkToSource && (xPointProp->getPropertyValue(aPropName) >>= nNumberFormat))
+ bHasNumberFormat = true;
+ }
return bHasNumberFormat;
}
sal_Int32 VDataSeries::getExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const
@@ -582,14 +586,6 @@ void VDataSeries::setRoleOfSequenceForDataLabelNumberFormatDetection( const OUSt
else if (rRole == "values-x")
m_pValueSequenceForDataLabelNumberFormatDetection = &m_aValues_X;
}
-bool VDataSeries::shouldLabelNumberFormatKeyBeDetectedFromYAxis() const
-{
- if( m_pValueSequenceForDataLabelNumberFormatDetection == &m_aValues_Bubble_Size )
- return false;
- else if( m_pValueSequenceForDataLabelNumberFormatDetection == &m_aValues_X )
- return false;
- return true;
-}
sal_Int32 VDataSeries::detectNumberFormatKey( sal_Int32 index ) const
{
sal_Int32 nRet = 0;
diff --git a/sw/qa/extras/layout/data/testAreaChartNumberFormat.docx b/sw/qa/extras/layout/data/testAreaChartNumberFormat.docx
new file mode 100644
index 000000000000..33e1c58788a5
--- /dev/null
+++ b/sw/qa/extras/layout/data/testAreaChartNumberFormat.docx
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index eac0b40ddcd0..5274bef2b8a0 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2474,6 +2474,22 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf129054)
CPPUNIT_ASSERT_EQUAL(sal_Int32(4810), nYTop - nYBottom);
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf129173)
+{
+ SwDoc* pDoc = createDoc("testAreaChartNumberFormat.docx");
+ SwDocShell* pShell = pDoc->GetDocShell();
+
+ // Dump the rendering of the first page as an XML file.
+ std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+ MetafileXmlDump dumper;
+ xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ // Check the first data label of area chart.
+ assertXPathContent(
+ pXmlDoc, "/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/textarray[22]/text", "56");
+}
+
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf116925)
{
SwDoc* pDoc = createDoc("tdf116925.docx");