diff options
Diffstat (limited to 'include/basic/sbxvar.hxx')
-rw-r--r-- | include/basic/sbxvar.hxx | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/include/basic/sbxvar.hxx b/include/basic/sbxvar.hxx index 14c3eb97a788..487b910aac84 100644 --- a/include/basic/sbxvar.hxx +++ b/include/basic/sbxvar.hxx @@ -20,10 +20,12 @@ #ifndef INCLUDED_BASIC_SBXVAR_HXX #define INCLUDED_BASIC_SBXVAR_HXX +#include <rtl/character.hxx> #include <rtl/ustring.hxx> #include <basic/sbxcore.hxx> #include <basic/basicdllapi.h> +#include <algorithm> #include <cstddef> #include <cstring> #include <memory> @@ -299,7 +301,20 @@ public: StarBASIC* pParentBasic ); void ClearComListener(); - static sal_uInt16 MakeHashCode( const OUString& rName ); + // Create a simple hashcode: the first six characters are evaluated. + static constexpr sal_uInt16 MakeHashCode(std::u16string_view aName) + { + sal_uInt16 n = 0; + const auto first6 = aName.substr(0, 6); + for (const auto& c : first6) + { + // If we have a comment sign break!! + if (c >= 0x80) + return 0; + n = static_cast<sal_uInt16>((n << 3) + rtl::toAsciiUpperCase(c)); + } + return n; + } }; typedef tools::SvRef<SbxObject> SbxObjectRef; |