sw/inc/calc.hxx                              |   12 ++++++++----
 sw/inc/ccoll.hxx                             |    2 +-
 sw/inc/fmtcol.hxx                            |    8 ++++----
 sw/source/core/bastyp/calc.cxx               |    4 ++--
 sw/source/core/doc/DocumentFieldsManager.cxx |   10 +++++-----
 sw/source/core/doc/docfld.cxx                |    4 ++--
 sw/source/core/doc/fmtcol.cxx                |    4 ++--
 7 files changed, 24 insertions(+), 20 deletions(-)

New commits:
commit 50bd2ca20618ba9c9f512716d8de7521a9fde0f6
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Sep 28 11:12:32 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Sep 28 13:08:28 2022 +0200

    sal_uLong->sal_uInt32 in CommandStruct
    
    we are already using sal_uInt32 for this in some places
    
    Change-Id: I69ed8f6c29215fcedcafc403861cdd0e06c034ef
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140701
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/ccoll.hxx b/sw/inc/ccoll.hxx
index 978b8c698a83..4052d4f0afdd 100644
--- a/sw/inc/ccoll.hxx
+++ b/sw/inc/ccoll.hxx
@@ -31,7 +31,7 @@ enum class Master_CollCondition;
 struct CommandStruct
 {
     Master_CollCondition nCnd;
-    sal_uLong nSubCond;
+    sal_uInt32 nSubCond;
 };
 
 sal_Int16 GetCommandContextIndex( std::u16string_view rContextName );
diff --git a/sw/inc/fmtcol.hxx b/sw/inc/fmtcol.hxx
index 1b1bd7d2e46d..b5706dc0761b 100644
--- a/sw/inc/fmtcol.hxx
+++ b/sw/inc/fmtcol.hxx
@@ -207,12 +207,12 @@ enum class Master_CollCondition
 class SW_DLLPUBLIC SwCollCondition final : public SwClient
 {
     Master_CollCondition m_nCondition;
-    sal_uLong m_nSubCondition;
+    sal_uInt32 m_nSubCondition;
 
 public:
 
     SwCollCondition( SwTextFormatColl* pColl, Master_CollCondition nMasterCond,
-                    sal_uLong nSubCond );
+                    sal_uInt32 nSubCond );
     virtual ~SwCollCondition() override;
 
     /// @@@ public copy ctor, but no copy assignment?
@@ -225,9 +225,9 @@ public:
     bool operator==( const SwCollCondition& rCmp ) const;
 
     Master_CollCondition GetCondition() const      { return m_nCondition; }
-    sal_uLong GetSubCondition() const   { return m_nSubCondition; }
+    sal_uInt32 GetSubCondition() const   { return m_nSubCondition; }
 
-    void SetCondition( Master_CollCondition nCond, sal_uLong nSubCond );
+    void SetCondition( Master_CollCondition nCond, sal_uInt32 nSubCond );
     SwTextFormatColl* GetTextFormatColl() const     { return 
const_cast<SwTextFormatColl*>(static_cast<const 
SwTextFormatColl*>(GetRegisteredIn())); }
     void RegisterToFormat( SwFormat& );
 };
diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx
index 9cc951b52a0c..b2e66b7c4d31 100644
--- a/sw/source/core/doc/fmtcol.cxx
+++ b/sw/source/core/doc/fmtcol.cxx
@@ -495,7 +495,7 @@ void SwTextFormatColls::dumpAsXml(xmlTextWriterPtr pWriter) 
const
 //FEATURE::CONDCOLL
 
 SwCollCondition::SwCollCondition( SwTextFormatColl* pColl, 
Master_CollCondition nMasterCond,
-                                sal_uLong nSubCond )
+                                sal_uInt32 nSubCond )
     : SwClient( pColl ), m_nCondition( nMasterCond ),
       m_nSubCondition( nSubCond )
 {
@@ -523,7 +523,7 @@ bool SwCollCondition::operator==( const SwCollCondition& 
rCmp ) const
         && ( m_nSubCondition == rCmp.m_nSubCondition );
 }
 
-void SwCollCondition::SetCondition( Master_CollCondition nCond, sal_uLong 
nSubCond )
+void SwCollCondition::SetCondition( Master_CollCondition nCond, sal_uInt32 
nSubCond )
 {
     m_nCondition = nCond;
     m_nSubCondition = nSubCond;
commit 913ed3e5673c2d70e2c4e519eb65368b0606d7f0
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Sep 28 11:01:22 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Sep 28 13:08:15 2022 +0200

    sal_uLong->sal_uInt32 in SwHashTable
    
    Also
    (*) increase the number of items this table supports from SAL_MAX_UINT16
    to SAL_MAX_UINT32
    (*) add some asserts to document and verify the above limit
    
    Change-Id: I53f83303af04a9ac4f3786b221e338a7684fa1ac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140700
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx
index 2a770dc447cd..f88fe8582f6c 100644
--- a/sw/inc/calc.hxx
+++ b/sw/inc/calc.hxx
@@ -154,15 +154,19 @@ class SwHashTable
 {
     std::vector<std::unique_ptr<T>> m_aData;
 public:
-    SwHashTable(size_t nSize) : m_aData(nSize) {}
+    SwHashTable(size_t nSize) : m_aData(nSize)
+    {
+        assert(nSize < SAL_MAX_UINT32);
+    }
     std::unique_ptr<T> & operator[](size_t idx) { return m_aData[idx]; }
     std::unique_ptr<T> const & operator[](size_t idx) const { return 
m_aData[idx]; }
     void resize(size_t nSize) { m_aData.resize(nSize); }
 
-    T* Find( const OUString& rStr, sal_uInt16* pPos = nullptr ) const
+    T* Find( const OUString& rStr, sal_uInt32* pPos = nullptr ) const
     {
         size_t nTableSize = m_aData.size();
-        sal_uLong ii = 0;
+        assert(nTableSize < SAL_MAX_UINT32);
+        sal_uInt32 ii = 0;
         for( sal_Int32 n = 0; n < rStr.getLength(); ++n )
         {
             ii = ii << 1 ^ rStr[n];
@@ -170,7 +174,7 @@ public:
         ii %= nTableSize;
 
         if( pPos )
-            *pPos = o3tl::narrowing<sal_uInt16>(ii);
+            *pPos = ii;
 
         for( T* pEntry = m_aData[ii].get(); pEntry; pEntry = 
static_cast<T*>(pEntry->pNext.get()) )
         {
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index d63ab0231914..592f969bde0b 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -429,7 +429,7 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns 
)
 {
     m_aErrExpr.nValue.SetVoidValue(false);
 
-    sal_uInt16 ii = 0;
+    sal_uInt32 ii = 0;
     OUString aStr = m_pCharClass->lowercase( rStr );
 
     SwCalcExp* pFnd = m_aVarTable.Find(aStr, &ii);
@@ -597,7 +597,7 @@ void SwCalc::VarChange( const OUString& rStr, const 
SwSbxValue& rValue )
 {
     OUString aStr = m_pCharClass->lowercase( rStr );
 
-    sal_uInt16 nPos = 0;
+    sal_uInt32 nPos = 0;
     SwCalcExp* pFnd = m_aVarTable.Find( aStr, &nPos );
 
     if( !pFnd )
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx 
b/sw/source/core/doc/DocumentFieldsManager.cxx
index 334b7edd1580..fc604900a139 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -928,7 +928,7 @@ void DocumentFieldsManager::UpdateExpFieldsImpl(
             case SwFieldIds::User:
                 {
                     // Entry present?
-                    sal_uInt16 nPos;
+                    sal_uInt32 nPos;
                     const OUString& rNm = pFieldType->GetName();
                     OUString 
sExpand(const_cast<SwUserFieldType*>(static_cast<const 
SwUserFieldType*>(pFieldType))->Expand(nsSwGetSetExpType::GSE_STRING, 0, 
LANGUAGE_SYSTEM));
                     SwHash* pFnd = aHashStrTable.Find( rNm, &nPos );
@@ -1110,7 +1110,7 @@ void DocumentFieldsManager::UpdateExpFieldsImpl(
 
             // Add entry to hash table
             // Entry present?
-            sal_uInt16 nPos;
+            sal_uInt32 nPos;
             HashStr* pFnd = aHashStrTable.Find( rName, &nPos );
             OUString const value(pField->ExpandField(m_rDoc.IsClipBoard(), 
nullptr));
             if( pFnd )
@@ -1159,7 +1159,7 @@ void DocumentFieldsManager::UpdateExpFieldsImpl(
                     // lookup the field's name
                     aNew = 
static_cast<SwSetExpFieldType*>(pSField->GetTyp())->GetSetRefName();
                     // Entry present?
-                    sal_uInt16 nPos;
+                    sal_uInt32 nPos;
                     HashStr* pFnd = aHashStrTable.Find( aNew, &nPos );
                     if( pFnd )
                         // Modify entry in the hash table
@@ -1659,7 +1659,7 @@ void DocumentFieldsManager::FieldsToExpand( 
SwHashTable<HashStr> & rHashTable,
                 // look up the field's name
                 aNew = 
static_cast<SwSetExpFieldType*>(pSField->GetTyp())->GetSetRefName();
                 // Entry present?
-                sal_uInt16 nPos;
+                sal_uInt32 nPos;
                 SwHash* pFnd = rHashTable.Find( aNew, &nPos );
                 if( pFnd )
                     // modify entry in the hash table
@@ -1676,7 +1676,7 @@ void DocumentFieldsManager::FieldsToExpand( 
SwHashTable<HashStr> & rHashTable,
 
                 // Insert entry in the hash table
                 // Entry present?
-                sal_uInt16 nPos;
+                sal_uInt32 nPos;
                 HashStr* pFnd = rHashTable.Find( rName, &nPos );
                 OUString const value(pField->ExpandField(m_rDoc.IsClipBoard(), 
nullptr));
                 if( pFnd )
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 03afc4668401..5cae8a66f8ee 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -1187,7 +1187,7 @@ void SwDocUpdateField::InsertFieldType( const 
SwFieldType& rType )
     SetFieldsDirty( true );
     // look up and remove from the hash table
     sFieldName = GetAppCharClass().lowercase( sFieldName );
-    sal_uInt16 n;
+    sal_uInt32 n;
 
     SwCalcFieldType* pFnd = GetFieldTypeTable().Find( sFieldName, &n );
 
@@ -1219,7 +1219,7 @@ void SwDocUpdateField::RemoveFieldType( const 
SwFieldType& rType )
     SetFieldsDirty( true );
     // look up and remove from the hash table
     sFieldName = GetAppCharClass().lowercase( sFieldName );
-    sal_uInt16 n;
+    sal_uInt32 n;
 
     SwCalcFieldType* pFnd = GetFieldTypeTable().Find( sFieldName, &n );
     if( !pFnd )

Reply via email to