diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-26 13:08:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-26 15:42:22 +0200 |
commit | 749573bfce08879587b4bd0c2cfeb6eada4c9912 (patch) | |
tree | 2ed9fe0b5e1f8c6c6d5253fc1cf24007c7d212af /sfx2 | |
parent | d9e044f04ac11b76b9a3dac575f4e9155b67490e (diff) |
use more string_view in sfx2
Change-Id: Idf80ebfe6fb72c4b61eca15a4aee5da7621ffa48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140591
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/filtergrouping.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/DocumentMetadataAccess.cxx | 16 | ||||
-rw-r--r-- | sfx2/source/doc/oleprops.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/doc/oleprops.hxx | 6 |
4 files changed, 17 insertions, 19 deletions
diff --git a/sfx2/source/dialog/filtergrouping.cxx b/sfx2/source/dialog/filtergrouping.cxx index 1d9a68952520..b6232e301e43 100644 --- a/sfx2/source/dialog/filtergrouping.cxx +++ b/sfx2/source/dialog/filtergrouping.cxx @@ -415,7 +415,7 @@ namespace sfx2 explicit CheckAppendSingleWildcard( OUString& _rBase ) : _rToBeExtended( _rBase ) { } - void operator() ( const OUString& _rWC ) + void operator() ( std::u16string_view _rWC ) { // check for double wildcards sal_Int32 nExistentPos = _rToBeExtended.indexOf( _rWC ); @@ -425,7 +425,7 @@ namespace sfx2 || ( s_cWildcardSeparator == _rToBeExtended[ nExistentPos - 1 ] ) ) { // the wildcard really starts at this position (it starts at pos 0 or the previous character is a separator - sal_Int32 nExistentWCEnd = nExistentPos + _rWC.getLength(); + sal_Int32 nExistentWCEnd = nExistentPos + _rWC.size(); if ( ( _rToBeExtended.getLength() == nExistentWCEnd ) || ( s_cWildcardSeparator == _rToBeExtended[ nExistentWCEnd ] ) ) diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx index cdf4c329a074..309728d816e3 100644 --- a/sfx2/source/doc/DocumentMetadataAccess.cxx +++ b/sfx2/source/doc/DocumentMetadataAccess.cxx @@ -282,17 +282,15 @@ splitPath(OUString const & i_rPath, } static bool -splitXmlId(OUString const & i_XmlId, +splitXmlId(std::u16string_view i_XmlId, OUString & o_StreamName, OUString& o_Idref ) { - const sal_Int32 idx(i_XmlId.indexOf(u'#')); - if ((idx <= 0) || (idx >= i_XmlId.getLength() - 1)) { + const size_t idx(i_XmlId.find(u'#')); + if (idx == std::u16string_view::npos) return false; - } else { - o_StreamName = i_XmlId.copy(0, idx); - o_Idref = i_XmlId.copy(idx+1); - return isValidXmlId(o_StreamName, o_Idref); - } + o_StreamName = i_XmlId.substr(0, idx); + o_Idref = i_XmlId.substr(idx+1); + return isValidXmlId(o_StreamName, o_Idref); } @@ -912,7 +910,7 @@ DocumentMetadataAccess::getElementByURI( } OUString path; OUString idref; - if (!splitXmlId(name.copy(baseURI.getLength()), path, idref)) { + if (!splitXmlId(name.subView(baseURI.getLength()), path, idref)) { return nullptr; } diff --git a/sfx2/source/doc/oleprops.cxx b/sfx2/source/doc/oleprops.cxx index a79ac984222e..4cde3ed014ba 100644 --- a/sfx2/source/doc/oleprops.cxx +++ b/sfx2/source/doc/oleprops.cxx @@ -249,7 +249,7 @@ OUString SfxOleStringHelper::LoadString8( SvStream& rStrm ) const return IsUnicode() ? ImplLoadString16( rStrm ) : ImplLoadString8( rStrm ); } -void SfxOleStringHelper::SaveString8( SvStream& rStrm, const OUString& rValue ) const +void SfxOleStringHelper::SaveString8( SvStream& rStrm, std::u16string_view rValue ) const { if( IsUnicode() ) ImplSaveString16( rStrm, rValue ); @@ -262,7 +262,7 @@ OUString SfxOleStringHelper::LoadString16( SvStream& rStrm ) return ImplLoadString16( rStrm ); } -void SfxOleStringHelper::SaveString16( SvStream& rStrm, const OUString& rValue ) +void SfxOleStringHelper::SaveString16( SvStream& rStrm, std::u16string_view rValue ) { ImplSaveString16( rStrm, rValue ); } @@ -316,13 +316,13 @@ void SfxOleStringHelper::ImplSaveString8( SvStream& rStrm, std::u16string_view r rStrm.WriteUChar( 0 ); } -void SfxOleStringHelper::ImplSaveString16( SvStream& rStrm, const OUString& rValue ) +void SfxOleStringHelper::ImplSaveString16( SvStream& rStrm, std::u16string_view rValue ) { // write size field (including trailing NUL character) - sal_Int32 nSize = static_cast< sal_Int32 >( rValue.getLength() + 1 ); + sal_Int32 nSize = static_cast< sal_Int32 >( rValue.size() + 1 ); rStrm.WriteInt32( nSize ); // write character array with trailing NUL character - for( sal_Int32 nIdx = 0; nIdx < rValue.getLength(); ++nIdx ) + for( size_t nIdx = 0; nIdx < rValue.size(); ++nIdx ) rStrm.WriteUInt16( rValue[ nIdx ] ); rStrm.WriteUInt16( 0 ); // stream is always padded to 32-bit boundary, add 2 bytes on odd character count diff --git a/sfx2/source/doc/oleprops.hxx b/sfx2/source/doc/oleprops.hxx index 81eb744eab89..5c486c8dad51 100644 --- a/sfx2/source/doc/oleprops.hxx +++ b/sfx2/source/doc/oleprops.hxx @@ -144,18 +144,18 @@ public: /** Loads a string from the passed stream with current encoding (maybe Unicode). */ OUString LoadString8( SvStream& rStrm ) const; /** Saves a string to the passed stream with current encoding (maybe Unicode). */ - void SaveString8( SvStream& rStrm, const OUString& rValue ) const; + void SaveString8( SvStream& rStrm, std::u16string_view rValue ) const; /** Loads a Unicode string from the passed stream, ignores own encoding. */ static OUString LoadString16( SvStream& rStrm ); /** Saves a Unicode string to the passed stream, ignores own encoding. */ - static void SaveString16( SvStream& rStrm, const OUString& rValue ); + static void SaveString16( SvStream& rStrm, std::u16string_view rValue ); private: OUString ImplLoadString8( SvStream& rStrm ) const; static OUString ImplLoadString16( SvStream& rStrm ); void ImplSaveString8( SvStream& rStrm, std::u16string_view rValue ) const; - static void ImplSaveString16( SvStream& rStrm, const OUString& rValue ); + static void ImplSaveString16( SvStream& rStrm, std::u16string_view rValue ); }; |