summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-11-06 20:01:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-11-11 11:58:37 +0100
commit93c64a61f2c84e684050294a1391cd32425b7837 (patch)
tree00aad2cb8f3ee29ba4ac99e159e26fb8d71d2f33 /framework
parent1fde62018c8d3344a3408c7b6317120aefc778fb (diff)
loplugin:stringview
Add new methods "subView" to O(U)String to return substring views of the underlying data. Add a clang plugin to warn when replacing existing calls to copy() would be better to use subView(). Change-Id: I03a5732431ce60808946f2ce2c923b22845689ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105420 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework')
-rw-r--r--framework/source/dispatch/popupmenudispatcher.cxx4
-rw-r--r--framework/source/fwe/xml/xmlnamespaces.cxx4
-rw-r--r--framework/source/uielement/generictoolbarcontroller.cxx6
-rw-r--r--framework/source/uielement/menubarmanager.cxx10
4 files changed, 12 insertions, 12 deletions
diff --git a/framework/source/dispatch/popupmenudispatcher.cxx b/framework/source/dispatch/popupmenudispatcher.cxx
index 991c8af1b555..16b0fbd678cc 100644
--- a/framework/source/dispatch/popupmenudispatcher.cxx
+++ b/framework/source/dispatch/popupmenudispatcher.cxx
@@ -129,9 +129,9 @@ SAL_CALL PopupMenuDispatcher::queryDispatch(
{
sal_Int32 nQueryPart = aURL.indexOf( '?', nSchemePart );
if ( nQueryPart > 0 )
- aBaseURL += aURL.copy( nSchemePart+1, nQueryPart-(nSchemePart+1) );
+ aBaseURL += aURL.subView( nSchemePart+1, nQueryPart-(nSchemePart+1) );
else if ( nQueryPart == -1 )
- aBaseURL += aURL.copy( nSchemePart+1 );
+ aBaseURL += aURL.subView( nSchemePart+1 );
}
css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider;
diff --git a/framework/source/fwe/xml/xmlnamespaces.cxx b/framework/source/fwe/xml/xmlnamespaces.cxx
index dfd79edde6b0..7faa6c48d8b6 100644
--- a/framework/source/fwe/xml/xmlnamespaces.cxx
+++ b/framework/source/fwe/xml/xmlnamespaces.cxx
@@ -89,7 +89,7 @@ OUString XMLNamespaces::applyNSToAttributeName( const OUString& aName ) const
// attribute with namespace but without name "namespace:" is not allowed!!
throw SAXException( "Attribute has no name only preceding namespace!", Reference< XInterface >(), Any() );
}
- OUString aAttributeName = getNamespaceValue( aName.copy( 0, index )) + "^" + aName.copy( index+1);
+ OUString aAttributeName = getNamespaceValue( aName.copy( 0, index )) + "^" + aName.subView( index+1);
return aAttributeName;
}
@@ -123,7 +123,7 @@ OUString XMLNamespaces::applyNSToElementName( const OUString& aName ) const
// attribute with namespace but without a name is not allowed (e.g. "cfg:" )
throw SAXException( "Attribute has no name only preceding namespace!", Reference< XInterface >(), Any() );
}
- aElementName += aName.copy( index+1 );
+ aElementName += aName.subView( index+1 );
}
else
aElementName += aName;
diff --git a/framework/source/uielement/generictoolbarcontroller.cxx b/framework/source/uielement/generictoolbarcontroller.cxx
index f8dc874b2902..c6fec020f502 100644
--- a/framework/source/uielement/generictoolbarcontroller.cxx
+++ b/framework/source/uielement/generictoolbarcontroller.cxx
@@ -240,15 +240,15 @@ void GenericToolbarController::statusChanged( const FeatureStateEvent& Event )
// Replacement for place holders
if ( aStrValue.startsWith("($1)") )
{
- aStrValue = FwkResId(STR_UPDATEDOC) + " " + aStrValue.copy( 4 );
+ aStrValue = FwkResId(STR_UPDATEDOC) + " " + aStrValue.subView( 4 );
}
else if ( aStrValue.startsWith("($2)") )
{
- aStrValue = FwkResId(STR_CLOSEDOC_ANDRETURN) + aStrValue.copy( 4 );
+ aStrValue = FwkResId(STR_CLOSEDOC_ANDRETURN) + aStrValue.subView( 4 );
}
else if ( aStrValue.startsWith("($3)") )
{
- aStrValue = FwkResId(STR_SAVECOPYDOC) + aStrValue.copy( 4 );
+ aStrValue = FwkResId(STR_SAVECOPYDOC) + aStrValue.subView( 4 );
}
m_xToolbar->SetItemText( m_nID, aStrValue );
// tdf#124267 strip mnemonic from tooltip
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index cff2f23a2178..f9bd9f2312ba 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -331,15 +331,15 @@ void SAL_CALL MenuBarManager::statusChanged( const FeatureStateEvent& Event )
// Replacement for place holders
if ( aItemText.startsWith("($1)") )
{
- aItemText = FwkResId(STR_UPDATEDOC) + " " + aItemText.copy( 4 );
+ aItemText = FwkResId(STR_UPDATEDOC) + " " + aItemText.subView( 4 );
}
else if ( aItemText.startsWith("($2)") )
{
- aItemText = FwkResId(STR_CLOSEDOC_ANDRETURN) + aItemText.copy( 4 );
+ aItemText = FwkResId(STR_CLOSEDOC_ANDRETURN) + aItemText.subView( 4 );
}
else if ( aItemText.startsWith("($3)") )
{
- aItemText = FwkResId(STR_SAVECOPYDOC) + aItemText.copy( 4 );
+ aItemText = FwkResId(STR_SAVECOPYDOC) + aItemText.subView( 4 );
}
m_pVCLMenu->SetItemText( menuItemHandler->nItemId, aItemText );
@@ -1506,9 +1506,9 @@ void MenuBarManager::GetPopupController( PopupControllerCache& rPopupController
OUString aMainURL( "vnd.sun.star.popup:" );
sal_Int32 nQueryPart = aMenuURL.indexOf( '?', nSchemePart );
if ( nQueryPart > 0 )
- aMainURL += aMenuURL.copy( nSchemePart, nQueryPart-nSchemePart );
+ aMainURL += aMenuURL.subView( nSchemePart, nQueryPart-nSchemePart );
else if ( nQueryPart == -1 )
- aMainURL += aMenuURL.copy( nSchemePart+1 );
+ aMainURL += aMenuURL.subView( nSchemePart+1 );
rPopupController.emplace( aMainURL, aPopupControllerEntry );
}