summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-08-01 18:58:55 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-08-01 20:53:28 +0200
commit75a862b887fb0b7ff633a396ee7f7f34c2c82964 (patch)
tree50361f282bfcd20ff04f97b59806b95029a9a405 /sc
parentf8d764b138fddde719a04683f9bd3720c21e0656 (diff)
use more string_view when dealing with attributes
which means we don't need to call strlen on them, since we already know how long they are. Change-Id: Iefc76f38a23250e87a65c27df3634d562464a760 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137679 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/inc/addressconverter.hxx6
-rw-r--r--sc/source/filter/oox/addressconverter.cxx9
-rw-r--r--sc/source/filter/oox/sheetdatacontext.cxx4
3 files changed, 10 insertions, 9 deletions
diff --git a/sc/source/filter/inc/addressconverter.hxx b/sc/source/filter/inc/addressconverter.hxx
index af1bc340c47b..e014167839d0 100644
--- a/sc/source/filter/inc/addressconverter.hxx
+++ b/sc/source/filter/inc/addressconverter.hxx
@@ -123,7 +123,7 @@ public:
sal_Int32 nLength = SAL_MAX_INT32 );
static bool parseOoxAddress2d(
- sal_Int32& ornColumn, sal_Int32& ornRow, const char* pStr );
+ sal_Int32& ornColumn, sal_Int32& ornRow, std::string_view pStr );
/** Tries to parse the passed string for a 2d cell range in A1 notation.
@@ -214,7 +214,7 @@ public:
sal_Int16 nSheet );
static bool convertToCellAddressUnchecked(
- ScAddress& orAddress, const char* pStr, sal_Int16 nSheet );
+ ScAddress& orAddress, std::string_view pStr, sal_Int16 nSheet );
/** Tries to convert the passed string to a single cell address.
@@ -233,7 +233,7 @@ public:
bool convertToCellAddress(
ScAddress& rAddress,
- const char* pStr, sal_Int16 nSheet, bool bTrackOverflow );
+ std::string_view pStr, sal_Int16 nSheet, bool bTrackOverflow );
/** Returns a valid cell address by moving it into allowed dimensions.
diff --git a/sc/source/filter/oox/addressconverter.cxx b/sc/source/filter/oox/addressconverter.cxx
index b3fc5b16722d..b13a4a5cd896 100644
--- a/sc/source/filter/oox/addressconverter.cxx
+++ b/sc/source/filter/oox/addressconverter.cxx
@@ -138,13 +138,14 @@ bool AddressConverter::parseOoxAddress2d(
return (ornColumn >= 0) && (ornRow >= 0);
}
-bool AddressConverter::parseOoxAddress2d( sal_Int32& ornColumn, sal_Int32& ornRow, const char* pStr )
+bool AddressConverter::parseOoxAddress2d( sal_Int32& ornColumn, sal_Int32& ornRow, std::string_view aStr )
{
ornColumn = ornRow = 0;
enum { STATE_COL, STATE_ROW } eState = STATE_COL;
- while (*pStr)
+ const char* pStr = aStr.data();
+ while (pStr != aStr.data() + aStr.size())
{
char cChar = *pStr;
switch( eState )
@@ -267,7 +268,7 @@ bool AddressConverter::convertToCellAddressUnchecked( ScAddress& orAddress,
}
bool AddressConverter::convertToCellAddressUnchecked(
- ScAddress& orAddress, const char* pStr, sal_Int16 nSheet )
+ ScAddress& orAddress, std::string_view pStr, sal_Int16 nSheet )
{
orAddress.SetTab(nSheet);
sal_Int32 nCol = 0;
@@ -289,7 +290,7 @@ bool AddressConverter::convertToCellAddress( ScAddress& orAddress,
bool AddressConverter::convertToCellAddress(
ScAddress& rAddress,
- const char* pStr, sal_Int16 nSheet, bool bTrackOverflow )
+ std::string_view pStr, sal_Int16 nSheet, bool bTrackOverflow )
{
if (!convertToCellAddressUnchecked(rAddress, pStr, nSheet))
return false;
diff --git a/sc/source/filter/oox/sheetdatacontext.cxx b/sc/source/filter/oox/sheetdatacontext.cxx
index d6c4c7a266ba..c1a270afb41a 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -312,9 +312,9 @@ void SheetDataContext::importRow( const AttributeList& rAttribs )
bool SheetDataContext::importCell( const AttributeList& rAttribs )
{
bool bValid = true;
- const char* p = rAttribs.getChar(XML_r);
+ std::string_view p = rAttribs.getView(XML_r);
- if (!p)
+ if (p.empty())
{
++mnCol;
ScAddress aAddress( mnCol, mnRow, mnSheet );