summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/qa/extras/chart2import.cxx55
-rw-r--r--chart2/qa/extras/data/docx/tdf136650.docxbin0 -> 25543 bytes
-rw-r--r--oox/source/drawingml/chart/seriesconverter.cxx22
3 files changed, 53 insertions, 24 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 651d2b829e06..fe0a2c48231e 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -1303,23 +1303,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
--- /dev/null
+++ b/chart2/qa/extras/data/docx/tdf136650.docx
Binary files differ
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index b1b6019dfb40..007c76cf8e1f 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 bCustomLabelField, bool bMSO2007Doc )
+ DataLabelModelBase& rDataLabel, const TypeGroupConverter& rTypeGroup,
+ bool bDataSeriesLabel, bool bCustomLabelField, 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,9 +274,12 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat
try
{
bool bMSO2007Doc = getFilter().isMSO2007Document();
- PropertySet aPropSet( rxDataSeries->getDataPointByIndex( mrModel.mnIndex ) );
+ bool bHasInternalData = getChartDocument()->hasInternalDataProvider();
bool bCustomLabelField = mrModel.mxText && mrModel.mxText->mxTextBody && !mrModel.mxText->mxTextBody->getParagraphs().empty();
- lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false, bCustomLabelField, bMSO2007Doc );
+ PropertySet aPropSet( rxDataSeries->getDataPointByIndex( mrModel.mnIndex ) );
+
+ lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false, bCustomLabelField, bHasInternalData, bMSO2007Doc );
+
const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo();
bool bIsPie = rTypeInfo.meTypeCategory == TYPECATEGORY_PIE;
@@ -403,10 +410,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, false, bMSO2007Doc );
+ bool bHasInternalData = getChartDocument()->hasInternalDataProvider();
+
+ lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, true, false, bHasInternalData, bMSO2007Doc );
if (mrModel.mxShapeProp)
{