summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-11 22:24:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-12 12:42:15 +0200
commitcbaf1fbaa6e707d939f815eda360fad68a492aca (patch)
tree20b3dfeac257130afb01572b2c117b7840d07007 /oox/source
parentf751417b77e6573a0c639778e76ec943449f4573 (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 'oox/source')
-rw-r--r--oox/source/drawingml/customshapepresetdata.cxx6
-rw-r--r--oox/source/ole/vbahelper.cxx11
-rw-r--r--oox/source/ole/vbamodule.cxx3
-rw-r--r--oox/source/vml/vmlformatting.cxx14
-rw-r--r--oox/source/vml/vmlshapecontext.cxx10
-rw-r--r--oox/source/vml/vmltextboxcontext.cxx3
6 files changed, 25 insertions, 22 deletions
diff --git a/oox/source/drawingml/customshapepresetdata.cxx b/oox/source/drawingml/customshapepresetdata.cxx
index c7e68a88165a..cd4efc2d4c93 100644
--- a/oox/source/drawingml/customshapepresetdata.cxx
+++ b/oox/source/drawingml/customshapepresetdata.cxx
@@ -29,13 +29,13 @@ namespace
// Parses a string like: Value = (any) { (long) 19098 }, State = (com.sun.star.beans.PropertyState) DIRECT_VALUE, Name = "adj"
void lcl_parseAdjustmentValue(
std::vector<drawing::EnhancedCustomShapeAdjustmentValue>& rAdjustmentValues,
- const OString& rValue)
+ std::string_view rValue)
{
sal_Int32 nIndex = 0;
drawing::EnhancedCustomShapeAdjustmentValue aAdjustmentValue;
do
{
- OString aToken = rValue.getToken(0, ',', nIndex).trim();
+ OString aToken(o3tl::trim(o3tl::getToken(rValue, 0, ',', nIndex)));
static const char aNamePrefix[] = "Name = \"";
static const char aValuePrefix[] = "Value = (any) { (long) ";
if (aToken.startsWith(aNamePrefix))
@@ -78,7 +78,7 @@ void lcl_parseAdjustmentValues(
{
lcl_parseAdjustmentValue(
rAdjustmentValues,
- rValue.copy(nStart + strlen("{ "), i - nStart - strlen(" },")));
+ rValue.subView(nStart + strlen("{ "), i - nStart - strlen(" },")));
}
}
}
diff --git a/oox/source/ole/vbahelper.cxx b/oox/source/ole/vbahelper.cxx
index 6b48055aa679..e5377568a563 100644
--- a/oox/source/ole/vbahelper.cxx
+++ b/oox/source/ole/vbahelper.cxx
@@ -19,6 +19,7 @@
#include <oox/ole/vbahelper.hxx>
#include <osl/diagnose.h>
+#include <o3tl/string_view.hxx>
#include <oox/helper/binaryinputstream.hxx>
namespace oox::ole {
@@ -41,13 +42,13 @@ bool VbaHelper::readDirRecord( sal_uInt16& rnRecId, StreamDataSequence& rRecData
return !rInStrm.isEof() && (rInStrm.readData( rRecData, nRecSize ) == nRecSize);
}
-bool VbaHelper::extractKeyValue( OUString& rKey, OUString& rValue, const OUString& rKeyValue )
+bool VbaHelper::extractKeyValue( OUString& rKey, OUString& rValue, std::u16string_view rKeyValue )
{
- sal_Int32 nEqSignPos = rKeyValue.indexOf( '=' );
- if( nEqSignPos > 0 )
+ size_t nEqSignPos = rKeyValue.find( '=' );
+ if( nEqSignPos > 0 && nEqSignPos != std::u16string_view::npos )
{
- rKey = rKeyValue.copy( 0, nEqSignPos ).trim();
- rValue = rKeyValue.copy( nEqSignPos + 1 ).trim();
+ rKey = o3tl::trim(rKeyValue.substr( 0, nEqSignPos ));
+ rValue = o3tl::trim(rKeyValue.substr( nEqSignPos + 1 ));
return !rKey.isEmpty() && !rValue.isEmpty();
}
return false;
diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx
index d53e525989e6..21a2af75caed 100644
--- a/oox/source/ole/vbamodule.cxx
+++ b/oox/source/ole/vbamodule.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/awt/KeyEvent.hpp>
#include <osl/diagnose.h>
#include <rtl/character.hxx>
+#include <o3tl/string_view.hxx>
#include <filter/msfilter/msvbahelper.hxx>
#include <oox/helper/binaryinputstream.hxx>
#include <oox/helper/storagebase.hxx>
@@ -237,7 +238,7 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg )
procInfo.nPos = aSourceCode.getLength();
}
}
- else if ( mbExecutable && aCodeLine.trim().match("End Sub") )
+ else if ( mbExecutable && o3tl::starts_with(o3tl::trim(aCodeLine), u"End Sub") )
{
// un-matched End Sub
if ( !procInfo.bInProcedure )
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index 2143647edec1..e195a1e94183 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -76,17 +76,17 @@ bool lclExtractDouble( double& orfValue, sal_Int32& ornEndPos, const OUString& r
} // namespace
bool ConversionHelper::separatePair( OUString& orValue1, OUString& orValue2,
- const OUString& rValue, sal_Unicode cSep )
+ std::u16string_view rValue, sal_Unicode cSep )
{
- sal_Int32 nSepPos = rValue.indexOf( cSep );
- if( nSepPos >= 0 )
+ size_t nSepPos = rValue.find( cSep );
+ if( nSepPos != std::u16string_view::npos )
{
- orValue1 = rValue.copy( 0, nSepPos ).trim();
- orValue2 = rValue.copy( nSepPos + 1 ).trim();
+ orValue1 = o3tl::trim(rValue.substr( 0, nSepPos ));
+ orValue2 = o3tl::trim(rValue.substr( nSepPos + 1 ));
}
else
{
- orValue1 = rValue.trim();
+ orValue1 = o3tl::trim(rValue);
}
return !orValue1.isEmpty() && !orValue2.isEmpty();
}
@@ -951,7 +951,7 @@ void TextpathModel::pushToPropMap(ShapePropertyMap& rPropMap, const uno::Referen
while( nIndex >= 0 )
{
OUString aName, aValue;
- if (ConversionHelper::separatePair(aName, aValue, aStyle.getToken(0, ';', nIndex), ':'))
+ if (ConversionHelper::separatePair(aName, aValue, o3tl::getToken(aStyle, 0, ';', nIndex), ':'))
{
if (aName == "font-family")
{
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index d5e7996cbada..a4d87bb0e9c9 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -157,9 +157,9 @@ ContextHandlerRef ShapeLayoutContext::onCreateContext( sal_Int32 nElement, const
sal_Int32 nIndex = 0;
while( nIndex >= 0 )
{
- OUString aToken = aBlockIds.getToken( 0, ' ', nIndex ).trim();
- if( !aToken.isEmpty() )
- mrDrawing.registerBlockId( aToken.toInt32() );
+ std::u16string_view aToken = o3tl::trim(o3tl::getToken(aBlockIds, 0, ' ', nIndex ));
+ if( !aToken.empty() )
+ mrDrawing.registerBlockId( o3tl::toInt32(aToken) );
}
}
break;
@@ -459,13 +459,13 @@ OptValue< OUString > ShapeTypeContext::decodeFragmentPath( const AttributeList&
return oFragmentPath;
}
-void ShapeTypeContext::setStyle( const OUString& rStyle )
+void ShapeTypeContext::setStyle( std::u16string_view rStyle )
{
sal_Int32 nIndex = 0;
while( nIndex >= 0 )
{
OUString aName, aValue;
- if( ConversionHelper::separatePair( aName, aValue, rStyle.getToken( 0, ';', nIndex ), ':' ) )
+ if( ConversionHelper::separatePair( aName, aValue, o3tl::getToken(rStyle, 0, ';', nIndex ), ':' ) )
{
if( aName == "position" ) mrTypeModel.maPosition = aValue;
else if( aName == "z-index" ) mrTypeModel.maZIndex = aValue;
diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx
index 2cf5ebfaf40d..00c56092ed2e 100644
--- a/oox/source/vml/vmltextboxcontext.cxx
+++ b/oox/source/vml/vmltextboxcontext.cxx
@@ -25,6 +25,7 @@
#include <oox/token/tokens.hxx>
#include <osl/diagnose.h>
#include <sal/log.hxx>
+#include <o3tl/string_view.hxx>
namespace oox::vml {
@@ -213,7 +214,7 @@ TextBoxContext::TextBoxContext( ContextHandler2Helper const & rParent, TextBox&
while( nIndex >= 0 )
{
OUString aName, aValue;
- if( ConversionHelper::separatePair( aName, aValue, sStyle.getToken( 0, ';', nIndex ), ':' ) )
+ if( ConversionHelper::separatePair( aName, aValue, o3tl::getToken(sStyle, 0, ';', nIndex ), ':' ) )
{
if( aName == "layout-flow" ) rTextBox.maLayoutFlow = aValue;
else if (aName == "mso-fit-shape-to-text")