diff options
author | Dennis Francis <dennis.francis@collabora.co.uk> | 2017-08-04 13:21:24 +0530 |
---|---|---|
committer | Dennis Francis <dennis.francis@collabora.co.uk> | 2017-08-08 08:31:22 +0200 |
commit | 70944a849dc59fa686e3f316a3983dbc8a47017f (patch) | |
tree | 9a803d30955593bcd0bf8c1e7c141f1f8e058f5d | |
parent | a209172669e7a2de6065486e385e4e3007b74bd2 (diff) |
tdf#109858: Override default point label placement setting...
with series label placement setting if available while
importing xlsx chart.
Adds unit test in chart2import.cxx that asserts one of
the point label setting in the bugzilla xlsx document.
Change-Id: I8bc04fd569f94a19633666ffdc51b61ac719e8a9
Reviewed-on: https://gerrit.libreoffice.org/40860
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Dennis Francis <dennis.francis@collabora.co.uk>
-rw-r--r-- | chart2/qa/extras/chart2import.cxx | 15 | ||||
-rw-r--r-- | chart2/qa/extras/data/xlsx/piechart_outside.xlsx | bin | 0 -> 15473 bytes | |||
-rw-r--r-- | oox/inc/drawingml/chart/seriesconverter.hxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/chart/seriesconverter.cxx | 20 |
4 files changed, 30 insertions, 7 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index e81a6e4d347d..7cb69a3398ce 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -94,6 +94,7 @@ public: void testAxisTitleRotationXLSX(); void testTdf90510(); // Pie chart label placement settings(XLS) + void testTdf109858(); // Pie chart label placement settings(XLSX) void testInternalDataProvider(); @@ -150,6 +151,7 @@ public: CPPUNIT_TEST(testSecondaryAxisTitleDefaultRotationXLSX); CPPUNIT_TEST(testAxisTitleRotationXLSX); CPPUNIT_TEST(testTdf90510); + CPPUNIT_TEST(testTdf109858); CPPUNIT_TEST(testInternalDataProvider); @@ -1262,6 +1264,19 @@ void Chart2ImportTest::testTdf90510() CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data labels should be placed outside", chart::DataLabelPlacement::OUTSIDE, nLabelPlacement ); } +void Chart2ImportTest::testTdf109858() +{ + load("/chart2/qa/extras/data/xlsx/", "piechart_outside.xlsx"); + uno::Reference< chart::XChartDocument > xChart1Doc( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW ); + CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart1Doc.is() ); + Reference<beans::XPropertySet> xPropSet( xChart1Doc->getDiagram()->getDataPointProperties( 0, 0 ), uno::UNO_QUERY_THROW ); + uno::Any aAny = xPropSet->getPropertyValue( "LabelPlacement" ); + CPPUNIT_ASSERT( aAny.hasValue() ); + sal_Int32 nLabelPlacement = 0; + CPPUNIT_ASSERT( aAny >>= nLabelPlacement ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data labels should be placed outside", chart::DataLabelPlacement::OUTSIDE, nLabelPlacement ); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/xlsx/piechart_outside.xlsx b/chart2/qa/extras/data/xlsx/piechart_outside.xlsx Binary files differnew file mode 100644 index 000000000000..e90eab1e904c --- /dev/null +++ b/chart2/qa/extras/data/xlsx/piechart_outside.xlsx diff --git a/oox/inc/drawingml/chart/seriesconverter.hxx b/oox/inc/drawingml/chart/seriesconverter.hxx index 6ee20c59f147..e381cdbc2148 100644 --- a/oox/inc/drawingml/chart/seriesconverter.hxx +++ b/oox/inc/drawingml/chart/seriesconverter.hxx @@ -47,7 +47,7 @@ public: /** Converts OOXML data label settings for the passed data point. */ void convertFromModel( const css::uno::Reference< css::chart2::XDataSeries >& rxDataSeries, - const TypeGroupConverter& rTypeGroup ); + const TypeGroupConverter& rTypeGroup, const PropertySet& rSeriesPropSet ); }; diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index 7233d67f009b..a1f2cb737c7f 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -99,7 +99,8 @@ Reference< XLabeledDataSequence > lclCreateLabeledDataSequence( } void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatter, - const DataLabelModelBase& rDataLabel, const TypeGroupConverter& rTypeGroup, bool bDataSeriesLabel, bool bMSO2007Doc ) + const DataLabelModelBase& rDataLabel, const TypeGroupConverter& rTypeGroup, + bool bDataSeriesLabel, bool bMSO2007Doc, const PropertySet* pSeriesPropSet ) { const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo(); @@ -170,6 +171,12 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt case XML_r: nPlacement = csscd::RIGHT; break; case XML_bestFit: nPlacement = csscd::AVOID_OVERLAP; break; } + + sal_Int32 nGlobalPlacement = 0; + if ( !bDataSeriesLabel && nPlacement == rTypeInfo.mnDefLabelPos && pSeriesPropSet && + pSeriesPropSet->getProperty( nGlobalPlacement, PROP_LabelPlacement ) ) + nPlacement = nGlobalPlacement; + rPropSet.setProperty( PROP_LabelPlacement, nPlacement ); } } @@ -204,7 +211,8 @@ DataLabelConverter::~DataLabelConverter() { } -void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDataSeries, const TypeGroupConverter& rTypeGroup ) +void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDataSeries, const TypeGroupConverter& rTypeGroup, + const PropertySet& rSeriesPropSet ) { if (!rxDataSeries.is()) return; @@ -213,7 +221,7 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat { bool bMSO2007Doc = getFilter().isMSO2007Document(); PropertySet aPropSet( rxDataSeries->getDataPointByIndex( mrModel.mnIndex ) ); - lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false, bMSO2007Doc ); + lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false, bMSO2007Doc, &rSeriesPropSet ); const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo(); bool bIsPie = rTypeInfo.meTypeCategory == TYPECATEGORY_PIE; if( mrModel.mxLayout && !mrModel.mxLayout->mbAutoLayout && !bIsPie ) @@ -256,11 +264,11 @@ DataLabelsConverter::~DataLabelsConverter() void DataLabelsConverter::convertFromModel( const Reference< XDataSeries >& rxDataSeries, const TypeGroupConverter& rTypeGroup ) { + PropertySet aPropSet( rxDataSeries ); if( !mrModel.mbDeleted ) { bool bMSO2007Doc = getFilter().isMSO2007Document(); - PropertySet aPropSet( rxDataSeries ); - lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, true, bMSO2007Doc ); + lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, true, bMSO2007Doc, nullptr ); if (mrModel.mxShapeProp) // Import baseline border properties for these data labels. @@ -274,7 +282,7 @@ void DataLabelsConverter::convertFromModel( const Reference< XDataSeries >& rxDa (*aIt)->maNumberFormat = mrModel.maNumberFormat; DataLabelConverter aLabelConv( *this, **aIt ); - aLabelConv.convertFromModel( rxDataSeries, rTypeGroup ); + aLabelConv.convertFromModel( rxDataSeries, rTypeGroup, aPropSet ); } } |