summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-13 21:00:50 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-14 11:24:53 +0200
commit41fa4bb83ad95f0b2171808b405fa755613cef81 (patch)
treeef9ba4a399ea497d8ce8841d762fbefcf06ad224
parent14f6700fefa945c4cf995c09af9326c2a022f886 (diff)
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.grandin@collabora.co.uk>
-rw-r--r--filter/source/msfilter/util.cxx14
-rw-r--r--filter/source/xsltdialog/typedetectionimport.cxx23
-rw-r--r--filter/source/xsltdialog/xmlfiltercommon.hxx2
-rw-r--r--filter/source/xsltdialog/xmlfiltersettingsdialog.cxx12
-rw-r--r--include/filter/msfilter/util.hxx2
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx2
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx4
7 files changed, 30 insertions, 29 deletions
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