include/unotools/datetime.hxx              |    2 +-
 include/unotools/fontdefs.hxx              |    2 +-
 unotools/source/misc/datetime.cxx          |   14 +++++++-------
 unotools/source/misc/fontdefs.cxx          |    6 +++---
 vcl/source/font/PhysicalFontCollection.cxx |    4 ++--
 vcl/source/font/fontmetric.cxx             |    2 +-
 6 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit ca1027e7d3a47402a016dba26d12db93b097a856
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Apr 21 16:08:20 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Apr 22 13:29:40 2022 +0200

    use more string_view in unotools
    
    Change-Id: If32767647d3fba22a8e4a2b10fc57f47efca01d2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133270
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/unotools/datetime.hxx b/include/unotools/datetime.hxx
index afb06bc652a1..368ffcb393f9 100644
--- a/include/unotools/datetime.hxx
+++ b/include/unotools/datetime.hxx
@@ -48,7 +48,7 @@ namespace utl
     UNOTOOLS_DLLPUBLIC void typeConvert(const css::util::DateTime& _rDateTime, 
DateTime& _rOut);
 
     UNOTOOLS_DLLPUBLIC OUString toISO8601(const css::util::DateTime& 
_rDateTime);
-    UNOTOOLS_DLLPUBLIC bool            ISO8601parseDateTime(const OUString 
&i_rIn, css::util::DateTime& o_rDateTime);
+    UNOTOOLS_DLLPUBLIC bool            
ISO8601parseDateTime(std::u16string_view i_rIn, css::util::DateTime& 
o_rDateTime);
     UNOTOOLS_DLLPUBLIC bool            ISO8601parseDate(std::u16string_view 
i_rIn, css::util::Date& o_rDate);
     UNOTOOLS_DLLPUBLIC bool            ISO8601parseTime(std::u16string_view 
i_rIn, css::util::Time& o_Time);
 
diff --git a/include/unotools/fontdefs.hxx b/include/unotools/fontdefs.hxx
index f5ff03efc837..7f145eba309e 100644
--- a/include/unotools/fontdefs.hxx
+++ b/include/unotools/fontdefs.hxx
@@ -84,7 +84,7 @@ enum class DefaultFontType
     CTL_DISPLAY         = 4004,
 };
 
-UNOTOOLS_DLLPUBLIC OUString GetNextFontToken( const OUString& rTokenStr, 
sal_Int32& rIndex );
+UNOTOOLS_DLLPUBLIC std::u16string_view GetNextFontToken( const OUString& 
rTokenStr, sal_Int32& rIndex );
 UNOTOOLS_DLLPUBLIC OUString GetEnglishSearchFontName( std::u16string_view 
rName );
 
 /** Strip any "script font suffix" from the font name
diff --git a/unotools/source/misc/datetime.cxx 
b/unotools/source/misc/datetime.cxx
index f1b1d6a8a33e..db7216ffa268 100644
--- a/unotools/source/misc/datetime.cxx
+++ b/unotools/source/misc/datetime.cxx
@@ -303,25 +303,25 @@ OUString toISO8601(const css::util::DateTime& rDateTime)
 }
 
 /** convert ISO8601 DateTime String to util::DateTime */
-bool ISO8601parseDateTime(const OUString &rString, css::util::DateTime& 
rDateTime)
+bool ISO8601parseDateTime(std::u16string_view rString, css::util::DateTime& 
rDateTime)
 {
     bool bSuccess = true;
 
-    OUString aDateStr, aTimeStr;
+    std::u16string_view aDateStr, aTimeStr;
     css::util::Date aDate;
     css::util::Time aTime;
-    sal_Int32 nPos = rString.indexOf( 'T' );
-    if ( nPos >= 0 )
+    size_t nPos = rString.find( 'T' );
+    if ( nPos != std::u16string_view::npos )
     {
-        aDateStr = rString.copy( 0, nPos );
-        aTimeStr = rString.copy( nPos + 1 );
+        aDateStr = rString.substr( 0, nPos );
+        aTimeStr = rString.substr( nPos + 1 );
     }
     else
         aDateStr = rString;         // no separator: only date part
 
     bSuccess = ISO8601parseDate(aDateStr, aDate);
 
-    if ( bSuccess && !aTimeStr.isEmpty() )           // time is optional
+    if ( bSuccess && !aTimeStr.empty() )           // time is optional
     {
         bSuccess = ISO8601parseTime(aTimeStr, aTime);
     }
diff --git a/unotools/source/misc/fontdefs.cxx 
b/unotools/source/misc/fontdefs.cxx
index 9015f93e9de6..4a07087fd71f 100644
--- a/unotools/source/misc/fontdefs.cxx
+++ b/unotools/source/misc/fontdefs.cxx
@@ -457,14 +457,14 @@ OUString GetEnglishSearchFontName(std::u16string_view 
rInName)
     return rNameStr;
 }
 
-OUString GetNextFontToken( const OUString& rTokenStr, sal_Int32& rIndex )
+std::u16string_view GetNextFontToken( const OUString& rTokenStr, sal_Int32& 
rIndex )
 {
     // check for valid start index
     sal_Int32 nStringLen = rTokenStr.getLength();
     if( rIndex >= nStringLen )
     {
         rIndex = -1;
-        return OUString();
+        return {};
     }
 
     // find the next token delimiter and return the token substring
@@ -498,7 +498,7 @@ OUString GetNextFontToken( const OUString& rTokenStr, 
sal_Int32& rIndex )
         }
     }
 
-    return rTokenStr.copy( nTokenStart, nTokenLen );
+    return rTokenStr.subView( nTokenStart, nTokenLen );
 }
 
 static bool ImplIsFontToken( const OUString& rName, std::u16string_view rToken 
)
diff --git a/vcl/source/font/PhysicalFontCollection.cxx 
b/vcl/source/font/PhysicalFontCollection.cxx
index 139e4f133e88..6a1b35372952 100644
--- a/vcl/source/font/PhysicalFontCollection.cxx
+++ b/vcl/source/font/PhysicalFontCollection.cxx
@@ -344,8 +344,8 @@ PhysicalFontFamily* 
PhysicalFontCollection::FindFontFamilyByTokenNames(OUString
     // use normalized font name tokens to find the font
     for( sal_Int32 nTokenPos = 0; nTokenPos != -1; )
     {
-        OUString aFamilyName = GetNextFontToken( rTokenStr, nTokenPos );
-        if( aFamilyName.isEmpty() )
+        std::u16string_view aFamilyName = GetNextFontToken( rTokenStr, 
nTokenPos );
+        if( aFamilyName.empty() )
             continue;
 
         pFoundData = FindFontFamily( aFamilyName );
diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx
index 000523941813..660b1a7d1f78 100644
--- a/vcl/source/font/fontmetric.cxx
+++ b/vcl/source/font/fontmetric.cxx
@@ -137,7 +137,7 @@ ImplFontMetricData::ImplFontMetricData( const 
vcl::font::FontSelectPattern& rFon
 {
     // initialize the used font name
     sal_Int32 nTokenPos = 0;
-    SetFamilyName( GetNextFontToken( rFontSelData.GetFamilyName(), nTokenPos ) 
);
+    SetFamilyName( OUString(GetNextFontToken( rFontSelData.GetFamilyName(), 
nTokenPos )) );
     SetStyleName( rFontSelData.GetStyleName() );
 }
 

Reply via email to