From 7840effb1d5efd1fd7f6798c7c504b05292a7793 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 22 Feb 2024 12:59:26 +0200 Subject: use more string_view found by tweaking the stringview loplugin Change-Id: I92203ba99642bef7951ffa146184c5562cb31d09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163744 Tested-by: Jenkins Reviewed-by: Noel Grandin --- test/source/screenshot_test.cxx | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/source/screenshot_test.cxx b/test/source/screenshot_test.cxx index b4c188fdbc34..9b85338303a0 100644 --- a/test/source/screenshot_test.cxx +++ b/test/source/screenshot_test.cxx @@ -24,15 +24,23 @@ namespace { - void splitHelpId( const OUString& rHelpId, OUString& rDirname, OUString &rBasename ) + void splitHelpId( std::u16string_view rHelpId, std::u16string_view& rDirname, std::u16string_view& rBasename ) { - sal_Int32 nIndex = rHelpId.lastIndexOf( '/' ); + size_t nIndex = rHelpId.rfind( '/' ); - if( nIndex > 0 ) - rDirname = rHelpId.subView( 0, nIndex ); + if( nIndex != 0 && nIndex != std::u16string_view::npos) + rDirname = rHelpId.substr( 0, nIndex ); - if( rHelpId.getLength() > nIndex+1 ) - rBasename = rHelpId.subView( nIndex+1 ); + if (nIndex == std::u16string_view::npos) + { + if( rHelpId.size() > 0 ) + rBasename = rHelpId; + } + else + { + if( rHelpId.size() > nIndex+1 ) + rBasename = rHelpId.substr( nIndex+1 ); + } } } @@ -71,11 +79,11 @@ void ScreenshotTest::setUp() } } -void ScreenshotTest::implSaveScreenshot(const BitmapEx& rScreenshot, const OUString& rScreenshotId) +void ScreenshotTest::implSaveScreenshot(const BitmapEx& rScreenshot, std::u16string_view rScreenshotId) { - OUString aDirname, aBasename; - splitHelpId(rScreenshotId, aDirname, aBasename); - aDirname = g_aScreenshotDirectory + "/" + aDirname + + std::u16string_view aSplitDirname, aBasename; + splitHelpId(rScreenshotId, aSplitDirname, aBasename); + OUString aDirname = g_aScreenshotDirectory + "/" + aSplitDirname + ( (maCurrentLanguage == "en-US") ? OUString() : "/" + maCurrentLanguage ); auto const dirUrl = m_directories.getURLFromWorkdir(aDirname); -- cgit