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

Dennis Francis dennis.francis at collabora.co.uk
Thu Jul 27 17:11:26 UTC 2017


 chart2/qa/extras/chart2import.cxx              |   16 ++++++++++++++++
 chart2/qa/extras/data/xls/piechart_outside.xls |binary
 sc/source/filter/excel/xichart.cxx             |   13 +++++++++----
 sc/source/filter/inc/xichart.hxx               |    4 ++--
 4 files changed, 27 insertions(+), 6 deletions(-)

New commits:
commit cb46bc6ba066c1c98d4e357f8469c5eecc171241
Author: Dennis Francis <dennis.francis at collabora.co.uk>
Date:   Tue Jul 25 13:16:28 2017 +0530

    tdf#90510 : Override default point label placement setting...
    
    with global label placement setting if available while
    importing xls chart.
    
    Added unit test in chart2import.cxx that asserts one of
    the point label setting in the bugzilla xls document.
    
    Change-Id: Id331f56c05873554b22920e02805909c50fb8619
    Reviewed-on: https://gerrit.libreoffice.org/40402
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    (cherry picked from commit 2a4d015ff896dc9e8d2219982da54c51a42482b8)
    Reviewed-on: https://gerrit.libreoffice.org/40495

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index e38612724ed0..2399cf7f5034 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -93,6 +93,8 @@ public:
     void testSecondaryAxisTitleDefaultRotationXLSX();
     void testAxisTitleRotationXLSX();
 
+    void testTdf90510(); // Pie chart label placement settings(XLS)
+
     void testInternalDataProvider();
 
     CPPUNIT_TEST_SUITE(Chart2ImportTest);
@@ -147,6 +149,7 @@ public:
     CPPUNIT_TEST(testAxisTitleDefaultRotationXLSX);
     CPPUNIT_TEST(testSecondaryAxisTitleDefaultRotationXLSX);
     CPPUNIT_TEST(testAxisTitleRotationXLSX);
+    CPPUNIT_TEST(testTdf90510);
 
     CPPUNIT_TEST(testInternalDataProvider);
 
@@ -1246,6 +1249,19 @@ void Chart2ImportTest::testInternalDataProvider() {
     CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("world")), xSequence[3]);
 }
 
+void Chart2ImportTest::testTdf90510()
+{
+    load("/chart2/qa/extras/data/xls/", "piechart_outside.xls");
+    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/xls/piechart_outside.xls b/chart2/qa/extras/data/xls/piechart_outside.xls
new file mode 100644
index 000000000000..02a4f7b85549
Binary files /dev/null and b/chart2/qa/extras/data/xls/piechart_outside.xls differ
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 49c35f7ee6a6..5a9a6ff47943 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -1071,7 +1071,7 @@ void XclImpChText::ConvertNumFmt( ScfPropertySet& rPropSet, bool bPercent ) cons
         mxSrcLink->ConvertNumFmt( rPropSet, bPercent );
 }
 
-void XclImpChText::ConvertDataLabel( ScfPropertySet& rPropSet, const XclChTypeInfo& rTypeInfo ) const
+void XclImpChText::ConvertDataLabel( ScfPropertySet& rPropSet, const XclChTypeInfo& rTypeInfo, const ScfPropertySet* pGlobalPropSet ) const
 {
     // existing CHFRLABELPROPS record wins over flags from CHTEXT
     sal_uInt16 nShowFlags = mxLabelProps ? mxLabelProps->mnFlags : maData.mnFlags;
@@ -1124,6 +1124,11 @@ void XclImpChText::ConvertDataLabel( ScfPropertySet& rPropSet, const XclChTypeIn
             case EXC_CHTEXT_POS_RIGHT:      nPlacement = RIGHT;                         break;
             case EXC_CHTEXT_POS_AUTO:       nPlacement = AVOID_OVERLAP;                 break;
         }
+        sal_Int32 nGlobalPlacement = 0;
+        if ( ( nPlacement == rTypeInfo.mnDefaultLabelPos ) && pGlobalPropSet &&
+             pGlobalPropSet->GetProperty( nGlobalPlacement, EXC_CHPROP_LABELPLACEMENT ) )
+            nPlacement = nGlobalPlacement;
+
         rPropSet.SetProperty( EXC_CHPROP_LABELPLACEMENT, nPlacement );
         // label number format (percentage format wins over value format)
         if( bShowPercent || bShowValue )
@@ -1506,7 +1511,7 @@ void XclImpChDataFormat::UpdateTrendLineFormat()
     UpdateDataLabel( nullptr );
 }
 
-void XclImpChDataFormat::Convert( ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo ) const
+void XclImpChDataFormat::Convert( ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo, const ScfPropertySet* pGlobalPropSet ) const
 {
     /*  Line and area format.
         #i71810# If the data points are filled with bitmaps, textures, or
@@ -1529,7 +1534,7 @@ void XclImpChDataFormat::Convert( ScfPropertySet& rPropSet, const XclChExtTypeIn
     if( mx3dDataFmt )
         mx3dDataFmt->Convert( rPropSet );
     if( mxLabel )
-        mxLabel->ConvertDataLabel( rPropSet, rTypeInfo );
+        mxLabel->ConvertDataLabel( rPropSet, rTypeInfo, pGlobalPropSet );
 
     // 3D settings
     rPropSet.SetProperty< sal_Int16 >( EXC_CHPROP_PERCENTDIAGONAL, 0 );
@@ -2067,7 +2072,7 @@ Reference< XDataSeries > XclImpChSeries::CreateDataSeries() const
         for( XclImpChDataFormatMap::const_iterator aIt = maPointFmts.begin(), aEnd = maPointFmts.end(); aIt != aEnd; ++aIt )
         {
             ScfPropertySet aPointProp = lclGetPointPropSet( xDataSeries, aIt->first );
-            aIt->second->Convert( aPointProp, rTypeInfo );
+            aIt->second->Convert( aPointProp, rTypeInfo, &aSeriesProp );
         }
     }
     return xDataSeries;
diff --git a/sc/source/filter/inc/xichart.hxx b/sc/source/filter/inc/xichart.hxx
index d4be01621e23..7389226e6298 100644
--- a/sc/source/filter/inc/xichart.hxx
+++ b/sc/source/filter/inc/xichart.hxx
@@ -507,7 +507,7 @@ public:
     /** Converts and writes the contained number format to the passed property set. */
     void                ConvertNumFmt( ScfPropertySet& rPropSet, bool bPercent ) const;
     /** Converts and writes all contained data to the passed data point label property set. */
-    void                ConvertDataLabel( ScfPropertySet& rPropSet, const XclChTypeInfo& rTypeInfo ) const;
+    void                ConvertDataLabel( ScfPropertySet& rPropSet, const XclChTypeInfo& rTypeInfo, const ScfPropertySet* pGlobalPropSet = nullptr ) const;
     /** Creates a title text object. */
     css::uno::Reference< css::chart2::XTitle >
                         CreateTitle() const;
@@ -665,7 +665,7 @@ public:
     const XclImpChText* GetDataLabel() const { return mxLabel.get(); }
 
     /** Converts and writes the contained data to the passed property set. */
-    void                Convert( ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo ) const;
+    void                Convert( ScfPropertySet& rPropSet, const XclChExtTypeInfo& rTypeInfo, const ScfPropertySet* pGlobalPropSet = nullptr ) const;
     /** Writes the line format only, e.g. for trend lines or error bars. */
     void                ConvertLine( ScfPropertySet& rPropSet, XclChObjectType eObjType ) const;
     /** Writes the area format only for the series or a data point. */


More information about the Libreoffice-commits mailing list