[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - chart2/qa oox/inc oox/source

Dennis Francis dennis.francis at collabora.co.uk
Wed Aug 9 14:04:29 UTC 2017


 chart2/qa/extras/chart2import.cxx                |   15 +++++++++++++++
 chart2/qa/extras/data/xlsx/piechart_outside.xlsx |binary
 oox/inc/drawingml/chart/seriesconverter.hxx      |    2 +-
 oox/source/drawingml/chart/seriesconverter.cxx   |   20 ++++++++++++++------
 4 files changed, 30 insertions(+), 7 deletions(-)

New commits:
commit 29594a1c9f9dd440c1012732d9e713f6e3db0838
Author: Dennis Francis <dennis.francis at collabora.co.uk>
Date:   Fri Aug 4 13:21:24 2017 +0530

    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 at libreoffice.org>
    Reviewed-by: Dennis Francis <dennis.francis at collabora.co.uk>
    (cherry picked from commit 70944a849dc59fa686e3f316a3983dbc8a47017f)
    Reviewed-on: https://gerrit.libreoffice.org/40861
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 2399cf7f5034..9ea527b1bf76 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
new file mode 100644
index 000000000000..e90eab1e904c
Binary files /dev/null and b/chart2/qa/extras/data/xlsx/piechart_outside.xlsx differ
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 );
     }
 }
 


More information about the Libreoffice-commits mailing list