diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-02 19:02:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-03 10:01:48 +0200 |
commit | 3e1e0af376d45f44dab975cea943de7fb676f967 (patch) | |
tree | 3a1e0f7cf57ee323b8cdde8ac02a010d1e02f0b3 /chart2 | |
parent | 744722123a8ce3d3c30583ba1285a21e129b471f (diff) |
loplugin:stringviewparam convert methods using match
which converts to a combination of substr and o3tl::starts_with
Change-Id: I5b01a181b9e6bee3483e4f49f1a9426abcc682d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132458
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/controller/inc/SelectionHelper.hxx | 2 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController_Window.cxx | 2 | ||||
-rw-r--r-- | chart2/source/controller/main/SelectionHelper.cxx | 2 | ||||
-rw-r--r-- | chart2/source/inc/ObjectIdentifier.hxx | 16 | ||||
-rw-r--r-- | chart2/source/tools/ObjectIdentifier.cxx | 96 | ||||
-rw-r--r-- | chart2/source/tools/PropertyHelper.cxx | 5 |
6 files changed, 63 insertions, 60 deletions
diff --git a/chart2/source/controller/inc/SelectionHelper.hxx b/chart2/source/controller/inc/SelectionHelper.hxx index ae241d61ab42..ff0e95eee27a 100644 --- a/chart2/source/controller/inc/SelectionHelper.hxx +++ b/chart2/source/controller/inc/SelectionHelper.hxx @@ -92,7 +92,7 @@ public: DrawViewWrapper const & rDrawViewWrapper, bool bGetDiagramInsteadOf_Wall=false ); - static bool isRotateableObject( const OUString& rCID + static bool isRotateableObject( std::u16string_view rCID , const rtl::Reference<::chart::ChartModel>& xChartModel ); explicit SelectionHelper( SdrObject* pSelectedObj ); diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 0e33cabfccbb..a6bae9b002a7 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -154,7 +154,7 @@ void lcl_insertMenuCommand( xMenu->setCommand( nId, rCommand ); } -OUString lcl_getFormatCommandForObjectCID( const OUString& rCID ) +OUString lcl_getFormatCommandForObjectCID( std::u16string_view rCID ) { OUString aDispatchCommand( ".uno:FormatSelection" ); diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx index 433a157ba828..cc01e09eff0a 100644 --- a/chart2/source/controller/main/SelectionHelper.cxx +++ b/chart2/source/controller/main/SelectionHelper.cxx @@ -443,7 +443,7 @@ OUString SelectionHelper::getHitObjectCID( // \\- solar mutex } -bool SelectionHelper::isRotateableObject( const OUString& rCID +bool SelectionHelper::isRotateableObject( std::u16string_view rCID , const rtl::Reference<::chart::ChartModel>& xChartModel ) { if( !ObjectIdentifier::isRotateableObject( rCID ) ) diff --git a/chart2/source/inc/ObjectIdentifier.hxx b/chart2/source/inc/ObjectIdentifier.hxx index f4ce48011419..5be9d9cf3a97 100644 --- a/chart2/source/inc/ObjectIdentifier.hxx +++ b/chart2/source/inc/ObjectIdentifier.hxx @@ -118,11 +118,11 @@ public: , const rtl::Reference<::chart::ChartModel>& xChartModel ); static OUString createClassifiedIdentifierForParticle( - const OUString& rParticle ); + std::u16string_view rParticle ); static OUString createClassifiedIdentifierForParticles( - const OUString& rParentParticle - , const OUString& rChildParticle + std::u16string_view rParentParticle + , std::u16string_view rChildParticle , std::u16string_view rDragMethodServiceName = std::u16string_view() , std::u16string_view rDragParameterString = std::u16string_view() ); @@ -165,22 +165,22 @@ public: , std::u16string_view rDragParameterString = std::u16string_view() ); - static bool isCID( const OUString& rName ); + static bool isCID( std::u16string_view rName ); static OUString getDragMethodServiceName( const OUString& rClassifiedIdentifier ); static OUString getDragParameterString( const OUString& rCID ); static bool isDragableObject( const OUString& rClassifiedIdentifier ); bool isDragableObject() const; - static bool isRotateableObject( const OUString& rClassifiedIdentifier ); - static bool isMultiClickObject( const OUString& rClassifiedIdentifier ); + static bool isRotateableObject( std::u16string_view rClassifiedIdentifier ); + static bool isMultiClickObject( std::u16string_view rClassifiedIdentifier ); static bool areSiblings( const OUString& rCID1, const OUString& rCID2 );//identical object is no sibling static bool areIdenticalObjects( const OUString& rCID1, const OUString& rCID2 ); static OUString getStringForType( ObjectType eObjectType ); - static ObjectType getObjectType( const OUString& rCID ); + static ObjectType getObjectType( std::u16string_view rCID ); ObjectType getObjectType() const; static OUString createSeriesSubObjectStub( ObjectType eSubObjectType - , const OUString& rSeriesParticle + , std::u16string_view rSeriesParticle , std::u16string_view rDragMethodServiceName = std::u16string_view() , std::u16string_view rDragParameterString = std::u16string_view() ); static OUString createPointCID( std::u16string_view rPointCID_Stub, sal_Int32 nIndex ); diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index 058314eae395..43c26d2aaf55 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -47,6 +47,7 @@ #include <rtl/ustrbuf.hxx> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> namespace com::sun::star::drawing { class XShape; } @@ -58,10 +59,10 @@ using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; -const char m_aMultiClick[] = "MultiClick"; +const sal_Unicode m_aMultiClick[] = u"MultiClick"; const char m_aDragMethodEquals[] = "DragMethod="; const char m_aDragParameterEquals[] = "DragParameter="; -const char m_aProtocol[] = "CID/"; +const sal_Unicode m_aProtocol[] = u"CID/"; const OUString m_aPieSegmentDragMethodServiceName("PieSegmentDragging"); namespace @@ -425,14 +426,14 @@ OUString ObjectIdentifier::createClassifiedIdentifierForObject( } OUString ObjectIdentifier::createClassifiedIdentifierForParticle( - const OUString& rParticle ) + std::u16string_view rParticle ) { - return ObjectIdentifier::createClassifiedIdentifierForParticles( rParticle, OUString() ); + return ObjectIdentifier::createClassifiedIdentifierForParticles( rParticle, u"" ); } OUString ObjectIdentifier::createClassifiedIdentifierForParticles( - const OUString& rParentParticle - , const OUString& rChildParticle + std::u16string_view rParentParticle + , std::u16string_view rChildParticle , std::u16string_view rDragMethodServiceName , std::u16string_view rDragParameterString ) { @@ -442,13 +443,13 @@ OUString ObjectIdentifier::createClassifiedIdentifierForParticles( OUStringBuffer aRet( m_aProtocol ); aRet.append( lcl_createClassificationStringForType( eObjectType, rDragMethodServiceName, rDragParameterString )); - if(aRet.getLength() > static_cast<sal_Int32>(strlen(m_aProtocol))) + if(aRet.getLength() > static_cast<sal_Int32>(std::size(m_aProtocol)-1)) aRet.append("/"); - if(!rParentParticle.isEmpty()) + if(!rParentParticle.empty()) { aRet.append(rParentParticle); - if( !rChildParticle.isEmpty() ) + if( !rChildParticle.empty() ) aRet.append(":"); } aRet.append(rChildParticle); @@ -566,7 +567,7 @@ OUString ObjectIdentifier::createClassifiedIdentifierWithParent( OUStringBuffer aRet( m_aProtocol ); aRet.append( lcl_createClassificationStringForType( eObjectType, rDragMethodServiceName, rDragParameterString )); - if(aRet.getLength() > static_cast<sal_Int32>(strlen(m_aProtocol))) + if(aRet.getLength() > static_cast<sal_Int32>(std::size(m_aProtocol)-1)) aRet.append("/"); aRet.append(rParentPartical); if(!rParentPartical.empty()) @@ -716,7 +717,7 @@ bool ObjectIdentifier::isDragableObject() const return bReturn; } -bool ObjectIdentifier::isRotateableObject( const OUString& rClassifiedIdentifier ) +bool ObjectIdentifier::isRotateableObject( std::u16string_view rClassifiedIdentifier ) { bool bReturn = false; ObjectType eObjectType = ObjectIdentifier::getObjectType( rClassifiedIdentifier ); @@ -733,7 +734,7 @@ bool ObjectIdentifier::isRotateableObject( const OUString& rClassifiedIdentifier return bReturn; } -bool ObjectIdentifier::isMultiClickObject( const OUString& rClassifiedIdentifier ) +bool ObjectIdentifier::isMultiClickObject( std::u16string_view rClassifiedIdentifier ) { //the name of a shape is it's ClassifiedIdentifier @@ -742,7 +743,7 @@ bool ObjectIdentifier::isMultiClickObject( const OUString& rClassifiedIdentifier //was selected before; //!!!!! by definition the name of a MultiClickObject starts with "CID/MultiClick:" - bool bRet = rClassifiedIdentifier.match( m_aMultiClick, strlen(m_aProtocol) ); + bool bRet = o3tl::starts_with(rClassifiedIdentifier.substr( std::size(m_aProtocol)-1 ), m_aMultiClick); return bRet; } @@ -877,69 +878,70 @@ OUString ObjectIdentifier::getStringForType( ObjectType eObjectType ) return aRet; } -ObjectType ObjectIdentifier::getObjectType( const OUString& rCID ) +ObjectType ObjectIdentifier::getObjectType( std::u16string_view aCID ) { ObjectType eRet; - sal_Int32 nLastSign = rCID.lastIndexOf( ':' );//last sign before the type string - if(nLastSign==-1) - nLastSign = rCID.lastIndexOf( '/' ); - if(nLastSign==-1) + size_t nLastSign = aCID.rfind( ':' );//last sign before the type string + if(nLastSign == std::u16string_view::npos) + nLastSign = aCID.rfind( '/' ); + if(nLastSign == std::u16string_view::npos) { - sal_Int32 nEndIndex = rCID.lastIndexOf( '=' ); - if(nEndIndex==-1) + size_t nEndIndex = aCID.rfind( '=' ); + if(nEndIndex == std::u16string_view::npos) return OBJECTTYPE_UNKNOWN; nLastSign = 0; } if( nLastSign>0 ) nLastSign++; - if( rCID.match("Page",nLastSign) ) + aCID = aCID.substr(nLastSign); + if( o3tl::starts_with(aCID, u"Page") ) eRet = OBJECTTYPE_PAGE; - else if( rCID.match("Title",nLastSign) ) + else if( o3tl::starts_with(aCID, u"Title") ) eRet = OBJECTTYPE_TITLE; - else if( rCID.match("LegendEntry",nLastSign) ) + else if( o3tl::starts_with(aCID, u"LegendEntry") ) eRet = OBJECTTYPE_LEGEND_ENTRY; - else if( rCID.match("Legend",nLastSign) ) + else if( o3tl::starts_with(aCID, u"Legend") ) eRet = OBJECTTYPE_LEGEND; - else if( rCID.match("DiagramWall",nLastSign) ) + else if( o3tl::starts_with(aCID, u"DiagramWall") ) eRet = OBJECTTYPE_DIAGRAM_WALL; - else if( rCID.match("DiagramFloor",nLastSign) ) + else if( o3tl::starts_with(aCID, u"DiagramFloor") ) eRet = OBJECTTYPE_DIAGRAM_FLOOR; - else if( rCID.match("D=",nLastSign) ) + else if( o3tl::starts_with(aCID, u"D=") ) eRet = OBJECTTYPE_DIAGRAM; - else if( rCID.match("AxisUnitLabel",nLastSign) ) + else if( o3tl::starts_with(aCID, u"AxisUnitLabel") ) eRet = OBJECTTYPE_AXIS_UNITLABEL; - else if( rCID.match("Axis",nLastSign) ) + else if( o3tl::starts_with(aCID, u"Axis") ) eRet = OBJECTTYPE_AXIS; - else if( rCID.match("Grid",nLastSign) ) + else if( o3tl::starts_with(aCID, u"Grid") ) eRet = OBJECTTYPE_GRID; - else if( rCID.match("SubGrid",nLastSign) ) + else if( o3tl::starts_with(aCID, u"SubGrid") ) eRet = OBJECTTYPE_SUBGRID; - else if( rCID.match("Series",nLastSign) ) + else if( o3tl::starts_with(aCID, u"Series") ) eRet = OBJECTTYPE_DATA_SERIES; - else if( rCID.match("Point",nLastSign) ) + else if( o3tl::starts_with(aCID, u"Point") ) eRet = OBJECTTYPE_DATA_POINT; - else if( rCID.match("DataLabels",nLastSign) ) + else if( o3tl::starts_with(aCID, u"DataLabels") ) eRet = OBJECTTYPE_DATA_LABELS; - else if( rCID.match("DataLabel",nLastSign) ) + else if( o3tl::starts_with(aCID, u"DataLabel") ) eRet = OBJECTTYPE_DATA_LABEL; - else if( rCID.match("ErrorsX",nLastSign) ) + else if( o3tl::starts_with(aCID, u"ErrorsX") ) eRet = OBJECTTYPE_DATA_ERRORS_X; - else if( rCID.match("ErrorsY",nLastSign) ) + else if( o3tl::starts_with(aCID, u"ErrorsY") ) eRet = OBJECTTYPE_DATA_ERRORS_Y; - else if( rCID.match("ErrorsZ",nLastSign) ) + else if( o3tl::starts_with(aCID, u"ErrorsZ") ) eRet = OBJECTTYPE_DATA_ERRORS_Z; - else if( rCID.match("Curve",nLastSign) ) + else if( o3tl::starts_with(aCID, u"Curve") ) eRet = OBJECTTYPE_DATA_CURVE; - else if( rCID.match("Equation",nLastSign) ) + else if( o3tl::starts_with(aCID, u"Equation") ) eRet = OBJECTTYPE_DATA_CURVE_EQUATION; - else if( rCID.match("Average",nLastSign) ) + else if( o3tl::starts_with(aCID, u"Average") ) eRet = OBJECTTYPE_DATA_AVERAGE_LINE; - else if( rCID.match("StockRange",nLastSign) ) + else if( o3tl::starts_with(aCID, u"StockRange") ) eRet = OBJECTTYPE_DATA_STOCK_RANGE; - else if( rCID.match("StockLoss",nLastSign) ) + else if( o3tl::starts_with(aCID, u"StockLoss") ) eRet = OBJECTTYPE_DATA_STOCK_LOSS; - else if( rCID.match("StockGain",nLastSign) ) + else if( o3tl::starts_with(aCID, u"StockGain") ) eRet = OBJECTTYPE_DATA_STOCK_GAIN; else eRet = OBJECTTYPE_UNKNOWN; @@ -1009,7 +1011,7 @@ sal_Int32 ObjectIdentifier::getIndexFromParticleOrCID( const OUString& rParticle } OUString ObjectIdentifier::createSeriesSubObjectStub( ObjectType eSubObjectType - , const OUString& rSeriesParticle + , std::u16string_view rSeriesParticle , std::u16string_view rDragMethodServiceName , std::u16string_view rDragParameterString ) { @@ -1067,9 +1069,9 @@ OUString ObjectIdentifier::getObjectID( const OUString& rCID ) return aRet; } -bool ObjectIdentifier::isCID( const OUString& rName ) +bool ObjectIdentifier::isCID( std::u16string_view rName ) { - return !rName.isEmpty() && rName.match( m_aProtocol ); + return !rName.empty() && o3tl::starts_with( rName, m_aProtocol ); } Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet( diff --git a/chart2/source/tools/PropertyHelper.cxx b/chart2/source/tools/PropertyHelper.cxx index cb3e860c0350..9718cbfa676f 100644 --- a/chart2/source/tools/PropertyHelper.cxx +++ b/chart2/source/tools/PropertyHelper.cxx @@ -23,6 +23,7 @@ #include <comphelper/sequence.hxx> #include <osl/diagnose.h> #include <tools/diagnose_ex.h> +#include <o3tl/string_view.hxx> #include <vector> #include <algorithm> @@ -67,9 +68,9 @@ struct lcl_StringMatches m_aCmpStr( rCmpStr ) {} - bool operator() ( const OUString & rStr ) + bool operator() ( std::u16string_view rStr ) { - return rStr.match( m_aCmpStr ); + return o3tl::starts_with( rStr, m_aCmpStr ); } private: |