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

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 9 08:26:26 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       |   22 +++++-
 chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx      |    2 
 chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx       |   22 +++++-
 chart2/source/controller/main/ChartController_Properties.cxx             |   11 ---
 chart2/source/inc/chartview/ExplicitValueProvider.hxx                    |    5 -
 chart2/source/view/main/ChartView.cxx                                    |   34 ----------
 sc/qa/uitest/chart/chartDataLabels.py                                    |    2 
 11 files changed, 53 insertions(+), 57 deletions(-)

New commits:
commit e4a087876da2584b772480d4fe8fc58081dfe0b8
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Wed Mar 25 11:31:02 2020 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Thu Apr 9 10:25:52 2020 +0200

    tdf#95425 follow-up: enable "Source format" checkbox of data label
    
    settings after file opening, if its value is true in the opened
    ODF or OOXML document, instead of always showing disabled state.
    
    Testing notes: double click on a data label during chart editing
    of unit test document testAreaChartNumberFormat.docx of
    commit e57d90cd4e51a1353eafc87bb29cfe6076704a7c
    (tdf#129173 tdf#129175 Fix number format of data labels)
    to see the Data Labels for Data Series... window. On the page
    "Data Labels...", click on the Number format... button to see
    the enabled checkbox "Source format" (that was disabled
    previously).
    
    Change-Id: I2845e6f462db273f21c47bb286bed56046f8cf21
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91038
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
index 52dd240a1587..45b7f401550d 100644
--- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
+++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
@@ -158,11 +158,7 @@ sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForSeries(
             const Reference< chart2::XDataSeries >& xSeries )
 {
     return ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
-        uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ),
-        xSeries,
-        -1 /*-1 for whole series*/,
-        ChartModelHelper::findDiagram( m_xChartModel )
-        );
+        uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ));
 }
 
 awt::Size Chart2ModelContact::GetPageSize() const
diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx
index c9651cbf3d34..2c7b2b050738 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 );
 
-    sal_Int32 getExplicitNumberFormatKeyForSeries(
+    static 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 a2da1089f555..1ce277c321ba 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 = m_spChart2ModelContact->getExplicitNumberFormatKeyForSeries( xSeries );
+            nKey = Chart2ModelContact::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 e353899eb81e..0fad7561bdc1 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 ), xSeries, -1, xDiagram );
+                                    Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ));
                             }
                             else if( aRole == "values-x" )
                                 nSequenceNumberFormatKey = nXAxisNumberFormat;
diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
index aae5266a59b7..8502eeba1f56 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -636,13 +636,31 @@ void DataPointItemConverter::FillSpecialItem(
 
         case SID_ATTR_NUMBERFORMAT_SOURCE:
         {
-            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue();
+            bool bUseSourceFormat = false;
+            try
+            {
+                GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
+            }
+            catch (const uno::Exception&)
+            {
+                TOOLS_WARN_EXCEPTION("chart2", "");
+            }
+            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue() && !bUseSourceFormat;
             rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
         }
         break;
         case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
         {
-            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ).hasValue();
+            bool bUseSourceFormat = false;
+            try
+            {
+                GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
+            }
+            catch (const uno::Exception&)
+            {
+                TOOLS_WARN_EXCEPTION("chart2", "");
+            }
+            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ).hasValue() && !bUseSourceFormat;
             rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet ));
         }
         break;
diff --git a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx
index c48b8b2b460a..63ab0723ee34 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, series, -1/*nPointIndex*/, ChartModelHelper::findDiagram( xChartModel ) );
+        sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties );
         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 95b38ad02402..eec17e7adb89 100644
--- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
@@ -548,13 +548,31 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r
         break;
         case SID_ATTR_NUMBERFORMAT_SOURCE:
         {
-            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue();
+            bool bUseSourceFormat = false;
+            try
+            {
+                GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
+            }
+            catch (const uno::Exception&)
+            {
+                TOOLS_WARN_EXCEPTION("chart2", "");
+            }
+            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue() && !bUseSourceFormat;
             rOutItemSet.Put(SfxBoolItem(nWhichId, !bNumberFormatIsSet));
         }
         break;
         case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE:
         {
-            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue("PercentageNumberFormat").hasValue();
+            bool bUseSourceFormat = false;
+            try
+            {
+                GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
+            }
+            catch (const uno::Exception&)
+            {
+                TOOLS_WARN_EXCEPTION("chart2", "");
+            }
+            bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue("PercentageNumberFormat").hasValue() && !bUseSourceFormat;
             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 6ee1eb39c7c1..587cbbfc00aa 100644
--- a/chart2/source/controller/main/ChartController_Properties.cxx
+++ b/chart2/source/controller/main/ChartController_Properties.cxx
@@ -176,16 +176,9 @@ wrapper::ItemConverter* createItemConverter(
 
                 uno::Reference<XDataSeries> xSeries = ObjectIdentifier::getDataSeriesForCID(aObjectCID, xChartModel);
 
-                uno::Reference<XDiagram> xDiagram = ChartModelHelper::findDiagram(xChartModel);
-
                 bool bDataSeries = eObjectType == OBJECTTYPE_DATA_LABELS;
 
-                sal_Int32 nPointIndex = -1; /*-1 for whole series*/
-                if (!bDataSeries)
-                    nPointIndex = aParticleID.toInt32();
-
-                sal_Int32 nNumberFormat = ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
-                    xObjectProperties, xSeries, nPointIndex, xDiagram);
+                sal_Int32 nNumberFormat = ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties );
                 sal_Int32 nPercentNumberFormat = ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
                     xObjectProperties,uno::Reference<util::XNumberFormatsSupplier>(xChartModel, uno::UNO_QUERY));
 
@@ -238,7 +231,7 @@ wrapper::ItemConverter* createItemConverter(
                         }
                     }
                 }
-                sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, xSeries, nPointIndex, xDiagram );
+                sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties );
                 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 7fec9b254625..b300339a21b1 100644
--- a/chart2/source/inc/chartview/ExplicitValueProvider.hxx
+++ b/chart2/source/inc/chartview/ExplicitValueProvider.hxx
@@ -82,10 +82,7 @@ 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::chart2::XDataSeries >& xSeries
-            , sal_Int32 nPointIndex /*-1 for whole series*/
-            , const css::uno::Reference< css::chart2::XDiagram >& xDiagram );
+            const css::uno::Reference< css::beans::XPropertySet >& xSeriesOrPointProp );
 
     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 9900d5139af4..547295155b12 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1874,45 +1874,17 @@ sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
         , true /*bSearchForParallelAxisIfNothingIsFound*/ );
 }
 
-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 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp )
 {
     sal_Int32 nFormat=0;
     if( !xSeriesOrPointProp.is() )
         return nFormat;
 
-    bool bLinkToSource = true;
     try
     {
-        xSeriesOrPointProp->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkToSource;
-    }
-    catch ( const beans::UnknownPropertyException& ) {}
-
-    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));
+        xSeriesOrPointProp->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nFormat;
     }
+    catch (const beans::UnknownPropertyException&) {}
 
     if(nFormat<0)
         nFormat=0;
diff --git a/sc/qa/uitest/chart/chartDataLabels.py b/sc/qa/uitest/chart/chartDataLabels.py
index a63d8fd8a23d..378670faec51 100644
--- a/sc/qa/uitest/chart/chartDataLabels.py
+++ b/sc/qa/uitest/chart/chartDataLabels.py
@@ -276,8 +276,10 @@ class chartDataLabels(UITestCase):
     def handle_number_dlg(dialog):
         categoryformat = dialog.getChild("categorylb")
         formatted = dialog.getChild("formatted")
+        sourceformat = dialog.getChild("sourceformat")
 
         # Select currency
+        sourceformat.executeAction("CLICK", tuple());
         categoryformat.getChild("4").executeAction("SELECT", tuple());
 
         self.assertEqual(get_state_as_dict(categoryformat)["SelectEntryText"], "Currency")


More information about the Libreoffice-commits mailing list