chart2/source/inc/ChartTypeHelper.hxx | 3 ++ chart2/source/tools/ChartTypeHelper.cxx | 9 +++++++ chart2/source/view/charttypes/AreaChart.cxx | 3 +- chart2/source/view/charttypes/VSeriesPlotter.cxx | 5 +++- chart2/source/view/inc/VDataSeries.hxx | 1 chart2/source/view/main/ChartView.cxx | 28 +++++++++++++++-------- chart2/source/view/main/VDataSeries.cxx | 16 ++++++++----- dev/null |binary sw/qa/extras/layout/layout.cxx | 16 ------------- 9 files changed, 48 insertions(+), 33 deletions(-)
New commits: commit 2af4d304992d2a508e0d79cd855b93ca7559ebef Author: Xisco Faulí <xiscofa...@libreoffice.org> AuthorDate: Wed Mar 11 17:59:40 2020 +0100 Commit: Xisco Faulí <xiscofa...@libreoffice.org> CommitDate: Mon Mar 16 10:38:17 2020 +0100 tdf#131291: Revert "tdf#129173 tdf#129175 Fix number format of data labels" This reverts commit d979eb16b9144c7ed230d7b0a4d0c1474664d7d0. Revert it only in libreoffice-6-3 branch Change-Id: Ib73a0344932eeec792935f46e4a86041ed448287 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90284 Tested-by: Jenkins Reviewed-by: Xisco Faulí <xiscofa...@libreoffice.org> diff --git a/chart2/source/inc/ChartTypeHelper.hxx b/chart2/source/inc/ChartTypeHelper.hxx index b97a256802c3..c2945dfb9380 100644 --- a/chart2/source/inc/ChartTypeHelper.hxx +++ b/chart2/source/inc/ChartTypeHelper.hxx @@ -78,6 +78,9 @@ 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 c8efc90b3f0f..78d841755374 100644 --- a/chart2/source/tools/ChartTypeHelper.cxx +++ b/chart2/source/tools/ChartTypeHelper.cxx @@ -657,6 +657,15 @@ 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 89ba4db47b2f..2699121ed357 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -724,7 +724,6 @@ 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) { @@ -752,6 +751,8 @@ 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 16fc40428b5a..6a3b142a0ce9 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -367,7 +367,10 @@ OUString VSeriesPlotter::getLabelTextForValue( VDataSeries const & rDataSeries } else { - nNumberFormatKey = rDataSeries.detectNumberFormatKey( nPointIndex ); + if( rDataSeries.shouldLabelNumberFormatKeyBeDetectedFromYAxis() && m_aAxesNumberFormats.hasFormat(1,rDataSeries.getAttachedAxisIndex()) ) //y-axis + nNumberFormatKey = m_aAxesNumberFormats.getFormat(1,rDataSeries.getAttachedAxisIndex()); + else + 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 b65ea66f1009..4a20eb79bfea 100644 --- a/chart2/source/view/inc/VDataSeries.hxx +++ b/chart2/source/view/inc/VDataSeries.hxx @@ -102,6 +102,7 @@ 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 3192da14afe3..9d3bf0bb46e6 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -1915,16 +1915,26 @@ sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( { uno::Reference< chart2::XChartType > xChartType( DataSeriesHelper::getChartTypeOfSeries( xSeries, xDiagram ) ); - 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() ) + 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< data::XDataSequence > xValues( xLabeledSequence->getValues() ); - if( xValues.is() ) - nFormat = xValues->getNumberFormatKeyByIndex( nPointIndex ); + 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 ); + } } if (nFormat >= 0 && nOldFormat != nFormat) diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx index 003bc9cf9fe5..b9ea9266abd0 100644 --- a/chart2/source/view/main/VDataSeries.cxx +++ b/chart2/source/view/main/VDataSeries.cxx @@ -552,14 +552,10 @@ 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(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkToSource)) - { - if( !bLinkToSource && (xPointProp->getPropertyValue(aPropName) >>= nNumberFormat)) - bHasNumberFormat = true; - } + if( xPointProp.is() && (xPointProp->getPropertyValue(aPropName) >>= nNumberFormat) ) + bHasNumberFormat = true; return bHasNumberFormat; } sal_Int32 VDataSeries::getExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const @@ -588,6 +584,14 @@ 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 deleted file mode 100644 index 33e1c58788a5..000000000000 Binary files a/sw/qa/extras/layout/data/testAreaChartNumberFormat.docx and /dev/null differ diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 331f25773253..7a5238ee534a 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -2515,22 +2515,6 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf124796) "15"); } -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"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits