[Libreoffice-commits] core.git: chart2/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 24 15:11:23 UTC 2020


 chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx          |    6 +
 chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx          |    2 
 chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx |    2 
 chart2/source/controller/dialogs/DataBrowserModel.cxx                    |    2 
 chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx       |    8 --
 chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx      |    2 
 chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx       |    8 --
 chart2/source/controller/main/ChartController_Properties.cxx             |    9 ++
 chart2/source/inc/chartview/ExplicitValueProvider.hxx                    |    5 +
 chart2/source/view/main/ChartView.cxx                                    |   32 ++++++++--
 10 files changed, 51 insertions(+), 25 deletions(-)

New commits:
commit 7de7512718ac192fcad441d5500d056316f72d72
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Mar 24 15:30:58 2020 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Mar 24 16:10:42 2020 +0100

    Revert "tdf#95425 follow-up: enable "Source format" checkbox of data label"
    
    This reverts commit 9bf40c635c41c6b3b072b7c61fea67a20ba4342b.
    
    Reason for revert: This apparently causes builds to hang.  Witness all the six failed Jenkins builds for <https://gerrit.libreoffice.org/c/core/+/90079> as well as <https://ci.libreoffice.org/job/lo_tb_master_linux_dbg/29218/> and following.
    
    Change-Id: I441e04cba0f1234cdc200a9aa714b166bda4ab89
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90950
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Tested-by: Jenkins

diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
index 45b7f401550d..52dd240a1587 100644
--- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
+++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
@@ -158,7 +158,11 @@ sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForSeries(
             const Reference< chart2::XDataSeries >& xSeries )
 {
     return ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
-        uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ));
+        uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ),
+        xSeries,
+        -1 /*-1 for whole series*/,
+        ChartModelHelper::findDiagram( m_xChartModel )
+        );
 }
 
 awt::Size Chart2ModelContact::GetPageSize() const
diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx
index 2c7b2b050738..c9651cbf3d34 100644
--- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx
+++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx
@@ -78,7 +78,7 @@ public:
     sal_Int32 getExplicitNumberFormatKeyForAxis(
             const css::uno::Reference< css::chart2::XAxis >& xAxis );
 
-    static sal_Int32 getExplicitNumberFormatKeyForSeries(
+    sal_Int32 getExplicitNumberFormatKeyForSeries(
             const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
 
     /** Returns the size of the page in logic coordinates.  This value is used
diff --git a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx
index 1ce277c321ba..a2da1089f555 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx
@@ -64,7 +64,7 @@ Any WrappedNumberFormatProperty::getPropertyValue( const Reference< beans::XProp
         sal_Int32 nKey = 0;
         Reference< chart2::XDataSeries > xSeries( xInnerPropertySet, uno::UNO_QUERY );
         if( xSeries.is() )
-            nKey = Chart2ModelContact::getExplicitNumberFormatKeyForSeries( xSeries );
+            nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForSeries( xSeries );
         else
         {
             Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY );
diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx
index 0fad7561bdc1..e353899eb81e 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.cxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx
@@ -864,7 +864,7 @@ void DataBrowserModel::updateFromModel()
                             if( aRole == aRoleForDataLabelNumberFormat )
                             {
                                 nSequenceNumberFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
-                                    Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ));
+                                    Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ), xSeries, -1, xDiagram );
                             }
                             else if( aRole == "values-x" )
                                 nSequenceNumberFormatKey = nXAxisNumberFormat;
diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
index 099b74060f07..aae5266a59b7 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -636,17 +636,13 @@ void DataPointItemConverter::FillSpecialItem(
 
         case SID_ATTR_NUMBERFORMAT_SOURCE:
         {
-            bool bUseSourceFormat = false;
-            GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
-            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue() && !bUseSourceFormat;
+            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue();
             rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
         }
         break;
         case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
         {
-            bool bUseSourceFormat = false;
-            GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
-            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ).hasValue() && !bUseSourceFormat;
+            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ).hasValue();
             rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
         }
         break;
diff --git a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
index eacc13f47b62..c48b8b2b460a 100644
--- a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
+++ b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
@@ -112,7 +112,7 @@ AllDataLabelItemConverter::AllDataLabelItemConverter(
         uno::Reference< beans::XPropertySet > xObjectProperties(series, uno::UNO_QUERY);
         uno::Reference< uno::XComponentContext> xContext;//do not need Context for label properties
 
-        sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(xObjectProperties);
+        sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, series, -1/*nPointIndex*/, ChartModelHelper::findDiagram( xChartModel ) );
         sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
                 xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY));
 
diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
index b3b53b067924..95b38ad02402 100644
--- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
@@ -548,17 +548,13 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r
         break;
         case SID_ATTR_NUMBERFORMAT_SOURCE:
         {
-            bool bUseSourceFormat = false;
-            GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
-            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue() && !bUseSourceFormat;
+            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue();
             rOutItemSet.Put(SfxBoolItem(nWhichId, !bNumberFormatIsSet));
         }
         break;
         case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
         {
-            bool bUseSourceFormat = false;
-            GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
-            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue("PercentageNumberFormat").hasValue() && !bUseSourceFormat;
+            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue("PercentageNumberFormat").hasValue();
             rOutItemSet.Put(SfxBoolItem(nWhichId, !bNumberFormatIsSet));
         }
         break;
diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx
index 348516f26abf..6ee1eb39c7c1 100644
--- a/chart2/source/controller/main/ChartController_Properties.cxx
+++ b/chart2/source/controller/main/ChartController_Properties.cxx
@@ -180,7 +180,12 @@ wrapper::ItemConverter* createItemConverter(
 
                 bool bDataSeries = eObjectType == OBJECTTYPE_DATA_LABELS;
 
-                sal_Int32 nNumberFormat = ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(xObjectProperties);
+                sal_Int32 nPointIndex = -1; /*-1 for whole series*/
+                if (!bDataSeries)
+                    nPointIndex = aParticleID.toInt32();
+
+                sal_Int32 nNumberFormat = ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
+                    xObjectProperties, xSeries, nPointIndex, xDiagram);
                 sal_Int32 nPercentNumberFormat = ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
                     xObjectProperties,uno::Reference<util::XNumberFormatsSupplier>(xChartModel, uno::UNO_QUERY));
 
@@ -233,7 +238,7 @@ wrapper::ItemConverter* createItemConverter(
                         }
                     }
                 }
-                sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(xObjectProperties);
+                sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, xSeries, nPointIndex, xDiagram );
                 sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
                         xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY));
 
diff --git a/chart2/source/inc/chartview/ExplicitValueProvider.hxx b/chart2/source/inc/chartview/ExplicitValueProvider.hxx
index b300339a21b1..7fec9b254625 100644
--- a/chart2/source/inc/chartview/ExplicitValueProvider.hxx
+++ b/chart2/source/inc/chartview/ExplicitValueProvider.hxx
@@ -82,7 +82,10 @@ public:
             , const css::uno::Reference< css::chart2::XChartDocument>& xChartDoc);
 
     static sal_Int32 getExplicitNumberFormatKeyForDataLabel(
-            const css::uno::Reference< css::beans::XPropertySet >& xSeriesOrPointProp );
+            const css::uno::Reference< css::beans::XPropertySet >& xSeriesOrPointProp
+            , const css::uno::Reference< css::chart2::XDataSeries >& xSeries
+            , sal_Int32 nPointIndex /*-1 for whole series*/
+            , const css::uno::Reference< css::chart2::XDiagram >& xDiagram );
 
     static sal_Int32 getExplicitPercentageNumberFormatKeyForDataLabel(
             const css::uno::Reference< css::beans::XPropertySet >& xSeriesOrPointProp
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index f84446fbe47d..bcda427a6bdb 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1874,7 +1874,12 @@ sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
         , true /*bSearchForParallelAxisIfNothingIsFound*/ );
 }
 
-sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp )
+sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
+        const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp,
+        const uno::Reference< XDataSeries >& xSeries,
+        sal_Int32 nPointIndex /*-1 for whole series*/,
+        const uno::Reference< XDiagram >& xDiagram
+        )
 {
     sal_Int32 nFormat=0;
     if( !xSeriesOrPointProp.is() )
@@ -1887,10 +1892,27 @@ sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( const u
     }
     catch ( const beans::UnknownPropertyException& ) {}
 
-    if( bLinkToSource )
-        xSeriesOrPointProp->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any(nFormat));
-    else
-        xSeriesOrPointProp->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nFormat;
+    xSeriesOrPointProp->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nFormat;
+    sal_Int32 nOldFormat = nFormat;
+    if (bLinkToSource)
+    {
+        uno::Reference< chart2::XChartType > xChartType( DataSeriesHelper::getChartTypeOfSeries( xSeries, xDiagram ) );
+
+        Reference< chart2::data::XDataSource > xSeriesSource( xSeries, uno::UNO_QUERY );
+        OUString aRole( ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( xChartType ) );
+
+        Reference< data::XLabeledDataSequence > xLabeledSequence(
+            DataSeriesHelper::getDataSequenceByRole( xSeriesSource, aRole ));
+        if( xLabeledSequence.is() )
+        {
+            Reference< data::XDataSequence > xValues( xLabeledSequence->getValues() );
+            if( xValues.is() )
+                nFormat = xValues->getNumberFormatKeyByIndex( nPointIndex );
+        }
+
+        if (nFormat >= 0 && nOldFormat != nFormat)
+            xSeriesOrPointProp->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any(nFormat));
+    }
 
     if(nFormat<0)
         nFormat=0;


More information about the Libreoffice-commits mailing list