diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-07 10:46:26 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-08 10:26:10 +0200 |
commit | 3a88b513fd90f4793b6de7a7412fa33369542f40 (patch) | |
tree | 293467f4143a28a2a19f037f3215f4391794c854 | |
parent | lok: unit test for invalid entry save (diff) | |
download | core-3a88b513fd90f4793b6de7a7412fa33369542f40.tar.gz core-3a88b513fd90f4793b6de7a7412fa33369542f40.zip |
loplugin:stringviewparam convert methods using trim
for which we add a new o3tl::trim method
Change-Id: I9d37b6264eea106aa2f3502bd24b8cccf7850938
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132658
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | basic/source/sbx/sbxcurr.cxx | 36 | ||||
-rw-r--r-- | chart2/qa/extras/chart2dump/chart2dump.cxx | 5 | ||||
-rw-r--r-- | comphelper/source/misc/string.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/stringviewparam.cxx | 3 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Util.cxx | 9 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Util.hxx | 2 | ||||
-rw-r--r-- | desktop/source/app/officeipcthread.cxx | 9 | ||||
-rw-r--r-- | filter/source/msfilter/msvbahelper.cxx | 31 | ||||
-rw-r--r-- | forms/source/xforms/xpathlib/xpathlib.cxx | 7 | ||||
-rw-r--r-- | include/comphelper/string.hxx | 2 | ||||
-rw-r--r-- | include/o3tl/string_view.hxx | 66 | ||||
-rw-r--r-- | l10ntools/inc/lngmerge.hxx | 2 | ||||
-rw-r--r-- | l10ntools/source/lngmerge.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 8 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 5 |
16 files changed, 138 insertions, 63 deletions
diff --git a/basic/source/sbx/sbxcurr.cxx b/basic/source/sbx/sbxcurr.cxx index 416229afbc95..ad558f2284c1 100644 --- a/basic/source/sbx/sbxcurr.cxx +++ b/basic/source/sbx/sbxcurr.cxx @@ -21,6 +21,7 @@ #include <basic/sberrors.hxx> #include <basic/sbxvar.hxx> +#include <o3tl/string_view.hxx> #include "sbxconv.hxx" @@ -85,7 +86,7 @@ static OUString ImpCurrencyToString( sal_Int64 rVal ) } -static sal_Int64 ImpStringToCurrency( const OUString &rStr ) +static sal_Int64 ImpStringToCurrency( std::u16string_view rStr ) { sal_Int32 nFractDigit = 4; @@ -99,50 +100,47 @@ static sal_Int64 ImpStringToCurrency( const OUString &rStr ) // we should share some existing ( possibly from calc is there a currency // conversion there ? #TODO check ) - OUString sTmp( rStr.trim() ); - const sal_Unicode* p = sTmp.getStr(); + std::u16string_view sTmp = o3tl::trim( rStr ); + auto p = sTmp.begin(); + auto pEnd = sTmp.end(); // normalise string number by removing thousand & decimal point separators - OUStringBuffer sNormalisedNumString( sTmp.getLength() + nFractDigit ); + OUStringBuffer sNormalisedNumString( static_cast<sal_Int32>(sTmp.size()) + nFractDigit ); - if ( *p == '-' || *p == '+' ) + if ( p != pEnd && (*p == '-' || *p == '+' ) ) sNormalisedNumString.append( *p++ ); - while ( *p >= '0' && *p <= '9' ) + while ( p != pEnd && *p >= '0' && *p <= '9' ) { sNormalisedNumString.append( *p++ ); // #TODO in vba mode set runtime error when a space ( or other ) // illegal character is found - if( *p == c1000Sep ) + if( p != pEnd && *p == c1000Sep ) p++; } bool bRoundUp = false; - if( *p == cDeciPnt ) + if( p != pEnd && *p == cDeciPnt ) { p++; - while( nFractDigit && *p >= '0' && *p <= '9' ) + while( nFractDigit && p != pEnd && *p >= '0' && *p <= '9' ) { sNormalisedNumString.append( *p++ ); nFractDigit--; } // Consume trailing content - if ( p != nullptr ) - { - // Round up if necessary - if( *p >= '5' && *p <= '9' ) - bRoundUp = true; - while( *p >= '0' && *p <= '9' ) - p++; - } - + // Round up if necessary + if( p != pEnd && *p >= '5' && *p <= '9' ) + bRoundUp = true; + while( p != pEnd && *p >= '0' && *p <= '9' ) + p++; } // can we raise error here ? ( previous behaviour was more forgiving ) // so... not sure that could break existing code, let's see if anyone // complains. - if ( p != sTmp.getStr() + sTmp.getLength() ) + if ( p != pEnd ) SbxBase::SetError( ERRCODE_BASIC_CONVERSION ); while( nFractDigit ) { diff --git a/chart2/qa/extras/chart2dump/chart2dump.cxx b/chart2/qa/extras/chart2dump/chart2dump.cxx index bae904d4faf3..7418b80a8d5a 100644 --- a/chart2/qa/extras/chart2dump/chart2dump.cxx +++ b/chart2/qa/extras/chart2dump/chart2dump.cxx @@ -16,6 +16,7 @@ #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/drawing/FillStyle.hpp> +#include <o3tl/string_view.hxx> #include <editeng/unoprnms.hxx> #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> @@ -157,12 +158,12 @@ protected: return OUString(sTemp.data(), sTemp.length(), RTL_TEXTENCODING_UTF8); } - void writeActual(const OUString& sActualValue, const OUString& sCheck) + void writeActual(std::u16string_view sActualValue, const OUString& sCheck) { assert(m_bDumpMode); assert(m_aDumpFile.is_open()); m_aDumpFile << "// " << sCheck << "\n"; // Add check string to make dump file readable - m_aDumpFile << sActualValue.trim() << "\n"; // Write out the checked value, will be used as reference later + m_aDumpFile << OUString(sActualValue) << "\n"; // Write out the checked value, will be used as reference later } void readNote(std::u16string_view sNote) diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx index acdb6c88adcb..2934a6b73cbd 100644 --- a/comphelper/source/misc/string.cxx +++ b/comphelper/source/misc/string.cxx @@ -541,6 +541,8 @@ OUString setToken(const OUString& rIn, sal_Int32 nToken, sal_Unicode cTok, return rIn; } + + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/compilerplugins/clang/stringviewparam.cxx b/compilerplugins/clang/stringviewparam.cxx index 72ebe98768b3..e0ca76ead49a 100644 --- a/compilerplugins/clang/stringviewparam.cxx +++ b/compilerplugins/clang/stringviewparam.cxx @@ -138,7 +138,8 @@ DeclRefExpr const* relevantCXXMemberCallExpr(CXXMemberCallExpr const* expr) { auto const n = i->getName(); if (n == "endsWith" || n == "isEmpty" || n == "startsWith" || n == "subView" - || n == "indexOf" || n == "lastIndexOf" || n == "compareTo" || n == "match") + || n == "indexOf" || n == "lastIndexOf" || n == "compareTo" || n == "match" + || n == "trim") { good = true; } diff --git a/connectivity/source/drivers/firebird/Util.cxx b/connectivity/source/drivers/firebird/Util.cxx index 344c0164ac66..c015f2d47d14 100644 --- a/connectivity/source/drivers/firebird/Util.cxx +++ b/connectivity/source/drivers/firebird/Util.cxx @@ -13,6 +13,7 @@ #include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/SQLException.hpp> +#include <o3tl/string_view.hxx> using namespace ::connectivity; @@ -22,12 +23,12 @@ using namespace ::com::sun::star::uno; using namespace firebird; -OUString firebird::sanitizeIdentifier(const OUString& rIdentifier) +OUString firebird::sanitizeIdentifier(std::u16string_view rIdentifier) { - OUString sRet = rIdentifier.trim(); - assert(sRet.getLength() <= 31); // Firebird identifiers cannot be longer than this. + std::u16string_view sRet = o3tl::trim(rIdentifier); + assert(sRet.size() <= 31); // Firebird identifiers cannot be longer than this. - return sRet; + return OUString(sRet); } OUString firebird::StatusVectorToString(const ISC_STATUS_ARRAY& rStatusVector, diff --git a/connectivity/source/drivers/firebird/Util.hxx b/connectivity/source/drivers/firebird/Util.hxx index 46fadebb1a20..bf1a172ed2c8 100644 --- a/connectivity/source/drivers/firebird/Util.hxx +++ b/connectivity/source/drivers/firebird/Util.hxx @@ -86,7 +86,7 @@ public: * for such shorter strings, however any trailing padding makes the gui * editing of such names harder, hence we remove all trailing whitespace. */ - OUString sanitizeIdentifier(const OUString& rIdentifier); + OUString sanitizeIdentifier(std::u16string_view rIdentifier); inline bool IndicatesError(const ISC_STATUS_ARRAY& rStatusVector) { diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index d748bef60c68..5937d1097cff 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -42,6 +42,7 @@ #include <cppuhelper/supportsservice.hxx> #include <osl/file.hxx> #include <rtl/process.h> +#include <o3tl/string_view.hxx> #include <cassert> #include <cstdlib> @@ -1236,7 +1237,7 @@ static void AddConversionsToDispatchList( const OUString& rPrinterName, const OUString& rFactory, const OUString& rParamOut, - const OUString& rImgOut, + std::u16string_view rImgOut, const bool isTextCat, const bool isScriptCat ) { @@ -1263,7 +1264,7 @@ static void AddConversionsToDispatchList( } OUString aOutDir( rParamOut.trim() ); - OUString aImgOut( rImgOut.trim() ); + std::u16string_view aImgOut = o3tl::trim(rImgOut); OUString aPWD; if (cwdUrl) { @@ -1287,8 +1288,8 @@ static void AddConversionsToDispatchList( aParam += ";" + aPWD; } - if( !rImgOut.trim().isEmpty() ) - aParam += "|" + aImgOut; + if( !rImgOut.empty() ) + aParam += OUString::Concat("|") + aImgOut; for (auto const& request : rRequestList) { diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx index 60d842d0d87c..89c5292a3cb3 100644 --- a/filter/source/msfilter/msvbahelper.cxx +++ b/filter/source/msfilter/msvbahelper.cxx @@ -38,7 +38,8 @@ #include <unotools/pathoptions.hxx> #include <rtl/character.hxx> #include <sfx2/objsh.hxx> - +#include <o3tl/string_view.hxx> +#include <o3tl/string_view.hxx> #include <svtools/acceleratorexecute.hxx> #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> #include <com/sun/star/ui/XUIConfigurationManager.hpp> @@ -66,13 +67,13 @@ OUString extractMacroName( const OUString& rMacroUrl ) return OUString(); } -static OUString trimMacroName( const OUString& rMacroName ) +static std::u16string_view trimMacroName( std::u16string_view rMacroName ) { // the name may contain whitespaces and may be enclosed in apostrophs - OUString aMacroName = rMacroName.trim(); - sal_Int32 nMacroLen = aMacroName.getLength(); + std::u16string_view aMacroName = o3tl::trim(rMacroName); + size_t nMacroLen = aMacroName.size(); if( (nMacroLen >= 2) && (aMacroName[ 0 ] == '\'') && (aMacroName[ nMacroLen - 1 ] == '\'') ) - aMacroName = aMacroName.copy( 1, nMacroLen - 2 ).trim(); + aMacroName = o3tl::trim(aMacroName.substr( 1, nMacroLen - 2 )); return aMacroName; } @@ -290,34 +291,34 @@ MacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const OUString& Macro return MacroResolvedInfo(); // the name may be enclosed in apostrophs - OUString aMacroName = trimMacroName( MacroName ); + std::u16string_view aMacroName = trimMacroName( MacroName ); // parse the macro name - sal_Int32 nDocSepIndex = aMacroName.indexOf( '!' ); - if( nDocSepIndex > 0 ) + size_t nDocSepIndex = aMacroName.find( '!' ); + if( nDocSepIndex > 0 && nDocSepIndex != std::u16string_view::npos ) { // macro specified by document name // find document shell for document name and call ourselves // recursively // assume for now that the document name is *this* document - OUString sDocUrlOrPath = aMacroName.copy( 0, nDocSepIndex ); - aMacroName = aMacroName.copy( nDocSepIndex + 1 ); + std::u16string_view sDocUrlOrPath = aMacroName.substr( 0, nDocSepIndex ); + aMacroName = aMacroName.substr( nDocSepIndex + 1 ); SAL_INFO("filter.ms", "doc search, current shell is " << pShell); SfxObjectShell* pFoundShell = nullptr; if( bSearchGlobalTemplates ) { SvtPathOptions aPathOpt; const OUString& aAddinPath = aPathOpt.GetAddinPath(); - if( sDocUrlOrPath.startsWith( aAddinPath ) ) + if( o3tl::starts_with(sDocUrlOrPath, aAddinPath) ) pFoundShell = pShell; } if( !pFoundShell ) - pFoundShell = findShellForUrl( sDocUrlOrPath ); + pFoundShell = findShellForUrl( OUString(sDocUrlOrPath) ); SAL_INFO( "filter.ms", "doc search, after find, found shell is " << pFoundShell); - return resolveVBAMacro( pFoundShell, aMacroName ); + return resolveVBAMacro( pFoundShell, OUString(aMacroName) ); } // macro is contained in 'this' document ( or code imported from a template @@ -328,7 +329,7 @@ MacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const OUString& Macro // macro format = Container.Module.Procedure OUString sContainer, sModule, sProcedure; - parseMacro( aMacroName, sContainer, sModule, sProcedure ); + parseMacro( OUString(aMacroName), sContainer, sModule, sProcedure ); #if 0 // As long as service VBAProjectNameProvider isn't supported in the model, disable the createInstance call @@ -553,7 +554,7 @@ OUString SAL_CALL VBAMacroResolver::resolveVBAMacroToScriptURL( const OUString& throw uno::RuntimeException(); // the name may be enclosed in apostrophs - OUString aMacroName = trimMacroName( rVBAMacroName ); + OUString aMacroName( trimMacroName( rVBAMacroName ) ); if( aMacroName.isEmpty() ) throw lang::IllegalArgumentException(); diff --git a/forms/source/xforms/xpathlib/xpathlib.cxx b/forms/source/xforms/xpathlib/xpathlib.cxx index 12a955639538..ee30f710419c 100644 --- a/forms/source/xforms/xpathlib/xpathlib.cxx +++ b/forms/source/xforms/xpathlib/xpathlib.cxx @@ -21,6 +21,7 @@ #include <string.h> #include <comphelper/servicehelper.hxx> +#include <o3tl/string_view.hxx> #include <sal/types.h> #include <rtl/ustring.hxx> #include <rtl/string.hxx> @@ -284,12 +285,12 @@ void xforms_nowFunction(xmlXPathParserContextPtr ctxt, int /*nargs*/) xmlXPathReturnString(ctxt, pString); } -static bool parseDateTime(const OUString& aString, DateTime& aDateTime) +static bool parseDateTime(std::u16string_view aString, DateTime& aDateTime) { // take apart a canonical literal xsd:dateTime string //CCYY-MM-DDThh:mm:ss(Z) - OUString aDateTimeString = aString.trim(); + OUString aDateTimeString( o3tl::trim(aString) ); // check length if (aDateTimeString.getLength() < 19 || aDateTimeString.getLength() > 20) @@ -306,7 +307,7 @@ static bool parseDateTime(const OUString& aString, DateTime& aDateTime) Date tmpDate(static_cast<sal_uInt16>(nDay), static_cast<sal_uInt16>(nMonth), static_cast<sal_uInt16>(nYear)); tools::Time tmpTime(nHour, nMinute, nSecond); DateTime tmpDateTime(tmpDate, tmpTime); - if (aString.lastIndexOf('Z') < 0) + if (aString.rfind('Z') == std::u16string_view::npos) tmpDateTime.ConvertToUTC(); aDateTime = tmpDateTime; diff --git a/include/comphelper/string.hxx b/include/comphelper/string.hxx index 7d1b549bb9e3..8bf0456e0e33 100644 --- a/include/comphelper/string.hxx +++ b/include/comphelper/string.hxx @@ -417,6 +417,6 @@ inline sal_Int32 toInt32( std::string_view str, sal_Int16 radix = 10 ) } -} +} // namespace comphelper::string /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/o3tl/string_view.hxx b/include/o3tl/string_view.hxx index 848143f189ed..c62fa5f23283 100644 --- a/include/o3tl/string_view.hxx +++ b/include/o3tl/string_view.hxx @@ -238,6 +238,72 @@ constexpr bool ends_with(std::u16string_view sv, std::u16string_view x, { return ends_with<char16_t>(sv, x, rest); } + +namespace internal +{ +// copy of rtl_ImplIsWhitespace from sal/rtl/strimp.cxx +inline bool rtl_ImplIsWhitespace(sal_Unicode c) +{ + /* Space or Control character? */ + if ((c <= 32) && c) + return true; + + /* Only in the General Punctuation area Space or Control characters are included? */ + if ((c < 0x2000) || (c > 0x206F)) + return false; + + if (((c >= 0x2000) && (c <= 0x200B)) || /* All Spaces */ + (c == 0x2028) || /* LINE SEPARATOR */ + (c == 0x2029)) /* PARAGRAPH SEPARATOR */ + return true; + + return false; +} +} // namespace internal + +// Like OUString::trim, but for std::u16string_view: +// copy of the trimView code from sal/rtl/strtmpl.hxx +inline std::u16string_view trim(std::u16string_view str) +{ + sal_Int32 nLen = str.size(); + sal_Int32 nPreSpaces = 0; + sal_Int32 nPostSpaces = 0; + sal_Int32 nIndex = str.size() - 1; + + while ((nPreSpaces < nLen) && internal::rtl_ImplIsWhitespace(*(str.data() + nPreSpaces))) + nPreSpaces++; + + while ((nIndex > nPreSpaces) && internal::rtl_ImplIsWhitespace(*(str.data() + nIndex))) + { + nPostSpaces++; + nIndex--; + } + + return std::u16string_view{ str.data() + nPreSpaces, + static_cast<size_t>(nLen - nPostSpaces - nPreSpaces) }; +} + +// Like OString::trim, but for std::string_view: +// copy of the trimView code from sal/rtl/strtmpl.hxx +inline std::string_view trim(std::string_view str) +{ + sal_Int32 nLen = str.size(); + sal_Int32 nPreSpaces = 0; + sal_Int32 nPostSpaces = 0; + sal_Int32 nIndex = str.size() - 1; + + while ((nPreSpaces < nLen) && internal::rtl_ImplIsWhitespace(*(str.data() + nPreSpaces))) + nPreSpaces++; + + while ((nIndex > nPreSpaces) && internal::rtl_ImplIsWhitespace(*(str.data() + nIndex))) + { + nPostSpaces++; + nIndex--; + } + + return std::string_view{ str.data() + nPreSpaces, + static_cast<size_t>(nLen - nPostSpaces - nPreSpaces) }; +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/l10ntools/inc/lngmerge.hxx b/l10ntools/inc/lngmerge.hxx index 89f383d92ab7..3a6c2cc27be5 100644 --- a/l10ntools/inc/lngmerge.hxx +++ b/l10ntools/inc/lngmerge.hxx @@ -44,7 +44,7 @@ private: OString sSource; std::vector<OString> aLanguages; - static bool isNextGroup(OString &sGroup_out, const OString &sLine_in); + static bool isNextGroup(OString &sGroup_out, std::string_view sLine_in); static void ReadLine(const OString &rLine_in, OStringHashMap &rText_inout); static void WritePO(PoOfstream &aPOStream, OStringHashMap &rText_inout, diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index 530bda4cfc5d..3accb5e4e636 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -19,6 +19,8 @@ #include <sal/config.h> +#include <o3tl/string_view.hxx> + #include <cstddef> #include <iostream> #include <memory> @@ -30,11 +32,11 @@ namespace { -bool lcl_isNextGroup(OString &sGroup_out, const OString &sLineTrim) +bool lcl_isNextGroup(OString &sGroup_out, std::string_view sLineTrim) { - if (sLineTrim.startsWith("[") && sLineTrim.endsWith("]")) + if (o3tl::starts_with(sLineTrim, "[") && o3tl::ends_with(sLineTrim, "]")) { - sGroup_out = sLineTrim.getToken(1, '[').getToken(0, ']').trim(); + sGroup_out = OString(sLineTrim).getToken(1, '[').getToken(0, ']').trim(); return true; } return false; @@ -125,9 +127,9 @@ void LngParser::WritePO(PoOfstream &aPOStream, rID, OString(), rText_inout.count("x-comment") ? rText_inout["x-comment"] : OString(), rText_inout["en-US"]); } -bool LngParser::isNextGroup(OString &sGroup_out, const OString &sLine_in) +bool LngParser::isNextGroup(OString &sGroup_out, std::string_view sLine_in) { - return lcl_isNextGroup(sGroup_out, sLine_in.trim()); + return lcl_isNextGroup(sGroup_out, o3tl::trim(sLine_in)); } void LngParser::ReadLine(const OString &rLine_in, diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index efb786086f76..f42af8e003df 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2472,12 +2472,12 @@ void DocxAttributeOutput::StartField_Impl( const SwTextNode* pNode, sal_Int32 nP } } -void DocxAttributeOutput::DoWriteCmd( const OUString& rCmd ) +void DocxAttributeOutput::DoWriteCmd( std::u16string_view rCmd ) { - OUString sCmd = rCmd.trim(); - if (sCmd.startsWith("SEQ")) + std::u16string_view sCmd = o3tl::trim(rCmd); + if (o3tl::starts_with(sCmd, u"SEQ")) { - OUString sSeqName = msfilter::util::findQuotedText(sCmd, "SEQ ", '\\').trim(); + OUString sSeqName = msfilter::util::findQuotedText(OUString(sCmd), "SEQ ", '\\').trim(); m_aSeqBookmarksNames[sSeqName].push_back(m_sLastOpenedBookmark); } // Write the Field command diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index cef2f871f1ae..843fc0450bfb 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -768,7 +768,7 @@ private: void WriteSdtEnd(); void StartField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun = false ); - void DoWriteCmd( const OUString& rCmd ); + void DoWriteCmd( std::u16string_view rCmd ); void CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun ); void CmdEndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, bool bWriteRun ); void EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos& rInfos ); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 75c40de267fe..672f78d27d39 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -112,6 +112,7 @@ #include <unotools/mediadescriptor.hxx> #include <tools/diagnose_ex.h> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/drawing/FillStyle.hpp> #include <unicode/errorcode.h> @@ -4367,11 +4368,11 @@ static bool lcl_FindInCommand( return bRet; } -static OUString lcl_trim(const OUString& sValue) +static OUString lcl_trim(std::u16string_view sValue) { // it seems, all kind of quotation marks are allowed around index type identifiers // TODO apply this on bookmarks, too, if needed - return sValue.trim().replaceAll("\"","").replaceAll(u"“", "").replaceAll(u"”", ""); + return OUString(o3tl::trim(sValue)).replaceAll("\"","").replaceAll(u"“", "").replaceAll(u"”", ""); } void DomainMapper_Impl::GetCurrentLocale(lang::Locale& rLocale) |