summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2020-01-21 14:20:38 +0100
committerXisco Faulí <xiscofauli@libreoffice.org>2020-02-26 11:59:27 +0100
commit14a4992311a7cffdf66f8c4656b0c9cb5ebd4e14 (patch)
treeb21945d084f91c4887fe45355fa0a51a701d0865
parenta563d4279e383de3f84379b6393188bcbcb64a95 (diff)
tdf#130105 Chart OOXML Import: Fix data label position
The position of datapoint labels was overwritten with the position of series placement. Do not overwrite datapoint labels placement, if we have explicit datapoint label placement. Regression from commit: 70944a849dc59fa686e3f316a3983dbc8a47017f (tdf#109858: Override default point label placement setting...) Change-Id: Ic27c8a7eb93e8c3776389d1b3d285d120568f024 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87137 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org> (cherry picked from commit a4cdd4d1266e77330d4745f369db85ee7dba265c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87594 Tested-by: Jenkins Reviewed-by: Balazs Varga <balazs.varga991@gmail.com> Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
-rw-r--r--chart2/qa/extras/chart2import.cxx32
-rw-r--r--chart2/qa/extras/data/xlsx/barchart_outend.xlsxbin0 -> 15277 bytes
-rw-r--r--oox/inc/drawingml/chart/seriesconverter.hxx2
-rw-r--r--oox/source/drawingml/chart/seriesconverter.cxx21
4 files changed, 40 insertions, 15 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 9fa051df2bc1..7b8aaed20371 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -117,6 +117,7 @@ public:
void testTdf90510(); // Pie chart label placement settings(XLS)
void testTdf109858(); // Pie chart label placement settings(XLSX)
+ void testTdf130105();
void testTdf111173();
void testTdf122226();
@@ -218,6 +219,7 @@ public:
CPPUNIT_TEST(testCombinedChartAttachedAxisXLSX);
CPPUNIT_TEST(testTdf90510);
CPPUNIT_TEST(testTdf109858);
+ CPPUNIT_TEST(testTdf130105);
CPPUNIT_TEST(testTdf111173);
CPPUNIT_TEST(testTdf122226);
@@ -1669,12 +1671,36 @@ void Chart2ImportTest::testTdf109858()
{
load("/chart2/qa/extras/data/xlsx/", "piechart_outside.xlsx");
uno::Reference< chart::XChartDocument > xChart1Doc( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW );
- Reference<beans::XPropertySet> xPropSet( xChart1Doc->getDiagram()->getDataPointProperties( 0, 0 ), uno::UNO_SET_THROW );
- uno::Any aAny = xPropSet->getPropertyValue( "LabelPlacement" );
+
+ // test data point labels position
+ Reference<beans::XPropertySet> xDataPointPropSet( xChart1Doc->getDiagram()->getDataPointProperties( 0, 0 ), uno::UNO_SET_THROW );
+ uno::Any aAny = xDataPointPropSet->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_ASSERT_EQUAL_MESSAGE( "Data point label should be placed bestFit", chart::DataLabelPlacement::AVOID_OVERLAP, nLabelPlacement );
+
+ // test data series label position
+ Reference<beans::XPropertySet> xSeriesPropSet(xChart1Doc->getDiagram()->getDataRowProperties(0), uno::UNO_SET_THROW);
+ aAny = xSeriesPropSet->getPropertyValue( "LabelPlacement" );
+ CPPUNIT_ASSERT( aAny >>= nLabelPlacement );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Data series labels should be placed outside", chart::DataLabelPlacement::OUTSIDE, nLabelPlacement );
+}
+
+void Chart2ImportTest::testTdf130105()
+{
+ load("/chart2/qa/extras/data/xlsx/", "barchart_outend.xlsx");
+ uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet(0, mxComponent);
+ CPPUNIT_ASSERT(xChartDoc.is());
+ uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
+ CPPUNIT_ASSERT(xDataSeries.is());
+
+ uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW);
+ uno::Any aAny = xPropertySet->getPropertyValue("LabelPlacement");
+ CPPUNIT_ASSERT(aAny.hasValue());
+ sal_Int32 nLabelPlacement = 0;
+ CPPUNIT_ASSERT(aAny >>= nLabelPlacement);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Data label should be placed outend", chart::DataLabelPlacement::OUTSIDE, nLabelPlacement);
}
void Chart2ImportTest::testTdf111173()
diff --git a/chart2/qa/extras/data/xlsx/barchart_outend.xlsx b/chart2/qa/extras/data/xlsx/barchart_outend.xlsx
new file mode 100644
index 000000000000..621c0c284439
--- /dev/null
+++ b/chart2/qa/extras/data/xlsx/barchart_outend.xlsx
Binary files differ
diff --git a/oox/inc/drawingml/chart/seriesconverter.hxx b/oox/inc/drawingml/chart/seriesconverter.hxx
index e381cdbc2148..6ee20c59f147 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 PropertySet& rSeriesPropSet );
+ const TypeGroupConverter& rTypeGroup );
};
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index 10edab47fd11..1a3936ecb2c9 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -134,7 +134,7 @@ void convertTextProperty(PropertySet& rPropSet, ObjectFormatter& rFormatter,
void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatter,
const DataLabelModelBase& rDataLabel, const TypeGroupConverter& rTypeGroup,
- bool bDataSeriesLabel, bool bMSO2007Doc, const PropertySet* pSeriesPropSet )
+ bool bDataSeriesLabel, bool bMSO2007Doc )
{
const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo();
@@ -193,7 +193,7 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt
if( bDataSeriesLabel || rDataLabel.monLabelPos.has() )
{
namespace csscd = ::com::sun::star::chart::DataLabelPlacement;
- sal_Int32 nPlacement = rTypeInfo.mnDefLabelPos;
+ sal_Int32 nPlacement = -1;
switch( rDataLabel.monLabelPos.get( XML_TOKEN_INVALID ) )
{
case XML_outEnd: nPlacement = csscd::OUTSIDE; break;
@@ -207,10 +207,10 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt
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;
+ if( !bDataSeriesLabel && nPlacement == -1 )
+ return;
+ else if( nPlacement == -1 )
+ nPlacement = rTypeInfo.mnDefLabelPos;
rPropSet.setProperty( PROP_LabelPlacement, nPlacement );
}
@@ -262,8 +262,7 @@ DataLabelConverter::~DataLabelConverter()
{
}
-void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDataSeries, const TypeGroupConverter& rTypeGroup,
- const PropertySet& rSeriesPropSet )
+void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDataSeries, const TypeGroupConverter& rTypeGroup )
{
if (!rxDataSeries.is())
return;
@@ -272,7 +271,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, &rSeriesPropSet );
+ lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, false, bMSO2007Doc );
const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo();
bool bIsPie = rTypeInfo.meTypeCategory == TYPECATEGORY_PIE;
if( mrModel.mxLayout && !mrModel.mxLayout->mbAutoLayout && !bIsPie )
@@ -372,7 +371,7 @@ void DataLabelsConverter::convertFromModel( const Reference< XDataSeries >& rxDa
if( !mrModel.mbDeleted )
{
bool bMSO2007Doc = getFilter().isMSO2007Document();
- lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, true, bMSO2007Doc, nullptr );
+ lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, true, bMSO2007Doc );
if (mrModel.mxShapeProp)
// Import baseline border properties for these data labels.
@@ -386,7 +385,7 @@ void DataLabelsConverter::convertFromModel( const Reference< XDataSeries >& rxDa
pointLabel->maNumberFormat = mrModel.maNumberFormat;
DataLabelConverter aLabelConv(*this, *pointLabel);
- aLabelConv.convertFromModel( rxDataSeries, rTypeGroup, aPropSet );
+ aLabelConv.convertFromModel( rxDataSeries, rTypeGroup );
}
}