diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-14 11:45:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-14 15:13:34 +0200 |
commit | dbe92dcfa79e3336411661fc94106deeba9317d6 (patch) | |
tree | b98def820790a9106502e5f752aff7db58545d5a /chart2/source/controller | |
parent | Fix comment again (diff) | |
download | core-dbe92dcfa79e3336411661fc94106deeba9317d6.tar.gz core-dbe92dcfa79e3336411661fc94106deeba9317d6.zip |
use more string_view in chart2
Change-Id: I9ab6cd3905bfb7c811e7ad14b54ced6c42d2e077
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133003
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/controller')
5 files changed, 26 insertions, 23 deletions
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 3918462e4ac4..4327297360d4 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -70,6 +70,7 @@ #include <com/sun/star/lang/XServiceName.hpp> #include <com/sun/star/util/XRefreshable.hpp> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star; using namespace ::chart::wrapper; @@ -473,21 +474,21 @@ sal_Int32 lcl_getNewAPIIndexForOldAPIIndex( return nNewAPIIndex; } -OUString lcl_getDiagramType( const OUString & rTemplateServiceName ) +OUString lcl_getDiagramType( std::u16string_view rTemplateServiceName ) { static const OUStringLiteral aPrefix(u"com.sun.star.chart2.template."); - if( rTemplateServiceName.match( aPrefix )) + if( o3tl::starts_with(rTemplateServiceName, aPrefix) ) { - const OUString aName( rTemplateServiceName.copy( aPrefix.getLength())); + const std::u16string_view aName( rTemplateServiceName.substr( aPrefix.getLength())); // "Area" "StackedArea" "PercentStackedArea" "ThreeDArea" // "StackedThreeDArea" "PercentStackedThreeDArea" - if( aName.indexOf( "Area" ) != -1 ) + if( aName.find( u"Area" ) != std::u16string_view::npos ) return "com.sun.star.chart.AreaDiagram"; // "Pie" "PieAllExploded" "ThreeDPie" "ThreeDPieAllExploded" - if( aName.indexOf( "Pie" ) != -1 ) + if( aName.find( u"Pie" ) != std::u16string_view::npos ) return "com.sun.star.chart.PieDiagram"; // "Column" "StackedColumn" "PercentStackedColumn" "ThreeDColumnDeep" @@ -496,33 +497,33 @@ OUString lcl_getDiagramType( const OUString & rTemplateServiceName ) // "PercentStackedBar" "ThreeDBarDeep" "ThreeDBarFlat" // "StackedThreeDBarFlat" "PercentStackedThreeDBarFlat" "ColumnWithLine" // "StackedColumnWithLine" - if( aName.indexOf( "Column" ) != -1 || aName.indexOf( "Bar" ) != -1 ) + if( aName.find( u"Column" ) != std::u16string_view::npos || aName.find( u"Bar" ) != std::u16string_view::npos ) return "com.sun.star.chart.BarDiagram"; // "Donut" "DonutAllExploded" "ThreeDDonut" "ThreeDDonutAllExploded" - if( aName.indexOf( "Donut" ) != -1 ) + if( aName.find( u"Donut" ) != std::u16string_view::npos ) return "com.sun.star.chart.DonutDiagram"; // "ScatterLineSymbol" "ScatterLine" "ScatterSymbol" "ThreeDScatter" - if( aName.indexOf( "Scatter" ) != -1 ) + if( aName.find( u"Scatter" ) != std::u16string_view::npos ) return "com.sun.star.chart.XYDiagram"; // "FilledNet" "StackedFilledNet" "PercentStackedFilledNet" - if( aName.indexOf( "FilledNet" ) != -1 ) + if( aName.find( u"FilledNet" ) != std::u16string_view::npos ) return "com.sun.star.chart.FilledNetDiagram"; // "Net" "NetSymbol" "NetLine" "StackedNet" "StackedNetSymbol" // "StackedNetLine" "PercentStackedNet" "PercentStackedNetSymbol" // "PercentStackedNetLine" - if( aName.indexOf( "Net" ) != -1 ) + if( aName.find( u"Net" ) != std::u16string_view::npos ) return "com.sun.star.chart.NetDiagram"; // "StockLowHighClose" "StockOpenLowHighClose" "StockVolumeLowHighClose" // "StockVolumeOpenLowHighClose" - if( aName.indexOf( "Stock" ) != -1 ) + if( aName.find( u"Stock" ) != std::u16string_view::npos ) return "com.sun.star.chart.StockDiagram"; - if( aName.indexOf( "Bubble" ) != -1 ) + if( aName.find( u"Bubble" ) != std::u16string_view::npos ) return "com.sun.star.chart.BubbleDiagram"; // Note: this must be checked after Bar, Net and Scatter @@ -531,7 +532,7 @@ OUString lcl_getDiagramType( const OUString & rTemplateServiceName ) // "PercentStackedLine" "LineSymbol" "StackedLineSymbol" // "PercentStackedLineSymbol" "ThreeDLine" "StackedThreeDLine" // "PercentStackedThreeDLine" "ThreeDLineDeep" - if( aName.indexOf( "Line" ) != -1 || aName.indexOf( "Symbol" ) != -1 ) + if( aName.find( u"Line" ) != std::u16string_view::npos || aName.find( u"Symbol" ) != std::u16string_view::npos ) return "com.sun.star.chart.LineDiagram"; OSL_FAIL( "unknown template" ); diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index 8ffb67543473..926b81a0ae15 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -52,6 +52,7 @@ #include <com/sun/star/chart2/XDataSeries.hpp> #include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> namespace chart { @@ -506,7 +507,7 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const rtl: rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ); if( xDiagram.is() && xSeries.is() ) { - sal_Int32 nPointIndex( ObjectIdentifier::getParticleID(rObjectCID).toInt32() ); + sal_Int32 nPointIndex = o3tl::toInt32(ObjectIdentifier::getParticleID(rObjectCID)); //replace data point index OUString aWildcard( "%POINTNUMBER" ); @@ -728,7 +729,7 @@ OUString ObjectNameProvider::getSelectedObjectText( const OUString & rObjectCID, rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartDocument ); if( xDiagram.is() && xSeries.is() ) { - sal_Int32 nPointIndex( ObjectIdentifier::getParticleID(rObjectCID).toInt32() ); + sal_Int32 nPointIndex = o3tl::toInt32( ObjectIdentifier::getParticleID(rObjectCID) ); // replace data point index replaceParamterInString( aRet, "%POINTNUMBER", OUString::number( nPointIndex + 1 )); diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 44bcdcaffcb8..7a14b9680d45 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -108,8 +108,8 @@ ObjectPropertiesDialogParameter::ObjectPropertiesDialogParameter( const OUString , m_bComplexCategoriesAxis( false ) , m_nNbPoints( 0 ) { - OUString aParticleID = ObjectIdentifier::getParticleID( m_aObjectCID ); - m_bAffectsMultipleObjects = (aParticleID == "ALLELEMENTS"); + std::u16string_view aParticleID = ObjectIdentifier::getParticleID( m_aObjectCID ); + m_bAffectsMultipleObjects = (aParticleID == u"ALLELEMENTS"); } ObjectPropertiesDialogParameter::~ObjectPropertiesDialogParameter() { diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 58bac63b0484..b04e43a82cfa 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -61,6 +61,7 @@ #include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <com/sun/star/util/CloseVetoException.hpp> #include <comphelper/servicehelper.hxx> +#include <o3tl/string_view.hxx> #include <memory> @@ -92,8 +93,8 @@ wrapper::ItemConverter* createItemConverter( return nullptr; } - OUString aParticleID = ObjectIdentifier::getParticleID( aObjectCID ); - bool bAffectsMultipleObjects = aParticleID == "ALLELEMENTS"; + std::u16string_view aParticleID = ObjectIdentifier::getParticleID( aObjectCID ); + bool bAffectsMultipleObjects = aParticleID == u"ALLELEMENTS"; if( !bAffectsMultipleObjects ) { uno::Reference< beans::XPropertySet > xObjectProperties = @@ -218,7 +219,7 @@ wrapper::ItemConverter* createItemConverter( sal_Int32 nPointIndex = -1; /*-1 for whole series*/ if(!bDataSeries) { - nPointIndex = aParticleID.toInt32(); + nPointIndex = o3tl::toInt32(aParticleID); bool bVaryColorsByPoint = false; if( xSeries.is() && (xSeries->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint) && @@ -530,7 +531,7 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const rt return rSelectedCID; else { - sal_Int32 nPointIndex = ObjectIdentifier::getParticleID( rSelectedCID ).toInt32(); + sal_Int32 nPointIndex = o3tl::toInt32(ObjectIdentifier::getParticleID( rSelectedCID )); if( nPointIndex>=0 ) { OUString aSeriesParticle = ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ); diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 92035d9d1bbd..905b84a6724c 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -144,7 +144,7 @@ bool lcl_deleteDataCurve( { uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( ObjectIdentifier::getObjectPropertySet( - ObjectIdentifier::getFullParentParticle( rCID ), xModel), uno::UNO_QUERY ); + OUString(ObjectIdentifier::getFullParentParticle( rCID )), xModel), uno::UNO_QUERY ); if( xRegressionCurveContainer.is()) { @@ -662,7 +662,7 @@ bool ChartController::executeDispatch_Delete() { uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( ObjectIdentifier::getObjectPropertySet( - ObjectIdentifier::getFullParentParticle( aCID ), getChartModel()), uno::UNO_QUERY ); + OUString(ObjectIdentifier::getFullParentParticle( aCID )), getChartModel()), uno::UNO_QUERY ); if( xRegCurveCnt.is()) { UndoGuard aUndoGuard( |