basic/source/classes/image.cxx | 78 ++++++++++++++++++++--------------------- basic/source/inc/image.hxx | 2 - 2 files changed, 40 insertions(+), 40 deletions(-)
New commits: commit 674918bcafcd4270dc67042df66efa85dd80f747 Author: Mike Kaganski <[email protected]> AuthorDate: Sat Sep 27 19:34:47 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Sat Sep 27 17:57:13 2025 +0200 Make sure that SbiImage::GetString sets peType And flatten the function. Change-Id: I3d8c3e7a7fcc8879be0c6f38094ef2716500a367 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191567 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx index e1b37fd926c0..ec67430dff39 100644 --- a/basic/source/classes/image.cxx +++ b/basic/source/classes/image.cxx @@ -619,53 +619,53 @@ void SbiImage::AddEnum(SbxObject* pObject) // Register enum type } // Note: IDs start with 1 -OUString SbiImage::GetString( sal_uInt32 nId, SbxDataType *eType ) const +OUString SbiImage::GetString(sal_uInt32 nId, SbxDataType* peType) const { - if( nId && nId <= mvStringOffsets.size() ) + if (nId < 1 || nId > mvStringOffsets.size()) { - sal_uInt32 nOff = mvStringOffsets[ nId - 1 ]; - sal_Unicode* pStr = pStrings.get() + nOff; + if (peType) + *peType = SbxEMPTY; + return {}; + } - sal_uInt32 nNextOff = (nId < mvStringOffsets.size()) ? mvStringOffsets[ nId ] : nStringSize; - sal_uInt32 nLen = nNextOff - nOff - 1; - // #i42467: Special treatment for vbNullChar - if (*pStr == 0) - { - if( nLen == 1 ) - { - return OUString( u' - } - } - else + sal_uInt32 nOff = mvStringOffsets[ nId - 1 ]; + sal_Unicode* pStr = pStrings.get() + nOff; + + sal_uInt32 nNextOff = (nId < mvStringOffsets.size()) ? mvStringOffsets[ nId ] : nStringSize; + sal_uInt32 nLen = nNextOff - nOff - 1; + OUString aOUStr(pStr); + // #i42467: Special treatment for vbNullChar + if (aOUStr.isEmpty() && nLen == 1) + { + if (peType) + *peType = SbxSTRING; + return OUString(u' + } + + // tdf#143707 - check if the data type character was added after the string termination + // symbol. It was added in basic/source/comp/symtbl.cxx. + if (peType) + { + *peType = SbxSTRING; + if (o3tl::make_unsigned(aOUStr.getLength()) < nLen) { - // tdf#143707 - check if the data type character was added after the string termination - // symbol. It was added in basic/source/comp/symtbl.cxx. - OUString aOUStr(pStr); - if (eType != nullptr) + const sal_Unicode pTypeChar = *(pStr + aOUStr.getLength() + 1); + switch (pTypeChar) { - *eType = SbxSTRING; - if (o3tl::make_unsigned(aOUStr.getLength()) < nLen) - { - const sal_Unicode pTypeChar = *(pStrings.get() + nOff + aOUStr.getLength() + 1); - switch (pTypeChar) - { - // See GetSuffixType in basic/source/comp/scanner.cxx for type characters - case '%': *eType = SbxINTEGER; break; - case '&': *eType = SbxLONG; break; - case '!': *eType = SbxSINGLE; break; - case '#': *eType = SbxDOUBLE; break; - case '@': *eType = SbxCURRENCY; break; - // tdf#142460 - properly handle boolean values in string pool - case 'b': *eType = SbxBOOL; break; - // tdf#168569 - support date values in string pool - case 'd': *eType = SbxDATE; break; // Not in GetSuffixType - } - } + // See GetSuffixType in basic/source/comp/scanner.cxx for type characters + case '%': *peType = SbxINTEGER; break; + case '&': *peType = SbxLONG; break; + case '!': *peType = SbxSINGLE; break; + case '#': *peType = SbxDOUBLE; break; + case '@': *peType = SbxCURRENCY; break; + // tdf#142460 - properly handle boolean values in string pool + case 'b': *peType = SbxBOOL; break; // Not in GetSuffixType + // tdf#168569 - support date values in string pool + case 'd': *peType = SbxDATE; break; // Not in GetSuffixType } - return aOUStr; } } - return OUString(); + return aOUStr; } const SbxObject* SbiImage::FindType (const OUString& aTypeName) const diff --git a/basic/source/inc/image.hxx b/basic/source/inc/image.hxx index 36f5ab5a0bc8..825d885c9359 100644 --- a/basic/source/inc/image.hxx +++ b/basic/source/inc/image.hxx @@ -84,7 +84,7 @@ public: const sal_uInt8* GetCode() const { return aCode.data(); } sal_uInt32 GetCodeSize() const { return aCode.size(); } sal_uInt16 GetBase() const { return nDimBase; } - OUString GetString( sal_uInt32 nId, SbxDataType *eType = nullptr ) const; + OUString GetString(sal_uInt32 nId, SbxDataType* peType = nullptr) const; const SbxObject* FindType (const OUString& aTypeName) const; const SbxArrayRef& GetEnums() const { return rEnums; }
