diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-07-02 13:42:16 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-07-02 14:00:41 +0100 |
commit | 8918dabbeed24d68a746309165e6c09a09b7b2f3 (patch) | |
tree | e83bb94cb71b78b872cb1360c7ddea775bf1bb5a /chart2 | |
parent | d528eb158cce3c44cd976a0d5a65b7f0c012672c (diff) |
coverity#705359 Mixing enum types
and
coverity#705361 Mixing enum types
coverity#705362 Mixing enum types
Change-Id: I557d7178277e5d497e3bbab12b75724c05653f57
Diffstat (limited to 'chart2')
6 files changed, 56 insertions, 145 deletions
diff --git a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx index 8dd0f80c3be6..1c63fe658595 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx @@ -56,27 +56,27 @@ Any lcl_getRegressionDefault() return aRet; } -::com::sun::star::chart::ChartRegressionCurveType lcl_getRegressionCurveType( RegressionCurveHelper::tRegressionType eRegressionType ) +::com::sun::star::chart::ChartRegressionCurveType lcl_getRegressionCurveType(SvxChartRegress eRegressionType) { ::com::sun::star::chart::ChartRegressionCurveType eRet = ::com::sun::star::chart::ChartRegressionCurveType_NONE; switch(eRegressionType) { - case RegressionCurveHelper::REGRESSION_TYPE_LINEAR: + case CHREGRESS_LINEAR: eRet = ::com::sun::star::chart::ChartRegressionCurveType_LINEAR; break; - case RegressionCurveHelper::REGRESSION_TYPE_LOG: + case CHREGRESS_LOG: eRet = ::com::sun::star::chart::ChartRegressionCurveType_LOGARITHM; break; - case RegressionCurveHelper::REGRESSION_TYPE_EXP: + case CHREGRESS_EXP: eRet = ::com::sun::star::chart::ChartRegressionCurveType_EXPONENTIAL; break; - case RegressionCurveHelper::REGRESSION_TYPE_POWER: + case CHREGRESS_POWER: eRet = ::com::sun::star::chart::ChartRegressionCurveType_POWER; break; - case RegressionCurveHelper::REGRESSION_TYPE_POLYNOMIAL: + case CHREGRESS_POLYNOMIAL: eRet = ::com::sun::star::chart::ChartRegressionCurveType_POLYNOMIAL; break; - /*case RegressionCurveHelper::REGRESSION_TYPE_MOVING_AVERAGE: + /*case CHREGRESS_MOVING_AVERAGE: eRet = ::com::sun::star::chart::ChartRegressionCurveType_MOVING_AVERAGE; break;*/ default: @@ -86,27 +86,27 @@ Any lcl_getRegressionDefault() return eRet; } -RegressionCurveHelper::tRegressionType lcl_getRegressionType( ::com::sun::star::chart::ChartRegressionCurveType eRegressionCurveType ) +SvxChartRegress lcl_getRegressionType( ::com::sun::star::chart::ChartRegressionCurveType eRegressionCurveType ) { - RegressionCurveHelper::tRegressionType eRet; - switch(eRegressionCurveType) + SvxChartRegress eRet; + switch (eRegressionCurveType) { case ::com::sun::star::chart::ChartRegressionCurveType_LINEAR: - eRet = RegressionCurveHelper::REGRESSION_TYPE_LINEAR; + eRet = CHREGRESS_LINEAR; break; case ::com::sun::star::chart::ChartRegressionCurveType_LOGARITHM: - eRet = RegressionCurveHelper::REGRESSION_TYPE_LOG; + eRet = CHREGRESS_LOG; break; case ::com::sun::star::chart::ChartRegressionCurveType_EXPONENTIAL: - eRet = RegressionCurveHelper::REGRESSION_TYPE_EXP; + eRet = CHREGRESS_EXP; break; case ::com::sun::star::chart::ChartRegressionCurveType_POLYNOMIAL: //case ::com::sun::star::chart::ChartRegressionCurveType_MOVING_AVERAGE: case ::com::sun::star::chart::ChartRegressionCurveType_POWER: - eRet = RegressionCurveHelper::REGRESSION_TYPE_POWER; + eRet = CHREGRESS_POWER; break; default: - eRet = RegressionCurveHelper::REGRESSION_TYPE_NONE; + eRet = CHREGRESS_NONE; break; } return eRet; @@ -831,6 +831,7 @@ WrappedRegressionCurvesProperty::WrappedRegressionCurvesProperty( , lcl_getRegressionDefault(), spChart2ModelContact, ePropertyType ) { } + WrappedRegressionCurvesProperty::~WrappedRegressionCurvesProperty() { } @@ -854,7 +855,7 @@ void WrappedRegressionCurvesProperty::setValueToSeries( const Reference< beans:: if( xRegressionCurveContainer.is() && xRegressionCurve.is() ) { - RegressionCurveHelper::tRegressionType eNewRegressionType = lcl_getRegressionType( aNewValue ); + SvxChartRegress eNewRegressionType = lcl_getRegressionType( aNewValue ); RegressionCurveHelper::changeRegressionCurveType( eNewRegressionType, diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx index df4b19ba4c4a..fc2cc1418031 100644 --- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx @@ -29,7 +29,6 @@ #include <svl/eitem.hxx> #include <svl/intitem.hxx> #include <svl/stritem.hxx> -#include <svx/chrtitem.hxx> #include <functional> #include <algorithm> @@ -38,36 +37,6 @@ using namespace ::com::sun::star; namespace { - -::chart::RegressionCurveHelper::tRegressionType lcl_convertRegressionType( SvxChartRegress eRegress ) -{ - ::chart::RegressionCurveHelper::tRegressionType eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_NONE; - switch( eRegress ) - { - case CHREGRESS_LINEAR: - eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LINEAR; - break; - case CHREGRESS_LOG: - eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LOG; - break; - case CHREGRESS_EXP: - eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_EXP; - break; - case CHREGRESS_POWER: - eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POWER; - break; - case CHREGRESS_POLYNOMIAL: - eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POLYNOMIAL; - break; - case CHREGRESS_MOVING_AVERAGE: - eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_MOVING_AVERAGE; - break; - case CHREGRESS_NONE: - break; - } - return eType; -} - template <class T, class D> bool lclConvertToPropertySet(const SfxItemSet& rItemSet, sal_uInt16 nWhichId, uno::Reference<beans::XPropertySet> xProperties, const OUString& aPropertyID) { @@ -181,8 +150,7 @@ bool RegressionCurveItemConverter::ApplySpecialItem( { case SCHATTR_REGRESSION_TYPE: { - SvxChartRegress eRegress = static_cast< SvxChartRegress >( - static_cast< sal_Int32 >( RegressionCurveHelper::getRegressionType( xCurve ))); + SvxChartRegress eRegress = RegressionCurveHelper::getRegressionType(xCurve); SvxChartRegress eNewRegress = static_cast< const SvxChartRegressItem & >( rItemSet.Get( nWhichId )).GetValue(); if( eRegress != eNewRegress ) @@ -192,7 +160,7 @@ bool RegressionCurveItemConverter::ApplySpecialItem( // currently the only way to handle the type in the // regression curve properties dialog xCurve = RegressionCurveHelper::changeRegressionCurveType( - lcl_convertRegressionType( eNewRegress ), + eNewRegress, m_xCurveContainer, xCurve, uno::Reference< uno::XComponentContext >()); @@ -284,8 +252,7 @@ void RegressionCurveItemConverter::FillSpecialItem(sal_uInt16 nWhichId, SfxItemS { case SCHATTR_REGRESSION_TYPE: { - sal_Int32 aRegressionType = static_cast< sal_Int32 >(RegressionCurveHelper::getRegressionType(xCurve)); - SvxChartRegress eRegress = static_cast< SvxChartRegress >(aRegressionType); + SvxChartRegress eRegress = RegressionCurveHelper::getRegressionType(xCurve); rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE )); } break; diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx index 1f24e8b37ca6..a7a0b5c81e3f 100644 --- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx @@ -68,35 +68,6 @@ uno::Reference< beans::XPropertySet > lcl_GetErrorBar( return xResult; } -::chart::RegressionCurveHelper::tRegressionType lcl_convertRegressionType( SvxChartRegress eRegress ) -{ - ::chart::RegressionCurveHelper::tRegressionType eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_NONE; - switch( eRegress ) - { - case CHREGRESS_LINEAR: - eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LINEAR; - break; - case CHREGRESS_LOG: - eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LOG; - break; - case CHREGRESS_EXP: - eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_EXP; - break; - case CHREGRESS_POWER: - eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POWER; - break; - case CHREGRESS_POLYNOMIAL: - eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POLYNOMIAL; - break; - case CHREGRESS_MOVING_AVERAGE: - eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_MOVING_AVERAGE; - break; - case CHREGRESS_NONE: - break; - } - return eType; -} - uno::Reference< beans::XPropertySet > lcl_GetDefaultErrorBar() { // todo: use a valid context @@ -262,24 +233,11 @@ StatisticsItemConverter::StatisticsItemConverter( ItemConverter( rPropertySet, rItemPool ), m_xModel( xModel ) { - OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_NONE ) == - static_cast< int >( CHREGRESS_NONE )); - OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_LINEAR ) == - static_cast< int >( CHREGRESS_LINEAR )); - OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_LOG ) == - static_cast< int >( CHREGRESS_LOG )); - OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_EXP ) == - static_cast< int >( CHREGRESS_EXP )); - OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_POWER ) == - static_cast< int >( CHREGRESS_POWER )); - OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_POLYNOMIAL ) == - static_cast< int >( CHREGRESS_POLYNOMIAL )); - OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_MOVING_AVERAGE ) == - static_cast< int >( CHREGRESS_MOVING_AVERAGE )); } StatisticsItemConverter::~StatisticsItemConverter() -{} +{ +} const sal_uInt16 * StatisticsItemConverter::GetWhichPairs() const { @@ -476,14 +434,12 @@ bool StatisticsItemConverter::ApplySpecialItem( if ( xCurve.is() ) { SvxChartRegress eOldRegress( - static_cast< SvxChartRegress >( - static_cast< sal_Int32 >( - RegressionCurveHelper::getRegressionType( xCurve )))); + RegressionCurveHelper::getRegressionType(xCurve)); if( eOldRegress != eRegress ) { xCurve = RegressionCurveHelper::changeRegressionCurveType( - lcl_convertRegressionType( eRegress ), + eRegress, xContainer, xCurve, uno::Reference< uno::XComponentContext >()); @@ -756,11 +712,10 @@ void StatisticsItemConverter::FillSpecialItem( case SCHATTR_REGRESSION_TYPE: { - SvxChartRegress eRegress = static_cast< SvxChartRegress >( - static_cast< sal_Int32 >( + SvxChartRegress eRegress = RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( uno::Reference< chart2::XRegressionCurveContainer >( - GetPropertySet(), uno::UNO_QUERY ) ))); + GetPropertySet(), uno::UNO_QUERY ) ); rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE )); } break; diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 610bfae12bb7..1111bbe8cd46 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -373,7 +373,7 @@ void ChartController::executeDispatch_InsertTrendline() uno::Reference< chart2::XRegressionCurve > xCurve = RegressionCurveHelper::addRegressionCurve( - RegressionCurveHelper::REGRESSION_TYPE_LINEAR, + CHREGRESS_LINEAR, xRegressionCurveContainer, m_xCC ); diff --git a/chart2/source/inc/RegressionCurveHelper.hxx b/chart2/source/inc/RegressionCurveHelper.hxx index ee1d1607ace4..772c3c3e2ffe 100644 --- a/chart2/source/inc/RegressionCurveHelper.hxx +++ b/chart2/source/inc/RegressionCurveHelper.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/chart2/XDiagram.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/frame/XModel.hpp> +#include <svx/chrtitem.hxx> #include "charttoolsdllapi.hxx" #include <vector> @@ -70,19 +71,6 @@ public: static void removeMeanValueLine( css::uno::Reference<css::chart2::XRegressionCurveContainer>& xRegCnt ); - enum tRegressionType - { - REGRESSION_TYPE_NONE, - REGRESSION_TYPE_LINEAR, - REGRESSION_TYPE_LOG, - REGRESSION_TYPE_EXP, - REGRESSION_TYPE_POWER, - REGRESSION_TYPE_POLYNOMIAL, - REGRESSION_TYPE_MOVING_AVERAGE, - REGRESSION_TYPE_MEAN_VALUE, - REGRESSION_TYPE_UNKNOWN - }; - /** Returns the first regression curve found that is not of type mean-value line */ @@ -100,10 +88,10 @@ public: /** Returns the type of the first regression curve found that is not of type mean-value line */ - static tRegressionType getFirstRegressTypeNotMeanValueLine( + static SvxChartRegress getFirstRegressTypeNotMeanValueLine( const css::uno::Reference<css::chart2::XRegressionCurveContainer>& xCurveContainer ); - static tRegressionType getRegressionType( + static SvxChartRegress getRegressionType( const css::uno::Reference<css::chart2::XRegressionCurve>& xCurve ); /** @param xPropertySource is taken as source to copy all properties from if @@ -113,7 +101,7 @@ public: */ static css::uno::Reference<css::chart2::XRegressionCurve> addRegressionCurve( - tRegressionType eType, + SvxChartRegress eType, css::uno::Reference<css::chart2::XRegressionCurveContainer>& xCurveContainer, const css::uno::Reference<css::uno::XComponentContext>& xContext, const css::uno::Reference<css::beans::XPropertySet >& xPropertySource = @@ -129,7 +117,7 @@ public: static css::uno::Reference<css::chart2::XRegressionCurve> changeRegressionCurveType( - tRegressionType eType, + SvxChartRegress eType, css::uno::Reference<css::chart2::XRegressionCurveContainer>& xRegressionCurveContainer, css::uno::Reference<css::chart2::XRegressionCurve>& xRegressionCurve, const css::uno::Reference<css::uno::XComponentContext>& xContext ); diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index 1f243370b18f..fd3ac69c9799 100644 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -48,27 +48,27 @@ using ::com::sun::star::uno::Exception; namespace { -OUString lcl_getServiceNameForType( ::chart::RegressionCurveHelper::tRegressionType eType ) +OUString lcl_getServiceNameForType(SvxChartRegress eType) { OUString aServiceName; switch( eType ) { - case ::chart::RegressionCurveHelper::REGRESSION_TYPE_LINEAR: + case CHREGRESS_LINEAR: aServiceName = "com.sun.star.chart2.LinearRegressionCurve"; break; - case ::chart::RegressionCurveHelper::REGRESSION_TYPE_LOG: + case CHREGRESS_LOG: aServiceName = "com.sun.star.chart2.LogarithmicRegressionCurve"; break; - case ::chart::RegressionCurveHelper::REGRESSION_TYPE_EXP: + case CHREGRESS_EXP: aServiceName = "com.sun.star.chart2.ExponentialRegressionCurve"; break; - case ::chart::RegressionCurveHelper::REGRESSION_TYPE_POWER: + case CHREGRESS_POWER: aServiceName = "com.sun.star.chart2.PotentialRegressionCurve"; break; - case ::chart::RegressionCurveHelper::REGRESSION_TYPE_POLYNOMIAL: + case CHREGRESS_POLYNOMIAL: aServiceName = "com.sun.star.chart2.PolynomialRegressionCurve"; break; - case ::chart::RegressionCurveHelper::REGRESSION_TYPE_MOVING_AVERAGE: + case CHREGRESS_MOVING_AVERAGE: aServiceName = "com.sun.star.chart2.MovingAverageRegressionCurve"; break; default: @@ -351,7 +351,7 @@ void RegressionCurveHelper::removeMeanValueLine( } uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::addRegressionCurve( - tRegressionType eType, + SvxChartRegress eType, uno::Reference< XRegressionCurveContainer >& xRegressionCurveContainer, const uno::Reference< XComponentContext >& /* xContext */, const uno::Reference< beans::XPropertySet >& xPropertySource, @@ -362,7 +362,7 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::addRegressionC if( !xRegressionCurveContainer.is() ) return xCurve; - if( eType == REGRESSION_TYPE_NONE ) + if( eType == CHREGRESS_NONE ) { OSL_FAIL("don't create a regression curve of type none"); return xCurve; @@ -470,7 +470,7 @@ void RegressionCurveHelper::removeEquations( } uno::Reference< XRegressionCurve > RegressionCurveHelper::changeRegressionCurveType( - tRegressionType eType, + SvxChartRegress eType, uno::Reference< XRegressionCurveContainer > & xRegressionCurveContainer, uno::Reference< XRegressionCurve > & xRegressionCurve, const uno::Reference< XComponentContext > & xContext ) @@ -534,10 +534,10 @@ uno::Reference< chart2::XRegressionCurve > RegressionCurveHelper::getRegressionC return NULL; } -RegressionCurveHelper::tRegressionType RegressionCurveHelper::getRegressionType( +SvxChartRegress RegressionCurveHelper::getRegressionType( const Reference< XRegressionCurve > & xCurve ) { - tRegressionType eResult = REGRESSION_TYPE_UNKNOWN; + SvxChartRegress eResult = CHREGRESS_UNKNOWN; try { @@ -548,31 +548,31 @@ RegressionCurveHelper::tRegressionType RegressionCurveHelper::getRegressionType( if( aServiceName == "com.sun.star.chart2.LinearRegressionCurve" ) { - eResult = REGRESSION_TYPE_LINEAR; + eResult = CHREGRESS_LINEAR; } else if( aServiceName == "com.sun.star.chart2.LogarithmicRegressionCurve" ) { - eResult = REGRESSION_TYPE_LOG; + eResult = CHREGRESS_LOG; } else if( aServiceName == "com.sun.star.chart2.ExponentialRegressionCurve" ) { - eResult = REGRESSION_TYPE_EXP; + eResult = CHREGRESS_EXP; } else if( aServiceName == "com.sun.star.chart2.PotentialRegressionCurve" ) { - eResult = REGRESSION_TYPE_POWER; + eResult = CHREGRESS_POWER; } else if( aServiceName == "com.sun.star.chart2.MeanValueRegressionCurve" ) { - eResult = REGRESSION_TYPE_MEAN_VALUE; + eResult = CHREGRESS_MEAN_VALUE; } else if( aServiceName == "com.sun.star.chart2.PolynomialRegressionCurve" ) { - eResult = REGRESSION_TYPE_POLYNOMIAL; + eResult = CHREGRESS_POLYNOMIAL; } else if( aServiceName == "com.sun.star.chart2.MovingAverageRegressionCurve" ) { - eResult = REGRESSION_TYPE_MOVING_AVERAGE; + eResult = CHREGRESS_MOVING_AVERAGE; } } } @@ -584,10 +584,10 @@ RegressionCurveHelper::tRegressionType RegressionCurveHelper::getRegressionType( return eResult; } -RegressionCurveHelper::tRegressionType RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( +SvxChartRegress RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( const Reference< XRegressionCurveContainer > & xRegCnt ) { - tRegressionType eResult = REGRESSION_TYPE_NONE; + SvxChartRegress eResult = CHREGRESS_NONE; if( xRegCnt.is()) { @@ -595,9 +595,9 @@ RegressionCurveHelper::tRegressionType RegressionCurveHelper::getFirstRegressTyp xRegCnt->getRegressionCurves()); for( sal_Int32 i = 0; i < aCurves.getLength(); ++i ) { - tRegressionType eType = getRegressionType( aCurves[i] ); - if( eType != REGRESSION_TYPE_MEAN_VALUE && - eType != REGRESSION_TYPE_UNKNOWN ) + SvxChartRegress eType = getRegressionType( aCurves[i] ); + if( eType != CHREGRESS_MEAN_VALUE && + eType != CHREGRESS_UNKNOWN ) { eResult = eType; break; |