editeng/source/misc/svxacorr.cxx | 8 +++--- filter/source/msfilter/util.cxx | 14 +++++------ filter/source/xsltdialog/typedetectionimport.cxx | 23 +++++++++---------- filter/source/xsltdialog/xmlfiltercommon.hxx | 2 - filter/source/xsltdialog/xmlfiltersettingsdialog.cxx | 12 ++++----- include/editeng/svxacorr.hxx | 4 +-- include/filter/msfilter/util.hxx | 2 - sw/source/filter/ww8/docxattributeoutput.cxx | 2 - writerfilter/source/dmapper/DomainMapper_Impl.cxx | 4 +-- 9 files changed, 36 insertions(+), 35 deletions(-)
New commits: commit 41fa4bb83ad95f0b2171808b405fa755613cef81 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Apr 13 21:00:50 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Apr 14 11:24:53 2022 +0200 use more string_view in filter Change-Id: Ieff65b96487051721f9016c005523f31b7415901 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132984 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx index a1d3929a218c..7747c9a0ecd1 100644 --- a/filter/source/msfilter/util.cxx +++ b/filter/source/msfilter/util.cxx @@ -309,19 +309,19 @@ const ApiPaperSize& PaperSizeConv::getApiSizeForMSPaperSizeIndex( sal_Int32 nMSO return spPaperSizeTable[ nMSOPaperIndex ]; } -OUString findQuotedText( const OUString& rCommand, +std::u16string_view findQuotedText( std::u16string_view rCommand, const char* cStartQuote, const sal_Unicode uEndQuote ) { - OUString sRet; + std::u16string_view sRet; OUString sStartQuote( OUString::createFromAscii(cStartQuote) ); - sal_Int32 nStartIndex = rCommand.indexOf( sStartQuote ); - if( nStartIndex >= 0 ) + size_t nStartIndex = rCommand.find( sStartQuote ); + if( nStartIndex != std::u16string_view::npos ) { sal_Int32 nStartLength = sStartQuote.getLength(); - sal_Int32 nEndIndex = rCommand.indexOf( uEndQuote, nStartIndex + nStartLength); - if( nEndIndex > nStartIndex ) + size_t nEndIndex = rCommand.find( uEndQuote, nStartIndex + nStartLength); + if( nEndIndex != std::u16string_view::npos && nEndIndex > nStartIndex ) { - sRet = rCommand.copy( nStartIndex + nStartLength, nEndIndex - nStartIndex - nStartLength); + sRet = rCommand.substr( nStartIndex + nStartLength, nEndIndex - nStartIndex - nStartLength); } } return sRet; diff --git a/filter/source/xsltdialog/typedetectionimport.cxx b/filter/source/xsltdialog/typedetectionimport.cxx index bba302de703c..5fc5ae582951 100644 --- a/filter/source/xsltdialog/typedetectionimport.cxx +++ b/filter/source/xsltdialog/typedetectionimport.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/xml/sax/XAttributeList.hpp> #include <tools/diagnose_ex.h> #include <rtl/ref.hxx> +#include <o3tl/string_view.hxx> #include "typedetectionimport.hxx" #include "xmlfiltercommon.hxx" @@ -80,18 +81,18 @@ void TypeDetectionImporter::fillFilterVector( std::vector< std::unique_ptr<filt maTypeNodes.clear(); } -static OUString getSubdata( int index, sal_Unicode delimiter, const OUString& rData ) +static std::u16string_view getSubdata( int index, sal_Unicode delimiter, std::u16string_view rData ) { sal_Int32 nLastIndex = 0; - sal_Int32 nNextIndex = rData.indexOf( delimiter ); + size_t nNextIndex = rData.find( delimiter ); - OUString aSubdata; + std::u16string_view aSubdata; while( index ) { - nLastIndex = nNextIndex + 1; - nNextIndex = rData.indexOf( delimiter, nLastIndex ); + nLastIndex = nNextIndex == std::u16string_view::npos ? 0 : nNextIndex + 1; + nNextIndex = rData.find( delimiter, nLastIndex ); index--; @@ -99,13 +100,13 @@ static OUString getSubdata( int index, sal_Unicode delimiter, const OUString& rD return aSubdata; } - if( nNextIndex == -1 ) + if( nNextIndex == std::u16string_view::npos ) { - aSubdata = rData.copy( nLastIndex ); + aSubdata = rData.substr( nLastIndex ); } else { - aSubdata = rData.copy( nLastIndex, nNextIndex - nLastIndex ); + aSubdata = rData.substr( nLastIndex, nNextIndex - nLastIndex ); } return aSubdata; @@ -136,7 +137,7 @@ std::unique_ptr<filter_info_impl> TypeDetectionImporter::createFilterForNode( No pFilter->maDocumentService = getSubdata( 2, aComma, aData ); OUString aFilterService( getSubdata( 3, aComma, aData ) ); - pFilter->maFlags = getSubdata( 4, aComma, aData ).toInt32(); + pFilter->maFlags = o3tl::toInt32(getSubdata( 4, aComma, aData )); // parse filter user data sal_Unicode aDelim(';'); @@ -144,7 +145,7 @@ std::unique_ptr<filter_info_impl> TypeDetectionImporter::createFilterForNode( No OUString aAdapterService( getSubdata( 0, aDelim, aFilterUserData ) ); //Import/ExportService - pFilter->mbNeedsXSLT2 = getSubdata( 1, aDelim, aFilterUserData ).toBoolean(); + pFilter->mbNeedsXSLT2 = OUString(getSubdata( 1, aDelim, aFilterUserData )).toBoolean(); pFilter->maImportService = getSubdata( 2, aDelim, aFilterUserData ); pFilter->maExportService = getSubdata( 3, aDelim, aFilterUserData ); pFilter->maImportXSLT = getSubdata( 4, aDelim, aFilterUserData ); @@ -161,7 +162,7 @@ std::unique_ptr<filter_info_impl> TypeDetectionImporter::createFilterForNode( No pFilter->maDocType = getSubdata( 2, aComma, aTypeUserData ); pFilter->maExtension = getSubdata( 4, aComma, aTypeUserData ); - pFilter->mnDocumentIconID = getSubdata( 5, aComma, aTypeUserData ).toInt32(); + pFilter->mnDocumentIconID = o3tl::toInt32(getSubdata( 5, aComma, aTypeUserData )); } bool bOk = true; diff --git a/filter/source/xsltdialog/xmlfiltercommon.hxx b/filter/source/xsltdialog/xmlfiltercommon.hxx index 0d340fa12e0f..4ac225183e60 100644 --- a/filter/source/xsltdialog/xmlfiltercommon.hxx +++ b/filter/source/xsltdialog/xmlfiltercommon.hxx @@ -30,7 +30,7 @@ extern OUString string_encode( const OUString & rText ); extern OUString string_decode( const OUString & rText ); bool copyStreams( const css::uno::Reference< css::io::XInputStream >& xIS, const css::uno::Reference< css::io::XOutputStream >& xOS ); -bool createDirectory( OUString const & rURL ); +bool createDirectory( std::u16string_view rURL ); class filter_info_impl diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx index a112544c83c6..eaf0444850ce 100644 --- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx @@ -1371,15 +1371,15 @@ bool copyStreams( const Reference< XInputStream >& xIS, const Reference< XOutput return false; } -bool createDirectory( OUString const & rURL ) +bool createDirectory( std::u16string_view rURL ) { - sal_Int32 nLastIndex = sizeof( "file:///" ) - 2; - while( nLastIndex != -1 ) + size_t nLastIndex = sizeof( "file:///" ) - 2; + while( nLastIndex != std::u16string_view::npos ) { - nLastIndex = rURL.indexOf( '/', nLastIndex + 1); - if( nLastIndex != -1 ) + nLastIndex = rURL.find( '/', nLastIndex + 1); + if( nLastIndex != std::u16string_view::npos ) { - OUString aDirURL( rURL.copy( 0, nLastIndex ) ); + OUString aDirURL( rURL.substr( 0, nLastIndex ) ); Directory aDir( aDirURL ); Directory::RC rc = aDir.open(); if( rc == Directory::E_NOENT ) diff --git a/include/filter/msfilter/util.hxx b/include/filter/msfilter/util.hxx index d540da35bae7..7ad1409cc32d 100644 --- a/include/filter/msfilter/util.hxx +++ b/include/filter/msfilter/util.hxx @@ -84,7 +84,7 @@ public: * * Example: SEQ "Figure" \someoption -> "Figure" */ -MSFILTER_DLLPUBLIC OUString findQuotedText( const OUString& rCommand, const char* cStartQuote, const sal_Unicode uEndQuote ); +MSFILTER_DLLPUBLIC std::u16string_view findQuotedText( std::u16string_view rCommand, const char* cStartQuote, const sal_Unicode uEndQuote ); class MSFILTER_DLLPUBLIC WW8ReadFieldParams { diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index bf120d3e47a9..620841b27537 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2514,7 +2514,7 @@ void DocxAttributeOutput::DoWriteCmd( std::u16string_view rCmd ) std::u16string_view sCmd = o3tl::trim(rCmd); if (o3tl::starts_with(sCmd, u"SEQ")) { - OUString sSeqName = msfilter::util::findQuotedText(OUString(sCmd), "SEQ ", '\\').trim(); + OUString sSeqName( o3tl::trim(msfilter::util::findQuotedText(sCmd, "SEQ ", '\\')) ); m_aSeqBookmarksNames[sSeqName].push_back(m_sLastOpenedBookmark); } // Write the Field command diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index d7d9be2bc10c..d87c05afff01 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -4176,7 +4176,7 @@ static OUString lcl_ParseFormat( const OUString& rCommand ) else command = rCommand; - return msfilter::util::findQuotedText(command, "\\@\"", '\"'); + return OUString(msfilter::util::findQuotedText(command, "\\@\"", '\"')); } /*------------------------------------------------------------------------- extract a parameter (with or without quotes) between the command and the following backslash @@ -6657,7 +6657,7 @@ void DomainMapper_Impl::CloseFieldCommand() // command looks like: " SEQ Table \* ARABIC " OUString sCmd(pContext->GetCommand()); // find the sequence name, e.g. "SEQ" - OUString sSeqName = msfilter::util::findQuotedText(sCmd, "SEQ ", '\\'); + OUString sSeqName( msfilter::util::findQuotedText(sCmd, "SEQ ", '\\') ); sSeqName = sSeqName.trim(); // create a sequence field master using the sequence name commit 14f6700fefa945c4cf995c09af9326c2a022f886 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Apr 13 20:44:55 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Apr 14 11:24:40 2022 +0200 use more string_view in editeng Change-Id: I5104dc8ce24089b110f9cd73e0f5e62ad5b44a0a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132983 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index f77cf8821a4a..753e79a8126b 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -543,7 +543,7 @@ bool SvxAutoCorrect::FnChgOrdinalNumber( // Replace dashes bool SvxAutoCorrect::FnChgToEnEmDash( - SvxAutoCorrDoc& rDoc, const OUString& rTxt, + SvxAutoCorrDoc& rDoc, std::u16string_view rTxt, sal_Int32 nSttPos, sal_Int32 nEndPos, LanguageType eLang ) { @@ -629,7 +629,7 @@ bool SvxAutoCorrect::FnChgToEnEmDash( bool bEnDash = (eLang == LANGUAGE_HUNGARIAN || eLang == LANGUAGE_FINNISH); if( 4 <= nEndPos - nSttPos ) { - OUString sTmp( rTxt.copy( nSttPos, nEndPos - nSttPos ) ); + OUString sTmp( rTxt.substr( nSttPos, nEndPos - nSttPos ) ); sal_Int32 nFndPos = sTmp.indexOf("--"); if( nFndPos != -1 && nFndPos && nFndPos + 2 < sTmp.getLength() && @@ -1744,7 +1744,7 @@ OUString SvxAutoCorrect::GetPrevAutoCorrWord(SvxAutoCorrDoc const& rDoc, const O } // static -std::vector<OUString> SvxAutoCorrect::GetChunkForAutoText(const OUString& rTxt, +std::vector<OUString> SvxAutoCorrect::GetChunkForAutoText(std::u16string_view rTxt, const sal_Int32 nPos) { constexpr sal_Int32 nMinLen = 3; @@ -1761,7 +1761,7 @@ std::vector<OUString> SvxAutoCorrect::GetChunkForAutoText(const OUString& rTxt, } if (nBegin + nMinLen <= nPos) { - OUString sRes = rTxt.copy(nBegin, nPos - nBegin); + OUString sRes( rTxt.substr(nBegin, nPos - nBegin) ); aRes.push_back(sRes); bool bLastStartedWithDelim = IsWordDelim(sRes[0]); for (sal_Int32 i = 1; i <= sRes.getLength() - nMinLen; ++i) diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx index 0a4027256d2a..b0f25713d0e0 100644 --- a/include/editeng/svxacorr.hxx +++ b/include/editeng/svxacorr.hxx @@ -312,7 +312,7 @@ public: // 3 and 9 characters long, that is a chunk of text starting with a whitespace or with a word's // first character, and ending at the current cursor position or empty string if no such string // exists - static std::vector<OUString> GetChunkForAutoText(const OUString& rTxt, sal_Int32 nPos); + static std::vector<OUString> GetChunkForAutoText(std::u16string_view rTxt, sal_Int32 nPos); // Search for the words in the replacement table. // rText - check in this text the words of the list @@ -406,7 +406,7 @@ public: bool FnChgOrdinalNumber( SvxAutoCorrDoc&, const OUString&, sal_Int32 nSttPos, sal_Int32 nEndPos, LanguageType eLang ); - bool FnChgToEnEmDash( SvxAutoCorrDoc&, const OUString&, + bool FnChgToEnEmDash( SvxAutoCorrDoc&, std::u16string_view, sal_Int32 nSttPos, sal_Int32 nEndPos, LanguageType eLang ); bool FnAddNonBrkSpace( SvxAutoCorrDoc&, const OUString&,