summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-15 16:46:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-15 21:32:59 +0200
commit15d8762dd07289447e782a3812dfd4425fe9a82b (patch)
treebc778d414915d40af12ddf25d1f744074e329eda /cui
parent267a0e94920dbaf3f9db316c9cbfe6fa72be8818 (diff)
use more string_view in cui
Change-Id: I377d95ec2d80cef611c6fce274f1e17504132564 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133074 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/customize/cfgutil.cxx22
-rw-r--r--cui/source/customize/macropg.cxx22
-rw-r--r--cui/source/dialogs/scriptdlg.cxx2
-rw-r--r--cui/source/inc/cfgutil.hxx2
4 files changed, 25 insertions, 23 deletions
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index aab25aa9bb8d..6b39170e18f7 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -54,6 +54,7 @@
#include <vcl/commandinfoprovider.hxx>
#include <vcl/help.hxx>
#include <vcl/svapp.hxx>
+#include <o3tl/string_view.hxx>
#include <sfx2/sidebar/ResourceManager.hxx>
#include <sfx2/sidebar/Context.hxx>
@@ -1027,22 +1028,23 @@ void CuiConfigGroupListBox::SelectMacro( const SfxMacroInfoItem *pItem )
}
void CuiConfigGroupListBox::SelectMacro( std::u16string_view rBasic,
- const OUString& rMacro )
+ std::u16string_view rMacro )
{
const OUString aBasicName(OUString::Concat(rBasic) + " " + xImp->m_sMacros);
- sal_Int32 nIdx {rMacro.lastIndexOf('.')};
- const OUString aMethod( rMacro.copy(nIdx+1) );
- OUString aLib;
- OUString aModule;
- if ( nIdx>0 )
+ size_t nIdx {rMacro.rfind('.')};
+ const std::u16string_view aMethod( rMacro.substr(nIdx == std::u16string_view::npos ? 0 : nIdx + 1) );
+ std::u16string_view aLib;
+ std::u16string_view aModule;
+ if ( nIdx>0 && nIdx != std::u16string_view::npos )
{
// string contains at least 2 tokens
- nIdx = rMacro.lastIndexOf('.', nIdx);
- if (nIdx>=0)
+ nIdx = rMacro.rfind('.', nIdx);
+ if (nIdx != std::u16string_view::npos)
{
// string contains at least 3 tokens
- aLib = rMacro.getToken( 0, '.' );
- aModule = rMacro.getToken( 0, '.', ++nIdx );
+ aLib = o3tl::getToken(rMacro, 0, '.' );
+ sal_Int32 nIdx2 = nIdx + 1;
+ aModule = o3tl::getToken(rMacro, 0, '.', nIdx2 );
}
}
diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx
index b1df3957de8b..ed9e4f6c0c4d 100644
--- a/cui/source/customize/macropg.cxx
+++ b/cui/source/customize/macropg.cxx
@@ -32,6 +32,7 @@
#include <svx/svxids.hrc>
#include <strings.hrc>
#include <comphelper/namedvaluecollection.hxx>
+#include <o3tl/string_view.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -269,21 +270,20 @@ bool SvxMacroTabPage_::IsReadOnly() const
namespace
{
- OUString GetEventDisplayText(const OUString &rURL)
+ std::u16string_view GetEventDisplayText(std::u16string_view rURL)
{
- if (rURL.isEmpty())
- return OUString();
- sal_Int32 nIndex = rURL.indexOf(aVndSunStarUNO);
- bool bUNO = nIndex == 0;
- OUString aPureMethod;
+ if (rURL.empty())
+ return std::u16string_view();
+ bool bUNO = o3tl::starts_with(rURL, aVndSunStarUNO);
+ std::u16string_view aPureMethod;
if (bUNO)
{
- aPureMethod = rURL.copy(aVndSunStarUNO.getLength());
+ aPureMethod = rURL.substr(aVndSunStarUNO.getLength());
}
else
{
- aPureMethod = rURL.copy(strlen("vnd.sun.star.script:"));
- aPureMethod = aPureMethod.copy( 0, aPureMethod.indexOf( '?' ) );
+ aPureMethod = rURL.substr(strlen("vnd.sun.star.script:"));
+ aPureMethod = aPureMethod.substr( 0, aPureMethod.find( '?' ) );
}
return aPureMethod;
}
@@ -344,7 +344,7 @@ void SvxMacroTabPage_::DisplayAppEvents( bool appEvents)
int nRow = mpImpl->xEventLB->n_children();
mpImpl->xEventLB->append(sEventName, displayName);
mpImpl->xEventLB->set_image(nRow, GetEventDisplayImage(eventURL), 1);
- mpImpl->xEventLB->set_text(nRow, GetEventDisplayText(eventURL), 2);
+ mpImpl->xEventLB->set_text(nRow, OUString(GetEventDisplayText(eventURL)), 2);
}
mpImpl->xEventLB->thaw();
@@ -478,7 +478,7 @@ void SvxMacroTabPage_::GenericHandler_Impl(SvxMacroTabPage_* pThis, const weld::
}
rListBox.set_image(nEntry, GetEventDisplayImage(sEventURL), 1);
- rListBox.set_text(nEntry, GetEventDisplayText(sEventURL), 2);
+ rListBox.set_text(nEntry, OUString(GetEventDisplayText(sEventURL)), 2);
rListBox.select(nEntry );
rListBox.scroll_to_row(nEntry);
diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx
index 4294e56ebac0..0c349367b44d 100644
--- a/cui/source/dialogs/scriptdlg.cxx
+++ b/cui/source/dialogs/scriptdlg.cxx
@@ -1113,7 +1113,7 @@ OUString FormatErrorString(
std::u16string_view type,
std::u16string_view message )
{
- OUString result = unformatted.copy( 0 );
+ OUString result = unformatted;
result = ReplaceString(result, "%LANGUAGENAME", language );
result = ReplaceString(result, "%SCRIPTNAME", script );
diff --git a/cui/source/inc/cfgutil.hxx b/cui/source/inc/cfgutil.hxx
index 8040b90afa8f..d4da1e76f5f9 100644
--- a/cui/source/inc/cfgutil.hxx
+++ b/cui/source/inc/cfgutil.hxx
@@ -230,7 +230,7 @@ public:
void GroupSelected();
#if HAVE_FEATURE_SCRIPTING
void SelectMacro(const SfxMacroInfoItem*);
- void SelectMacro(std::u16string_view, const OUString&);
+ void SelectMacro(std::u16string_view, std::u16string_view);
#endif
void SetStylesInfo(SfxStylesInfo_Impl* pStyles);
};