summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-09-27 09:37:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-27 14:06:42 +0200
commit97eccc5d55d8786f91c88a0f3de36640c112e68e (patch)
treeacf3be78e6c95abd1e3c2c0881d4da1ae4dfb3c8 /extensions
parentf6bf58503dda832bad97b262e4feed633fdd4853 (diff)
use more string_view in cui,extensions
Change-Id: I76253ae06af53f63206a47a84035317c6a5058b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140637 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/logging/csvformatter.cxx14
-rw-r--r--extensions/source/propctrlr/eventhandler.cxx8
-rw-r--r--extensions/source/propctrlr/newdatatype.cxx6
-rw-r--r--extensions/source/propctrlr/newdatatype.hxx2
4 files changed, 16 insertions, 14 deletions
diff --git a/extensions/source/logging/csvformatter.cxx b/extensions/source/logging/csvformatter.cxx
index 8e749db42831..ddbf3a9a2c36 100644
--- a/extensions/source/logging/csvformatter.cxx
+++ b/extensions/source/logging/csvformatter.cxx
@@ -97,25 +97,27 @@ namespace
return str.find_first_of(u"\",\n\r") != std::u16string_view::npos;
};
- void appendEncodedString(OUStringBuffer& buf, const OUString& str)
+ void appendEncodedString(OUStringBuffer& buf, std::u16string_view str)
{
if(needsQuoting(str))
{
// each double-quote will get replaced by two double-quotes
buf.append(quote_char);
const sal_Int32 buf_offset = buf.getLength();
- const sal_Int32 str_length = str.getLength();
+ const size_t str_length = str.size();
buf.append(str);
// special treatment for the last character
if(quote_char==str[str_length-1])
buf.append(quote_char);
// iterating backwards because the index at which we insert won't be shifted
// when moving that way.
- for(sal_Int32 i = str_length; i>=0; )
+ for(size_t i = str_length;; )
{
- i=str.lastIndexOf(quote_char, --i);
- if(i!=-1)
- buf.insert(buf_offset + i, quote_char);
+ --i;
+ i=str.substr(i).rfind(quote_char);
+ if(i==std::u16string_view::npos)
+ break;
+ buf.insert(buf_offset + i, quote_char);
}
buf.append(quote_char);
}
diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx
index 9d158b8d467c..ea99755244af 100644
--- a/extensions/source/propctrlr/eventhandler.cxx
+++ b/extensions/source/propctrlr/eventhandler.cxx
@@ -973,14 +973,14 @@ namespace pcr
namespace
{
- bool lcl_endsWith( const OUString& _rText, const OUString& _rCheck )
+ bool lcl_endsWith( std::u16string_view _rText, std::u16string_view _rCheck )
{
- sal_Int32 nTextLen = _rText.getLength();
- sal_Int32 nCheckLen = _rCheck.getLength();
+ size_t nTextLen = _rText.size();
+ size_t nCheckLen = _rCheck.size();
if ( nCheckLen > nTextLen )
return false;
- return _rText.indexOf( _rCheck ) == ( nTextLen - nCheckLen );
+ return _rText.find( _rCheck ) == ( nTextLen - nCheckLen );
}
}
diff --git a/extensions/source/propctrlr/newdatatype.cxx b/extensions/source/propctrlr/newdatatype.cxx
index 09c774d3aa42..b2399d680668 100644
--- a/extensions/source/propctrlr/newdatatype.cxx
+++ b/extensions/source/propctrlr/newdatatype.cxx
@@ -26,7 +26,7 @@ namespace pcr
//= NewDataTypeDialog
- NewDataTypeDialog::NewDataTypeDialog(weld::Window* pParent, const OUString& _rNameBase, const std::vector< OUString >& _rProhibitedNames)
+ NewDataTypeDialog::NewDataTypeDialog(weld::Window* pParent, std::u16string_view _rNameBase, const std::vector< OUString >& _rProhibitedNames)
: GenericDialogController(pParent, "modules/spropctrlr/ui/datatypedialog.ui", "DataTypeDialog")
, m_aProhibitedNames( _rProhibitedNames.begin(), _rProhibitedNames.end() )
, m_xName(m_xBuilder->weld_entry("entry"))
@@ -36,7 +36,7 @@ namespace pcr
// find an initial name
// for this, first remove trailing digits
- sal_Int32 nStripUntil = _rNameBase.getLength();
+ sal_Int32 nStripUntil = _rNameBase.size();
while ( nStripUntil > 0 )
{
sal_Unicode nChar = _rNameBase[ --nStripUntil ];
@@ -48,7 +48,7 @@ namespace pcr
}
}
- OUString sNameBase = OUString::Concat(_rNameBase.subView( 0, nStripUntil ? nStripUntil + 1 : 0 )) + " ";
+ OUString sNameBase = OUString::Concat(_rNameBase.substr( 0, nStripUntil ? nStripUntil + 1 : 0 )) + " ";
OUString sInitialName;
sal_Int32 nPostfixNumber = 1;
do
diff --git a/extensions/source/propctrlr/newdatatype.hxx b/extensions/source/propctrlr/newdatatype.hxx
index e6d46f1af329..ba4b6fa38269 100644
--- a/extensions/source/propctrlr/newdatatype.hxx
+++ b/extensions/source/propctrlr/newdatatype.hxx
@@ -36,7 +36,7 @@ namespace pcr
std::unique_ptr<weld::Entry> m_xName;
std::unique_ptr<weld::Button> m_xOK;
public:
- NewDataTypeDialog(weld::Window* _pParent, const OUString& _rNameBase,
+ NewDataTypeDialog(weld::Window* _pParent, std::u16string_view _rNameBase,
const std::vector< OUString >& _rProhibitedNames );
virtual ~NewDataTypeDialog() override;