diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-01-24 19:22:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-25 16:25:41 +0100 |
commit | d48530c535574a827d7261ae8d9d1068fd53c5aa (patch) | |
tree | 8e1ce050fd0ef51613330a1df139a65f2579ab52 /chart2/source/controller/dialogs | |
parent | 933464ad3cfc8af141d1035afbebdcceb6814bb7 (diff) |
use more concrete types in chart2, ChartType
Change-Id: I5efd85ac51fbb8bd3cd9a9d2e07b345782d0fdc1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128882
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/controller/dialogs')
-rw-r--r-- | chart2/source/controller/dialogs/DataBrowser.cxx | 9 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/DataBrowserModel.cxx | 160 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/DataBrowserModel.hxx | 5 |
3 files changed, 86 insertions, 88 deletions
diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index 0fc400b740c9..1df9535a5713 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -31,6 +31,7 @@ #include <bitmaps.hlst> #include <helpids.h> #include <ChartModel.hxx> +#include <ChartType.hxx> #include <vcl/weld.hxx> #include <vcl/settings.hxx> @@ -171,7 +172,7 @@ public: void SetColor( const Color & rCol ); void SetPos(); void SetWidth( sal_Int32 nWidth ); - void SetChartType( const Reference< chart2::XChartType > & xChartType, + void SetChartType( const rtl::Reference< ::chart::ChartType > & xChartType, bool bSwapXAndYAxis ); void SetSeriesName( const OUString & rName ); void SetRange( sal_Int32 nStartCol, sal_Int32 nEndCol ); @@ -223,7 +224,7 @@ private: DECL_LINK( SeriesNameEdited, SeriesHeaderEdit&, void ); static OUString GetChartTypeImage( - const Reference< chart2::XChartType > & xChartType, + const rtl::Reference< ::chart::ChartType > & xChartType, bool bSwapXAndYAxis ); @@ -324,7 +325,7 @@ void SeriesHeader::SetPixelWidth( sal_Int32 nWidth ) } void SeriesHeader::SetChartType( - const Reference< chart2::XChartType > & xChartType, + const rtl::Reference< ChartType > & xChartType, bool bSwapXAndYAxis ) { @@ -382,7 +383,7 @@ bool SeriesHeader::HasFocus() const } OUString SeriesHeader::GetChartTypeImage( - const Reference< chart2::XChartType > & xChartType, + const rtl::Reference< ChartType > & xChartType, bool bSwapXAndYAxis ) { diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index 0455adf3212f..6171c1c87242 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -464,8 +464,7 @@ void DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColu return; } - Reference<chart2::XDataSeriesContainer> xSeriesCnt( - getHeaderForSeries(xSeries).m_xChartType, uno::UNO_QUERY); + rtl::Reference<ChartType> xSeriesCnt(getHeaderForSeries(xSeries).m_xChartType); if (!xSeriesCnt.is()) { // Unexpected happened. Bail out. @@ -804,101 +803,98 @@ void DataBrowserModel::updateFromModel() const std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysSeq( xDiagram->getBaseCoordinateSystems()); for( rtl::Reference< BaseCoordinateSystem > const & coords : aCooSysSeq ) { - const Sequence< Reference< chart2::XChartType > > aChartTypes( coords->getChartTypes()); + const std::vector< rtl::Reference< ChartType > > aChartTypes( coords->getChartTypes2()); sal_Int32 nXAxisNumberFormat = DataSeriesHelper::getNumberFormatKeyFromAxis( nullptr, coords, 0, 0 ); - for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) + for( sal_Int32 nCTIdx=0; nCTIdx < static_cast<sal_Int32>(aChartTypes.size()); ++nCTIdx ) { - Reference< chart2::XDataSeriesContainer > xSeriesCnt( aChartTypes[nCTIdx], uno::UNO_QUERY ); - if( xSeriesCnt.is()) - { - OUString aRoleForDataLabelNumberFormat = ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( aChartTypes[nCTIdx] ); + rtl::Reference< ChartType > xSeriesCnt( aChartTypes[nCTIdx] ); + OUString aRoleForDataLabelNumberFormat = ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( aChartTypes[nCTIdx] ); - const Sequence< Reference< chart2::XDataSeries > > aSeries( xSeriesCnt->getDataSeries()); - lcl_tSharedSeqVec aSharedSequences( lcl_getSharedSequences( aSeries )); - for (auto const& sharedSequence : aSharedSequences) - { - tDataColumn aSharedSequence; - aSharedSequence.m_xLabeledDataSequence = sharedSequence; - aSharedSequence.m_aUIRoleName = lcl_getUIRoleName(sharedSequence); - aSharedSequence.m_eCellType = NUMBER; - // as the sequences are shared it should be ok to take the first series - // @todo: dimension index 0 for x-values used here. This is just a guess. - // Also, the axis index is 0, as there is usually only one x-axis - aSharedSequence.m_nNumberFormatKey = nXAxisNumberFormat; - m_aColumns.push_back( aSharedSequence ); - ++nHeaderStart; - } - for( Reference< chart2::XDataSeries > const & dataSeries : aSeries ) + const Sequence< Reference< chart2::XDataSeries > > aSeries( xSeriesCnt->getDataSeries()); + lcl_tSharedSeqVec aSharedSequences( lcl_getSharedSequences( aSeries )); + for (auto const& sharedSequence : aSharedSequences) + { + tDataColumn aSharedSequence; + aSharedSequence.m_xLabeledDataSequence = sharedSequence; + aSharedSequence.m_aUIRoleName = lcl_getUIRoleName(sharedSequence); + aSharedSequence.m_eCellType = NUMBER; + // as the sequences are shared it should be ok to take the first series + // @todo: dimension index 0 for x-values used here. This is just a guess. + // Also, the axis index is 0, as there is usually only one x-axis + aSharedSequence.m_nNumberFormatKey = nXAxisNumberFormat; + m_aColumns.push_back( aSharedSequence ); + ++nHeaderStart; + } + for( Reference< chart2::XDataSeries > const & dataSeries : aSeries ) + { + tDataColumnVector::size_type nStartColIndex = m_aColumns.size(); + Reference< chart2::XDataSeries > xSeries( dataSeries ); + Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY ); + if( xSource.is()) { - tDataColumnVector::size_type nStartColIndex = m_aColumns.size(); - Reference< chart2::XDataSeries > xSeries( dataSeries ); - Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY ); - if( xSource.is()) + Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeqs( xSource->getDataSequences()); + if( !aLSeqs.hasElements() ) + continue; + nHeaderEnd = nHeaderStart; + + // @todo: dimension index 1 for y-values used here. This is just a guess + sal_Int32 nYAxisNumberFormatKey = + DataSeriesHelper::getNumberFormatKeyFromAxis( + dataSeries, coords, 1 ); + + sal_Int32 nSeqIdx=0; + for( ; nSeqIdx<aLSeqs.getLength(); ++nSeqIdx ) { - Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeqs( xSource->getDataSequences()); - if( !aLSeqs.hasElements() ) - continue; - nHeaderEnd = nHeaderStart; - - // @todo: dimension index 1 for y-values used here. This is just a guess - sal_Int32 nYAxisNumberFormatKey = - DataSeriesHelper::getNumberFormatKeyFromAxis( - dataSeries, coords, 1 ); - - sal_Int32 nSeqIdx=0; - for( ; nSeqIdx<aLSeqs.getLength(); ++nSeqIdx ) + sal_Int32 nSequenceNumberFormatKey = nYAxisNumberFormatKey; + OUString aRole = DataSeriesHelper::getRole(aLSeqs[nSeqIdx]); + + if( aRole == aRoleForDataLabelNumberFormat ) { - sal_Int32 nSequenceNumberFormatKey = nYAxisNumberFormatKey; - OUString aRole = DataSeriesHelper::getRole(aLSeqs[nSeqIdx]); - - if( aRole == aRoleForDataLabelNumberFormat ) - { - nSequenceNumberFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( - Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY )); - } - else if( aRole == "values-x" ) - nSequenceNumberFormatKey = nXAxisNumberFormat; - - if( std::none_of( aSharedSequences.begin(), aSharedSequences.end(), - lcl_RepresentationsOfLSeqMatch( aLSeqs[nSeqIdx] )) ) - { - // no shared sequence - m_aColumns.emplace_back( - dataSeries, - lcl_getUIRoleName( aLSeqs[nSeqIdx] ), - aLSeqs[nSeqIdx], - NUMBER, - nSequenceNumberFormatKey ); - ++nHeaderEnd; - } - // else skip + nSequenceNumberFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( + Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY )); } - bool bSwapXAndYAxis = false; - try + else if( aRole == "values-x" ) + nSequenceNumberFormatKey = nXAxisNumberFormat; + + if( std::none_of( aSharedSequences.begin(), aSharedSequences.end(), + lcl_RepresentationsOfLSeqMatch( aLSeqs[nSeqIdx] )) ) { - coords->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndYAxis; + // no shared sequence + m_aColumns.emplace_back( + dataSeries, + lcl_getUIRoleName( aLSeqs[nSeqIdx] ), + aLSeqs[nSeqIdx], + NUMBER, + nSequenceNumberFormatKey ); + ++nHeaderEnd; } - catch( const beans::UnknownPropertyException & ) {} + // else skip + } + bool bSwapXAndYAxis = false; + try + { + coords->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndYAxis; + } + catch( const beans::UnknownPropertyException & ) {} - // add ranges for error bars if present for a series - if( StatisticsHelper::usesErrorBarRanges( dataSeries )) - addErrorBarRanges( dataSeries, nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, true ); + // add ranges for error bars if present for a series + if( StatisticsHelper::usesErrorBarRanges( dataSeries )) + addErrorBarRanges( dataSeries, nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, true ); - if( StatisticsHelper::usesErrorBarRanges( dataSeries, /* bYError = */ false )) - addErrorBarRanges( dataSeries, nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, false ); + if( StatisticsHelper::usesErrorBarRanges( dataSeries, /* bYError = */ false )) + addErrorBarRanges( dataSeries, nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, false ); - m_aHeaders.emplace_back( - dataSeries, - aChartTypes[nCTIdx], - bSwapXAndYAxis, - nHeaderStart, - nHeaderEnd - 1 ); + m_aHeaders.emplace_back( + dataSeries, + aChartTypes[nCTIdx], + bSwapXAndYAxis, + nHeaderStart, + nHeaderEnd - 1 ); - nHeaderStart = nHeaderEnd; + nHeaderStart = nHeaderEnd; - std::sort( m_aColumns.begin() + nStartColIndex, m_aColumns.end(), implColumnLess() ); - } + std::sort( m_aColumns.begin() + nStartColIndex, m_aColumns.end(), implColumnLess() ); } } } diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx index d7c7be071f66..fe7faa53083d 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.hxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.hxx @@ -37,6 +37,7 @@ namespace chart class DialogModel; class ChartModel; +class ChartType; class DataBrowserModel final { @@ -99,7 +100,7 @@ public: struct tDataHeader { css::uno::Reference< css::chart2::XDataSeries > m_xDataSeries; - css::uno::Reference< css::chart2::XChartType > m_xChartType; + rtl::Reference< ::chart::ChartType > m_xChartType; bool m_bSwapXAndYAxis; sal_Int32 m_nStartColumn; sal_Int32 m_nEndColumn; @@ -113,7 +114,7 @@ public: // "full" CTOR tDataHeader( css::uno::Reference< css::chart2::XDataSeries > const & xDataSeries, - css::uno::Reference< css::chart2::XChartType > const &xChartType, + rtl::Reference< ::chart::ChartType > const &xChartType, bool bSwapXAndYAxis, sal_Int32 nStartColumn, sal_Int32 nEndColumn ) : |