diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-15 15:33:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-16 09:36:35 +0000 |
commit | d14a83bf989d09e27ab3b787f4d3dcac087c9f0d (patch) | |
tree | ad787fa22a30648b1f5eac84cdcb2038f5fe40a2 /chart2 | |
parent | 0d8d0fb8932652f182c46805d5cf3ae7f6ebadd5 (diff) |
move getCorrectedMissingValueTreatment inside chart2::Diagram
and also switch to using getFastPropertyValue
Change-Id: I0c6617841a364ccb8e1c7b624e1ef6fde28426d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148928
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx | 3 | ||||
-rw-r--r-- | chart2/source/inc/Diagram.hxx | 5 | ||||
-rw-r--r-- | chart2/source/inc/DiagramHelper.hxx | 5 | ||||
-rw-r--r-- | chart2/source/model/main/Diagram.cxx | 28 | ||||
-rw-r--r-- | chart2/source/tools/DiagramHelper.cxx | 26 | ||||
-rw-r--r-- | chart2/source/view/main/SeriesPlotterContainer.cxx | 2 |
6 files changed, 35 insertions, 34 deletions
diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx index 568ca28639c4..2af1e694156f 100644 --- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx @@ -130,8 +130,7 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( } m_aSupportedMissingValueTreatments = ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ); - m_nMissingValueTreatment = DiagramHelper::getCorrectedMissingValueTreatment( - ChartModelHelper::findDiagram(m_xChartModel), xChartType ); + m_nMissingValueTreatment = xDiagram->getCorrectedMissingValueTreatment( xChartType ); uno::Reference< beans::XPropertySet > xProp( m_xChartModel->getDataProvider(), uno::UNO_QUERY ); if( xProp.is() ) diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx index d9c4b17aa283..99d9dc3aee65 100644 --- a/chart2/source/inc/Diagram.hxx +++ b/chart2/source/inc/Diagram.hxx @@ -39,6 +39,7 @@ namespace com::sun::star::uno { class XComponentContext; } namespace chart { class BaseCoordinateSystem; +class ChartType; class Legend; class DataTable; class Wall; @@ -167,6 +168,10 @@ public: DiagramPositioningMode getDiagramPositioningMode(); + //returns integer from constant group css::chart::MissingValueTreatment + sal_Int32 getCorrectedMissingValueTreatment( + const rtl::Reference< ::chart::ChartType >& xChartType ); + private: // ____ XModifyListener ____ virtual void SAL_CALL modified( diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx index 0798a3305021..3555155556cf 100644 --- a/chart2/source/inc/DiagramHelper.hxx +++ b/chart2/source/inc/DiagramHelper.hxx @@ -275,11 +275,6 @@ public: const rtl::Reference< ::chart::Diagram > & xDiagram, sal_Int32 nNewGeometry ); - //returns integer from constant group css::chart::MissingValueTreatment - static sal_Int32 getCorrectedMissingValueTreatment( - const rtl::Reference< ::chart::Diagram > & xDiagram, - const rtl::Reference< ::chart::ChartType >& xChartType ); - static bool setDiagramPositioning( const rtl::Reference<::chart::ChartModel>& xChartModel, const css::awt::Rectangle& rPosRect /*100th mm*/ ); diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index cda52d52a5bc..bcbef67f5b41 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -18,6 +18,7 @@ */ #include <Diagram.hxx> +#include <ChartTypeHelper.hxx> #include <ChartTypeManager.hxx> #include <ChartTypeTemplate.hxx> #include <PropertyHelper.hxx> @@ -38,6 +39,7 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> +#include <com/sun/star/chart/MissingValueTreatment.hpp> #include <com/sun/star/container/NoSuchElementException.hpp> #include <com/sun/star/uno/XComponentContext.hpp> @@ -721,6 +723,32 @@ DiagramPositioningMode Diagram::getDiagramPositioningMode() } +sal_Int32 Diagram::getCorrectedMissingValueTreatment( + const rtl::Reference< ChartType >& xChartType ) +{ + sal_Int32 nResult = css::chart::MissingValueTreatment::LEAVE_GAP; + const uno::Sequence < sal_Int32 > aAvailableMissingValueTreatments( + ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ) ); + + if( getFastPropertyValue( PROP_DIAGRAM_MISSING_VALUE_TREATMENT ) >>= nResult ) + { + //ensure that the set value is supported by this charttype + for( sal_Int32 n : aAvailableMissingValueTreatments ) + if( n == nResult ) + return nResult; //ok + } + + //otherwise use the first supported one + if( aAvailableMissingValueTreatments.hasElements() ) + { + nResult = aAvailableMissingValueTreatments[0]; + return nResult; + } + + return nResult; +} + + } // namespace chart extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 54da63cd0b35..d5cbf8b0bf7c 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -1412,32 +1412,6 @@ void DiagramHelper::setGeometry3D( } } -sal_Int32 DiagramHelper::getCorrectedMissingValueTreatment( - const rtl::Reference< Diagram > & xDiagram, - const rtl::Reference< ChartType >& xChartType ) -{ - sal_Int32 nResult = css::chart::MissingValueTreatment::LEAVE_GAP; - const uno::Sequence < sal_Int32 > aAvailableMissingValueTreatments( - ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ) ); - - if( xDiagram.is() && (xDiagram->getPropertyValue( "MissingValueTreatment" ) >>= nResult) ) - { - //ensure that the set value is supported by this charttype - for( sal_Int32 n : aAvailableMissingValueTreatments ) - if( n == nResult ) - return nResult; //ok - } - - //otherwise use the first supported one - if( aAvailableMissingValueTreatments.hasElements() ) - { - nResult = aAvailableMissingValueTreatments[0]; - return nResult; - } - - return nResult; -} - static void lcl_ensureRange0to1( double& rValue ) { if(rValue<0.0) diff --git a/chart2/source/view/main/SeriesPlotterContainer.cxx b/chart2/source/view/main/SeriesPlotterContainer.cxx index bb699e3378c1..6bba86eb61e9 100644 --- a/chart2/source/view/main/SeriesPlotterContainer.cxx +++ b/chart2/source/view/main/SeriesPlotterContainer.cxx @@ -240,7 +240,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart if (pVCooSys) pPlotter->setExplicitCategoriesProvider(pVCooSys->getExplicitCategoriesProvider()); sal_Int32 nMissingValueTreatment - = DiagramHelper::getCorrectedMissingValueTreatment(xDiagram, xChartType); + = xDiagram->getCorrectedMissingValueTreatment(xChartType); if (pVCooSys) pVCooSys->addMinimumAndMaximumSupplier(pPlotter); |