chart2/qa/extras/chart2import.cxx | 55 +++++++++++++++++-------- chart2/qa/extras/data/docx/tdf136650.docx |binary oox/source/drawingml/chart/seriesconverter.cxx | 20 +++++---- 3 files changed, 52 insertions(+), 23 deletions(-)
New commits: commit 851b8a299f62aec885c958630a17910072c132a5 Author: Balazs Varga <balazs.varga...@gmail.com> AuthorDate: Tue Sep 15 16:50:45 2020 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Sep 29 16:10:18 2020 +0200 tdf#136650 DOCX pie chart import: fix percentage Follow-up of commit e0da00d655ecca5986eea3812a8a670c6adbc40f (tdf#132174 Chart DOCX import: fix label number format). Change-Id: Ie0b2fe6305d7696de6dddc1f17d078fc2e749e4e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102753 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103611 Tested-by: Jenkins diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 5a896f89a18d..8fd7ca7a2277 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -1299,23 +1299,46 @@ void Chart2ImportTest::testNumberFormatsXLSX() void Chart2ImportTest::testNumberFormatsDOCX() { load("/chart2/qa/extras/data/docx/", "tdf132174.docx"); - uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - css::uno::Reference<chart2::XDiagram> xDiagram(xChartDoc->getFirstDiagram(), UNO_SET_THROW); - Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); - uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries, uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT(xPropertySet.is()); + { + uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + css::uno::Reference<chart2::XDiagram> xDiagram(xChartDoc->getFirstDiagram(), UNO_SET_THROW); + Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); + uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xPropertySet.is()); + + sal_Int32 nNumberFormat; + bool bLinkNumberFormatToSource = true; + const sal_Int32 nChartDataNumberFormat = getNumberFormat(xChartDoc, "0%"); + xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat; + CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat); + xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource; + // LinkNumberFormatToSource should be set to false even if the original OOXML contain a true value, + // because the inner data table of charts have no own number format! + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !bLinkNumberFormatToSource); + } - sal_Int32 nNumberFormat; - bool bLinkNumberFormatToSource = true; - const sal_Int32 nChartDataNumberFormat = getNumberFormat(xChartDoc, "0%"); - xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat; - CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat); - xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource; - // LinkNumberFormatToSource should be set to false even if the OOXML contain a true value, - // because the inner data table of charts have no own number format! - CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !bLinkNumberFormatToSource); + load("/chart2/qa/extras/data/docx/", "tdf136650.docx"); + { + uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + css::uno::Reference<chart2::XDiagram> xDiagram(xChartDoc->getFirstDiagram(), UNO_SET_THROW); + Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(1), uno::UNO_SET_THROW); + + sal_Int32 nNumberFormat; + bool bLinkNumberFormatToSource = true; + const sal_Int32 nChartDataNumberFormat = getNumberFormat(xChartDoc, "0%"); + xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat; + CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat); + xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource; + // LinkNumberFormatToSource should be set to false even if the original OOXML file contain a true value, + // because the inner data table of charts have no own number format! + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !bLinkNumberFormatToSource); + } } void Chart2ImportTest::testPercentageNumberFormatsDOCX() diff --git a/chart2/qa/extras/data/docx/tdf136650.docx b/chart2/qa/extras/data/docx/tdf136650.docx new file mode 100644 index 000000000000..cd095ec63110 Binary files /dev/null and b/chart2/qa/extras/data/docx/tdf136650.docx differ diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index b34bc355ca4d..32ee4fbd2cd7 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -108,8 +108,8 @@ void convertTextProperty(PropertySet& rPropSet, ObjectFormatter& rFormatter, } void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatter, - const DataLabelModelBase& rDataLabel, const TypeGroupConverter& rTypeGroup, - bool bDataSeriesLabel, bool bMSO2007Doc ) + DataLabelModelBase& rDataLabel, const TypeGroupConverter& rTypeGroup, + bool bDataSeriesLabel, bool bHasInternalData, bool bMSO2007Doc ) { const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo(); @@ -134,6 +134,10 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt bool bShowCateg = !rDataLabel.mbDeleted && rDataLabel.mobShowCatName.get( !bMSO2007Doc ); bool bShowSymbol = !rDataLabel.mbDeleted && rDataLabel.mobShowLegendKey.get( !bMSO2007Doc ); + // tdf#132174, tdf#136650: the inner data table has no own cell number format. + if( bHasInternalData && bShowValue && !bShowPercent ) + rDataLabel.maNumberFormat.mbSourceLinked = false; + // type of attached label if( bHasAnyElement || rDataLabel.mbDeleted ) { @@ -270,8 +274,11 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat try { bool bMSO2007Doc = getFilter().isMSO2007Document(); + bool bHasInternalData = getChartDocument()->hasInternalDataProvider(); PropertySet aPropSet( rxDataSeries->getDataPointByIndex( mrModel.mnIndex ) ); - lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false, bMSO2007Doc ); + + lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false, bHasInternalData, bMSO2007Doc ); + const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo(); bool bIsPie = rTypeInfo.meTypeCategory == TYPECATEGORY_PIE; @@ -401,10 +408,9 @@ void DataLabelsConverter::convertFromModel( const Reference< XDataSeries >& rxDa if( !mrModel.mbDeleted ) { bool bMSO2007Doc = getFilter().isMSO2007Document(); - // tdf#132174: the inner data table has no own cell number format. - if( getChartDocument()->hasInternalDataProvider() && mrModel.mobShowVal.get(!bMSO2007Doc) ) - mrModel.maNumberFormat.mbSourceLinked = false; - lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, true, bMSO2007Doc ); + bool bHasInternalData = getChartDocument()->hasInternalDataProvider(); + + lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, true, bHasInternalData, bMSO2007Doc ); if (mrModel.mxShapeProp) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits