diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2022-09-04 16:08:26 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-05 15:52:12 +0200 |
commit | 8364ed3d2f927c6bdb874baff96e0affcc20977b (patch) | |
tree | 7ea205f98609c53ff86ee7ce269d6e0fb00d213b /reportdesign/source | |
parent | 90b4e348114cc9d060ce056690858c4849ed8b2e (diff) |
Simplify by using replace instead of replaceAt in 2 loops in reportdesign
It required to fix loplugin:stringviewparam error during build
Change-Id: I0111ea5001d18df2913aaa9c154371a86ae7f3bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139370
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'reportdesign/source')
-rw-r--r-- | reportdesign/source/core/misc/conditionalexpression.cxx | 10 | ||||
-rw-r--r-- | reportdesign/source/filter/xml/xmlExport.cxx | 7 |
2 files changed, 3 insertions, 14 deletions
diff --git a/reportdesign/source/core/misc/conditionalexpression.cxx b/reportdesign/source/core/misc/conditionalexpression.cxx index 0fe6dbb40702..0a0eda11f3fd 100644 --- a/reportdesign/source/core/misc/conditionalexpression.cxx +++ b/reportdesign/source/core/misc/conditionalexpression.cxx @@ -64,7 +64,7 @@ namespace rptui } - bool ConditionalExpression::matchExpression( const OUString& _rExpression, const OUString& _rFieldDataSource, OUString& _out_rLHS, OUString& _out_rRHS ) const + bool ConditionalExpression::matchExpression( const OUString& _rExpression, const std::u16string_view _rFieldDataSource, OUString& _out_rLHS, OUString& _out_rRHS ) const { // if we had regular expression, the matching would be pretty easy ... // just replace $1 and $2 in the pattern with (.*), and then get them with \1 resp. \2. @@ -72,13 +72,7 @@ namespace rptui // Okay, let's start with replacing all $$ in our pattern with the actual field data source OUString sMatchExpression( m_sPattern ); - static const OUStringLiteral sFieldDataPattern( u"$$" ); - sal_Int32 nIndex( sMatchExpression.indexOf( sFieldDataPattern ) ); - while ( nIndex != -1 ) - { - sMatchExpression = sMatchExpression.replaceAt( nIndex, sFieldDataPattern.getLength(), _rFieldDataSource ); - nIndex = sMatchExpression.indexOf( sFieldDataPattern, nIndex + _rFieldDataSource.getLength() ); - } + sMatchExpression = sMatchExpression.replaceAll(u"$$", _rFieldDataSource); static const OUStringLiteral sLHSPattern( u"$1" ); static const OUStringLiteral sRHSPattern( u"$2" ); diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx index 7472b549e52e..24e2261cbdf1 100644 --- a/reportdesign/source/filter/xml/xmlExport.cxx +++ b/reportdesign/source/filter/xml/xmlExport.cxx @@ -1039,12 +1039,7 @@ void ORptExport::exportGroup(const Reference<XReportDefinition>& _xReportDefinit OUString sExpression = sField; if ( !sExpression.isEmpty() ) { - sal_Int32 nIndex = sExpression.indexOf('"'); - while ( nIndex > -1 ) - { - sExpression = sExpression.replaceAt(nIndex, 1, u"\"\""); - nIndex = sExpression.indexOf('"',nIndex+2); - } + sExpression = sExpression.replaceAll(u"\"", u"\"\""); TGroupFunctionMap::const_iterator aGroupFind = m_aGroupFunctionMap.find(xGroup); if ( aGroupFind != m_aGroupFunctionMap.end() ) |