summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-02-09 11:11:21 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-02-09 15:24:21 +0100
commita3e8bacbdb8d50ca5eb4917462cc9806be4879a2 (patch)
tree105690d88805a8e85afec983bcc3acda8ea4e0a9 /tools
parentdce85afb01c74eddb2cec3656fa76867aa131bd1 (diff)
Flatten SvGlobalName::MakeId
Change-Id: I5b592162d0fad3e57cfe9ad6d4b2252e7f7596d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129709 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/ref/globname.cxx100
1 files changed, 46 insertions, 54 deletions
diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index 87bb46d50c2b..7784f3fc722a 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -100,63 +100,55 @@ void SvGlobalName::MakeFromMemory( void const * pData )
bool SvGlobalName::MakeId( const OUString & rIdStr )
{
const sal_Unicode *pStr = rIdStr.getStr();
- if( rIdStr.getLength() == 36
- && '-' == pStr[ 8 ] && '-' == pStr[ 13 ]
- && '-' == pStr[ 18 ] && '-' == pStr[ 23 ] )
+ if( rIdStr.getLength() != 36
+ || '-' != pStr[ 8 ] || '-' != pStr[ 13 ]
+ || '-' != pStr[ 18 ] || '-' != pStr[ 23 ] )
+ return false;
+
+ SvGUID aGuid = {};
+ auto asciiHexDigitToNumber = [](sal_Unicode c) -> sal_uInt8
{
- SvGUID aGuid = {};
- auto asciiHexDigitToNumber = [](sal_Unicode c) -> sal_uInt8
- {
- if (rtl::isAsciiDigit(c))
- return c - '0';
- else
- return rtl::toAsciiUpperCase(c) - 'A' + 10;
- };
- for( int i = 0; i < 8; i++ )
- {
- if( rtl::isAsciiHexDigit( *pStr ) )
- aGuid.Data1 = aGuid.Data1 * 16 + asciiHexDigitToNumber( *pStr );
- else
- return false;
- pStr++;
- }
-
- pStr++;
- for( int i = 0; i < 4; i++ )
- {
- if( rtl::isAsciiHexDigit( *pStr ) )
- aGuid.Data2 = aGuid.Data2 * 16 + asciiHexDigitToNumber( *pStr );
- else
- return false;
- pStr++;
- }
-
- pStr++;
- for( int i = 0; i < 4; i++ )
- {
- if( rtl::isAsciiHexDigit( *pStr ) )
- aGuid.Data3 = aGuid.Data3 * 16 + asciiHexDigitToNumber( *pStr );
- else
- return false;
- pStr++;
- }
-
- pStr++;
- for( int i = 0; i < 16; i++ )
- {
- if( rtl::isAsciiHexDigit( *pStr ) )
- aGuid.Data4[i/2] = aGuid.Data4[i/2] * 16 + asciiHexDigitToNumber( *pStr );
- else
- return false;
- pStr++;
- if( i == 3 )
- pStr++;
- }
+ if (rtl::isAsciiDigit(c))
+ return c - '0';
+ else
+ return rtl::toAsciiUpperCase(c) - 'A' + 10;
+ };
- m_aData = aGuid;
- return true;
+ for( int i = 0; i < 8; i++ )
+ {
+ if( !rtl::isAsciiHexDigit( *pStr ) )
+ return false;
+ aGuid.Data1 = aGuid.Data1 * 16 + asciiHexDigitToNumber( *pStr++ );
}
- return false;
+
+ pStr++;
+ for( int i = 0; i < 4; i++ )
+ {
+ if( !rtl::isAsciiHexDigit( *pStr ) )
+ return false;
+ aGuid.Data2 = aGuid.Data2 * 16 + asciiHexDigitToNumber( *pStr++ );
+ }
+
+ pStr++;
+ for( int i = 0; i < 4; i++ )
+ {
+ if( !rtl::isAsciiHexDigit( *pStr ) )
+ return false;
+ aGuid.Data3 = aGuid.Data3 * 16 + asciiHexDigitToNumber( *pStr++ );
+ }
+
+ pStr++;
+ for( int i = 0; i < 16; i++ )
+ {
+ if( !rtl::isAsciiHexDigit( *pStr ) )
+ return false;
+ aGuid.Data4[i/2] = aGuid.Data4[i/2] * 16 + asciiHexDigitToNumber( *pStr++ );
+ if( i == 3 )
+ pStr++;
+ }
+
+ m_aData = aGuid;
+ return true;
}
OUString SvGlobalName::GetHexName() const