include/vcl/IconThemeInfo.hxx | 4 +- include/vcl/font/FeatureParser.hxx | 2 - include/vcl/i18nhelp.hxx | 2 - vcl/inc/sallayout.hxx | 2 - vcl/qa/cppunit/FontFeatureTest.cxx | 42 +++++++++++++-------------- vcl/qa/cppunit/app/test_IconThemeInfo.cxx | 10 +++--- vcl/qa/cppunit/app/test_IconThemeScanner.cxx | 4 +- vcl/source/app/IconThemeInfo.cxx | 26 ++++++++-------- vcl/source/app/i18nhelp.cxx | 8 ++--- vcl/source/control/field2.cxx | 12 +++---- vcl/source/font/FeatureParser.cxx | 8 ++--- vcl/source/gdi/CommonSalLayout.cxx | 2 - vcl/source/image/ImplImageTree.cxx | 23 +++++++------- 13 files changed, 73 insertions(+), 72 deletions(-)
New commits: commit 239752d358a44d9bd9e5e2a9b7e6084da97d8862 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Apr 13 14:32:50 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Apr 13 16:55:54 2022 +0200 use more string_view in vcl Change-Id: Iabe6c14d17c7805fcc3697cd919234abe3f0a0f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132963 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/vcl/IconThemeInfo.hxx b/include/vcl/IconThemeInfo.hxx index ec116ca2f4fc..f061821ceaa1 100644 --- a/include/vcl/IconThemeInfo.hxx +++ b/include/vcl/IconThemeInfo.hxx @@ -51,7 +51,7 @@ public: static Size SizeByThemeName(std::u16string_view); /** Check whether an IconThemeInfo can be constructed from a URL */ - static bool UrlCanBeParsed(const OUString& url); + static bool UrlCanBeParsed(std::u16string_view url); /** Find an icon theme by its id in a vector. * Throws a runtime_error if the theme is not contained in the vector @@ -73,7 +73,7 @@ private: * If the name does not have an underscore in it, the whole name until the last dot is returned, * e.g. default.zip becomes default */ - static OUString FileNameToThemeId(const OUString&); + static OUString FileNameToThemeId(std::u16string_view); /** Creates the display name for the given id of a file. * Currently, we only uppercase the id. diff --git a/include/vcl/font/FeatureParser.hxx b/include/vcl/font/FeatureParser.hxx index 3662c6a20baf..93fe6eabe261 100644 --- a/include/vcl/font/FeatureParser.hxx +++ b/include/vcl/font/FeatureParser.hxx @@ -32,7 +32,7 @@ private: std::vector<FeatureSetting> m_aFeatures; public: - FeatureParser(OUString const& sFontName); + FeatureParser(std::u16string_view sFontName); OUString const& getLanguage() const { return m_sLanguage; } diff --git a/include/vcl/i18nhelp.hxx b/include/vcl/i18nhelp.hxx index f48d562c40a9..e5368da08547 100644 --- a/include/vcl/i18nhelp.hxx +++ b/include/vcl/i18nhelp.hxx @@ -63,7 +63,7 @@ public: sal_Int32 CompareString( const OUString& rStr1, const OUString& rStr2 ) const; bool MatchString( const OUString& rStr1, const OUString& rStr2 ) const; - bool MatchMnemonic( const OUString& rString, sal_Unicode cMnemonicChar ) const; + bool MatchMnemonic( std::u16string_view rString, sal_Unicode cMnemonicChar ) const; OUString GetNum( tools::Long nNumber, sal_uInt16 nDecimals, bool bUseThousandSep = true, bool bTrailingZeros = true ) const; diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 75110158dc53..894be0a3098b 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -154,7 +154,7 @@ private: bool HasVerticalAlternate(sal_UCS4 aChar, sal_UCS4 aNextChar); - void ParseFeatures(const OUString& name); + void ParseFeatures(std::u16string_view name); css::uno::Reference<css::i18n::XBreakIterator> mxBreak; diff --git a/vcl/qa/cppunit/FontFeatureTest.cxx b/vcl/qa/cppunit/FontFeatureTest.cxx index 091654b8a87a..0e9ada19cdd4 100644 --- a/vcl/qa/cppunit/FontFeatureTest.cxx +++ b/vcl/qa/cppunit/FontFeatureTest.cxx @@ -128,11 +128,11 @@ void FontFeatureTest::testGetFontFeatures() void FontFeatureTest::testParseFeature() { { // No font features specified - vcl::font::FeatureParser aParser("Font name with no features"); + vcl::font::FeatureParser aParser(u"Font name with no features"); CPPUNIT_ASSERT_EQUAL(size_t(0), aParser.getFeatures().size()); } { // One feature specified, no value - vcl::font::FeatureParser aParser("Font name:abcd"); + vcl::font::FeatureParser aParser(u"Font name:abcd"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -140,7 +140,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue); } { // One feature specified, explicit value - vcl::font::FeatureParser aParser("Font name:abcd=5"); + vcl::font::FeatureParser aParser(u"Font name:abcd=5"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -148,7 +148,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(uint32_t(5), aFeatures[0].m_nValue); } { // One feature specified, explicit zero value - vcl::font::FeatureParser aParser("Font name:abcd=0"); + vcl::font::FeatureParser aParser(u"Font name:abcd=0"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -156,7 +156,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures[0].m_nValue); } { // One feature specified, using plus prefix - vcl::font::FeatureParser aParser("Font name:+abcd"); + vcl::font::FeatureParser aParser(u"Font name:+abcd"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -164,7 +164,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue); } { // One feature specified, using minus prefix - vcl::font::FeatureParser aParser("Font name:-abcd"); + vcl::font::FeatureParser aParser(u"Font name:-abcd"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -172,7 +172,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures[0].m_nValue); } { // One feature specified, with empty character range - vcl::font::FeatureParser aParser("Font name:abcd[]"); + vcl::font::FeatureParser aParser(u"Font name:abcd[]"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -182,7 +182,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(-1), aFeatures[0].m_nEnd); } { // One feature specified, with empty character range - vcl::font::FeatureParser aParser("Font name:abcd[:]"); + vcl::font::FeatureParser aParser(u"Font name:abcd[:]"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -192,7 +192,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(-1), aFeatures[0].m_nEnd); } { // One feature specified, with start character range - vcl::font::FeatureParser aParser("Font name:abcd[3:]"); + vcl::font::FeatureParser aParser(u"Font name:abcd[3:]"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -202,7 +202,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(-1), aFeatures[0].m_nEnd); } { // One feature specified, with end character range - vcl::font::FeatureParser aParser("Font name:abcd[:3]"); + vcl::font::FeatureParser aParser(u"Font name:abcd[:3]"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -212,7 +212,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(3), aFeatures[0].m_nEnd); } { // One feature specified, with character range - vcl::font::FeatureParser aParser("Font name:abcd[3:6]"); + vcl::font::FeatureParser aParser(u"Font name:abcd[3:6]"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -222,7 +222,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), aFeatures[0].m_nEnd); } { // One feature specified, with character range - vcl::font::FeatureParser aParser("Font name:abcd[3]"); + vcl::font::FeatureParser aParser(u"Font name:abcd[3]"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -232,7 +232,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(4), aFeatures[0].m_nEnd); } { // One feature specified, with character range and value - vcl::font::FeatureParser aParser("Font name:abcd[3:6]=2"); + vcl::font::FeatureParser aParser(u"Font name:abcd[3:6]=2"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -242,7 +242,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), aFeatures[0].m_nEnd); } { // One feature specified, with character range and 0 value - vcl::font::FeatureParser aParser("Font name:abcd[3:6]=0"); + vcl::font::FeatureParser aParser(u"Font name:abcd[3:6]=0"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -252,7 +252,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), aFeatures[0].m_nEnd); } { // One feature specified, with character range and minus prefix - vcl::font::FeatureParser aParser("Font name:-abcd[3:6]"); + vcl::font::FeatureParser aParser(u"Font name:-abcd[3:6]"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -262,7 +262,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), aFeatures[0].m_nEnd); } { // One feature specified, with CSS on - vcl::font::FeatureParser aParser("Font name:\"abcd\" on"); + vcl::font::FeatureParser aParser(u"Font name:\"abcd\" on"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -270,7 +270,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(uint32_t(1), aFeatures[0].m_nValue); } { // One feature specified, with CSS off - vcl::font::FeatureParser aParser("Font name:'abcd' off"); + vcl::font::FeatureParser aParser(u"Font name:'abcd' off"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -278,7 +278,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(uint32_t(0), aFeatures[0].m_nValue); } { // One feature specified, with CSS value - vcl::font::FeatureParser aParser("Font name:\"abcd\" 2"); + vcl::font::FeatureParser aParser(u"Font name:\"abcd\" 2"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -286,7 +286,7 @@ void FontFeatureTest::testParseFeature() CPPUNIT_ASSERT_EQUAL(uint32_t(2), aFeatures[0].m_nValue); } { // Multiple features specified, no values - vcl::font::FeatureParser aParser("Font name:abcd&bcde&efgh"); + vcl::font::FeatureParser aParser(u"Font name:abcd&bcde&efgh"); CPPUNIT_ASSERT_EQUAL(size_t(3), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -302,7 +302,7 @@ void FontFeatureTest::testParseFeature() { // Multiple features specified, explicit values // Only 4 char parameter names supported - "toolong" is too long and ignored - vcl::font::FeatureParser aParser("Font name:abcd=1&bcde=0&toolong=1&cdef=3"); + vcl::font::FeatureParser aParser(u"Font name:abcd=1&bcde=0&toolong=1&cdef=3"); CPPUNIT_ASSERT_EQUAL(size_t(3), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); @@ -318,7 +318,7 @@ void FontFeatureTest::testParseFeature() { // Special case - "lang" is parsed specially and access separately not as a feature. - vcl::font::FeatureParser aParser("Font name:abcd=1&lang=slo"); + vcl::font::FeatureParser aParser(u"Font name:abcd=1&lang=slo"); CPPUNIT_ASSERT_EQUAL(size_t(1), aParser.getFeatures().size()); auto aFeatures = aParser.getFeatures(); diff --git a/vcl/qa/cppunit/app/test_IconThemeInfo.cxx b/vcl/qa/cppunit/app/test_IconThemeInfo.cxx index a68df2f78b9e..ff1ad985b156 100644 --- a/vcl/qa/cppunit/app/test_IconThemeInfo.cxx +++ b/vcl/qa/cppunit/app/test_IconThemeInfo.cxx @@ -61,21 +61,21 @@ IconThemeInfoTest::UpperCaseDisplayNameIsReturnedForNonDefaultId() void IconThemeInfoTest::ImagesZipIsNotValid() { - bool valid = vcl::IconThemeInfo::UrlCanBeParsed("file://images.zip"); + bool valid = vcl::IconThemeInfo::UrlCanBeParsed(u"file://images.zip"); CPPUNIT_ASSERT_EQUAL_MESSAGE("images.zip is not a valid theme name", false, valid); } void IconThemeInfoTest::ImagesColibreZipIsValid() { - bool valid = vcl::IconThemeInfo::UrlCanBeParsed("file://images_colibre.zip"); + bool valid = vcl::IconThemeInfo::UrlCanBeParsed(u"file://images_colibre.zip"); CPPUNIT_ASSERT_EQUAL_MESSAGE("images_colibre.zip is a valid theme name", true, valid); } void IconThemeInfoTest::ThemeIdIsDetectedFromFileNameWithUnderscore() { - OUString sname = vcl::IconThemeInfo::FileNameToThemeId("images_colibre.zip"); + OUString sname = vcl::IconThemeInfo::FileNameToThemeId(u"images_colibre.zip"); CPPUNIT_ASSERT_EQUAL_MESSAGE("'colibre' theme id is returned for 'images_colibre.zip'", OUString("colibre"), sname); } @@ -84,7 +84,7 @@ IconThemeInfoTest::ExceptionIsThrownWhenIdCannotBeDetermined1() { bool thrown = false; try { - vcl::IconThemeInfo::FileNameToThemeId("images_colibre"); + vcl::IconThemeInfo::FileNameToThemeId(u"images_colibre"); } catch (std::runtime_error&) { thrown = true; @@ -97,7 +97,7 @@ IconThemeInfoTest::ExceptionIsThrownWhenIdCannotBeDetermined2() { bool thrown = false; try { - vcl::IconThemeInfo::FileNameToThemeId("image_colibre.zip"); + vcl::IconThemeInfo::FileNameToThemeId(u"image_colibre.zip"); } catch (std::runtime_error&) { thrown = true; diff --git a/vcl/qa/cppunit/app/test_IconThemeScanner.cxx b/vcl/qa/cppunit/app/test_IconThemeScanner.cxx index f65e70bc6bdd..d02fe752ce51 100644 --- a/vcl/qa/cppunit/app/test_IconThemeScanner.cxx +++ b/vcl/qa/cppunit/app/test_IconThemeScanner.cxx @@ -43,7 +43,7 @@ IconThemeScannerTest::AddedThemeIsFoundById() { vcl::IconThemeScanner scanner; scanner.AddIconThemeByPath("file:://images_katze.zip"); - OUString id = vcl::IconThemeInfo::FileNameToThemeId("images_katze.zip"); + OUString id = vcl::IconThemeInfo::FileNameToThemeId(u"images_katze.zip"); bool found = scanner.IconThemeIsInstalled(id); CPPUNIT_ASSERT_EQUAL_MESSAGE("icon theme could be added by url", true, found); } @@ -54,7 +54,7 @@ IconThemeScannerTest::AddedThemeInfoIsReturned() vcl::IconThemeScanner scanner; OUString theme("file:://images_katze.zip"); scanner.AddIconThemeByPath(theme); - OUString id = vcl::IconThemeInfo::FileNameToThemeId("images_katze.zip"); + OUString id = vcl::IconThemeInfo::FileNameToThemeId(u"images_katze.zip"); const vcl::IconThemeInfo& info = scanner.GetIconThemeInfo(id); CPPUNIT_ASSERT_EQUAL_MESSAGE("'katze' icon theme is found from id", theme, info.GetUrlToFile()); } diff --git a/vcl/source/app/IconThemeInfo.cxx b/vcl/source/app/IconThemeInfo.cxx index 139181e65a1a..4a5ff157cfa9 100644 --- a/vcl/source/app/IconThemeInfo.cxx +++ b/vcl/source/app/IconThemeInfo.cxx @@ -23,13 +23,13 @@ constexpr OUStringLiteral KARASA_JAGA_DISPLAY_NAME(u"Karasa Jaga"); constexpr OUStringLiteral HELPIMG_FAKE_THEME(u"helpimg"); OUString -filename_from_url(const OUString& url) +filename_from_url(std::u16string_view url) { - sal_Int32 slashPosition = url.lastIndexOf( '/' ); - if (slashPosition < 0) { + size_t slashPosition = url.rfind( '/' ); + if (slashPosition == std::u16string_view::npos) { return OUString(); } - OUString filename = url.copy( slashPosition+1 ); + OUString filename( url.substr( slashPosition+1 ) ); return filename; } @@ -37,9 +37,9 @@ filename_from_url(const OUString& url) namespace vcl { -const char ICON_THEME_PACKAGE_PREFIX[] = "images_"; +const sal_Unicode ICON_THEME_PACKAGE_PREFIX[] = u"images_"; -const char EXTENSION_FOR_ICON_PACKAGES[] = ".zip"; +const sal_Unicode EXTENSION_FOR_ICON_PACKAGES[] = u".zip"; IconThemeInfo::IconThemeInfo() { @@ -70,7 +70,7 @@ IconThemeInfo::SizeByThemeName(std::u16string_view themeName) } /*static*/ bool -IconThemeInfo::UrlCanBeParsed(const OUString& url) +IconThemeInfo::UrlCanBeParsed(std::u16string_view url) { OUString fname = filename_from_url(url); if (fname.isEmpty()) { @@ -93,19 +93,19 @@ IconThemeInfo::UrlCanBeParsed(const OUString& url) } /*static*/ OUString -IconThemeInfo::FileNameToThemeId(const OUString& filename) +IconThemeInfo::FileNameToThemeId(std::u16string_view filename) { OUString r; - sal_Int32 positionOfLastDot = filename.lastIndexOf(EXTENSION_FOR_ICON_PACKAGES); - if (positionOfLastDot < 0) { // -1 means index not found + size_t positionOfLastDot = filename.rfind(EXTENSION_FOR_ICON_PACKAGES); + if (positionOfLastDot == std::u16string_view::npos) { // means index not found throw std::runtime_error("IconThemeInfo::FileNameToThemeId() called with invalid filename."); } - sal_Int32 positionOfFirstUnderscore = filename.indexOf(ICON_THEME_PACKAGE_PREFIX); - if (positionOfFirstUnderscore < 0) { // -1 means index not found. Use the whole name instead + size_t positionOfFirstUnderscore = filename.find(ICON_THEME_PACKAGE_PREFIX); + if (positionOfFirstUnderscore == std::u16string_view::npos) { // means index not found. Use the whole name instead throw std::runtime_error("IconThemeInfo::FileNameToThemeId() called with invalid filename."); } positionOfFirstUnderscore += RTL_CONSTASCII_LENGTH(ICON_THEME_PACKAGE_PREFIX); - r = filename.copy(positionOfFirstUnderscore, positionOfLastDot - positionOfFirstUnderscore); + r = filename.substr(positionOfFirstUnderscore, positionOfLastDot - positionOfFirstUnderscore); return r; } diff --git a/vcl/source/app/i18nhelp.cxx b/vcl/source/app/i18nhelp.cxx index 1cff03689ec5..1ed017b77895 100644 --- a/vcl/source/app/i18nhelp.cxx +++ b/vcl/source/app/i18nhelp.cxx @@ -138,12 +138,12 @@ bool vcl::I18nHelper::MatchString( const OUString& rStr1, const OUString& rStr2 return ImplGetTransliterationWrapper().isMatch( aStr1, aStr2 ); } -bool vcl::I18nHelper::MatchMnemonic( const OUString& rString, sal_Unicode cMnemonicChar ) const +bool vcl::I18nHelper::MatchMnemonic( std::u16string_view rString, sal_Unicode cMnemonicChar ) const { - sal_Int32 n = rString.indexOf( '~' ); - if ( n == -1 ) + size_t n = rString.find( '~' ); + if ( n == std::u16string_view::npos ) return false; - OUString aMatchStr = rString.copy( n+1 ); // not only one char, because of transliteration... + OUString aMatchStr( rString.substr( n+1 ) ); // not only one char, because of transliteration... return MatchString( OUString(cMnemonicChar), aMatchStr ); } diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index b3f132014a71..d3649ee4fa7c 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -522,7 +522,7 @@ namespace static bool ImplPatternProcessKeyInput( IEditImplementation& rEdit, const KeyEvent& rKEvt, const OString& rEditMask, - const OUString& rLiteralMask, + std::u16string_view rLiteralMask, bool bStrictFormat, bool bSameMask, bool& rbInKeyInput ) @@ -619,8 +619,8 @@ static bool ImplPatternProcessKeyInput( IEditImplementation& rEdit, const KeyEve aStr.remove( static_cast<sal_Int32>(aSel.Min()), static_cast<sal_Int32>(aSel.Len()) ); else { - OUString aRep = rLiteralMask.copy( static_cast<sal_Int32>(aSel.Min()), static_cast<sal_Int32>(aSel.Len()) ); - aStr.remove( aSel.Min(), aRep.getLength() ); + std::u16string_view aRep = rLiteralMask.substr( static_cast<sal_Int32>(aSel.Min()), static_cast<sal_Int32>(aSel.Len()) ); + aStr.remove( aSel.Min(), aRep.size() ); aStr.insert( aSel.Min(), aRep ); } } @@ -749,7 +749,7 @@ static bool ImplPatternProcessKeyInput( IEditImplementation& rEdit, const KeyEve { // possibly extend string until cursor position if ( aStr.getLength() < nNewPos ) - aStr.append( rLiteralMask.subView(aStr.getLength(), nNewPos-aStr.getLength()) ); + aStr.append( rLiteralMask.substr(aStr.getLength(), nNewPos-aStr.getLength()) ); if ( nNewPos < aStr.getLength() ) aStr.insert( cChar, nNewPos ); else if ( nNewPos < rEditMask.getLength() ) @@ -764,8 +764,8 @@ static bool ImplPatternProcessKeyInput( IEditImplementation& rEdit, const KeyEve if ( aSel.Len() ) { // delete selection - OUString aRep = rLiteralMask.copy( aSel.Min(), aSel.Len() ); - aStr.remove( aSel.Min(), aRep.getLength() ); + std::u16string_view aRep = rLiteralMask.substr( aSel.Min(), aSel.Len() ); + aStr.remove( aSel.Min(), aRep.size() ); aStr.insert( aSel.Min(), aRep ); } diff --git a/vcl/source/font/FeatureParser.cxx b/vcl/source/font/FeatureParser.cxx index c886482dfd96..32e407671336 100644 --- a/vcl/source/font/FeatureParser.cxx +++ b/vcl/source/font/FeatureParser.cxx @@ -23,14 +23,14 @@ OUString trimFontNameFeatures(OUString const& rFontName) return rFontName.copy(0, nPrefixIdx); } -FeatureParser::FeatureParser(OUString const& rFontName) +FeatureParser::FeatureParser(std::u16string_view rFontName) { - sal_Int32 nPrefixIdx{ rFontName.indexOf(vcl::font::FeaturePrefix) }; + size_t nPrefixIdx{ rFontName.find(vcl::font::FeaturePrefix) }; - if (nPrefixIdx < 0) + if (nPrefixIdx == std::u16string_view::npos) return; - OUString sName = rFontName.copy(++nPrefixIdx); + OUString sName(rFontName.substr(++nPrefixIdx)); sal_Int32 nIndex = 0; do { diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index edf5538e49e0..96db59fa048f 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -73,7 +73,7 @@ GenericSalLayout::~GenericSalLayout() { } -void GenericSalLayout::ParseFeatures(const OUString& aName) +void GenericSalLayout::ParseFeatures(std::u16string_view aName) { vcl::font::FeatureParser aParser(aName); const OUString& sLanguage = aParser.getLanguage(); diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx index 3979206cb184..eb6dd1ecc4d8 100644 --- a/vcl/source/image/ImplImageTree.cxx +++ b/vcl/source/image/ImplImageTree.cxx @@ -54,7 +54,7 @@ #include <vcl/filter/PngImageReader.hxx> #include <vcl/outdev.hxx> #include <vcl/pngwrite.hxx> - +#include <o3tl/string_view.hxx> #include <bitmap/BitmapLightenFilter.hxx> #include <o3tl/string_view.hxx> @@ -84,17 +84,18 @@ sal_Int32 ImageRequestParameters::scalePercentage() namespace { -OUString convertLcTo32Path(OUString const & rPath) +OUString convertLcTo32Path(std::u16string_view rPath) { OUString aResult; - if (rPath.lastIndexOf('/') != -1) + size_t nSlashPos = rPath.rfind('/'); + if (nSlashPos != std::u16string_view::npos) { - sal_Int32 nCopyFrom = rPath.lastIndexOf('/') + 1; - OUString sFile = rPath.copy(nCopyFrom); - OUString sDir = rPath.copy(0, rPath.lastIndexOf('/')); - if (!sFile.isEmpty() && sFile.startsWith("lc_")) + sal_Int32 nCopyFrom = nSlashPos + 1; + std::u16string_view sFile = rPath.substr(nCopyFrom); + std::u16string_view sDir = rPath.substr(0, nSlashPos); + if (!sFile.empty() && o3tl::starts_with(sFile, u"lc_")) { - aResult = sDir + "/32/" + sFile.subView(3); + aResult = OUString::Concat(sDir) + "/32/" + sFile.substr(3); } } return aResult; @@ -133,10 +134,10 @@ bool urlExists(OUString const & sUrl) return osl::FileBase::E_None == eRC; } -OUString getNameNoExtension(OUString const & sName) +OUString getNameNoExtension(std::u16string_view sName) { - sal_Int32 nDotPosition = sName.lastIndexOf('.'); - return sName.copy(0, nDotPosition); + size_t nDotPosition = sName.rfind('.'); + return OUString(sName.substr(0, nDotPosition)); } std::shared_ptr<SvMemoryStream> wrapStream(uno::Reference<io::XInputStream> const & rInputStream)