summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2020-03-06 10:27:11 +0100
committerLászló Németh <nemeth@numbertext.org>2020-03-24 11:20:46 +0100
commit9bf40c635c41c6b3b072b7c61fea67a20ba4342b (patch)
tree00e3dd6fbbe44dc21dc01328024fd84f710c77e6
parent45435e2ac007aed2aabd175ad944d6c779d99167 (diff)
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 to see the Data Labels for Data Series... window. On the page "Data Labels...", click on the Number format... button to see the checkbox "Source format". Change-Id: Idb837d9492ad7e83b9020167c47ed52499c070a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90079 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx6
-rw-r--r--chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx2
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx2
-rw-r--r--chart2/source/controller/dialogs/DataBrowserModel.cxx2
-rw-r--r--chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx8
-rw-r--r--chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx2
-rw-r--r--chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx8
-rw-r--r--chart2/source/controller/main/ChartController_Properties.cxx9
-rw-r--r--chart2/source/inc/chartview/ExplicitValueProvider.hxx5
-rw-r--r--chart2/source/view/main/ChartView.cxx32
10 files changed, 25 insertions, 51 deletions
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..099b74060f07 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -636,13 +636,17 @@ void DataPointItemConverter::FillSpecialItem(
case SID_ATTR_NUMBERFORMAT_SOURCE:
{
- bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(CHART_UNONAME_NUMFMT).hasValue();
+ bool bUseSourceFormat = false;
+ GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
+ 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;
+ GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
+ 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..eacc13f47b62 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..b3b53b067924 100644
--- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
@@ -548,13 +548,17 @@ 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;
+ GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
+ 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;
+ GetPropertySet()->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bUseSourceFormat;
+ 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..348516f26abf 100644
--- a/chart2/source/controller/main/ChartController_Properties.cxx
+++ b/chart2/source/controller/main/ChartController_Properties.cxx
@@ -180,12 +180,7 @@ wrapper::ItemConverter* createItemConverter(
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 +233,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 bcda427a6bdb..f84446fbe47d 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1874,12 +1874,7 @@ 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() )
@@ -1892,27 +1887,10 @@ sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
}
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));
- }
+ if( bLinkToSource )
+ xSeriesOrPointProp->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any(nFormat));
+ else
+ xSeriesOrPointProp->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nFormat;
if(nFormat<0)
nFormat=0;