diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-11 22:24:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-12 12:42:15 +0200 |
commit | cbaf1fbaa6e707d939f815eda360fad68a492aca (patch) | |
tree | 20b3dfeac257130afb01572b2c117b7840d07007 /sw/source | |
parent | f751417b77e6573a0c639778e76ec943449f4573 (diff) |
loplugin:stringview more o3tl conversion
look for call sequences that can use string_view and the new o3tl
functions in o3tl/string_view.hxx
Also add a few more wrappers to said #include file
Change-Id: I05d8752cc67a7b55b0b57e8eed803bd06bfcd9ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132840
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/crsr/viscrs.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/fields/authfld.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/html/htmlfldw.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par5.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/fldui/flddb.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/fldui/flddinf.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/fldui/flddok.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldfunc.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldref.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldvar.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/misc/bookmark.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/misc/glossary.cxx | 2 |
13 files changed, 20 insertions, 15 deletions
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index d72289bdbb36..90f20d09207e 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -57,6 +57,7 @@ #include <SwGrammarMarkUp.hxx> #include <docsh.hxx> #include <svtools/optionsdrawinglayer.hxx> +#include <o3tl/string_view.hxx> #include <cellfrm.hxx> #include <wrtsh.hxx> #include <textcontentcontrol.hxx> @@ -123,7 +124,7 @@ OString buildHyperlinkJSON(const OUString& sText, const OUString& sLink) std::stringstream aStream; boost::property_tree::write_json(aStream, aTree, false); - return OString(aStream.str().c_str()).trim(); + return OString(o3tl::trim(aStream.str())); } } diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx index 0232dbe01e75..4906dc28cdca 100644 --- a/sw/source/core/fields/authfld.cxx +++ b/sw/source/core/fields/authfld.cxx @@ -24,6 +24,7 @@ #include <comphelper/string.hxx> #include <i18nlangtag/languagetag.hxx> #include <o3tl/any.hxx> +#include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <tools/urlobj.hxx> #include <swtypes.hxx> @@ -500,7 +501,7 @@ OUString SwAuthorityField::ConditionalExpandAuthIdentifier( { OUString sIdentifier(m_xAuthEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER)); // tdf#107784 Use title if it's a ooxml citation - if (sIdentifier.trim().startsWith("CITATION")) + if (o3tl::starts_with(o3tl::trim(sIdentifier), u"CITATION")) return m_xAuthEntry->GetAuthorField(AUTH_FIELD_TITLE); else sRet += sIdentifier; diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx index 91fa6120eae2..222ac3e96589 100644 --- a/sw/source/filter/html/htmlfldw.cxx +++ b/sw/source/filter/html/htmlfldw.cxx @@ -22,6 +22,7 @@ #include <svtools/htmlkywd.hxx> #include <svtools/htmlout.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> #include <fmtfld.hxx> #include <doc.hxx> #include <breakit.hxx> @@ -466,7 +467,7 @@ Writer& OutHTML_SwFormatField( Writer& rWrt, const SfxPoolItem& rHt ) bool bWritten = false; if( (rComment.getLength() >= 6 && rComment.startsWith("<") && rComment.endsWith(">") && - rComment.copy( 1, 4 ).equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_meta) ) || + o3tl::equalsIgnoreAsciiCase(rComment.subView( 1, 4 ), u"" OOO_STRING_SVTOOLS_HTML_meta) ) || (rComment.getLength() >= 7 && rComment.startsWith( "<!--" ) && rComment.endsWith( "-->" )) ) diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 44063c816d9e..032c302460c6 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -1816,7 +1816,7 @@ void WW8Export::OutputField( const SwField* pField, ww::eField eFieldType, break; case ww::eCITATION: eFieldType = ww::eQUOTE; - assert(rFieldCmd.trim().startsWith("CITATION")); + assert(o3tl::starts_with(o3tl::trim(rFieldCmd), u"CITATION")); sFieldCmd = rFieldCmd.replaceFirst(FieldString(ww::eCITATION), FieldString(ww::eQUOTE)); break; @@ -3060,7 +3060,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) // FIXME: DomainMapper_Impl::CloseFieldCommand() stuffs fully formed // field instructions in here, but if the field doesn't originate // from those filters it won't have that - if (!sRet.trim().startsWith("CITATION")) + if (!o3tl::starts_with(o3tl::trim(sRet), u"CITATION")) { sRet = FieldString(ww::eCITATION) + " \"" + sRet + "\""; } diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index cecad8f6d370..fd19f6c11630 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -631,7 +631,7 @@ sal_uInt16 SwWW8ImplReader::End_Field() } default: OUString aCode = m_aFieldStack.back().GetBookmarkCode(); - if (!aCode.isEmpty() && !aCode.trim().startsWith("SHAPE")) + if (!aCode.isEmpty() && !o3tl::starts_with(o3tl::trim(aCode), u"SHAPE")) { // Unhandled field with stored code SwPosition aEndPos = *m_pPaM->GetPoint(); diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx index 73a63255cc62..3293a6bc670d 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -153,7 +153,7 @@ void SwFieldDBPage::Reset(const SfxItemSet*) { const OUString sUserData = GetUserData(); sal_Int32 nIdx{ 0 }; - if (sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) + if (o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1)) { const sal_uInt16 nVal = o3tl::narrowing<sal_uInt16>(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); if (nVal != USHRT_MAX) diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx index c3247352fe8a..50ce0548fd54 100644 --- a/sw/source/ui/fldui/flddinf.cxx +++ b/sw/source/ui/fldui/flddinf.cxx @@ -124,7 +124,7 @@ void SwFieldDokInfPage::Reset(const SfxItemSet* ) sal_Int32 nSelEntryData = -1; const OUString sUserData = GetUserData(); sal_Int32 nIdx{ 0 }; - if (sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) + if (o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1)) { nSelEntryData = o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx)); } diff --git a/sw/source/ui/fldui/flddok.cxx b/sw/source/ui/fldui/flddok.cxx index 25e77775a2ba..2e7c1c67dbc2 100644 --- a/sw/source/ui/fldui/flddok.cxx +++ b/sw/source/ui/fldui/flddok.cxx @@ -154,7 +154,7 @@ void SwFieldDokPage::Reset(const SfxItemSet* ) { const OUString sUserData = GetUserData(); sal_Int32 nIdx{ 0 }; - if (sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) + if (o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1)) { const sal_uInt16 nVal = static_cast< sal_uInt16 >(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); if(nVal != USHRT_MAX) diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx index 874b8fe5e90f..017a4d19c6aa 100644 --- a/sw/source/ui/fldui/fldfunc.cxx +++ b/sw/source/ui/fldui/fldfunc.cxx @@ -144,7 +144,7 @@ void SwFieldFuncPage::Reset(const SfxItemSet* ) { const OUString sUserData = GetUserData(); sal_Int32 nIdx{ 0 }; - if(sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) + if(o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1)) { const sal_uInt16 nVal = static_cast< sal_uInt16 >(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); if(nVal != USHRT_MAX) diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index 0c6c4ace6e11..5392df80463e 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -239,8 +239,8 @@ void SwFieldRefPage::Reset(const SfxItemSet* ) { sal_Int32 nIdx{ 0 }; const OUString sUserData = GetUserData(); - if(!IsRefresh() && sUserData.getToken(0, ';', nIdx). - equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) + if(!IsRefresh() && o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), + u"" USER_DATA_VERSION_1)) { const sal_uInt16 nVal = static_cast< sal_uInt16 >(o3tl::toInt32(o3tl::getToken(sUserData, 0, ';', nIdx))); if(nVal != USHRT_MAX) diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx index e07117a3c737..af34366b2d36 100644 --- a/sw/source/ui/fldui/fldvar.cxx +++ b/sw/source/ui/fldui/fldvar.cxx @@ -33,6 +33,7 @@ #include <calc.hxx> #include <svl/numformat.hxx> #include <svl/zformat.hxx> +#include <o3tl/string_view.hxx> #include <strings.hrc> #define USER_DATA_VERSION_1 "1" @@ -157,7 +158,7 @@ void SwFieldVarPage::Reset(const SfxItemSet* ) { OUString sUserData = GetUserData(); sal_Int32 nIdx{ 0 }; - if(!IsRefresh() && sUserData.getToken(0, ';', nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1)) + if(!IsRefresh() && o3tl::equalsIgnoreAsciiCase(o3tl::getToken(sUserData, 0, ';', nIdx), u"" USER_DATA_VERSION_1)) { OUString sVal = sUserData.getToken(0, ';', nIdx); sal_uInt16 nVal = o3tl::narrowing<sal_uInt16>(sVal.toInt32()); diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index c886c603953d..48260cd48f0b 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -442,7 +442,8 @@ void BookmarkTable::InsertBookmark(sw::mark::IMark* pMark) } bool bExceedsLength = nBookmarkTextLen > nMaxTextLen; nBookmarkTextLen = std::min<sal_Int32>(nMaxTextLen, nBookmarkTextLen); - sBookmarkNodeText = sBookmarkNodeText.copy(nBookmarkNodeTextPos, nBookmarkTextLen).trim(); + sBookmarkNodeText + = o3tl::trim(sBookmarkNodeText.subView(nBookmarkNodeTextPos, nBookmarkTextLen)); if (bExceedsLength) sBookmarkNodeText += "..."; else if (bPulling && !bPulledAll) diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index 58121c6734e7..4e657a260d02 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -250,7 +250,7 @@ OUString getCurrentGlossary() const OUString sTemp{ ::GetCurrGlosGroup() }; // the zeroth path is not being recorded! - if (sTemp.getToken(1, GLOS_DELIM).startsWith("0")) + if (o3tl::starts_with(o3tl::getToken(sTemp, 1, GLOS_DELIM), u"0")) return sTemp.getToken(0, GLOS_DELIM); return sTemp; |