sc/inc/chartpos.hxx                    |    8 +++---
 sc/inc/column.hxx                      |    6 ++--
 sc/inc/document.hxx                    |   39 +++++++++++++++---------------
 sc/inc/progress.hxx                    |   20 +++++++--------
 sc/inc/rangelst.hxx                    |    2 -
 sc/inc/table.hxx                       |   40 +++++++++++++++----------------
 sc/qa/unit/rangelst_test.cxx           |   10 +++----
 sc/qa/unit/subsequent_export_test2.cxx |    6 ++--
 sc/qa/unit/ucalc.cxx                   |   26 ++++++++++----------
 sc/source/core/data/column2.cxx        |   10 +++----
 sc/source/core/data/dociter.cxx        |    8 +++---
 sc/source/core/data/documen3.cxx       |    2 -
 sc/source/core/data/documen4.cxx       |    6 ++--
 sc/source/core/data/document.cxx       |   32 ++++++++++++-------------
 sc/source/core/data/table1.cxx         |    6 ++--
 sc/source/core/data/table2.cxx         |   38 ++++++++++++++---------------
 sc/source/core/data/table3.cxx         |   16 ++++++------
 sc/source/core/data/table4.cxx         |   42 ++++++++++++++++-----------------
 sc/source/core/data/table5.cxx         |    8 +++---
 sc/source/core/tool/editutil.cxx       |    2 -
 sc/source/core/tool/progress.cxx       |    8 +++---
 sc/source/core/tool/rangelst.cxx       |   12 ++++-----
 sc/source/filter/html/htmlexp.cxx      |    2 -
 sc/source/filter/xml/xmlimprt.cxx      |    2 -
 sc/source/ui/unoobj/cellsuno.cxx       |    2 -
 sc/source/ui/view/output.cxx           |    8 +++---
 sc/source/ui/view/output2.cxx          |    8 +++---
 sc/source/ui/view/printfun.cxx         |    2 -
 sc/source/ui/view/select.cxx           |    2 -
 sc/source/ui/view/tabview.cxx          |    2 -
 sc/source/ui/view/viewdata.cxx         |    8 +++---
 sc/source/ui/view/viewfun5.cxx         |    2 -
 32 files changed, 193 insertions(+), 192 deletions(-)

New commits:
commit 8232965cfb5f50bb2e01f7749d04c227a9622860
Author:     Luboš Luňák <[email protected]>
AuthorDate: Mon Feb 7 18:15:20 2022 +0100
Commit:     Luboš Luňák <[email protected]>
CommitDate: Thu Feb 10 17:31:36 2022 +0100

    replace various sal_uLong that might overflow with huge sheets
    
    16Mx16k cells is more than 32bit, so things like cell counts
    or progress -> sal_uInt64. Height/widths of complete rows/columns
    -> tools::Long.
    
    Change-Id: I8077ec0c97782310db024c20c335cfcbc3833227
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129634
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <[email protected]>

diff --git a/sc/inc/chartpos.hxx b/sc/inc/chartpos.hxx
index efc1a94e7c6d..882810d900a8 100644
--- a/sc/inc/chartpos.hxx
+++ b/sc/inc/chartpos.hxx
@@ -36,7 +36,7 @@ class ScChartPositionMap
             std::unique_ptr<std::unique_ptr<ScAddress>[]> ppData;
             std::unique_ptr<std::unique_ptr<ScAddress>[]> ppColHeader;
             std::unique_ptr<std::unique_ptr<ScAddress>[]> ppRowHeader;
-            sal_uLong           nCount;
+            sal_uInt64          nCount;
             SCCOL               nColCount;
             SCROW               nRowCount;
 
@@ -58,10 +58,10 @@ public:
             bool                IsValid( SCCOL nCol, SCROW nRow ) const
                                     { return nCol < nColCount && nRow < 
nRowCount; }
                                 // data column by column
-            sal_uLong               GetIndex( SCCOL nCol, SCROW nRow ) const
-                                    { return static_cast<sal_uLong>(nCol) * 
nRowCount + nRow; }
+            sal_uInt64          GetIndex( SCCOL nCol, SCROW nRow ) const
+                                    { return static_cast<sal_uInt64>(nCol) * 
nRowCount + nRow; }
 
-            const ScAddress*    GetPosition( sal_uLong nIndex ) const
+            const ScAddress*    GetPosition( sal_uInt64 nIndex ) const
                                     {
                                         if ( nIndex < nCount )
                                             return ppData[ nIndex ].get();
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 480e691366c2..49fd2dc9b612 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -383,9 +383,9 @@ public:
     ScFormulaCell * const * GetFormulaCellBlockAddress( SCROW nRow, size_t& 
rBlockSize ) const;
     CellType    GetCellType( SCROW nRow ) const;
     SCSIZE      GetCellCount() const;
-    sal_uLong GetWeightedCount() const;
-    sal_uLong GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
-    sal_uInt32 GetCodeCount() const;       // RPN-Code in formulas
+    sal_uInt64  GetWeightedCount() const;
+    sal_uInt64  GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
+    sal_uInt64  GetCodeCount() const;       // RPN-Code in formulas
     FormulaError  GetErrCode( SCROW nRow ) const;
 
     bool    HasStringData( SCROW nRow ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 33e529d0b426..158b9f3844c6 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -277,8 +277,8 @@ struct ScDocStat
 {
     OUString  aDocName;
     SCTAB   nTableCount;
-    sal_uLong   nCellCount;
-    sal_uLong   nFormulaCount;
+    sal_uInt64  nCellCount;
+    sal_uInt64  nFormulaCount;
     sal_uInt16  nPageCount;
     ScDocStat()
         : nTableCount(0)
@@ -456,8 +456,8 @@ private:
         documents, GRAM_ODFF for ODF 1.2 documents. */
     formula::FormulaGrammar::Grammar  eStorageGrammar;
 
-    sal_uLong               nFormulaCodeInTree;             // formula RPN in 
the formula tree
-    sal_uLong               nXMLImportedFormulaCount;        // progress count 
during XML import
+    sal_uInt64              nFormulaCodeInTree;             // formula RPN in 
the formula tree
+    sal_uInt64              nXMLImportedFormulaCount;       // progress count 
during XML import
     sal_uInt16              nInterpretLevel;                // >0 if in 
interpreter
     sal_uInt16              nMacroInterpretLevel;           // >0 if macro in 
interpreter
     sal_uInt16              nInterpreterTableOpLevel;       // >0 if in 
interpreter TableOp
@@ -588,9 +588,9 @@ public:
     void SetImagePreferredDPI(sal_Int32 nValue) { mnImagePreferredDPI = 
nValue; }
     sal_Int32 GetImagePreferredDPI() { return mnImagePreferredDPI; }
 
-    SC_DLLPUBLIC sal_uLong   GetCellCount() const;       // all cells
-    SC_DLLPUBLIC sal_uLong   GetFormulaGroupCount() const;       // all cells
-    sal_uLong                GetCodeCount() const;       // RPN-Code in 
formulas
+    SC_DLLPUBLIC sal_uInt64  GetCellCount() const;       // all cells
+    SC_DLLPUBLIC sal_uInt64  GetFormulaGroupCount() const;       // all cells
+    sal_uInt64               GetCodeCount() const;       // RPN-Code in 
formulas
     DECL_LINK( GetUserDefinedColor, sal_uInt16, Color* );
                                                                 // number 
formatter
 public:
@@ -1730,7 +1730,7 @@ public:
 
     SC_DLLPUBLIC void   Fill(   SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2,
                                 ScProgress* pProgress, const ScMarkData& rMark,
-                                sal_uLong nFillCount, FillDir eFillDir = 
FILL_TO_BOTTOM,
+                                sal_uInt64 nFillCount, FillDir eFillDir = 
FILL_TO_BOTTOM,
                                 FillCmd eFillCmd = FILL_LINEAR, FillDateCmd 
eFillDateCmd = FILL_DAY,
                                 double nStepValue = 1.0, double nMaxValue = 
1E307 );
     OUString            GetAutoFillPreview( const ScRange& rSource, SCCOL 
nEndX, SCROW nEndY );
@@ -1903,20 +1903,21 @@ public:
     SC_DLLPUBLIC void           SetManualHeight( SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab, bool bManual );
 
     SC_DLLPUBLIC sal_uInt16         GetColWidth( SCCOL nCol, SCTAB nTab, bool 
bHiddenAsZero = true ) const;
-    SC_DLLPUBLIC sal_uLong          GetColWidth( SCCOL nStartCol, SCCOL 
nEndCol, SCTAB nTab ) const;
+    SC_DLLPUBLIC tools::Long        GetColWidth( SCCOL nStartCol, SCCOL 
nEndCol, SCTAB nTab ) const;
     SC_DLLPUBLIC sal_uInt16         GetRowHeight( SCROW nRow, SCTAB nTab, bool 
bHiddenAsZero = true ) const;
     SC_DLLPUBLIC sal_uInt16         GetRowHeight( SCROW nRow, SCTAB nTab, 
SCROW* pStartRow, SCROW* pEndRow ) const;
-    SC_DLLPUBLIC sal_uLong          GetRowHeight( SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
+    SC_DLLPUBLIC tools::Long        GetRowHeight( SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
 
     /**
      * Given the height i.e. total vertical distance from the top of the sheet
      * grid, return the first visible row whose top position is below the
      * specified height.
      */
-    SCROW                       GetRowForHeight( SCTAB nTab, sal_uLong nHeight 
) const;
-    sal_uLong                   GetScaledRowHeight( SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab, double fScale, const sal_uLong* pnMaxHeight = nullptr ) 
const;
-    SC_DLLPUBLIC sal_uLong      GetColOffset( SCCOL nCol, SCTAB nTab, bool 
bHiddenAsZero = true ) const;
-    SC_DLLPUBLIC sal_uLong      GetRowOffset( SCROW nRow, SCTAB nTab, bool 
bHiddenAsZero = true ) const;
+    SCROW                       GetRowForHeight( SCTAB nTab, tools::Long 
nHeight ) const;
+    tools::Long                 GetScaledRowHeight( SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab,
+                                    double fScale, const tools::Long* 
pnMaxHeight = nullptr ) const;
+    SC_DLLPUBLIC tools::Long    GetColOffset( SCCOL nCol, SCTAB nTab, bool 
bHiddenAsZero = true ) const;
+    SC_DLLPUBLIC tools::Long    GetRowOffset( SCROW nRow, SCTAB nTab, bool 
bHiddenAsZero = true ) const;
 
     SC_DLLPUBLIC sal_uInt16     GetOriginalWidth( SCCOL nCol, SCTAB nTab ) 
const;
     SC_DLLPUBLIC sal_uInt16     GetOriginalHeight( SCROW nRow, SCTAB nTab ) 
const;
@@ -2243,7 +2244,7 @@ private:
                                         bool bColumns,
                                         ScDocument& rOtherDoc, SCTAB nThisTab, 
SCTAB nOtherTab,
                                         SCCOLROW nEndCol, const SCCOLROW* 
pTranslate,
-                                        ScProgress* pProgress, sal_uLong 
nProAdd );
+                                        ScProgress* pProgress, sal_uInt64 
nProAdd );
 
     DECL_LINK(TrackTimeHdl, Timer *, void);
 
@@ -2330,7 +2331,7 @@ public:
     SC_DLLPUBLIC void   StartAllListeners( const ScRange& rRange );
 
     void                SetForcedFormulas( bool bVal ) { bHasForcedFormulas = 
bVal; }
-    sal_uLong           GetFormulaCodeInTree() const { return 
nFormulaCodeInTree; }
+    sal_uInt64          GetFormulaCodeInTree() const { return 
nFormulaCodeInTree; }
 
     bool                IsInInterpreter() const { return nInterpretLevel != 0; 
}
 
@@ -2379,13 +2380,13 @@ public:
     void                SetExpandRefs( bool bVal );
     bool                IsExpandRefs() const { return bExpandRefs; }
 
-    sal_uLong           GetXMLImportedFormulaCount() const { return 
nXMLImportedFormulaCount; }
-    void                IncXMLImportedFormulaCount( sal_uLong nVal )
+    sal_uInt64          GetXMLImportedFormulaCount() const { return 
nXMLImportedFormulaCount; }
+    void                IncXMLImportedFormulaCount( sal_uInt64 nVal )
                             {
                                 if ( nXMLImportedFormulaCount + nVal > 
nXMLImportedFormulaCount )
                                     nXMLImportedFormulaCount += nVal;
                             }
-    void                DecXMLImportedFormulaCount( sal_uLong nVal )
+    void                DecXMLImportedFormulaCount( sal_uInt64 nVal )
                             {
                                 if ( nVal <= nXMLImportedFormulaCount )
                                     nXMLImportedFormulaCount -= nVal;
diff --git a/sc/inc/progress.hxx b/sc/inc/progress.hxx
index c7afd949f60e..80d01df3c894 100644
--- a/sc/inc/progress.hxx
+++ b/sc/inc/progress.hxx
@@ -40,10 +40,10 @@ class SC_DLLPUBLIC ScProgress
 {
 private:
     static  SfxProgress*    pGlobalProgress;
-    static  sal_uLong        nGlobalRange;
-    static  sal_uLong       nGlobalPercent;
+    static  sal_uInt64      nGlobalRange;
+    static  sal_uInt64      nGlobalPercent;
     static  ScProgress*     pInterpretProgress;
-    static  sal_uLong       nInterpretProgress;
+    static  sal_uInt64      nInterpretProgress;
     static  ScDocument*     pInterpretDoc;
     static  bool            bIdleWasEnabled;
             bool            bEnabled;
@@ -53,7 +53,7 @@ private:
                             ScProgress( const ScProgress& ) = delete;
             ScProgress&     operator=( const ScProgress& ) = delete;
 
-    static  void            CalcGlobalPercent( sal_uLong nVal )
+    static  void            CalcGlobalPercent( sal_uInt64 nVal )
                                 {
                                     nGlobalPercent = nGlobalRange ?
                                         nVal * 100 / nGlobalRange : 0;
@@ -67,7 +67,7 @@ public:
 
                             ScProgress( SfxObjectShell* pObjSh,
                                          const OUString& rText,
-                                         sal_uLong nRange,
+                                         sal_uInt64 nRange,
                                          bool bWait );
                             ~ScProgress();
 
@@ -75,7 +75,7 @@ public:
                             /// for DummyInterpret only, never use otherwise!!!
                             ScProgress();
 #endif
-            void            SetState( sal_uLong nVal, sal_uLong nNewRange = 0 )
+            void            SetState( sal_uInt64 nVal, sal_uInt64 nNewRange = 
0 )
                                 {
                                     if ( pProgress )
                                     {
@@ -85,7 +85,7 @@ public:
                                         pProgress->SetState( nVal, nNewRange );
                                     }
                                 }
-            void            SetStateCountDown( sal_uLong nVal )
+            void            SetStateCountDown( sal_uInt64 nVal )
                                 {
                                     if ( pProgress )
                                     {
@@ -93,20 +93,20 @@ public:
                                         pProgress->SetState( nGlobalRange - 
nVal );
                                     }
                                 }
-            void            SetStateOnPercent( sal_uLong nVal )
+            void            SetStateOnPercent( sal_uInt64 nVal )
                                 {   /// only if percentage increased
                                     if ( nGlobalRange && (nVal * 100 /
                                             nGlobalRange) > nGlobalPercent )
                                         SetState( nVal );
                                 }
-            void            SetStateCountDownOnPercent( sal_uLong nVal )
+            void            SetStateCountDownOnPercent( sal_uInt64 nVal )
                                 {   /// only if percentage increased
                                     if ( nGlobalRange &&
                                             ((nGlobalRange - nVal) * 100 /
                                             nGlobalRange) > nGlobalPercent )
                                         SetStateCountDown( nVal );
                                 }
-            sal_uLong           GetState() const
+            sal_uInt64          GetState() const
                                 {
                                     if ( pProgress )
                                         return pProgress->GetState();
diff --git a/sc/inc/rangelst.hxx b/sc/inc/rangelst.hxx
index 9052b086680f..46a4ad91c849 100644
--- a/sc/inc/rangelst.hxx
+++ b/sc/inc/rangelst.hxx
@@ -73,7 +73,7 @@ public:
     bool            operator!=( const ScRangeList& r ) const;
     bool            Intersects( const ScRange& ) const;
     bool            Contains( const ScRange& ) const;
-    size_t          GetCellCount() const;
+    sal_uInt64      GetCellCount() const;
     ScAddress       GetTopLeftCorner() const;
 
     ScRangeList     GetIntersectedRange(const ScRange& rRange) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index fa8d6326d479..deae36131dda 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -292,10 +292,10 @@ public:
     }
     // out-of-line the cold part of the function
     void CreateColumnIfNotExistsImpl( const SCCOL nScCol ) const;
-    sal_uLong       GetCellCount() const;
-    sal_uLong       GetWeightedCount() const;
-    sal_uLong       GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
-    sal_uLong       GetCodeCount() const;       // RPN code in formula
+    sal_uInt64      GetCellCount() const;
+    sal_uInt64      GetWeightedCount() const;
+    sal_uInt64      GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
+    sal_uInt64      GetCodeCount() const;       // RPN code in formula
 
     sal_uInt16 GetTextWidth(SCCOL nCol, SCROW nRow) const;
 
@@ -675,7 +675,7 @@ public:
     void        FindRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
                                  sc::UpdatedRangeNames& rIndexes) const;
     void        Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                        sal_uLong nFillCount, FillDir eFillDir, FillCmd 
eFillCmd, FillDateCmd eFillDateCmd,
+                        sal_uInt64 nFillCount, FillDir eFillDir, FillCmd 
eFillCmd, FillDateCmd eFillDateCmd,
                         double nStepValue, double nMaxValue, ScProgress* 
pProgress);
     OUString    GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW 
nEndY );
 
@@ -795,11 +795,11 @@ public:
                                     const ScColWidthParam* pParam );
     bool SetOptimalHeight(
         sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, bool bApi,
-        ScProgress* pOuterProgress = nullptr, sal_uLong nProgressStart = 0 );
+        ScProgress* pOuterProgress = nullptr, sal_uInt64 nProgressStart = 0 );
 
     void SetOptimalHeightOnly(
         sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
-        ScProgress* pOuterProgress = nullptr, sal_uLong nProgressStart = 0 );
+        ScProgress* pOuterProgress = nullptr, sal_uInt64 nProgressStart = 0 );
 
     tools::Long        GetNeededSize( SCCOL nCol, SCROW nRow,
                                     OutputDevice* pDev,
@@ -826,12 +826,12 @@ public:
     void        SetManualHeight( SCROW nStartRow, SCROW nEndRow, bool bManual 
);
 
     sal_uInt16      GetColWidth( SCCOL nCol, bool bHiddenAsZero = true ) const;
-    sal_uLong GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const;
+    tools::Long     GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const;
     sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, 
bool bHiddenAsZero = true ) const;
-    sal_uLong       GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool 
bHiddenAsZero = true ) const;
-    sal_uLong       GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double 
fScale, const sal_uLong* pnMaxHeight = nullptr ) const;
-    sal_uLong       GetColOffset( SCCOL nCol, bool bHiddenAsZero = true ) 
const;
-    sal_uLong       GetRowOffset( SCROW nRow, bool bHiddenAsZero = true ) 
const;
+    tools::Long     GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool 
bHiddenAsZero = true ) const;
+    tools::Long     GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double 
fScale, const tools::Long* pnMaxHeight = nullptr ) const;
+    tools::Long     GetColOffset( SCCOL nCol, bool bHiddenAsZero = true ) 
const;
+    tools::Long     GetRowOffset( SCROW nRow, bool bHiddenAsZero = true ) 
const;
 
     /**
      * Get the last row such that the height of row 0 to the end row is as
@@ -841,7 +841,7 @@ public:
      *
      * @return SCROW last row of the range within specified height.
      */
-    SCROW       GetRowForHeight(sal_uLong nHeight) const;
+    SCROW       GetRowForHeight(tools::Long nHeight) const;
 
     sal_uInt16      GetOriginalWidth( SCCOL nCol ) const;
     sal_uInt16      GetOriginalHeight( SCROW nRow ) const;
@@ -924,7 +924,7 @@ public:
     SCROW       FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
     SCROW       LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
     SCROW       CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const;
-    sal_uInt32  GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool 
bHiddenAsZero = true) const;
+    tools::Long GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool 
bHiddenAsZero = true) const;
 
     SCCOLROW    LastHiddenColRow(SCCOLROW nPos, bool bCol) const;
 
@@ -1109,21 +1109,21 @@ private:
     void FillFormulaVertical(
         const ScFormulaCell& rSrcCell,
         SCCOLROW& rInner, SCCOL nCol, SCROW nRow1, SCROW nRow2,
-        ScProgress* pProgress, sal_uLong& rProgress );
+        ScProgress* pProgress, sal_uInt64& rProgress );
 
     void FillSeriesSimple(
         const ScCellValue& rSrcCell, SCCOLROW& rInner, SCCOLROW nIMin, 
SCCOLROW nIMax,
-        const SCCOLROW& rCol, const SCCOLROW& rRow, bool bVertical, 
ScProgress* pProgress, sal_uLong& rProgress );
+        const SCCOLROW& rCol, const SCCOLROW& rRow, bool bVertical, 
ScProgress* pProgress, sal_uInt64& rProgress );
 
     void FillAutoSimple(
         SCCOLROW nISrcStart, SCCOLROW nISrcEnd, SCCOLROW nIStart, SCCOLROW 
nIEnd,
         SCCOLROW& rInner, const SCCOLROW& rCol, const SCCOLROW& rRow,
-        sal_uLong nActFormCnt, sal_uLong nMaxFormCnt,
+        sal_uInt64 nActFormCnt, sal_uInt64 nMaxFormCnt,
         bool bHasFiltered, bool bVertical, bool bPositive,
-        ScProgress* pProgress, sal_uLong& rProgress );
+        ScProgress* pProgress, sal_uInt64& rProgress );
 
     void        FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                                sal_uLong nFillCount, FillDir eFillDir, 
FillCmd eFillCmd,
+                                sal_uInt64 nFillCount, FillDir eFillDir, 
FillCmd eFillCmd,
                                 FillDateCmd eFillDateCmd,
                                 double nStepValue, double nMaxValue, 
sal_uInt16 nMinDigits,
                                 bool bAttribs, ScProgress* pProgress,
@@ -1136,7 +1136,7 @@ private:
                                 bool bHasFiltered, bool& rSkipOverlappedCells,
                                 std::vector<sal_Int32>& rNonOverlappedCellIdx 
);
     void        FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                        sal_uLong nFillCount, FillDir eFillDir, ScProgress* 
pProgress );
+                        sal_uInt64 nFillCount, FillDir eFillDir, ScProgress* 
pProgress );
 
     bool        ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
                                 bool bMarked, bool bUnprotected ) const;
diff --git a/sc/qa/unit/rangelst_test.cxx b/sc/qa/unit/rangelst_test.cxx
index 6957891c653a..883519f5323b 100644
--- a/sc/qa/unit/rangelst_test.cxx
+++ b/sc/qa/unit/rangelst_test.cxx
@@ -145,7 +145,7 @@ void Test::testDeleteArea_3Ranges()
         }
     }
 
-    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(28), aList.GetCellCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(28), aList.GetCellCount());
 }
 
 void Test::testDeleteArea_3Ranges_Case2()
@@ -263,7 +263,7 @@ void Test::testDeleteArea_2Ranges_Case2()
         else
             CPPUNIT_ASSERT(aList.Contains(ScRange(1,nRow,0)));
     }
-    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), aList.GetCellCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(4), aList.GetCellCount());
 }
 
 void Test::testDeleteArea_2Ranges_Case3()
@@ -391,7 +391,7 @@ void Test::testDeleteArea_1Range()
     {
         CPPUNIT_ASSERT(aList.Contains(ScRange(3,nRow,0)));
     }
-    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), aList.GetCellCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(3), aList.GetCellCount());
 }
 
 void Test::testDeleteArea_0Ranges()
@@ -515,7 +515,7 @@ void Test::testUpdateReference_DeleteRow()
         }
         CPPUNIT_ASSERT(!aList.Contains(ScRange(nCol, 4, 0)));
     }
-    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(12), aList.GetCellCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(12), aList.GetCellCount());
 
     ScRangeList aList2(ScRange(2,2,0,2,2,0));
     aList2.UpdateReference(URM_INSDEL, m_pDoc, ScRange(0,3,0,MAXCOL,MAXROW,0), 
0, -1, 0);
@@ -557,7 +557,7 @@ void Test::testUpdateReference_DeleteCol()
         }
         CPPUNIT_ASSERT(!aList.Contains(ScRange(4, nRow, 0)));
     }
-    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(12), aList.GetCellCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(12), aList.GetCellCount());
 }
 
 void Test::testGetIntersectedRange()
diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index f9f1e22e7686..760628f2310c 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -2638,7 +2638,7 @@ void ScExportTest2::testTdf144642_RowHeightRounding()
     ScDocument& rDoc = xShell->GetDocument();
     // 10mm == 567 twips == 28.35pt
     CPPUNIT_ASSERT_EQUAL(sal_uInt16(567), rDoc.GetRowHeight(0, 0));
-    CPPUNIT_ASSERT_EQUAL(sal_uLong(567 * 26), rDoc.GetRowHeight(0, 25, 0, 
true));
+    CPPUNIT_ASSERT_EQUAL(tools::Long(567 * 26), rDoc.GetRowHeight(0, 25, 0, 
true));
     xShell->DoClose();
 
     xShell = loadDoc(u"tdf144642_RowHeight_28.35pt_SavedByExcel.", 
FORMAT_XLSX);
@@ -2646,7 +2646,7 @@ void ScExportTest2::testTdf144642_RowHeightRounding()
     ScDocument& rDoc2 = xShell->GetDocument();
     // 555twips == 27.75pt == 9.79mm
     CPPUNIT_ASSERT_EQUAL(sal_uInt16(555), rDoc2.GetRowHeight(0, 0));
-    CPPUNIT_ASSERT_EQUAL(sal_uLong(555 * 26), rDoc2.GetRowHeight(0, 25, 0, 
true));
+    CPPUNIT_ASSERT_EQUAL(tools::Long(555 * 26), rDoc2.GetRowHeight(0, 25, 0, 
true));
     xShell->DoClose();
 }
 
@@ -2661,7 +2661,7 @@ void 
ScExportTest2::testTdf145129_DefaultRowHeightRounding()
     ScDocument& rDoc = xShell->GetDocument();
     // 555twips == 27.75pt == 9.79mm
     CPPUNIT_ASSERT_EQUAL(sal_uInt16(555), rDoc.GetRowHeight(0, 0));
-    CPPUNIT_ASSERT_EQUAL(sal_uLong(555 * 52), rDoc.GetRowHeight(0, 51, 0, 
true));
+    CPPUNIT_ASSERT_EQUAL(tools::Long(555 * 52), rDoc.GetRowHeight(0, 51, 0, 
true));
     xShell->DoClose();
 }
 
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 8c305df59467..71ebe3278d23 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -721,25 +721,25 @@ void Test::testDocStatistics()
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to increment sheet count.",
                                static_cast<SCTAB>(nStartTabs+2), 
m_pDoc->GetTableCount());
 
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(0), m_pDoc->GetCellCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(0), m_pDoc->GetCellCount());
     m_pDoc->SetValue(ScAddress(0,0,0), 2.0);
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(1), m_pDoc->GetCellCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(1), m_pDoc->GetCellCount());
     m_pDoc->SetValue(ScAddress(2,2,0), 2.5);
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(2), m_pDoc->GetCellCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(2), m_pDoc->GetCellCount());
     m_pDoc->SetString(ScAddress(1,1,1), "Test");
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(3), m_pDoc->GetCellCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(3), m_pDoc->GetCellCount());
 
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(0), 
m_pDoc->GetFormulaGroupCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(0), 
m_pDoc->GetFormulaGroupCount());
     m_pDoc->SetString(ScAddress(3,0,1), "=A1");
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(1), 
m_pDoc->GetFormulaGroupCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(1), 
m_pDoc->GetFormulaGroupCount());
     m_pDoc->SetString(ScAddress(3,1,1), "=A2");
     m_pDoc->SetString(ScAddress(3,2,1), "=A3");
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(1), 
m_pDoc->GetFormulaGroupCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(1), 
m_pDoc->GetFormulaGroupCount());
     m_pDoc->SetString(ScAddress(3,3,1), "=A5");
     m_pDoc->SetString(ScAddress(3,4,1), "=A6");
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(2), 
m_pDoc->GetFormulaGroupCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(2), 
m_pDoc->GetFormulaGroupCount());
     m_pDoc->SetString(ScAddress(3,1,1), "=A3");
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uLong>(4), 
m_pDoc->GetFormulaGroupCount());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt64>(4), 
m_pDoc->GetFormulaGroupCount());
 
     m_pDoc->DeleteTab(1);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to decrement sheet count.",
@@ -760,7 +760,7 @@ void Test::testRowForHeight()
 
     struct Check
     {
-        sal_uLong nHeight;
+        tools::Long nHeight;
         SCROW nRow;
     };
 
@@ -6258,9 +6258,9 @@ void Test::testUndoDataAnchor()
 
 void Test::testEmptyCalcDocDefaults()
 {
-    CPPUNIT_ASSERT_EQUAL( sal_uLong(0), m_pDoc->GetCellCount() );
-    CPPUNIT_ASSERT_EQUAL( sal_uLong(0), m_pDoc->GetFormulaGroupCount() );
-    CPPUNIT_ASSERT_EQUAL( sal_uLong(0), m_pDoc->GetCodeCount() );
+    CPPUNIT_ASSERT_EQUAL( sal_uInt64(0), m_pDoc->GetCellCount() );
+    CPPUNIT_ASSERT_EQUAL( sal_uInt64(0), m_pDoc->GetFormulaGroupCount() );
+    CPPUNIT_ASSERT_EQUAL( sal_uInt64(0), m_pDoc->GetCodeCount() );
     CPPUNIT_ASSERT_EQUAL( int(CharCompressType::NONE), 
static_cast<int>(m_pDoc->GetAsianCompression()) );
 
     CPPUNIT_ASSERT_EQUAL( false, m_pDoc->HasPrintRange() );
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index ef20c848e622..138a1deadd7a 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -3618,14 +3618,14 @@ public:
 
 }
 
-sal_uLong ScColumn::GetWeightedCount() const
+sal_uInt64 ScColumn::GetWeightedCount() const
 {
     const WeightedCounter aFunc = std::for_each(maCells.begin(), maCells.end(),
         WeightedCounter());
     return aFunc.getCount();
 }
 
-sal_uLong ScColumn::GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const
+sal_uInt64 ScColumn::GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const
 {
     const WeightedCounterWithRows aFunc = std::for_each(maCells.begin(), 
maCells.end(),
         WeightedCounterWithRows(nStartRow, nEndRow));
@@ -3636,7 +3636,7 @@ namespace {
 
 class CodeCounter
 {
-    size_t mnCount;
+    sal_uInt64 mnCount;
 public:
     CodeCounter() : mnCount(0) {}
 
@@ -3645,12 +3645,12 @@ public:
         mnCount += p->GetCode()->GetCodeLen();
     }
 
-    size_t getCount() const { return mnCount; }
+    sal_uInt64 getCount() const { return mnCount; }
 };
 
 }
 
-sal_uInt32 ScColumn::GetCodeCount() const
+sal_uInt64 ScColumn::GetCodeCount() const
 {
     CodeCounter aFunc;
     sc::ParseFormula(maCells, aFunc);
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index a50b6f00550e..28543f720c16 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -2695,7 +2695,7 @@ void ScDocRowHeightUpdater::update()
         return;
     }
 
-    sal_uLong nCellCount = 0;
+    sal_uInt64 nCellCount = 0;
     for (const auto& rTabRanges : *mpTabRangesArray)
     {
         const SCTAB nTab = rTabRanges.mnTab;
@@ -2716,7 +2716,7 @@ void ScDocRowHeightUpdater::update()
     ScProgress aProgress(mrDoc.GetDocumentShell(), 
ScResId(STR_PROGRESS_HEIGHTING), nCellCount, true);
 
     Fraction aZoom(1, 1);
-    sal_uLong nProgressStart = 0;
+    sal_uInt64 nProgressStart = 0;
     for (const auto& rTabRanges : *mpTabRangesArray)
     {
         const SCTAB nTab = rTabRanges.mnTab;
@@ -2741,7 +2741,7 @@ void ScDocRowHeightUpdater::update()
 
 void ScDocRowHeightUpdater::updateAll()
 {
-    sal_uInt32 nCellCount = 0;
+    sal_uInt64 nCellCount = 0;
     for (SCTAB nTab = 0; nTab < mrDoc.GetTableCount(); ++nTab)
     {
         if (!ValidTab(nTab) || !mrDoc.maTabs[nTab])
@@ -2754,7 +2754,7 @@ void ScDocRowHeightUpdater::updateAll()
 
     Fraction aZoom(1, 1);
     sc::RowHeightContext aCxt(mrDoc.MaxRow(), mfPPTX, mfPPTY, aZoom, aZoom, 
mpOutDev);
-    sal_uLong nProgressStart = 0;
+    sal_uInt64 nProgressStart = 0;
     for (SCTAB nTab = 0; nTab < mrDoc.GetTableCount(); ++nTab)
     {
         if (!ValidTab(nTab) || !mrDoc.maTabs[nTab])
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 35f1f936392e..01f8be42f085 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1154,7 +1154,7 @@ void ScDocument::UpdateGrow( const ScRange& rArea, SCCOL 
nGrowX, SCROW nGrowY )
 }
 
 void ScDocument::Fill(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, 
ScProgress* pProgress, const ScMarkData& rMark,
-                        sal_uLong nFillCount, FillDir eFillDir, FillCmd 
eFillCmd, FillDateCmd eFillDateCmd,
+                        sal_uInt64 nFillCount, FillDir eFillDir, FillCmd 
eFillCmd, FillDateCmd eFillDateCmd,
                         double nStepValue, double nMaxValue)
 {
     PutInOrder( nCol1, nCol2 );
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index a8e786b68ebf..de75f206b34e 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -968,8 +968,8 @@ sal_uInt16 ScDocument::ColDifferences( SCCOL nThisCol, 
SCTAB nThisTab,
 
     //TODO: optimize e.g. with iterator?
 
-    sal_uLong nDif = 0;
-    sal_uLong nUsed = 0;
+    sal_uInt64 nDif = 0;
+    sal_uInt64 nUsed = 0;
     for (SCROW nThisRow=0; nThisRow<=nMaxRow; nThisRow++)
     {
         SCROW nOtherRow;
@@ -1004,7 +1004,7 @@ sal_uInt16 ScDocument::ColDifferences( SCCOL nThisCol, 
SCTAB nThisTab,
 
 void ScDocument::FindOrder( SCCOLROW* pOtherRows, SCCOLROW nThisEndRow, 
SCCOLROW nOtherEndRow,
                             bool bColumns, ScDocument& rOtherDoc, SCTAB 
nThisTab, SCTAB nOtherTab,
-                            SCCOLROW nEndCol, const SCCOLROW* pTranslate, 
ScProgress* pProgress, sal_uLong nProAdd )
+                            SCCOLROW nEndCol, const SCCOLROW* pTranslate, 
ScProgress* pProgress, sal_uInt64 nProAdd )
 {
     //  bColumns=true: rows are columns and vice versa
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 3592eb4a3ee1..b822a910504a 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4138,7 +4138,7 @@ sal_uInt16 ScDocument::GetColWidth( SCCOL nCol, SCTAB 
nTab, bool bHiddenAsZero )
     return 0;
 }
 
-sal_uLong ScDocument::GetColWidth( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab 
) const
+tools::Long ScDocument::GetColWidth( SCCOL nStartCol, SCCOL nEndCol, SCTAB 
nTab ) const
 {
     const ScTable* pTab = FetchTable(nTab);
     if (!pTab)
@@ -4187,7 +4187,7 @@ sal_uInt16 ScDocument::GetRowHeight( SCROW nRow, SCTAB 
nTab, SCROW* pStartRow, S
     return 0;
 }
 
-sal_uLong ScDocument::GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB 
nTab, bool bHiddenAsZero ) const
+tools::Long ScDocument::GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB 
nTab, bool bHiddenAsZero ) const
 {
     if (nStartRow == nEndRow)
         return GetRowHeight( nStartRow, nTab, bHiddenAsZero );  // faster for 
a single row
@@ -4203,17 +4203,17 @@ sal_uLong ScDocument::GetRowHeight( SCROW nStartRow, 
SCROW nEndRow, SCTAB nTab,
     return 0;
 }
 
-SCROW ScDocument::GetRowForHeight( SCTAB nTab, sal_uLong nHeight ) const
+SCROW ScDocument::GetRowForHeight( SCTAB nTab, tools::Long nHeight ) const
 {
     return maTabs[nTab]->GetRowForHeight(nHeight);
 }
 
-sal_uLong ScDocument::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow,
-        SCTAB nTab, double fScale, const sal_uLong* pnMaxHeight ) const
+tools::Long ScDocument::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow,
+        SCTAB nTab, double fScale, const tools::Long* pnMaxHeight ) const
 {
     // faster for a single row
     if (nStartRow == nEndRow)
-        return static_cast<sal_uLong>(GetRowHeight( nStartRow, nTab) * fScale);
+        return static_cast<tools::Long>(GetRowHeight( nStartRow, nTab) * 
fScale);
 
     // check bounds because this method replaces former 
for(i=start;i<=end;++i) loops
     if (nStartRow > nEndRow)
@@ -4234,7 +4234,7 @@ SCROW ScDocument::GetHiddenRowCount( SCROW nRow, SCTAB 
nTab ) const
     return 0;
 }
 
-sal_uLong ScDocument::GetColOffset( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero 
) const
+tools::Long ScDocument::GetColOffset( SCCOL nCol, SCTAB nTab, bool 
bHiddenAsZero ) const
 {
     if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && 
maTabs[nTab] )
         return maTabs[nTab]->GetColOffset( nCol, bHiddenAsZero );
@@ -4242,7 +4242,7 @@ sal_uLong ScDocument::GetColOffset( SCCOL nCol, SCTAB 
nTab, bool bHiddenAsZero )
     return 0;
 }
 
-sal_uLong ScDocument::GetRowOffset( SCROW nRow, SCTAB nTab, bool bHiddenAsZero 
) const
+tools::Long ScDocument::GetRowOffset( SCROW nRow, SCTAB nTab, bool 
bHiddenAsZero ) const
 {
     if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && 
maTabs[nTab] )
         return maTabs[nTab]->GetRowOffset( nRow, bHiddenAsZero );
@@ -4289,14 +4289,14 @@ void ScDocument::UpdateAllRowHeights( 
sc::RowHeightContext& rCxt, const ScMarkDa
 {
     // one progress across all (selected) sheets
 
-    sal_uLong nCellCount = 0;
+    sal_uInt64 nCellCount = 0;
     for ( SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()); nTab++ )
         if ( maTabs[nTab] && ( !pTabMark || pTabMark->GetTableSelect(nTab) ) )
             nCellCount += maTabs[nTab]->GetWeightedCount();
 
     ScProgress aProgress( GetDocumentShell(), ScResId(STR_PROGRESS_HEIGHTING), 
nCellCount, true );
 
-    sal_uLong nProgressStart = 0;
+    sal_uInt64 nProgressStart = 0;
     for ( SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()); nTab++ )
         if ( maTabs[nTab] && ( !pTabMark || pTabMark->GetTableSelect(nTab) ) )
         {
@@ -6140,9 +6140,9 @@ void ScDocument::StylesToNames()
     
const_cast<ScPatternAttr&>(pPool->GetDefaultItem(ATTR_PATTERN)).StyleToName();
 }
 
-sal_uLong ScDocument::GetCellCount() const
+sal_uInt64 ScDocument::GetCellCount() const
 {
-    sal_uLong nCellCount = 0;
+    sal_uInt64 nCellCount = 0;
 
     for (const auto& a : maTabs)
     {
@@ -6153,9 +6153,9 @@ sal_uLong ScDocument::GetCellCount() const
     return nCellCount;
 }
 
-sal_uLong ScDocument::GetFormulaGroupCount() const
+sal_uInt64 ScDocument::GetFormulaGroupCount() const
 {
-    sal_uLong nFormulaGroupCount = 0;
+    sal_uInt64 nFormulaGroupCount = 0;
 
     ScFormulaGroupIterator aIter( *const_cast<ScDocument*>(this) );
     for ( sc::FormulaGroupEntry* ptr = aIter.first(); ptr; ptr = aIter.next())
@@ -6166,9 +6166,9 @@ sal_uLong ScDocument::GetFormulaGroupCount() const
     return nFormulaGroupCount;
 }
 
-sal_uLong ScDocument::GetCodeCount() const
+sal_uInt64 ScDocument::GetCodeCount() const
 {
-    sal_uLong nCodeCount = 0;
+    sal_uInt64 nCodeCount = 0;
 
     for (const auto& a : maTabs)
     {
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index d613ec905575..fd26b42dbe04 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -109,7 +109,7 @@ void GetOptimalHeightsInColumn(
 
     const SCROW nMinStart = nPos;
 
-    sal_uLong nWeightedCount = nProgressStart + 
rCol.back().GetWeightedCount(nStartRow, nEndRow);
+    sal_uInt64 nWeightedCount = nProgressStart + 
rCol.back().GetWeightedCount(nStartRow, nEndRow);
     const SCCOL maxCol = rCol.size() - 1; // last col done already above
     for (SCCOL nCol=0; nCol<maxCol; nCol++)
     {
@@ -455,7 +455,7 @@ tools::Long ScTable::GetNeededSize( SCCOL nCol, SCROW nRow,
 
 bool ScTable::SetOptimalHeight(
     sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow, bool bApi,
-    ScProgress* pOuterProgress, sal_uLong nProgressStart )
+    ScProgress* pOuterProgress, sal_uInt64 nProgressStart )
 {
     assert(nStartRow <= nEndRow);
 
@@ -488,7 +488,7 @@ bool ScTable::SetOptimalHeight(
 
 void ScTable::SetOptimalHeightOnly(
     sc::RowHeightContext& rCxt, SCROW nStartRow, SCROW nEndRow,
-    ScProgress* pOuterProgress, sal_uLong nProgressStart )
+    ScProgress* pOuterProgress, sal_uInt64 nProgressStart )
 {
     OSL_ENSURE( rCxt.getExtraHeight() == 0 || rCxt.isForceAutoSize(),
         "automatic OptimalHeight with Extra" );
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index a19549e89f9d..cc756fbcb6a4 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -3281,12 +3281,12 @@ sal_uInt16 ScTable::GetColWidth( SCCOL nCol, bool 
bHiddenAsZero ) const
         return sal_uInt16(STD_COL_WIDTH);
 }
 
-sal_uLong ScTable::GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const
+tools::Long ScTable::GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const
 {
     if (!ValidCol(nStartCol) || !ValidCol(nEndCol) || nStartCol > nEndCol)
         return 0;
 
-    sal_uLong nW = 0;
+    tools::Long nW = 0;
     bool bHidden = false;
     SCCOL nLastHiddenCol = -1;
     auto colWidthIt = mpColWidth->begin() + nStartCol;
@@ -3406,13 +3406,13 @@ sal_uInt16 ScTable::GetRowHeight( SCROW nRow, SCROW* 
pStartRow, SCROW* pEndRow,
     }
 }
 
-sal_uLong ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool 
bHiddenAsZero ) const
+tools::Long ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool 
bHiddenAsZero ) const
 {
     OSL_ENSURE(ValidRow(nStartRow) && ValidRow(nEndRow),"wrong row number");
 
     if (ValidRow(nStartRow) && ValidRow(nEndRow) && mpRowHeights)
     {
-        sal_uLong nHeight = 0;
+        tools::Long nHeight = 0;
         SCROW nRow = nStartRow;
         while (nRow <= nEndRow)
         {
@@ -3428,16 +3428,16 @@ sal_uLong ScTable::GetRowHeight( SCROW nStartRow, SCROW 
nEndRow, bool bHiddenAsZ
         return nHeight;
     }
     else
-        return (nEndRow - nStartRow + 1) * 
static_cast<sal_uLong>(ScGlobal::nStdRowHeight);
+        return (nEndRow - nStartRow + 1) * 
static_cast<tools::Long>(ScGlobal::nStdRowHeight);
 }
 
-sal_uLong ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double 
fScale, const sal_uLong* pnMaxHeight ) const
+tools::Long ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, 
double fScale, const tools::Long* pnMaxHeight ) const
 {
     OSL_ENSURE(ValidRow(nStartRow) && ValidRow(nEndRow),"wrong row number");
 
     if (ValidRow(nStartRow) && ValidRow(nEndRow) && mpRowHeights)
     {
-        sal_uLong nHeight = 0;
+        tools::Long nHeight = 0;
         SCROW nRow = nStartRow;
         while (nRow <= nEndRow)
         {
@@ -3458,7 +3458,7 @@ sal_uLong ScTable::GetScaledRowHeight( SCROW nStartRow, 
SCROW nEndRow, double fS
                     SCROW nSegmentEnd = std::min( nLastRow, 
aSegmentIter.getLastPos() );
 
                     // round-down a single height value, multiply resulting 
(pixel) values
-                    const sal_uLong nOneHeight = static_cast<sal_uLong>( 
nRowVal * fScale );
+                    const tools::Long nOneHeight = static_cast<tools::Long>( 
nRowVal * fScale );
                     // sometimes scaling results in zero height
                     if (nOneHeight)
                     {
@@ -3483,7 +3483,7 @@ sal_uLong ScTable::GetScaledRowHeight( SCROW nStartRow, 
SCROW nEndRow, double fS
     }
     else
     {
-        const sal_uLong nOneHeight = 
static_cast<sal_uLong>(ScGlobal::nStdRowHeight * fScale);
+        const tools::Long nOneHeight = 
static_cast<tools::Long>(ScGlobal::nStdRowHeight * fScale);
         SCROW nRowsInSegment = nEndRow - nStartRow + 1;
         if (pnMaxHeight)
         {
@@ -3491,7 +3491,7 @@ sal_uLong ScTable::GetScaledRowHeight( SCROW nStartRow, 
SCROW nEndRow, double fS
             return nOneHeight * nRowsInSegment;
         }
         else
-            return static_cast<sal_uLong>(nRowsInSegment * nOneHeight);
+            return static_cast<tools::Long>(nRowsInSegment * nOneHeight);
     }
 }
 
@@ -4100,9 +4100,9 @@ ScRangeName* ScTable::GetRangeName() const
     return mpRangeName.get();
 }
 
-sal_uLong ScTable::GetRowOffset( SCROW nRow, bool bHiddenAsZero ) const
+tools::Long ScTable::GetRowOffset( SCROW nRow, bool bHiddenAsZero ) const
 {
-    sal_uLong n = 0;
+    tools::Long n = 0;
     if ( mpHiddenRows && mpRowHeights )
     {
         if (nRow == 0)
@@ -4112,7 +4112,7 @@ sal_uLong ScTable::GetRowOffset( SCROW nRow, bool 
bHiddenAsZero ) const
 
         n = GetTotalRowHeight(0, nRow-1, bHiddenAsZero);
 #if OSL_DEBUG_LEVEL > 0
-        if (n == ::std::numeric_limits<tools::ULong>::max())
+        if (n == ::std::numeric_limits<tools::Long>::max())
             OSL_FAIL("ScTable::GetRowOffset: row heights overflow");
 #endif
     }
@@ -4123,9 +4123,9 @@ sal_uLong ScTable::GetRowOffset( SCROW nRow, bool 
bHiddenAsZero ) const
     return n;
 }
 
-SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const
+SCROW ScTable::GetRowForHeight(tools::Long nHeight) const
 {
-    sal_uLong nSum = 0;
+    tools::Long nSum = 0;
 
     ScFlatBoolRowSegments::RangeData aData;
 
@@ -4159,8 +4159,8 @@ SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const
         SCROW nCommon = nLastCommon - nRow + 1;
 
         // how much further to go ?
-        sal_uLong nPixelsLeft = nHeight - nSum;
-        sal_uLong nCommonPixels = 
static_cast<sal_uLong>(aRowHeightRange.mnValue) * nCommon;
+        tools::Long nPixelsLeft = nHeight - nSum;
+        tools::Long nCommonPixels = 
static_cast<tools::Long>(aRowHeightRange.mnValue) * nCommon;
 
         // are we in the zone ?
         if (nCommonPixels > nPixelsLeft)
@@ -4190,9 +4190,9 @@ SCROW ScTable::GetRowForHeight(sal_uLong nHeight) const
     return -1;
 }
 
-sal_uLong ScTable::GetColOffset( SCCOL nCol, bool bHiddenAsZero ) const
+tools::Long ScTable::GetColOffset( SCCOL nCol, bool bHiddenAsZero ) const
 {
-    sal_uLong n = 0;
+    tools::Long n = 0;
     if ( mpColWidth )
     {
         auto colWidthIt = mpColWidth->begin();
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 7ccae5442178..8c2c298eb2f1 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2999,9 +2999,9 @@ bool ScTable::GetDataEntries(SCCOL nCol, SCROW nRow, 
std::set<ScTypedStrData>& r
     return aCol[nCol].GetDataEntries( nRow, rStrings);
 }
 
-sal_uLong ScTable::GetCellCount() const
+sal_uInt64 ScTable::GetCellCount() const
 {
-    sal_uLong nCellCount = 0;
+    sal_uInt64 nCellCount = 0;
 
     for ( SCCOL nCol=0; nCol < aCol.size(); nCol++ )
         nCellCount += aCol[nCol].GetCellCount();
@@ -3009,9 +3009,9 @@ sal_uLong ScTable::GetCellCount() const
     return nCellCount;
 }
 
-sal_uLong ScTable::GetWeightedCount() const
+sal_uInt64 ScTable::GetWeightedCount() const
 {
-    sal_uLong nCellCount = 0;
+    sal_uInt64 nCellCount = 0;
 
     for ( SCCOL nCol=0; nCol < aCol.size(); nCol++ )
         nCellCount += aCol[nCol].GetWeightedCount();
@@ -3019,9 +3019,9 @@ sal_uLong ScTable::GetWeightedCount() const
     return nCellCount;
 }
 
-sal_uLong ScTable::GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const
+sal_uInt64 ScTable::GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const
 {
-    sal_uLong nCellCount = 0;
+    sal_uInt64 nCellCount = 0;
 
     for ( SCCOL nCol=0; nCol < aCol.size(); nCol++ )
         nCellCount += aCol[nCol].GetWeightedCount(nStartRow, nEndRow);
@@ -3029,9 +3029,9 @@ sal_uLong ScTable::GetWeightedCount(SCROW nStartRow, 
SCROW nEndRow) const
     return nCellCount;
 }
 
-sal_uLong ScTable::GetCodeCount() const
+sal_uInt64 ScTable::GetCodeCount() const
 {
-    sal_uLong nCodeCount = 0;
+    sal_uInt64 nCodeCount = 0;
 
     for ( SCCOL nCol=0; nCol < aCol.size(); nCol++ )
         if ( aCol[nCol].GetCellCount() )
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 5c7c00dc1ff0..a4b232ea44d9 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -787,7 +787,7 @@ void ScTable::FillFormula(
 }
 
 void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                        sal_uLong nFillCount, FillDir eFillDir, ScProgress* 
pProgress )
+                        sal_uInt64 nFillCount, FillDir eFillDir, ScProgress* 
pProgress )
 {
     if ( (nFillCount == 0) || !ValidColRow(nCol1, nRow1) || 
!ValidColRow(nCol2, nRow2) )
         return;
@@ -851,8 +851,8 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
             aFillRange = ScRange(nCol1 - 1, nRow1, 0, nCol1 - nFillCount, 
nRow2, 0);
         }
     }
-    sal_uLong nIMin = nIStart;
-    sal_uLong nIMax = nIEnd;
+    sal_uInt64 nIMin = nIStart;
+    sal_uInt64 nIMax = nIEnd;
     PutInOrder(nIMin,nIMax);
     bool bHasFiltered = IsDataFiltered(aFillRange);
 
@@ -864,7 +864,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
             DeleteArea(static_cast<SCCOL>(nIMin), nRow1, 
static_cast<SCCOL>(nIMax), nRow2, InsertDeleteFlags::AUTOFILL);
     }
 
-    sal_uLong nProgress = 0;
+    sal_uInt64 nProgress = 0;
     if (pProgress)
         nProgress = pProgress->GetState();
 
@@ -889,10 +889,10 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
 
     //  execute
 
-    sal_uLong nActFormCnt = 0;
+    sal_uInt64 nActFormCnt = 0;
     for (rOuter = nOStart; rOuter <= nOEnd; rOuter++)
     {
-        sal_uLong nMaxFormCnt = 0;                      // for formulas
+        sal_uInt64 nMaxFormCnt = 0;                      // for formulas
 
         //  transfer attributes
 
@@ -1218,7 +1218,7 @@ OUString ScTable::GetAutoFillPreview( const ScRange& 
rSource, SCCOL nEndX, SCROW
     SCROW nRow2 = rSource.aEnd.Row();
     bool bOk = true;
     tools::Long nIndex = 0;
-    sal_uLong nSrcCount = 0;
+    sal_uInt64 nSrcCount = 0;
     FillDir eFillDir = FILL_TO_BOTTOM;
     if ( nEndX == nCol2 && nEndY == nRow2 )     // empty
         bOk = false;
@@ -1268,10 +1268,10 @@ OUString ScTable::GetAutoFillPreview( const ScRange& 
rSource, SCCOL nEndX, SCROW
             sal_uInt16 nListCount = pListData->GetSubCount();
             if ( nListCount )
             {
-                sal_uLong nSub = nSrcCount - 1; //  nListIndex is from last 
source entry
+                sal_uInt64 nSub = nSrcCount - 1; //  nListIndex is from last 
source entry
                 while ( nIndex < sal::static_int_cast<tools::Long>(nSub) )
                     nIndex += nListCount;
-                sal_uLong nPos = ( nListIndex + nIndex - nSub ) % nListCount;
+                sal_uInt64 nPos = ( nListIndex + nIndex - nSub ) % nListCount;
                 aValue = 
pListData->GetSubStr(sal::static_int_cast<sal_uInt16>(nPos));
             }
         }
@@ -1304,7 +1304,7 @@ OUString ScTable::GetAutoFillPreview( const ScRange& 
rSource, SCCOL nEndX, SCROW
             tools::Long nPosIndex = nIndex;
             while ( nPosIndex < 0 )
                 nPosIndex += nSrcCount;
-            sal_uLong nPos = nPosIndex % nSrcCount;
+            sal_uInt64 nPos = nPosIndex % nSrcCount;
             SCCOL nSrcX = nCol1;
             SCROW nSrcY = nRow1;
             if ( eFillDir == FILL_TO_TOP || eFillDir == FILL_TO_BOTTOM )
@@ -1614,7 +1614,7 @@ bool HiddenRowColumn(const ScTable* pTable, SCCOLROW 
nRowColumn, bool bVertical,
 void ScTable::FillFormulaVertical(
     const ScFormulaCell& rSrcCell,
     SCCOLROW& rInner, SCCOL nCol, SCROW nRow1, SCROW nRow2,
-    ScProgress* pProgress, sal_uLong& rProgress )
+    ScProgress* pProgress, sal_uInt64& rProgress )
 {
     // rInner is the row position when filling vertically.  Also, when filling
     // across hidden regions, it may create multiple dis-jointed spans of
@@ -1678,7 +1678,7 @@ void ScTable::FillFormulaVertical(
 
 void ScTable::FillSeriesSimple(
     const ScCellValue& rSrcCell, SCCOLROW& rInner, SCCOLROW nIMin, SCCOLROW 
nIMax,
-    const SCCOLROW& rCol, const SCCOLROW& rRow, bool bVertical, ScProgress* 
pProgress, sal_uLong& rProgress )
+    const SCCOLROW& rCol, const SCCOLROW& rRow, bool bVertical, ScProgress* 
pProgress, sal_uInt64& rProgress )
 {
     bool bHidden = false;
     SCCOLROW nHiddenLast = -1;
@@ -1758,9 +1758,9 @@ void ScTable::FillSeriesSimple(
 
 void ScTable::FillAutoSimple(
     SCCOLROW nISrcStart, SCCOLROW nISrcEnd, SCCOLROW nIStart, SCCOLROW nIEnd,
-    SCCOLROW& rInner, const SCCOLROW& rCol, const SCCOLROW& rRow, sal_uLong 
nActFormCnt,
-    sal_uLong nMaxFormCnt, bool bHasFiltered, bool bVertical, bool bPositive,
-    ScProgress* pProgress, sal_uLong& rProgress )
+    SCCOLROW& rInner, const SCCOLROW& rCol, const SCCOLROW& rRow, sal_uInt64 
nActFormCnt,
+    sal_uInt64 nMaxFormCnt, bool bHasFiltered, bool bVertical, bool bPositive,
+    ScProgress* pProgress, sal_uInt64& rProgress )
 {
     SCCOLROW nSource = nISrcStart;
     double nDelta;
@@ -1770,7 +1770,7 @@ void ScTable::FillAutoSimple(
         nDelta = 1.0;
     else
         nDelta = -1.0;
-    sal_uLong nFormulaCounter = nActFormCnt;
+    sal_uInt64 nFormulaCounter = nActFormCnt;
     bool bGetCell = true;
     bool bBooleanCell = false;
     bool bPercentCell = false;
@@ -2051,7 +2051,7 @@ inline bool isOverflow( const double& rVal, const double& 
rMax, const double& rS
 }
 
 void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                    sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd, 
FillDateCmd eFillDateCmd,
+                    sal_uInt64 nFillCount, FillDir eFillDir, FillCmd eFillCmd, 
FillDateCmd eFillDateCmd,
                     double nStepValue, double nMaxValue, sal_uInt16 
nArgMinDigits,
                     bool bAttribs, ScProgress* pProgress,
                     bool bSkipOverlappedCells, std::vector<sal_Int32>* 
pNonOverlappedCellIdx )
@@ -2079,7 +2079,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
     SCCOLROW nIEnd;
     SCCOLROW nISource;
     ScRange aFillRange;
-    sal_uLong nFillerCount;
+    sal_uInt64 nFillerCount;
     std::vector<bool> aIsNonEmptyCell;
 
     if (bVertical)
@@ -2191,14 +2191,14 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2,
             DeleteArea(static_cast<SCCOL>(nIMin), nRow1, 
static_cast<SCCOL>(nIMax), nRow2, nDel);
     }
 
-    sal_uLong nProgress = 0;
+    sal_uInt64 nProgress = 0;
     if (pProgress)
         nProgress = pProgress->GetState();
 
     // Perform the fill once per each 'outer' position i.e. one per column
     // when filling vertically.
 
-    sal_uLong nActFormCnt = 0;
+    sal_uInt64 nActFormCnt = 0;
     for (rOuter = nOStart; rOuter <= nOEnd; rOuter++)
     {
         rInner = nISource;
@@ -2497,7 +2497,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
 }
 
 void ScTable::Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-                    sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd, 
FillDateCmd eFillDateCmd,
+                    sal_uInt64 nFillCount, FillDir eFillDir, FillCmd eFillCmd, 
FillDateCmd eFillDateCmd,
                     double nStepValue, double nMaxValue, ScProgress* pProgress)
 {
     if (eFillCmd == FILL_AUTO)
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index 9c030ae1ac6f..d62b94e40f28 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -241,9 +241,9 @@ void ScTable::UpdatePageBreaks(const ScRange* pUserArea)
         if (bStartOfPage && bRepeatRow && nY > nRepeatStartY && !bRowFound)
         {
             // subtract size of repeat rows from page size
-            tools::ULong nHeights = GetTotalRowHeight(nRepeatStartY, 
nRepeatEndY);
+            tools::Long nHeights = GetTotalRowHeight(nRepeatStartY, 
nRepeatEndY);
 #if OSL_DEBUG_LEVEL > 0
-            if (nHeights == ::std::numeric_limits<tools::ULong>::max())
+            if (nHeights == ::std::numeric_limits<tools::Long>::max())
                 OSL_FAIL("ScTable::UpdatePageBreaks: row heights overflow");
 #endif
             nPageSizeY -= nHeights;
@@ -773,9 +773,9 @@ SCROW ScTable::CountVisibleRows(SCROW nStartRow, SCROW 
nEndRow) const
     return nCount;
 }
 
-sal_uInt32 ScTable::GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool 
bHiddenAsZero) const
+tools::Long ScTable::GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool 
bHiddenAsZero) const
 {
-    sal_uInt32 nHeight = 0;
+    tools::Long nHeight = 0;
     SCROW nRow = nStartRow;
     ScFlatBoolRowSegments::RangeData aData;
     while (nRow <= nEndRow)
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 56ee97ab7bde..be0906929c41 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -355,7 +355,7 @@ tools::Rectangle ScEditUtil::GetEditArea( const 
ScPatternAttr* pPattern, bool bF
         if (bInPrintTwips)
             nCellY += pDoc->GetRowHeight(nRow + 1, nRow + nCountY - 1, nTab);
         else
-            nCellY += static_cast<tools::Long>(pDoc->GetScaledRowHeight( 
nRow+1, nRow+nCountY-1, nTab, nPPTY));
+            nCellY += pDoc->GetScaledRowHeight( nRow+1, nRow+nCountY-1, nTab, 
nPPTY);
     }
 
     tools::Long nRightMargin = 0;
diff --git a/sc/source/core/tool/progress.cxx b/sc/source/core/tool/progress.cxx
index 2a187f8aa603..9a695bb8cfe5 100644
--- a/sc/source/core/tool/progress.cxx
+++ b/sc/source/core/tool/progress.cxx
@@ -38,10 +38,10 @@ using namespace com::sun::star;
 
 static ScProgress theDummyInterpretProgress;
 SfxProgress*    ScProgress::pGlobalProgress = nullptr;
-sal_uLong       ScProgress::nGlobalRange = 0;
-sal_uLong       ScProgress::nGlobalPercent = 0;
+sal_uInt64      ScProgress::nGlobalRange = 0;
+sal_uInt64      ScProgress::nGlobalPercent = 0;
 ScProgress*     ScProgress::pInterpretProgress = &theDummyInterpretProgress;
-sal_uLong       ScProgress::nInterpretProgress = 0;
+sal_uInt64      ScProgress::nInterpretProgress = 0;
 ScDocument*     ScProgress::pInterpretDoc;
 bool            ScProgress::bIdleWasEnabled = false;
 
@@ -71,7 +71,7 @@ static bool lcl_HasControllersLocked( const SfxObjectShell& 
rObjSh )
 }
 
 ScProgress::ScProgress(SfxObjectShell* pObjSh, const OUString& rText,
-                       sal_uLong nRange, bool bWait)
+                       sal_uInt64 nRange, bool bWait)
     : bEnabled(true)
 {
 
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index b913568e4f4b..ab6033dfa3de 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -82,15 +82,15 @@ public:
     void operator() (const ScRange & r)
     {
         mnCellCount +=
-              size_t(r.aEnd.Col() - r.aStart.Col() + 1)
-            * size_t(r.aEnd.Row() - r.aStart.Row() + 1)
-            * size_t(r.aEnd.Tab() - r.aStart.Tab() + 1);
+              sal_uInt64(r.aEnd.Col() - r.aStart.Col() + 1)
+            * sal_uInt64(r.aEnd.Row() - r.aStart.Row() + 1)
+            * sal_uInt64(r.aEnd.Tab() - r.aStart.Tab() + 1);
     }
 
-    size_t getCellCount() const { return mnCellCount; }
+    sal_uInt64 getCellCount() const { return mnCellCount; }
 
 private:
-    size_t mnCellCount;
+    sal_uInt64 mnCellCount;
 };
 
 
@@ -1096,7 +1096,7 @@ bool ScRangeList::Contains( const ScRange& rRange ) const
     return std::any_of(maRanges.begin(), maRanges.end(), 
FindEnclosingRange<ScRange>(rRange));
 }
 
-size_t ScRangeList::GetCellCount() const
+sal_uInt64 ScRangeList::GetCellCount() const
 {
     CountCells func;
     return for_each(maRanges.begin(), maRanges.end(), func).getCellCount();
diff --git a/sc/source/filter/html/htmlexp.cxx 
b/sc/source/filter/html/htmlexp.cxx
index 102117b7526c..3290e2cf4d5d 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -948,7 +948,7 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& 
rBlockPos, SCCOL nCol, SC
     {
         SCCOL nC, jC;
         SCROW nR;
-        sal_uLong v;
+        tools::Long v;
         if ( pGraphEntry )
             nC = std::max( SCCOL(pGraphEntry->aRange.aEnd.Col() - nCol + 1),
                            rMergeAttr.GetColMerge() );
diff --git a/sc/source/filter/xml/xmlimprt.cxx 
b/sc/source/filter/xml/xmlimprt.cxx
index d2d36d634caf..093e19ba319a 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -484,7 +484,7 @@ void ScXMLImport::SetStatistics(const 
uno::Sequence<beans::NamedValue> & i_rStat
 
     SvXMLImport::SetStatistics(i_rStats);
 
-    sal_uInt32 nCount(0);
+    sal_uInt64 nCount(0);
     for (const auto& rStat : i_rStats) {
         for (const char** pStat = s_stats; *pStat != nullptr; ++pStat) {
             if (rStat.Name.equalsAscii(*pStat)) {
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 91483f02476e..46d4b188053d 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -3883,7 +3883,7 @@ uno::Reference<util::XReplaceDescriptor> SAL_CALL 
ScCellRangesBase::createReplac
 sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const 
uno::Reference<util::XSearchDescriptor>& xDesc )
 {
     SolarMutexGuard aGuard;
-    sal_Int32 nReplaced = 0;
+    sal_uInt64 nReplaced = 0;
     if ( pDocShell && xDesc.is() )
     {
         ScCellSearchObj* pSearch = 
comphelper::getFromUnoTunnel<ScCellSearchObj>( xDesc );
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 810b01812769..d689dbd72777 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -2527,9 +2527,9 @@ void ScOutputData::DrawClipMarks()
                         const ScMergeAttr* pMerge = mpDoc->GetAttr( nOverX, 
nOverY, nTab, ATTR_MERGE );
                         SCCOL nCountX = pMerge->GetColMerge();
                         for (SCCOL i=1; i<nCountX; i++)
-                            nOutWidth += static_cast<tools::Long>( 
mpDoc->GetColWidth(nOverX+i,nTab) * mnPPTX );
+                            nOutWidth += mpDoc->GetColWidth(nOverX+i,nTab) * 
mnPPTX;
                         SCROW nCountY = pMerge->GetRowMerge();
-                        nOutHeight += 
static_cast<tools::Long>(mpDoc->GetScaledRowHeight( nOverY+1, nOverY+nCountY-1, 
nTab, mnPPTY));
+                        nOutHeight += mpDoc->GetScaledRowHeight( nOverY+1, 
nOverY+nCountY-1, nTab, mnPPTY);
 
                         if ( bLayoutRTL )
                             nStartPosX -= nOutWidth - 1;
@@ -2548,9 +2548,9 @@ void ScOutputData::DrawClipMarks()
                                     &pInfo->pPatternAttr->GetItem(ATTR_MERGE);
                             SCCOL nCountX = pMerge->GetColMerge();
                             for (SCCOL i=1; i<nCountX; i++)
-                                nOutWidth += static_cast<tools::Long>( 
mpDoc->GetColWidth(nOverX+i,nTab) * mnPPTX );
+                                nOutWidth += mpDoc->GetColWidth(nOverX+i,nTab) 
* mnPPTX;
                             SCROW nCountY = pMerge->GetRowMerge();
-                            nOutHeight += 
static_cast<tools::Long>(mpDoc->GetScaledRowHeight( nOverY+1, nOverY+nCountY-1, 
nTab, mnPPTY));
+                            nOutHeight += mpDoc->GetScaledRowHeight( nOverY+1, 
nOverY+nCountY-1, nTab, mnPPTY);
                         }
 
                         tools::Long nStartPosX = nPosX;
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 78cec1f661ef..4fc1e84b1f2a 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1278,7 +1278,7 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, 
tools::Long nPosX, too
             ++nCompRow;
         }
     }
-    nCellPosY -= static_cast<tools::Long>(mpDoc->GetScaledRowHeight( nCellY, 
nCompRow-1, nTab, mnPPTY ));
+    nCellPosY -= mpDoc->GetScaledRowHeight( nCellY, nCompRow-1, nTab, mnPPTY );
 
     const ScMergeAttr* pMerge = &rPattern.GetItem( ATTR_MERGE );
     bool bMerged = pMerge->IsMerged();
@@ -1306,7 +1306,7 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, 
tools::Long nPosX, too
         nDirect = 1;        // skip in loop
     }
     // following rows always from document
-    nMergeSizeY += static_cast<tools::Long>(mpDoc->GetScaledRowHeight( 
nCellY+nDirect, nCellY+nMergeRows-1, nTab, mnPPTY));
+    nMergeSizeY += mpDoc->GetScaledRowHeight( nCellY+nDirect, 
nCellY+nMergeRows-1, nTab, mnPPTY);
 
     --nMergeSizeX;      // leave out the grid horizontally, also for alignment 
(align between grid lines)
 
@@ -4634,9 +4634,9 @@ void ScOutputData::DrawRotated(bool bPixelToLogic)
                             {
                                 SCCOL nCountX = pMerge->GetColMerge();
                                 for (SCCOL i=1; i<nCountX; i++)
-                                    nOutWidth += static_cast<tools::Long>( 
mpDoc->GetColWidth(nX+i,nTab) * mnPPTX );
+                                    nOutWidth += mpDoc->GetColWidth(nX+i,nTab) 
* mnPPTX;
                                 SCROW nCountY = pMerge->GetRowMerge();
-                                nOutHeight += 
static_cast<tools::Long>(mpDoc->GetScaledRowHeight( nY+1, nY+nCountY-1, nTab, 
mnPPTY));
+                                nOutHeight += mpDoc->GetScaledRowHeight( nY+1, 
nY+nCountY-1, nTab, mnPPTY);
                             }
 
                             SvxCellVerJustify eVerJust =
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index dd2195b61401..c9d376a1e3e4 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -532,7 +532,7 @@ void ScPrintFunc::DrawToDev(ScDocument& rDoc, OutputDevice* 
pDev, double /* nPri
     tools::Long nTwipsSizeX = 0;
     for (SCCOL i=nX1; i<=nX2; i++)
         nTwipsSizeX += rDoc.GetColWidth( i, nTab );
-    tools::Long nTwipsSizeY = static_cast<tools::Long>(rDoc.GetRowHeight( nY1, 
nY2, nTab ));
+    tools::Long nTwipsSizeY = rDoc.GetRowHeight( nY1, nY2, nTab );
 
     //  if no lines, still space for the outline frame (20 Twips = 1pt)
     //  (HasLines initializes aLines to 0,0,0,0)
diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx
index c2433e57c277..18ac99b0ccd9 100644
--- a/sc/source/ui/view/select.cxx
+++ b/sc/source/ui/view/select.cxx
@@ -520,7 +520,7 @@ bool ScViewFunctionSet::SetCursorAtCell( SCCOL nPosX, SCROW 
nPosY, bool bScroll
             tools::Long nSizeX = 0;
             for (SCCOL i=nPosX+1; i<=nEndX; i++)
                 nSizeX += rDoc.GetColWidth( i, nTab );
-            tools::Long nSizeY = static_cast<tools::Long>(rDoc.GetRowHeight( 
nPosY+1, nEndY, nTab ));
+            tools::Long nSizeY = rDoc.GetRowHeight( nPosY+1, nEndY, nTab );
 
             SCCOL nDelStartX = nStartX;
             SCROW nDelStartY = nStartY;
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 8f0ce9d9bd06..5862d87a8fa0 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -1678,7 +1678,7 @@ Point ScTabView::GetInsertPos() const
     nPosX = o3tl::convert(nPosX, o3tl::Length::twip, o3tl::Length::mm100);
     if ( rDoc.IsNegativePage( nTab ) )
         nPosX = -nPosX;
-    tools::Long nPosY = static_cast<tools::Long>(rDoc.GetRowHeight( 0, nRow-1, 
nTab));
+    tools::Long nPosY = rDoc.GetRowHeight( 0, nRow-1, nTab);
     nPosY = o3tl::convert(nPosY, o3tl::Length::twip, o3tl::Length::mm100);
     return Point(nPosX,nPosY);
 }
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index fa0ab9c868bc..c6ed2d5519c7 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -2419,7 +2419,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW 
nWhereY, ScSplitPos eWhich,
         const_cast<ScViewData*>(this)->aScrSize.setHeight( 
pView->GetGridHeight(eWhichY) );
     }
 
-    sal_uLong nTSize;
+    tools::Long nTSize;
     bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive();
 
 
@@ -2505,13 +2505,13 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW 
nWhereY, ScSplitPos eWhich,
                     nScrPosY = 0x7FFFFFFF;
                 else if (bAllowNeg || bIsTiledRendering)
                 {
-                    sal_uLong nSizeYPix = mrDoc.GetScaledRowHeight(nStartPosY, 
nWhereY - 1, nForTab, nPPTY);
+                    tools::Long nSizeYPix = 
mrDoc.GetScaledRowHeight(nStartPosY, nWhereY - 1, nForTab, nPPTY);
                     nScrPosY += nSizeYPix;
                 }
                 else
                 {
-                    sal_uLong nMaxHeight = aScrSize.getHeight() - nScrPosY;
-                    sal_uLong nSizeYPix = mrDoc.GetScaledRowHeight(nStartPosY, 
nWhereY - 1, nForTab, nPPTY, &nMaxHeight);
+                    tools::Long nMaxHeight = aScrSize.getHeight() - nScrPosY;
+                    tools::Long nSizeYPix = 
mrDoc.GetScaledRowHeight(nStartPosY, nWhereY - 1, nForTab, nPPTY, &nMaxHeight);
                     nScrPosY += nSizeYPix;
                 }
             }
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index ac61b30f593b..1ca4c7ba7809 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -99,7 +99,7 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId 
nFormatId,
                 nXT += rDoc.GetColWidth(i,nTab);
             if (rDoc.IsNegativePage(nTab))
                 nXT = -nXT;
-            sal_uLong nYT = rDoc.GetRowHeight( 0, nPosY-1, nTab);
+            tools::Long nYT = rDoc.GetRowHeight( 0, nPosY-1, nTab);
             aPos = Point(o3tl::convert(nXT, o3tl::Length::twip, 
o3tl::Length::mm100),
                          o3tl::convert(nYT, o3tl::Length::twip, 
o3tl::Length::mm100));
         }

Reply via email to