basctl/source/basicide/baside2.cxx                   |    2 
 basic/source/sbx/sbxdec.cxx                          |    2 
 dbaccess/source/ui/app/AppIconControl.cxx            |    2 
 desktop/qa/desktop_lib/test_desktop_lib.cxx          |    4 -
 drawinglayer/source/primitive2d/textlayoutdevice.cxx |    6 +-
 drawinglayer/source/processor2d/vclprocessor2d.cxx   |    2 
 editeng/inc/editdoc.hxx                              |    2 
 editeng/source/editeng/impedit3.cxx                  |    2 
 editeng/source/misc/txtrange.cxx                     |   24 +++++------
 filter/source/graphicfilter/ieps/ieps.cxx            |    4 -
 filter/source/svg/svgwriter.cxx                      |    2 
 include/editeng/txtrange.hxx                         |    4 -
 include/svx/xtable.hxx                               |    2 
 include/vcl/layout.hxx                               |    4 -
 include/vcl/toolkit/treelistbox.hxx                  |    2 
 oox/source/core/xmlfilterbase.cxx                    |    4 +
 oox/source/drawingml/fillproperties.cxx              |    2 
 oox/source/export/chartexport.cxx                    |   19 +++++----
 oox/source/export/drawingml.cxx                      |    2 
 reportdesign/source/ui/report/ReportWindow.cxx       |    2 
 sc/inc/dpgroup.hxx                                   |    2 
 sc/inc/dptabdat.hxx                                  |   10 ++--
 sc/inc/dptabres.hxx                                  |    2 
 sc/inc/dptabsrc.hxx                                  |    8 +--
 sc/source/core/data/dpgroup.cxx                      |   10 ++--
 sc/source/core/data/dpobject.cxx                     |    2 
 sc/source/core/data/dptabdat.cxx                     |    2 
 sc/source/core/data/dptabsrc.cxx                     |   14 +++---
 sc/source/core/data/table2.cxx                       |    2 
 sc/source/core/data/table4.cxx                       |    2 
 sc/source/core/inc/interpre.hxx                      |    4 -
 sc/source/core/tool/interpr3.cxx                     |    6 +-
 sc/source/core/tool/interpr5.cxx                     |    2 
 sc/source/filter/excel/xepivotxml.cxx                |    6 +-
 sc/source/ui/docshell/docsh8.cxx                     |    4 -
 sc/source/ui/inc/pfuncache.hxx                       |    4 -
 sc/source/ui/inc/preview.hxx                         |    6 +-
 sc/source/ui/view/output.cxx                         |    2 
 sc/source/ui/view/output2.cxx                        |    2 
 sc/source/ui/view/preview.cxx                        |    2 
 sc/source/ui/view/tabview.cxx                        |    6 +-
 sd/source/ui/view/drtxtob1.cxx                       |   10 ++--
 sd/source/ui/view/drviewse.cxx                       |    4 -
 sd/source/ui/view/outlnvs2.cxx                       |    4 -
 sd/source/ui/view/viewshel.cxx                       |    4 -
 sfx2/source/sidebar/PanelLayout.cxx                  |    2 
 starmath/source/dialog.cxx                           |    4 -
 starmath/source/edit.cxx                             |    2 
 starmath/source/node.cxx                             |    4 -
 svtools/source/brwbox/brwbox1.cxx                    |    6 +-
 svtools/source/control/ctrlbox.cxx                   |    6 +-
 svx/source/dialog/fntctrl.cxx                        |    2 
 svx/source/dialog/framelinkarray.cxx                 |   10 ++--
 svx/source/dialog/rulritem.cxx                       |    4 -
 svx/source/inc/fmshimp.hxx                           |    2 
 svx/source/svdraw/svdotext.cxx                       |    4 -
 sw/inc/redline.hxx                                   |    2 
 sw/qa/extras/layout/layout.cxx                       |   20 +++++----
 sw/qa/extras/ww8export/ww8export2.cxx                |    4 -
 sw/source/core/doc/DocumentStatisticsManager.cxx     |    2 
 sw/source/core/layout/dbg_lay.cxx                    |    2 
 sw/source/core/layout/newfrm.cxx                     |    2 
 sw/source/core/layout/tabfrm.cxx                     |    2 
 sw/source/core/layout/wsfrm.cxx                      |    2 
 sw/source/core/table/swnewtable.cxx                  |    2 
 sw/source/core/table/swtable.cxx                     |   12 ++---
 sw/source/core/text/inftxt.hxx                       |    6 +-
 sw/source/core/text/itrform2.cxx                     |    6 +-
 sw/source/core/text/porlay.cxx                       |    2 
 sw/source/core/text/porlay.hxx                       |    4 -
 sw/source/core/text/pormulti.cxx                     |    4 -
 sw/source/core/text/txtfly.cxx                       |    2 
 sw/source/filter/html/htmlcss1.cxx                   |    4 -
 sw/source/filter/writer/wrtswtbl.cxx                 |    2 
 sw/source/filter/ww8/WW8TableInfo.hxx                |    2 
 sw/source/filter/ww8/ww8par.cxx                      |    2 
 sw/source/ui/index/cnttab.cxx                        |   10 ++--
 sw/source/uibase/shells/tabsh.cxx                    |    4 -
 tools/qa/cppunit/test_bigint.cxx                     |   12 ++---
 vcl/headless/svpbmp.cxx                              |    2 
 vcl/headless/svpgdi.cxx                              |    2 
 vcl/qa/cppunit/complextext.cxx                       |    9 ++--
 vcl/source/app/salvtables.cxx                        |    6 +-
 vcl/source/bitmap/BitmapFilterStackBlur.cxx          |   10 ++--
 vcl/source/bitmap/BitmapScaleSuperFilter.cxx         |    6 +-
 vcl/source/bitmap/bitmappaint.cxx                    |   40 +++++++++----------
 vcl/source/control/imp_listbox.cxx                   |    2 
 vcl/source/edit/texteng.cxx                          |    4 -
 vcl/source/gdi/bmpfast.cxx                           |    2 
 vcl/source/gdi/salmisc.cxx                           |    2 
 vcl/source/outdev/map.cxx                            |    2 
 vcl/source/treelist/treelistbox.cxx                  |    4 -
 vcl/source/window/dialog.cxx                         |    4 -
 vcl/source/window/layout.cxx                         |   14 +++---
 vcl/unx/generic/gdi/salbmp.cxx                       |    2 
 vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx            |    4 -
 vcl/win/gdi/salfont.cxx                              |    2 
 vcl/win/gdi/salprn.cxx                               |    2 
 vcl/win/window/salobj.cxx                            |    4 -
 99 files changed, 251 insertions(+), 241 deletions(-)

New commits:
commit 4b6ebf3b4f2992a8b796443fe666ee32e2e47c1d
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Tue Oct 27 21:17:58 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Oct 28 07:22:17 2020 +0100

    std::set->o3tl::sorted_vector in oox
    
    Change-Id: Id7cdf8c4787d89adc9c343a5417093bee2aa603a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104905
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/oox/source/core/xmlfilterbase.cxx 
b/oox/source/core/xmlfilterbase.cxx
index 259e0bf2e406..d1d1e82f0bb9 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -66,6 +66,7 @@
 #include <sax/tools/converter.hxx>
 #include <oox/token/namespacemap.hxx>
 #include <editeng/unoprnms.hxx>
+#include <o3tl/sorted_vector.hxx>
 
 using ::com::sun::star::xml::dom::DocumentBuilder;
 using ::com::sun::star::xml::dom::XDocument;
@@ -157,7 +158,8 @@ void registerNamespaces( FastParser& rParser )
 
     // Filter out duplicates: a namespace can have multiple URLs, think of
     // strict vs transitional.
-    std::set<sal_Int32> aSet;
+    o3tl::sorted_vector<sal_Int32> aSet;
+    aSet.reserve(ids.getLength());
     for (const auto& rId : ids)
         aSet.insert(rId.Second);
 
diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index 5b52d312c091..19c5b7abf5f4 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -103,6 +103,7 @@
 
 #include <rtl/math.hxx>
 #include <o3tl/temporary.hxx>
+#include <o3tl/sorted_vector.hxx>
 
 using namespace css;
 using namespace css::uno;
@@ -3664,10 +3665,11 @@ void ChartExport::exportDataPoints(
 
     if( bVaryColorsByPoint && xColorScheme.is() )
     {
-        ::std::set< sal_Int32 > aAttrPointSet;
-        ::std::copy( pPoints, pPoints + aDataPointSeq.getLength(),
-                    ::std::inserter( aAttrPointSet, aAttrPointSet.begin()));
-        const ::std::set< sal_Int32 >::const_iterator aEndIt( 
aAttrPointSet.end());
+        o3tl::sorted_vector< sal_Int32 > aAttrPointSet;
+        aAttrPointSet.reserve(aDataPointSeq.getLength());
+        for (auto p = pPoints; p < pPoints + aDataPointSeq.getLength(); ++p)
+            aAttrPointSet.insert(*p);
+        const auto aEndIt = aAttrPointSet.end();
         for( nElement = 0; nElement < nSeriesLength; ++nElement )
         {
             uno::Reference< beans::XPropertySet > xPropSet;
@@ -3724,10 +3726,11 @@ void ChartExport::exportDataPoints(
     if( bVaryColorsByPoint )
         return;
 
-    ::std::set< sal_Int32 > aAttrPointSet;
-    ::std::copy( pPoints, pPoints + aDataPointSeq.getLength(),
-                ::std::inserter( aAttrPointSet, aAttrPointSet.begin()));
-    const ::std::set< sal_Int32 >::const_iterator aEndIt( aAttrPointSet.end());
+    o3tl::sorted_vector< sal_Int32 > aAttrPointSet;
+    aAttrPointSet.reserve(aDataPointSeq.getLength());
+    for (auto p = pPoints; p < pPoints + aDataPointSeq.getLength(); ++p)
+        aAttrPointSet.insert(*p);
+    const auto aEndIt = aAttrPointSet.end();
     for( nElement = 0; nElement < nSeriesLength; ++nElement )
     {
         uno::Reference< beans::XPropertySet > xPropSet;
commit 6436302f40252bc6619e304e2051115fee902e20
Author:     Noel <noelgran...@gmail.com>
AuthorDate: Mon Oct 26 14:17:32 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Oct 28 07:21:59 2020 +0100

    convert some more long -> tools::Long
    
    grepping for stuff in template params this time
    
    Change-Id: Ia37bfd85480b3a72c3c465489581d56ad8dde851
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104855
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/basctl/source/basicide/baside2.cxx 
b/basctl/source/basicide/baside2.cxx
index bccf765c786b..41c0ff4413f3 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -836,7 +836,7 @@ sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, 
sal_Int32 nPrintPage )
     sal_Int32 nLinespPage = aPaperSz.Height()/nLineHeight;
     tools::Long nXTextWidth = pPrinter->approximate_digit_width();
 
-    sal_Int32 nCharspLine = aPaperSz.Width() / std::max<long>(nXTextWidth, 1);
+    sal_Int32 nCharspLine = aPaperSz.Width() / 
std::max<tools::Long>(nXTextWidth, 1);
     const sal_uInt32 nParas = GetEditEngine()->GetParagraphCount();
 
     sal_Int32 nPages = nParas/nLinespPage+1;
diff --git a/basic/source/sbx/sbxdec.cxx b/basic/source/sbx/sbxdec.cxx
index 81685f7744e2..50f509cfe87d 100644
--- a/basic/source/sbx/sbxdec.cxx
+++ b/basic/source/sbx/sbxdec.cxx
@@ -156,7 +156,7 @@ void SbxDecimal::setShort( sal_Int16 val )
 
 void SbxDecimal::setLong( sal_Int32 val )
 {
-    VarDecFromI4( static_cast<long>(val), &maDec );
+    VarDecFromI4( static_cast<tools::Long>(val), &maDec );
 }
 
 void SbxDecimal::setUShort( sal_uInt16 val )
diff --git a/dbaccess/source/ui/app/AppIconControl.cxx 
b/dbaccess/source/ui/app/AppIconControl.cxx
index 2a89362ec91e..21f830cc3c62 100644
--- a/dbaccess/source/ui/app/AppIconControl.cxx
+++ b/dbaccess/source/ui/app/AppIconControl.cxx
@@ -91,7 +91,7 @@ void OApplicationIconControl::Fill()
         m_nMaxWidth = std::max(m_nMaxWidth, rSize.Width());
         m_nMaxHeight = std::max(m_nMaxHeight, rSize.Height());
         xItem->maTitle = DBA_RES(aCategorie.pLabelResId);
-        m_nMaxWidth = std::max<long>(m_nMaxWidth, 
GetTextWidth(xItem->maTitle));
+        m_nMaxWidth = std::max<tools::Long>(m_nMaxWidth, 
GetTextWidth(xItem->maTitle));
         AppendItem(std::move(xItem));
     }
 
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 858548d6b569..2d338d20014a 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1008,7 +1008,7 @@ void DesktopLOKTest::testSheetSelections()
     {
         char* pUsedMimeType = nullptr;
         char* pCopiedContent = pDocument->pClass->getTextSelection(pDocument, 
nullptr, &pUsedMimeType);
-        std::vector<long> aExpected = {5, 6, 7, 8, 9};
+        std::vector<tools::Long> aExpected = {5, 6, 7, 8, 9};
         std::istringstream iss(pCopiedContent);
         for (size_t i = 0; i < aExpected.size(); i++)
         {
@@ -1055,7 +1055,7 @@ void DesktopLOKTest::testSheetSelections()
     {
         char* pUsedMimeType  = nullptr;
         char* pCopiedContent = pDocument->pClass->getTextSelection(pDocument, 
nullptr, &pUsedMimeType);
-        std::vector<long> aExpected = { 8 };
+        std::vector<tools::Long> aExpected = { 8 };
         std::istringstream iss(pCopiedContent);
         for (size_t i = 0; i < aExpected.size(); i++)
         {
diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx 
b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
index e34fe1822fa4..f2d2e205d76b 100644
--- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx
+++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
@@ -349,7 +349,7 @@ namespace drawinglayer::primitive2d
             if(nTextLength)
             {
                 aRetval.reserve(nTextLength);
-                std::vector<long> aArray(nTextLength);
+                std::vector<tools::Long> aArray(nTextLength);
                 mrDevice.GetTextArray(rText, aArray.data(), nIndex, nLength);
                 aRetval.assign(aArray.begin(), aArray.end());
             }
@@ -374,7 +374,7 @@ namespace drawinglayer::primitive2d
             if(nTextLength)
             {
                 aRetval.reserve(2 * nTextLength);
-                std::vector<long> aArray(2 * nTextLength);
+                std::vector<tools::Long> aArray(2 * nTextLength);
                 mrDevice.GetCaretPositions(rText, aArray.data(), nIndex, 
nLength);
                 aRetval.assign(aArray.begin(), aArray.end());
             }
@@ -457,7 +457,7 @@ namespace drawinglayer::primitive2d
             // TODO: eKerning
 
             // set FontHeight and init to no FontScaling
-            o_rSize.setY(std::max<long>(rFont.GetFontSize().getHeight(), 0));
+            
o_rSize.setY(std::max<tools::Long>(rFont.GetFontSize().getHeight(), 0));
             o_rSize.setX(o_rSize.getY());
 
 #ifdef _WIN32
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx 
b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index 9f5f5d77c0d5..e4083043f1b7 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -252,7 +252,7 @@ void 
VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(
             }
 
             // create transformed integer DXArray in view coordinate system
-            std::vector<long> aTransformedDXArray;
+            std::vector<tools::Long> aTransformedDXArray;
 
             if (!rTextCandidate.getDXArray().empty())
             {
diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 4b4f610772a5..440221bc047b 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -457,7 +457,7 @@ class ParaPortion;
 class EditLine
 {
 public:
-    typedef std::vector<long> CharPosArrayType;
+    typedef std::vector<tools::Long> CharPosArrayType;
 
 private:
     CharPosArrayType aPositions;
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index d070ec660786..4ffaeec6afaa 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -818,7 +818,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
         tools::Long nTmpWidth = 0;
         tools::Long nXWidth = nMaxLineWidth;
 
-        std::deque<long>* pTextRanges = nullptr;
+        std::deque<tools::Long>* pTextRanges = nullptr;
         tools::Long nTextExtraYOffset = 0;
         tools::Long nTextXOffset = 0;
         tools::Long nTextLineHeight = 0;
diff --git a/editeng/source/misc/txtrange.cxx b/editeng/source/misc/txtrange.cxx
index 8ae51a790899..b8c46e0cdcba 100644
--- a/editeng/source/misc/txtrange.cxx
+++ b/editeng/source/misc/txtrange.cxx
@@ -93,7 +93,7 @@ namespace {
 class SvxBoundArgs
 {
     std::vector<bool> aBoolArr;
-    std::deque<long>* pLongArr;
+    std::deque<tools::Long>* pLongArr;
     TextRanger *pTextRanger;
     tools::Long nMin;
     tools::Long nMax;
@@ -126,7 +126,7 @@ class SvxBoundArgs
     tools::Long A( const Point& rP ) const { return bRotate ? rP.Y() : rP.X(); 
}
     tools::Long B( const Point& rP ) const { return bRotate ? rP.X() : rP.Y(); 
}
 public:
-    SvxBoundArgs( TextRanger* pRanger, std::deque<long>* pLong, const Range& 
rRange );
+    SvxBoundArgs( TextRanger* pRanger, std::deque<tools::Long>* pLong, const 
Range& rRange );
     void NotePoint( const tools::Long nA ) { NoteMargin( nA - nStart, nA + 
nEnd ); }
     void NoteMargin( const tools::Long nL, const tools::Long nR )
         { if( nMin > nL ) nMin = nL; if( nMax < nR ) nMax = nR; }
@@ -142,7 +142,7 @@ public:
 
 }
 
-SvxBoundArgs::SvxBoundArgs( TextRanger* pRanger, std::deque<long>* pLong,
+SvxBoundArgs::SvxBoundArgs( TextRanger* pRanger, std::deque<tools::Long>* 
pLong,
     const Range& rRange )
     : pLongArr(pLong)
     , pTextRanger(pRanger)
@@ -488,18 +488,18 @@ void SvxBoundArgs::Concat( const tools::PolyPolygon* 
pPoly )
 {
     SetConcat( true );
     DBG_ASSERT( pPoly, "Nothing to do?" );
-    std::deque<long>* pOld = pLongArr;
-    pLongArr = new std::deque<long>;
+    std::deque<tools::Long>* pOld = pLongArr;
+    pLongArr = new std::deque<tools::Long>;
     aBoolArr.clear();
     bInner = false;
     Calc( *pPoly ); // Note that this updates pLongArr, which is why we 
swapped it out earlier.
-    std::deque<long>::size_type nCount = pLongArr->size();
-    std::deque<long>::size_type nIdx = 0;
-    std::deque<long>::size_type i = 0;
+    std::deque<tools::Long>::size_type nCount = pLongArr->size();
+    std::deque<tools::Long>::size_type nIdx = 0;
+    std::deque<tools::Long>::size_type i = 0;
     bool bSubtract = pTextRanger->IsInner();
     while( i < nCount )
     {
-        std::deque<long>::size_type nOldCount = pOld->size();
+        std::deque<tools::Long>::size_type nOldCount = pOld->size();
         if( nIdx == nOldCount )
         {   // Reached the end of the old Array...
             if( !bSubtract )
@@ -508,7 +508,7 @@ void SvxBoundArgs::Concat( const tools::PolyPolygon* pPoly )
         }
         tools::Long nLeft = (*pLongArr)[ i++ ];
         tools::Long nRight = (*pLongArr)[ i++ ];
-        std::deque<long>::size_type nLeftPos = nIdx + 1;
+        std::deque<tools::Long>::size_type nLeftPos = nIdx + 1;
         while( nLeftPos < nOldCount && nLeft > (*pOld)[ nLeftPos ] )
             nLeftPos += 2;
         if( nLeftPos >= nOldCount )
@@ -517,7 +517,7 @@ void SvxBoundArgs::Concat( const tools::PolyPolygon* pPoly )
                 pOld->insert( pOld->begin() + nOldCount, pLongArr->begin() + i 
- 2, pLongArr->end() );
             break;
         }
-        std::deque<long>::size_type nRightPos = nLeftPos - 1;
+        std::deque<tools::Long>::size_type nRightPos = nLeftPos - 1;
         while( nRightPos < nOldCount && nRight >= (*pOld)[ nRightPos ] )
             nRightPos += 2;
         if( nRightPos < nLeftPos )
@@ -630,7 +630,7 @@ void SvxBoundArgs::NoteUpLow( tools::Long nA, const 
sal_uInt8 nArea )
     }
 }
 
-std::deque<long>* TextRanger::GetTextRanges( const Range& rRange )
+std::deque<tools::Long>* TextRanger::GetTextRanges( const Range& rRange )
 {
     DBG_ASSERT( rRange.Min() || rRange.Max(), "Zero-Range not allowed, Bye 
Bye" );
     //Can we find the result we need in the cache?
diff --git a/filter/source/graphicfilter/ieps/ieps.cxx 
b/filter/source/graphicfilter/ieps/ieps.cxx
index 010d984d3eb0..0873bf9cff75 100644
--- a/filter/source/graphicfilter/ieps/ieps.cxx
+++ b/filter/source/graphicfilter/ieps/ieps.cxx
@@ -96,8 +96,8 @@ static tools::Long ImplGetNumber(sal_uInt8* &rBuf, 
sal_uInt32& nSecurityCount)
                     nSecurityCount = 1;         // error parsing the bounding 
box values
                 else if ( bValid )
                 {
-                    const bool bFail = o3tl::checked_multiply<long>(nRetValue, 
10, nRetValue) ||
-                                       o3tl::checked_add<long>(nRetValue, 
*rBuf - '0', nRetValue);
+                    const bool bFail = 
o3tl::checked_multiply<tools::Long>(nRetValue, 10, nRetValue) ||
+                                       
o3tl::checked_add<tools::Long>(nRetValue, *rBuf - '0', nRetValue);
                     if (bFail)
                         return 0;
                 }
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index f92204ac3442..7d5ac70e1a0c 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -2714,7 +2714,7 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, 
const OUString& rText,
         return;
 
     tools::Polygon aPoly( 4 );
-    const tools::Long  nLineHeight = std::max<long>( FRound( 
aMetric.GetLineHeight() * 0.05 ), 1 );
+    const tools::Long  nLineHeight = std::max<tools::Long>( FRound( 
aMetric.GetLineHeight() * 0.05 ), 1 );
 
     if( rFont.GetStrikeout() )
     {
diff --git a/include/editeng/txtrange.hxx b/include/editeng/txtrange.hxx
index 1898a364966b..e6509291d388 100644
--- a/include/editeng/txtrange.hxx
+++ b/include/editeng/txtrange.hxx
@@ -37,7 +37,7 @@ class EDITENG_DLLPUBLIC TextRanger
     struct RangeCacheItem
     {
         Range range;        //!< Range for which we calculated results.
-        std::deque<long> results;  //!< Calculated results for the range.
+        std::deque<tools::Long> results;  //!< Calculated results for the 
range.
         RangeCacheItem(const Range& rng) : range(rng) {};
     };
     std::deque<RangeCacheItem> mRangeCache; //!< Cached range calculations.
@@ -63,7 +63,7 @@ public:
                 sal_uInt16 nCacheSize, sal_uInt16 nLeft, sal_uInt16 nRight,
                 bool bSimple, bool bInner, bool bVert = false );
     ~TextRanger();
-    std::deque<long>* GetTextRanges( const Range& rRange );
+    std::deque<tools::Long>* GetTextRanges( const Range& rRange );
     sal_uInt16 GetRight() const { return nRight; }
     sal_uInt16 GetLeft() const { return nLeft; }
     sal_uInt16 GetUpper() const { return nUpper; }
diff --git a/include/svx/xtable.hxx b/include/svx/xtable.hxx
index d7a16f4f01ff..2c48fc7b1006 100644
--- a/include/svx/xtable.hxx
+++ b/include/svx/xtable.hxx
@@ -175,7 +175,7 @@ public:
     XPropertyListType Type() const { return meType; }
     tools::Long Count() const;
 
-    void Insert(std::unique_ptr<XPropertyEntry> pEntry, tools::Long nIndex = 
std::numeric_limits<long>::max());
+    void Insert(std::unique_ptr<XPropertyEntry> pEntry, tools::Long nIndex = 
std::numeric_limits<tools::Long>::max());
     void Replace(std::unique_ptr<XPropertyEntry> pEntry, tools::Long nIndex);
     void Remove(tools::Long nIndex);
 
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index d67ab24ffb21..e91bb629ff1d 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -222,8 +222,8 @@ private:
     VclButtonBoxStyle m_eLayoutStyle;
     struct Requisition
     {
-        std::vector<long> m_aMainGroupDimensions;
-        std::vector<long> m_aSubGroupDimensions;
+        std::vector<tools::Long> m_aMainGroupDimensions;
+        std::vector<tools::Long> m_aSubGroupDimensions;
         Size m_aMainGroupSize;
         Size m_aSubGroupSize;
     };
diff --git a/include/vcl/toolkit/treelistbox.hxx 
b/include/vcl/toolkit/treelistbox.hxx
index 379401ac7ea5..199f37c093e8 100644
--- a/include/vcl/toolkit/treelistbox.hxx
+++ b/include/vcl/toolkit/treelistbox.hxx
@@ -664,7 +664,7 @@ public:
     SvTreeListEntry*    GetNextEntryInView(SvTreeListEntry*) const;
     void            ScrollToAbsPos( tools::Long nPos );
 
-    tools::Long            getPreferredDimensions(std::vector<long> &rWidths) 
const;
+    tools::Long            getPreferredDimensions(std::vector<tools::Long> 
&rWidths) const;
 
     virtual Size    GetOptimalSize() const override;
 
diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 74a5d39fe1df..fe19a556609d 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -770,7 +770,7 @@ void GraphicProperties::pushToPropMap( PropertyMap& 
rPropMap, const GraphicHelpe
             // When custom shape is rotated, bitmap have to be rotated too.
             if(rPropMap.hasProperty(PROP_RotateAngle))
             {
-                tools::Long nAngle = 
rPropMap.getProperty(PROP_RotateAngle).get<long>();
+                tools::Long nAngle = 
rPropMap.getProperty(PROP_RotateAngle).get<tools::Long>();
                 xGraphic = lclRotateGraphic(xGraphic, Degree10(nAngle/10) );
             }
 
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 8b69d23ab499..8908af370e0b 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2463,7 +2463,7 @@ void DrawingML::WriteParagraphNumbering(const Reference< 
XPropertySet >& rXPropS
             // Add padding to get the bullet point centered in PPT
             Size aDestSize(64, 64);
             float fBulletSizeRelX = fBulletSizeRel / aGraphicSize.Height * 
aGraphicSize.Width;
-            tools::Long nPaddingX = std::max<long>(0, 
std::lround((aDestSize.Width() - fBulletSizeRelX * aDestSize.Width()) / 2.f));
+            tools::Long nPaddingX = std::max<tools::Long>(0, 
std::lround((aDestSize.Width() - fBulletSizeRelX * aDestSize.Width()) / 2.f));
             tools::Long nPaddingY = std::lround((aDestSize.Height() - 
fBulletSizeRel * aDestSize.Height()) / 2.f);
             tools::Rectangle aDestRect(nPaddingX, nPaddingY, aDestSize.Width() 
- nPaddingX, aDestSize.Height() - nPaddingY);
 
diff --git a/reportdesign/source/ui/report/ReportWindow.cxx 
b/reportdesign/source/ui/report/ReportWindow.cxx
index e6bd5325b2df..674e72da8e9c 100644
--- a/reportdesign/source/ui/report/ReportWindow.cxx
+++ b/reportdesign/source/ui/report/ReportWindow.cxx
@@ -178,7 +178,7 @@ void OReportWindow::Resize()
     aPageSize.setHeight( m_aHRuler->GetSizePixel().Height() );
 
     const tools::Long nTermp(m_aViewsWindow->getTotalHeight() + 
aPageSize.Height());
-    tools::Long nSectionsHeight = 
::std::max<long>(nTermp,aTotalOutputSize.Height());
+    tools::Long nSectionsHeight = 
::std::max<tools::Long>(nTermp,aTotalOutputSize.Height());
 
     m_aHRuler->SetPosSizePixel(aStartPoint,aPageSize);
     m_aHRuler->SetNullOffset(nLeftMargin);
diff --git a/sc/inc/dpgroup.hxx b/sc/inc/dpgroup.hxx
index f30f85f6f394..720e07a3c8da 100644
--- a/sc/inc/dpgroup.hxx
+++ b/sc/inc/dpgroup.hxx
@@ -122,7 +122,7 @@ class ScDPGroupTableData final : public ScDPTableData
                             pNumGroups;     // array[nSourceCount]
     ScDocument*             pDoc;
 
-    void FillGroupValues(std::vector<SCROW>& rItems, const std::vector<long>& 
rDims);
+    void FillGroupValues(std::vector<SCROW>& rItems, const 
std::vector<tools::Long>& rDims);
     virtual tools::Long                GetSourceDim( tools::Long nDim ) 
override;
 
     bool        IsNumGroupDimension( tools::Long nDimension ) const;
diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx
index 8f8aa3cd578c..8ab4eb167b7f 100644
--- a/sc/inc/dptabdat.hxx
+++ b/sc/inc/dptabdat.hxx
@@ -69,14 +69,14 @@ public:
         should be passed as a const instance. */
     struct SAL_DLLPRIVATE CalcInfo
     {
-        ::std::vector<long>             aColLevelDims;
+        ::std::vector<tools::Long>             aColLevelDims;
         ::std::vector<ScDPDimension*>   aColDims;
         ::std::vector<ScDPLevel*>       aColLevels;
-        ::std::vector<long>             aRowLevelDims;
+        ::std::vector<tools::Long>             aRowLevelDims;
         ::std::vector<ScDPDimension*>   aRowDims;
         ::std::vector<ScDPLevel*>       aRowLevels;
-        ::std::vector<long>             aPageDims;
-        ::std::vector<long>             aDataSrcCols;
+        ::std::vector<tools::Long>             aPageDims;
+        ::std::vector<tools::Long>             aDataSrcCols;
 
         ScDPInitState*                  pInitState;
         ScDPResultMember*               pColRoot;
@@ -154,7 +154,7 @@ protected:
 
 private:
     void            GetItemData(const ScDPFilteredCache& rCacheTable, 
sal_Int32 nRow,
-                                          const ::std::vector<long>& rDims, 
::std::vector< SCROW >& rItemData);
+                                          const ::std::vector<tools::Long>& 
rDims, ::std::vector< SCROW >& rItemData);
 };
 #endif
 
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index 2ea654a9c32f..7a8f23564720 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -105,7 +105,7 @@ struct ScDPSubTotalState
 class ScDPRunningTotalState
 {
 public:
-    typedef std::vector<long> IndexArray; /// array of long integers 
terminated by -1.
+    typedef std::vector<tools::Long> IndexArray; /// array of long integers 
terminated by -1.
 
     ScDPRunningTotalState( ScDPResultMember* pColRoot, ScDPResultMember* 
pRowRoot );
 
diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index 692eb2a987fa..106c6cd74b66 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -85,10 +85,10 @@ private:
     rtl::Reference<ScDPDimensions> pDimensions; // api objects
                                                 // settings:
 
-    std::vector<long> maColDims;
-    std::vector<long> maRowDims;
-    std::vector<long> maDataDims;
-    std::vector<long> maPageDims;
+    std::vector<tools::Long> maColDims;
+    std::vector<tools::Long> maRowDims;
+    std::vector<tools::Long> maDataDims;
+    std::vector<tools::Long> maPageDims;
     ScDPResultTree maResFilterSet;
 
     bool                    bColumnGrand;
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index fd9b9098dd25..a54e91fe4274 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -553,7 +553,7 @@ OUString ScDPGroupTableData::getDimensionName(tools::Long 
nColumn)
 {
     if ( nColumn >= nSourceCount )
     {
-        if ( nColumn == sal::static_int_cast<long>( nSourceCount + 
aGroups.size() ) )     // data layout dimension?
+        if ( nColumn == sal::static_int_cast<tools::Long>( nSourceCount + 
aGroups.size() ) )     // data layout dimension?
             nColumn = nSourceCount;                         // index of data 
layout in source data
         else
             return aGroups[nColumn - nSourceCount].GetName();
@@ -565,14 +565,14 @@ OUString ScDPGroupTableData::getDimensionName(tools::Long 
nColumn)
 bool ScDPGroupTableData::getIsDataLayoutDimension(tools::Long nColumn)
 {
     // position of data layout dimension is moved from source data
-    return ( nColumn == sal::static_int_cast<long>( nSourceCount + 
aGroups.size() ) );    // data layout dimension?
+    return ( nColumn == sal::static_int_cast<tools::Long>( nSourceCount + 
aGroups.size() ) );    // data layout dimension?
 }
 
 bool ScDPGroupTableData::IsDateDimension(tools::Long nDim)
 {
     if ( nDim >= nSourceCount )
     {
-        if ( nDim == sal::static_int_cast<long>( nSourceCount + aGroups.size() 
) )        // data layout dimension?
+        if ( nDim == sal::static_int_cast<tools::Long>( nSourceCount + 
aGroups.size() ) )        // data layout dimension?
             nDim = nSourceCount;                            // index of data 
layout in source data
         else
             nDim = aGroups[nDim - nSourceCount].GetSourceDim();  // look at 
original dimension
@@ -585,7 +585,7 @@ sal_uInt32 ScDPGroupTableData::GetNumberFormat(tools::Long 
nDim)
 {
     if ( nDim >= nSourceCount )
     {
-        if ( nDim == sal::static_int_cast<long>( nSourceCount + aGroups.size() 
) )        // data layout dimension?
+        if ( nDim == sal::static_int_cast<tools::Long>( nSourceCount + 
aGroups.size() ) )        // data layout dimension?
             nDim = nSourceCount;                            // index of data 
layout in source data
         else
             nDim = aGroups[nDim - nSourceCount].GetSourceDim();  // look at 
original dimension
@@ -801,7 +801,7 @@ void ScDPGroupTableData::ReloadCacheTable()
     pSourceData->ReloadCacheTable();
 }
 
-void ScDPGroupTableData::FillGroupValues(vector<SCROW>& rItems, const 
vector<long>& rDims)
+void ScDPGroupTableData::FillGroupValues(vector<SCROW>& rItems, const 
vector<tools::Long>& rDims)
 {
     tools::Long nGroupedColumns = aGroups.size();
 
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 99c974fc64b9..883913949fe1 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2159,7 +2159,7 @@ static void lcl_FillOldFields( ScPivotFieldVector& 
rFields,
     //TODO: merge multiple occurrences (data field with different functions)
     //TODO: force data field in one dimension
 
-    vector<long> aPos;
+    vector<tools::Long> aPos;
 
     uno::Reference<container::XNameAccess> xDimsName = 
xSource->getDimensions();
     uno::Reference<container::XIndexAccess> xDims = new ScNameToIndexAccess( 
xDimsName );
diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx
index c0b39a445e47..1e547a6a6242 100644
--- a/sc/source/core/data/dptabdat.cxx
+++ b/sc/source/core/data/dptabdat.cxx
@@ -215,7 +215,7 @@ void ScDPTableData::CalcResultsFromCacheTable(const 
ScDPFilteredCache& rCacheTab
 }
 
 void ScDPTableData::GetItemData(const ScDPFilteredCache& rCacheTable, 
sal_Int32 nRow,
-                                const vector<long>& rDims, vector<SCROW>& 
rItemData)
+                                const vector<tools::Long>& rDims, 
vector<SCROW>& rItemData)
 {
     sal_Int32 nDimSize = rDims.size();
     rItemData.reserve(rItemData.size() + nDimSize);
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 667d60ab9241..62ef223a8eeb 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -165,7 +165,7 @@ OUString ScDPSource::GetDataDimName(tools::Long nIndex)
 
 tools::Long ScDPSource::GetPosition(tools::Long nColumn)
 {
-    std::vector<long>::const_iterator it, itBeg = maColDims.begin(), itEnd = 
maColDims.end();
+    std::vector<tools::Long>::const_iterator it, itBeg = maColDims.begin(), 
itEnd = maColDims.end();
     it = std::find(itBeg, itEnd, nColumn);
     if (it != itEnd)
         return std::distance(itBeg, it);
@@ -193,10 +193,10 @@ tools::Long ScDPSource::GetPosition(tools::Long nColumn)
 
 namespace {
 
-bool testSubTotal( bool& rAllowed, tools::Long nColumn, const 
std::vector<long>& rDims, ScDPSource* pSource )
+bool testSubTotal( bool& rAllowed, tools::Long nColumn, const 
std::vector<tools::Long>& rDims, ScDPSource* pSource )
 {
     rAllowed = true;
-    std::vector<long>::const_iterator it = rDims.begin(), itEnd = rDims.end();
+    std::vector<tools::Long>::const_iterator it = rDims.begin(), itEnd = 
rDims.end();
     for (; it != itEnd; ++it)
     {
         if (*it != nColumn)
@@ -222,9 +222,9 @@ bool testSubTotal( bool& rAllowed, tools::Long nColumn, 
const std::vector<long>&
     return false;
 }
 
-void removeDim( tools::Long nRemove, std::vector<long>& rDims )
+void removeDim( tools::Long nRemove, std::vector<tools::Long>& rDims )
 {
-    std::vector<long>::iterator it = std::find(rDims.begin(), rDims.end(), 
nRemove);
+    std::vector<tools::Long>::iterator it = std::find(rDims.begin(), 
rDims.end(), nRemove);
     if (it != rDims.end())
         rDims.erase(it);
 }
@@ -598,7 +598,7 @@ static tools::Long lcl_CountMinMembers(const 
vector<ScDPDimension*>& ppDim, cons
 
 void ScDPSource::FillCalcInfo(bool bIsRow, ScDPTableData::CalcInfo& rInfo, 
bool &rHasAutoShow)
 {
-    const std::vector<long>& rDims = bIsRow ? maRowDims : maColDims;
+    const std::vector<tools::Long>& rDims = bIsRow ? maRowDims : maColDims;
     for (const auto& rDimIndex : rDims)
     {
         ScDPDimension* pDim = GetDimensionsObject()->getByIndex(rDimIndex);
@@ -957,7 +957,7 @@ void ScDPSource::FillLevelList( 
sheet::DataPilotFieldOrientation nOrientation, s
 {
     rList.clear();
 
-    std::vector<long>* pDimIndex = nullptr;
+    std::vector<tools::Long>* pDimIndex = nullptr;
     switch (nOrientation)
     {
         case sheet::DataPilotFieldOrientation_COLUMN:
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 02f40b63507e..826c7125a89e 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -3910,7 +3910,7 @@ void ScTable::SetDrawPageSize(bool bResetStreamValid, 
bool bUpdateNoteCaptionPos
     {
         double fValX = GetColOffset( rDocument.MaxCol() + 1 ) * HMM_PER_TWIPS;
         double fValY = GetRowOffset( rDocument.MaxRow() + 1 ) * HMM_PER_TWIPS;
-        const tools::Long nMax = ::std::numeric_limits<long>::max();
+        const tools::Long nMax = ::std::numeric_limits<tools::Long>::max();
         // #i113884# Avoid int32 overflow with possible negative results than 
can cause bad effects.
         // If the draw page size is smaller than all rows, only the bottom of 
the sheet is affected.
         tools::Long x = ( fValX > static_cast<double>(nMax) ) ? nMax : 
static_cast<tools::Long>(fValX);
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 795dbf06c925..d947e16cddd9 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -1125,7 +1125,7 @@ OUString ScTable::GetAutoFillPreview( const ScRange& 
rSource, SCCOL nEndX, SCROW
             if ( nListCount )
             {
                 sal_uLong nSub = nSrcCount - 1; //  nListIndex is from last 
source entry
-                while ( nIndex < sal::static_int_cast<long>(nSub) )
+                while ( nIndex < sal::static_int_cast<tools::Long>(nSub) )
                     nIndex += nListCount;
                 sal_uLong nPos = ( nListIndex + nIndex - nSub ) % nListCount;
                 aValue = 
pListData->GetSubStr(sal::static_int_cast<sal_uInt16>(nPos));
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 46b6f49da87e..a8a5d0e1038e 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -944,8 +944,8 @@ private:
     double GetPercentileExclusive( ::std::vector<double> & rArray, double 
fPercentile );
     std::vector<double> GetTopNumberArray( SCSIZE& rCol, SCSIZE& rRow );
     void GetNumberSequenceArray( sal_uInt8 nParamCount, ::std::vector<double>& 
rArray, bool bConvertTextInArray );
-    void GetSortArray( sal_uInt8 nParamCount, ::std::vector<double>& 
rSortArray, ::std::vector<long>* pIndexOrder, bool bConvertTextInArray, bool 
bAllowEmptyArray );
-    static void QuickSort(::std::vector<double>& rSortArray, 
::std::vector<long>* pIndexOrder);
+    void GetSortArray( sal_uInt8 nParamCount, ::std::vector<double>& 
rSortArray, ::std::vector<tools::Long>* pIndexOrder, bool bConvertTextInArray, 
bool bAllowEmptyArray );
+    static void QuickSort(::std::vector<double>& rSortArray, 
::std::vector<tools::Long>* pIndexOrder);
     void ScModalValue();
     void ScModalValue_MS( bool bSingle );
     void ScAveDev();
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 9f9f07186d50..f17e72ae0287 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -4125,7 +4125,7 @@ void ScInterpreter::GetNumberSequenceArray( sal_uInt8 
nParamCount, vector<double
         PopError();
 }
 
-void ScInterpreter::GetSortArray( sal_uInt8 nParamCount, vector<double>& 
rSortArray, vector<long>* pIndexOrder, bool bConvertTextInArray, bool 
bAllowEmptyArray )
+void ScInterpreter::GetSortArray( sal_uInt8 nParamCount, vector<double>& 
rSortArray, vector<tools::Long>* pIndexOrder, bool bConvertTextInArray, bool 
bAllowEmptyArray )
 {
     GetNumberSequenceArray( nParamCount, rSortArray, bConvertTextInArray );
     if (rSortArray.size() > MAX_COUNT_DOUBLE_FOR_SORT(mrDoc.GetSheetLimits()))
@@ -4141,7 +4141,7 @@ void ScInterpreter::GetSortArray( sal_uInt8 nParamCount, 
vector<double>& rSortAr
         QuickSort( rSortArray, pIndexOrder);
 }
 
-static void lcl_QuickSort( tools::Long nLo, tools::Long nHi, vector<double>& 
rSortArray, vector<long>* pIndexOrder )
+static void lcl_QuickSort( tools::Long nLo, tools::Long nHi, vector<double>& 
rSortArray, vector<tools::Long>* pIndexOrder )
 {
     // If pIndexOrder is not NULL, we assume rSortArray.size() == 
pIndexOrder->size().
 
@@ -4192,7 +4192,7 @@ static void lcl_QuickSort( tools::Long nLo, tools::Long 
nHi, vector<double>& rSo
     }
 }
 
-void ScInterpreter::QuickSort( vector<double>& rSortArray, vector<long>* 
pIndexOrder )
+void ScInterpreter::QuickSort( vector<double>& rSortArray, 
vector<tools::Long>* pIndexOrder )
 {
     tools::Long n = static_cast<tools::Long>(rSortArray.size());
 
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 6de3e2d2150b..3930de33ba2e 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1867,7 +1867,7 @@ void ScInterpreter::ScFrequency()
         return;
 
     vector<double>  aBinArray;
-    vector<long>    aBinIndexOrder;
+    vector<tools::Long>    aBinIndexOrder;
 
     GetSortArray( 1, aBinArray, &aBinIndexOrder, false, false );
     SCSIZE nBinSize = aBinArray.size();
diff --git a/sc/source/filter/excel/xepivotxml.cxx 
b/sc/source/filter/excel/xepivotxml.cxx
index b69e4b340735..98e983459144 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -769,9 +769,9 @@ void XclExpXmlPivotTables::SavePivotTableXml( 
XclExpXmlStream& rStrm, const ScDP
         aCachedDims.push_back(pDim);
     }
 
-    std::vector<long> aRowFields;
-    std::vector<long> aColFields;
-    std::vector<long> aPageFields;
+    std::vector<tools::Long> aRowFields;
+    std::vector<tools::Long> aColFields;
+    std::vector<tools::Long> aPageFields;
     std::vector<DataField> aDataFields;
 
     tools::Long nDataDimCount = rSaveData.GetDataDimensionCount();
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 9afb24ebc84c..b4a7faf5cc18 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -222,7 +222,7 @@ bool ScDocShell::IsDocument( const INetURLObject& rURL )
 
 #if HAVE_FEATURE_DBCONNECTIVITY
 
-static void lcl_setScalesToColumns(ScDocument& rDoc, const vector<long>& 
rScales)
+static void lcl_setScalesToColumns(ScDocument& rDoc, const 
vector<tools::Long>& rScales)
 {
     SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
     if (!pFormatter)
@@ -343,7 +343,7 @@ ErrCode ScDocShell::DBaseImport( const OUString& 
rFullFileName, rtl_TextEncoding
 
         aProgress.SetState( 0 );
 
-        vector<long> aScales(nColCount, -1);
+        vector<tools::Long> aScales(nColCount, -1);
         for (i=0; i<nColCount; i++)
         {
             OUString aHeader = xMeta->getColumnLabel( i+1 );
diff --git a/sc/source/ui/inc/pfuncache.hxx b/sc/source/ui/inc/pfuncache.hxx
index 888c60c0fd4c..7ae640834dda 100644
--- a/sc/source/ui/inc/pfuncache.hxx
+++ b/sc/source/ui/inc/pfuncache.hxx
@@ -87,8 +87,8 @@ class ScPrintFuncCache
     ScPrintSelectionStatus  aSelection;
     ScDocShell*             pDocSh;
     tools::Long                    nTotalPages;
-    std::vector<long>       nPages;
-    std::vector<long>       nFirstAttr;
+    std::vector<tools::Long>       nPages;
+    std::vector<tools::Long>       nFirstAttr;
     std::vector<ScPrintPageLocation> aLocations;
     bool                    bLocInitialized;
 
diff --git a/sc/source/ui/inc/preview.hxx b/sc/source/ui/inc/preview.hxx
index ecb6a9646106..3f06121f31f1 100644
--- a/sc/source/ui/inc/preview.hxx
+++ b/sc/source/ui/inc/preview.hxx
@@ -41,8 +41,8 @@ private:
                                         // calculated:
     SCTAB           nTabCount;
     SCTAB           nTabsTested;        // for how many sheets is nPages valid?
-    std::vector<long>       nPages;
-    std::vector<long>       nFirstAttr;
+    std::vector<tools::Long>       nPages;
+    std::vector<tools::Long>       nFirstAttr;
     SCTAB           nTab;               // Sheet
     tools::Long            nTabPage;           // Page of sheet
     tools::Long            nTabStart;          // First (real) page of the 
sheet
@@ -80,7 +80,7 @@ private:
     bool            mbHasEmptyRangeTable:1; /// we have at least one sheet 
with empty print range (print range set to '- none -').
 
     ScRange         aPageArea;
-    std::vector<long> mvRight;
+    std::vector<tools::Long> mvRight;
     tools::Long            nLeftPosition;
     tools::Long            mnScale;
     SCCOL           nColNumberButtonDown;
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 4a9c035d16a2..4205db5c8fae 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -905,7 +905,7 @@ void drawIconSets(vcl::RenderContext& rRenderContext, const 
ScIconSetInfo* pOldI
     ScIconSetType eType = pOldIconSetInfo->eIconSetType;
     sal_Int32 nIndex = pOldIconSetInfo->nIconIndex;
     const BitmapEx& rIcon = getIcon(rIconSetBitmapMap, eType, nIndex);
-    tools::Long aOrigSize = 
std::max<long>(0,std::min(rRect.GetSize().getWidth() - 4 * nOneX, 
rRect.GetSize().getHeight() -4 * nOneY));
+    tools::Long aOrigSize = 
std::max<tools::Long>(0,std::min(rRect.GetSize().getWidth() - 4 * nOneX, 
rRect.GetSize().getHeight() -4 * nOneY));
     rRenderContext.DrawBitmapEx( Point( rRect.Left() + 2 * nOneX, rRect.Top() 
+ 2 * nOneY), Size(aOrigSize, aOrigSize), rIcon );
 }
 
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 564221da4ade..367d0dca1f5a 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1488,7 +1488,7 @@ tools::Rectangle ScOutputData::LayoutStrings(bool 
bPixelToLogic, bool bPaint, co
     // before processing the cell value.
     std::vector<std::unique_ptr<ScPatternAttr> > aAltPatterns;
 
-    std::vector<long> aDX;
+    std::vector<tools::Long> aDX;
     tools::Long nPosY = nScrY;
     for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++)
     {
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index d2d19f3ff720..2ad68508b2e6 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -67,7 +67,7 @@
 
 #define SC_PREVIEW_SHADOWSIZE   2
 
-static tools::Long lcl_GetDisplayStart( SCTAB nTab, const ScDocument* pDoc, 
std::vector<long>& nPages )
+static tools::Long lcl_GetDisplayStart( SCTAB nTab, const ScDocument* pDoc, 
std::vector<tools::Long>& nPages )
 {
     tools::Long nDisplayStart = 0;
     for (SCTAB i=0; i<nTab; i++)
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index b0856d33343a..bcf2831995c0 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2361,7 +2361,7 @@ void lcl_getGroupIndexes(const ScOutlineArray& rArray, 
SCCOLROW nStart, SCCOLROW
 void lcl_createGroupsData(
         SCCOLROW nHeaderIndex, SCCOLROW nEnd, tools::Long nSizePx, tools::Long 
nTotalPx,
         const ScOutlineArray& rArray, std::vector<size_t>& rGroupIndexes,
-        std::vector<long>& rGroupStartPositions, OStringBuffer& rGroupsBuffer)
+        std::vector<tools::Long>& rGroupStartPositions, OStringBuffer& 
rGroupsBuffer)
 {
     const size_t nGroupDepth = rArray.GetDepth();
     // create string data for group controls
@@ -2683,7 +2683,7 @@ void ScTabView::getRowColumnHeaders(const 
tools::Rectangle& rRectangle, tools::J
             rJsonWriter.put("groupLevels", 
static_cast<sal_Int64>(nRowGroupDepth));
         }
 
-        std::vector<long> aRowGroupStartPositions(nRowGroupDepth, 
-nTotalPixels);
+        std::vector<tools::Long> aRowGroupStartPositions(nRowGroupDepth, 
-nTotalPixels);
         for (SCROW nRow = nStartRow + 1; nRow <= nEndRow; ++nRow)
         {
             // nSize will be 0 for hidden rows.
@@ -2776,7 +2776,7 @@ void ScTabView::getRowColumnHeaders(const 
tools::Rectangle& rRectangle, tools::J
             rJsonWriter.put("groupLevels", 
static_cast<sal_Int64>(nColGroupDepth));
         }
 
-        std::vector<long> aColGroupStartPositions(nColGroupDepth, 
-nTotalPixels);
+        std::vector<tools::Long> aColGroupStartPositions(nColGroupDepth, 
-nTotalPixels);
         nPrevSizePx = -1;
         for (SCCOL nCol = nStartCol + 1; nCol <= nEndCol; ++nCol)
         {
diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx
index 22f2eaf81d55..996265c3c9ea 100644
--- a/sd/source/ui/view/drtxtob1.cxx
+++ b/sd/source/ui/view/drtxtob1.cxx
@@ -196,7 +196,7 @@ void TextObjectBar::Execute( SfxRequest &rReq )
                         else
                         {
                             nLeft -= 1000;
-                            nLeft = std::max<long>( nLeft, 0 );
+                            nLeft = std::max<::tools::Long>( nLeft, 0 );
                         }
                         pNewItem->SetLeftValue( static_cast<sal_uInt16>(nLeft) 
);
 
@@ -253,7 +253,7 @@ void TextObjectBar::Execute( SfxRequest &rReq )
                         else
                         {
                             nUpper -= 100;
-                            nUpper = std::max<long>( nUpper, 0 );
+                            nUpper = std::max<::tools::Long>( nUpper, 0 );
                         }
                         pNewItem->SetUpper( static_cast<sal_uInt16>(nUpper) );
 
@@ -263,7 +263,7 @@ void TextObjectBar::Execute( SfxRequest &rReq )
                         else
                         {
                             nLower -= 100;
-                            nLower = std::max<long>( nLower, 0 );
+                            nLower = std::max<::tools::Long>( nLower, 0 );
                         }
                         pNewItem->SetLower( static_cast<sal_uInt16>(nLower) );
 
@@ -296,7 +296,7 @@ void TextObjectBar::Execute( SfxRequest &rReq )
                     else
                     {
                         nUpper -= 100;
-                        nUpper = std::max<long>( nUpper, 0 );
+                        nUpper = std::max<::tools::Long>( nUpper, 0 );
                     }
                     pNewItem->SetUpper( static_cast<sal_uInt16>(nUpper) );
 
@@ -306,7 +306,7 @@ void TextObjectBar::Execute( SfxRequest &rReq )
                     else
                     {
                         nLower -= 100;
-                        nLower = std::max<long>( nLower, 0 );
+                        nLower = std::max<::tools::Long>( nLower, 0 );
                     }
                     pNewItem->SetLower( static_cast<sal_uInt16>(nLower) );
 
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 33ed1a0ff2d6..bde926aef869 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -1179,7 +1179,7 @@ void DrawViewShell::FuSupport(SfxRequest& rReq)
         case SID_ZOOM_IN:  // BASIC
         {
             mbZoomOnPage = false;
-            SetZoom( std::max<long>( GetActiveWindow()->GetZoom() / 2, 
GetActiveWindow()->GetMinZoom() ) );
+            SetZoom( std::max<::tools::Long>( GetActiveWindow()->GetZoom() / 
2, GetActiveWindow()->GetMinZoom() ) );
             ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( 
::tools::Rectangle( Point(0,0),
                                               
GetActiveWindow()->GetOutputSizePixel()) );
             mpZoomList->InsertZoomRect(aVisAreaWin);
@@ -1193,7 +1193,7 @@ void DrawViewShell::FuSupport(SfxRequest& rReq)
         case SID_ZOOM_OUT:
         {
             mbZoomOnPage = false;
-            SetZoom( std::min<long>( GetActiveWindow()->GetZoom() * 2, 
GetActiveWindow()->GetMaxZoom() ) );
+            SetZoom( std::min<::tools::Long>( GetActiveWindow()->GetZoom() * 
2, GetActiveWindow()->GetMaxZoom() ) );
             ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( 
::tools::Rectangle( Point(0,0),
                                               
GetActiveWindow()->GetOutputSizePixel()) );
             mpZoomList->InsertZoomRect(aVisAreaWin);
diff --git a/sd/source/ui/view/outlnvs2.cxx b/sd/source/ui/view/outlnvs2.cxx
index 72626b9654ed..4acabdf2dbf7 100644
--- a/sd/source/ui/view/outlnvs2.cxx
+++ b/sd/source/ui/view/outlnvs2.cxx
@@ -127,7 +127,7 @@ void OutlineViewShell::FuTemporary(SfxRequest &rReq)
 
         case SID_ZOOM_OUT:
         {
-            SetZoom( std::min<long>( GetActiveWindow()->GetZoom() * 2, 
GetActiveWindow()->GetMaxZoom() ) );
+            SetZoom( std::min<::tools::Long>( GetActiveWindow()->GetZoom() * 
2, GetActiveWindow()->GetMaxZoom() ) );
             ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( 
::tools::Rectangle( Point(0,0),
                                              
GetActiveWindow()->GetOutputSizePixel()) );
             mpZoomList->InsertZoomRect(aVisAreaWin);
@@ -154,7 +154,7 @@ void OutlineViewShell::FuTemporary(SfxRequest &rReq)
 
         case SID_ZOOM_IN:
         {
-            SetZoom( std::max<long>( GetActiveWindow()->GetZoom() / 2, 
GetActiveWindow()->GetMinZoom() ) );
+            SetZoom( std::max<::tools::Long>( GetActiveWindow()->GetZoom() / 
2, GetActiveWindow()->GetMinZoom() ) );
             ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( 
::tools::Rectangle( Point(0,0),
                                              
GetActiveWindow()->GetOutputSizePixel()) );
             mpZoomList->InsertZoomRect(aVisAreaWin);
diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
index 691e5f8a0963..f97c26ea5ece 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -721,9 +721,9 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& 
rCEvt, ::sd::Window* pWi
                         Point aOldMousePos = 
GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel());
 
                         if( pData->GetDelta() < 0 )
-                            nNewZoom = std::max<long>( pWin->GetMinZoom(), 
basegfx::zoomtools::zoomOut( nOldZoom ));
+                            nNewZoom = std::max<::tools::Long>( 
pWin->GetMinZoom(), basegfx::zoomtools::zoomOut( nOldZoom ));
                         else
-                            nNewZoom = std::min<long>( pWin->GetMaxZoom(), 
basegfx::zoomtools::zoomIn( nOldZoom ));
+                            nNewZoom = std::min<::tools::Long>( 
pWin->GetMaxZoom(), basegfx::zoomtools::zoomIn( nOldZoom ));
 
                         SetZoom( nNewZoom );
                         // Keep mouse at same doc point before zoom
diff --git a/sfx2/source/sidebar/PanelLayout.cxx 
b/sfx2/source/sidebar/PanelLayout.cxx
index 5508d1a5e70d..c419403bdf79 100644
--- a/sfx2/source/sidebar/PanelLayout.cxx
+++ b/sfx2/source/sidebar/PanelLayout.cxx
@@ -58,7 +58,7 @@ Size PanelLayout::GetOptimalSize() const
         SidebarController* pController
             = SidebarController::GetSidebarControllerForFrame(mxFrame);
         if (pController)
-            aSize.setWidth(std::min<long>(
+            aSize.setWidth(std::min<tools::Long>(
                 aSize.Width(), (pController->getMaximumWidth() - 
TabBar::GetDefaultWidth())
                                    * GetDPIScaleFactor()));
     }
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index cf9616ad9980..87bf6a6c41be 100644
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -1088,8 +1088,8 @@ void SmShowSymbolSet::calccols(const vcl::RenderContext& 
rRenderContext)
 
     nColumns = aOutputSize.Width() / nLen;
     nRows = aOutputSize.Height() / nLen;
-    nColumns = std::max<long>(1, nColumns);
-    nRows = std::max<long>(1, nRows);
+    nColumns = std::max<tools::Long>(1, nColumns);
+    nRows = std::max<tools::Long>(1, nRows);
 
     nXOffset = (aOutputSize.Width() - (nColumns * nLen)) / 2;
     nYOffset = (aOutputSize.Height() - (nRows * nLen)) / 2;
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 59cef03975bf..c8f82355468e 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -283,7 +283,7 @@ void SmEditWindow::Resize()
         if (pEditView->GetVisArea().Top() > nMaxVisAreaStart)
         {
             tools::Rectangle aVisArea(pEditView->GetVisArea() );
-            aVisArea.SetTop( std::max<long>(nMaxVisAreaStart, 0) );
+            aVisArea.SetTop( std::max<tools::Long>(nMaxVisAreaStart, 0) );
             aVisArea.SetSize(pEditView->GetOutputArea().GetSize());
             pEditView->SetVisArea(aVisArea);
             pEditView->ShowCursor();
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 1604655c08c1..e252b83ee308 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -1921,7 +1921,7 @@ void SmMatrixNode::Arrange(OutputDevice &rDev, const 
SmFormat &rFormat)
 
     // initialize array that is to hold the maximum widths of all
     // elements (subnodes) in that column.
-    std::vector<long> aColWidth(mnNumCols);
+    std::vector<tools::Long> aColWidth(mnNumCols);
 
     // arrange subnodes and calculate the above arrays contents
     size_t nNodes = GetNumSubNodes();
@@ -1945,7 +1945,7 @@ void SmMatrixNode::Arrange(OutputDevice &rDev, const 
SmFormat &rFormat)
           nVerDist = nNormDist * rFormat.GetDistance(DIS_MATRIXROW) / 100;
 
     // build array that holds the leftmost position for each column
-    std::vector<long> aColLeft(mnNumCols);
+    std::vector<tools::Long> aColLeft(mnNumCols);
     tools::Long  nX = 0;
     for (size_t j = 0; j < mnNumCols; ++j)
     {
diff --git a/svtools/source/brwbox/brwbox1.cxx 
b/svtools/source/brwbox/brwbox1.cxx
index 5eac20c1514e..4737698d145c 100644
--- a/svtools/source/brwbox/brwbox1.cxx
+++ b/svtools/source/brwbox/brwbox1.cxx
@@ -1004,7 +1004,7 @@ tools::Long BrowseBox::ScrollRows( tools::Long nRows )
     // compute new top row
     tools::Long nTmpMin = std::min( static_cast<tools::Long>(nTopRow + nRows), 
static_cast<tools::Long>(nRowCount - 1) );
 
-    tools::Long nNewTopRow = std::max<long>( nTmpMin, 0 );
+    tools::Long nNewTopRow = std::max<tools::Long>( nTmpMin, 0 );
 
     if ( nNewTopRow == nTopRow )
         return 0;
@@ -1017,7 +1017,7 @@ tools::Long BrowseBox::ScrollRows( tools::Long nRows )
     // compute new top row again (nTopRow might have changed!)
     nTmpMin = std::min( static_cast<tools::Long>(nTopRow + nRows), 
static_cast<tools::Long>(nRowCount - 1) );
 
-    nNewTopRow = std::max<long>( nTmpMin, 0 );
+    nNewTopRow = std::max<tools::Long>( nTmpMin, 0 );
 
     StartScroll();
 
@@ -1659,7 +1659,7 @@ void BrowseBox::SelectAll()
         tools::Rectangle aHighlightRect;
         sal_uInt16 nVisibleRows =
             static_cast<sal_uInt16>(pDataWin->GetOutputSizePixel().Height() / 
GetDataRowHeight() + 1);
-        for ( tools::Long nRow = std::max<long>( nTopRow, 
uRow.pSel->FirstSelected() );
+        for ( tools::Long nRow = std::max<tools::Long>( nTopRow, 
uRow.pSel->FirstSelected() );
               nRow != BROWSER_ENDOFSELECTION && nRow < nTopRow + nVisibleRows;
               nRow = uRow.pSel->NextSelected() )
             aHighlightRect.Union( tools::Rectangle(
diff --git a/svtools/source/control/ctrlbox.cxx 
b/svtools/source/control/ctrlbox.cxx
index 180fe6a9661b..cc7f1c699069 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -91,7 +91,7 @@ tools::Long BorderWidthImpl::GetLine1( tools::Long nWidth ) 
const
     {
         tools::Long const nConstant2 = (m_nFlags & 
BorderWidthImplFlags::CHANGE_LINE2) ? 0 : m_nRate2;
         tools::Long const nConstantD = (m_nFlags & 
BorderWidthImplFlags::CHANGE_DIST ) ? 0 : m_nRateGap;
-        result = std::max<long>(0,
+        result = std::max<tools::Long>(0,
                     static_cast<tools::Long>((m_nRate1 * nWidth) + 0.5)
                         - (nConstant2 + nConstantD));
         if (result == 0 && m_nRate1 > 0.0 && nWidth > 0)
@@ -109,7 +109,7 @@ tools::Long BorderWidthImpl::GetLine2( tools::Long nWidth ) 
const
     {
         tools::Long const nConstant1 = (m_nFlags & 
BorderWidthImplFlags::CHANGE_LINE1) ? 0 : m_nRate1;
         tools::Long const nConstantD = (m_nFlags & 
BorderWidthImplFlags::CHANGE_DIST ) ? 0 : m_nRateGap;
-        result = std::max<long>(0,
+        result = std::max<tools::Long>(0,
                     static_cast<tools::Long>((m_nRate2 * nWidth) + 0.5)
                         - (nConstant1 + nConstantD));
     }
@@ -123,7 +123,7 @@ tools::Long BorderWidthImpl::GetGap( tools::Long nWidth ) 
const
     {
         tools::Long const nConstant1 = (m_nFlags & 
BorderWidthImplFlags::CHANGE_LINE1) ? 0 : m_nRate1;
         tools::Long const nConstant2 = (m_nFlags & 
BorderWidthImplFlags::CHANGE_LINE2) ? 0 : m_nRate2;
-        result = std::max<long>(0,
+        result = std::max<tools::Long>(0,
                     static_cast<tools::Long>((m_nRateGap * nWidth) + 0.5)
                         - (nConstant1 + nConstant2));
     }
diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx
index 4d86e4974f51..edf8b7881297 100644
--- a/svx/source/dialog/fntctrl.cxx
+++ b/svx/source/dialog/fntctrl.cxx
@@ -144,7 +144,7 @@ class FontPrevWin_Impl
     bool mbDelPrinter;
 
     Reference <XBreakIterator> mxBreak;
-    std::vector<long> maTextWidth;
+    std::vector<tools::Long> maTextWidth;
     std::deque<sal_Int32> maScriptChg;
     std::vector<sal_uInt16> maScriptType;
     SvxFont maCJKFont;
diff --git a/svx/source/dialog/framelinkarray.cxx 
b/svx/source/dialog/framelinkarray.cxx
index bf89b58dfba9..c54fc5167120 100644
--- a/svx/source/dialog/framelinkarray.cxx
+++ b/svx/source/dialog/framelinkarray.cxx
@@ -152,7 +152,7 @@ void Cell::MirrorSelfX()
 }
 
 
-static void lclRecalcCoordVec( std::vector<long>& rCoords, const 
std::vector<long>& rSizes )
+static void lclRecalcCoordVec( std::vector<tools::Long>& rCoords, const 
std::vector<tools::Long>& rSizes )
 {
     DBG_ASSERT( rCoords.size() == rSizes.size() + 1, "lclRecalcCoordVec - 
inconsistent vectors" );
     auto aCIt = rCoords.begin();
@@ -185,10 +185,10 @@ const Cell OBJ_CELL_NONE;
 struct ArrayImpl
 {
     CellVec             maCells;
-    std::vector<long>   maWidths;
-    std::vector<long>   maHeights;
-    mutable std::vector<long>     maXCoords;
-    mutable std::vector<long>     maYCoords;
+    std::vector<tools::Long>   maWidths;
+    std::vector<tools::Long>   maHeights;
+    mutable std::vector<tools::Long>     maXCoords;
+    mutable std::vector<tools::Long>     maYCoords;
     size_t              mnWidth;
     size_t              mnHeight;
     size_t              mnFirstClipCol;
diff --git a/svx/source/dialog/rulritem.cxx b/svx/source/dialog/rulritem.cxx
index 7943283364e8..c9973fdd7462 100644
--- a/svx/source/dialog/rulritem.cxx
+++ b/svx/source/dialog/rulritem.cxx
@@ -584,8 +584,8 @@ SvxColumnDescription::SvxColumnDescription(tools::Long 
start, tools::Long end, t
     nEnd     (end),
     bVisible (bVis),
     // fdo#85858 hack: clamp these to smaller value to prevent overflow
-    nEndMin(std::min<long>(endMin, std::numeric_limits<unsigned 
short>::max())),
-    nEndMax(std::min<long>(endMax, std::numeric_limits<unsigned short>::max()))
+    nEndMin(std::min<tools::Long>(endMin, std::numeric_limits<unsigned 
short>::max())),
+    nEndMax(std::min<tools::Long>(endMax, std::numeric_limits<unsigned 
short>::max()))
 {}
 
 bool SvxColumnDescription::operator==(const SvxColumnDescription& rCmp) const
diff --git a/svx/source/inc/fmshimp.hxx b/svx/source/inc/fmshimp.hxx
index 0c30e1b8819d..affa74dfcaf9 100644
--- a/svx/source/inc/fmshimp.hxx
+++ b/svx/source/inc/fmshimp.hxx
@@ -178,7 +178,7 @@ class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) FmXFormShell 
final : public FmXFormShe
         // since I want to mark an SdrObject when searching for the treatment 
of the "found",
         // I get all relevant objects before yanking up of the search dialog
         // (the array is thus only valid during the search process)
-    std::vector<long> m_arrRelativeGridColumn;
+    std::vector<tools::Long> m_arrRelativeGridColumn;
 
     ::osl::Mutex    m_aMutex;
     ImplSVEvent *   m_nInvalidationEvent;
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 8919c5d1c7dd..b7450c83a44d 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -492,7 +492,7 @@ void SdrTextObj::AdaptTextMinSize()
     {
         // Set minimum width.
         const tools::Long nDist = GetTextLeftDistance() + 
GetTextRightDistance();
-        const tools::Long nW = std::max<long>(0, maRect.GetWidth() - 1 - 
nDist); // text width without margins
+        const tools::Long nW = std::max<tools::Long>(0, maRect.GetWidth() - 1 
- nDist); // text width without margins
 
         aSet.Put(makeSdrTextMinFrameWidthItem(nW));
 
@@ -507,7 +507,7 @@ void SdrTextObj::AdaptTextMinSize()
     {
         // Set Minimum height.
         const tools::Long nDist = GetTextUpperDistance() + 
GetTextLowerDistance();
-        const tools::Long nH = std::max<long>(0, maRect.GetHeight() - 1 - 
nDist); // text height without margins
+        const tools::Long nH = std::max<tools::Long>(0, maRect.GetHeight() - 1 
- nDist); // text height without margins
 
         aSet.Put(makeSdrTextMinFrameHeightItem(nH));
 
diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index 8fbded6e61f1..35bacea29950 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -158,7 +158,7 @@ class SW_DLLPUBLIC SwRangeRedline : public SwPaM
     bool m_bIsVisible : 1;
     sal_uInt32 m_nId;
 
-    std::optional<long> m_oLOKLastNodeTop;
+    std::optional<tools::Long> m_oLOKLastNodeTop;
 
     void MoveToSection();
     void CopyToSection();
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 95891b40d7b1..4b6e9c22bd62 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -851,10 +851,14 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025)
     CPPUNIT_ASSERT(pFrameFormat);
 
     // The shape has these values to copy to the associated text frame after 
modification::
-    const tools::Long nLPaddng = 
xShapeProps->getPropertyValue("TextLeftDistance").get<long>();
-    const tools::Long nRPaddng = 
xShapeProps->getPropertyValue("TextRightDistance").get<long>();
-    const tools::Long nTPaddng = 
xShapeProps->getPropertyValue("TextUpperDistance").get<long>();
-    const tools::Long nBPaddng = 
xShapeProps->getPropertyValue("TextLowerDistance").get<long>();
+    const tools::Long nLPaddng
+        = xShapeProps->getPropertyValue("TextLeftDistance").get<tools::Long>();
+    const tools::Long nRPaddng
+        = 
xShapeProps->getPropertyValue("TextRightDistance").get<tools::Long>();
+    const tools::Long nTPaddng
+        = 
xShapeProps->getPropertyValue("TextUpperDistance").get<tools::Long>();
+    const tools::Long nBPaddng
+        = 
xShapeProps->getPropertyValue("TextLowerDistance").get<tools::Long>();
 
     CPPUNIT_ASSERT_EQUAL(tools::Long(1000), nLPaddng);
     CPPUNIT_ASSERT_EQUAL(tools::Long(2000), nRPaddng);
@@ -868,13 +872,13 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025)
     uno::Reference<beans::XPropertySet> xFrameProps(xTxFrm, uno::UNO_QUERY);
 
     const tools::Long nFrameLeftPaddng
-        = xFrameProps->getPropertyValue("LeftBorderDistance").get<long>();
+        = 
xFrameProps->getPropertyValue("LeftBorderDistance").get<tools::Long>();
     const tools::Long nFrameRightPaddng
-        = xFrameProps->getPropertyValue("RightBorderDistance").get<long>();
+        = 
xFrameProps->getPropertyValue("RightBorderDistance").get<tools::Long>();
     const tools::Long nFrameTopPaddng
-        = xFrameProps->getPropertyValue("TopBorderDistance").get<long>();
+        = 
xFrameProps->getPropertyValue("TopBorderDistance").get<tools::Long>();
     const tools::Long nFrameBottomPaddng
-        = xFrameProps->getPropertyValue("BottomBorderDistance").get<long>();
+        = 
xFrameProps->getPropertyValue("BottomBorderDistance").get<tools::Long>();
 
     // Check if the shape and frame have different setting
     CPPUNIT_ASSERT_EQUAL(nLPaddng, nFrameLeftPaddng);
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx 
b/sw/qa/extras/ww8export/ww8export2.cxx
index bded9504b579..004451247cdf 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -343,8 +343,8 @@ DECLARE_WW8EXPORT_TEST(testTdf112074_RTLtableJustification, 
"tdf112074_RTLtableJ
 
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Right To Left writing mode", 
text::WritingMode2::RL_TB, getProperty<sal_Int16>(xTable, "WritingMode"));
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Horizontal Orientation", 
text::HoriOrientation::LEFT_AND_WIDTH, getProperty<sal_Int16>(xTable, 
"HoriOrient"));
-    CPPUNIT_ASSERT_MESSAGE("Table Indent", getProperty<long>(xTable, 
"LeftMargin") > 3000);
-    CPPUNIT_ASSERT_MESSAGE("Table Indent is 3750", getProperty<long>(xTable, 
"LeftMargin") < 4000 );
+    CPPUNIT_ASSERT_MESSAGE("Table Indent", getProperty<tools::Long>(xTable, 
"LeftMargin") > 3000);
+    CPPUNIT_ASSERT_MESSAGE("Table Indent is 3750", 
getProperty<tools::Long>(xTable, "LeftMargin") < 4000 );
     CPPUNIT_ASSERT_EQUAL( style::ParagraphAdjust_RIGHT, 
static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraphOrTable(2),
 "ParaAdjust")) );
 }
 
diff --git a/sw/source/core/doc/DocumentStatisticsManager.cxx 
b/sw/source/core/doc/DocumentStatisticsManager.cxx
index 91ca7aa498e9..dd67d88ea89e 100644
--- a/sw/source/core/doc/DocumentStatisticsManager.cxx
+++ b/sw/source/core/doc/DocumentStatisticsManager.cxx
@@ -93,7 +93,7 @@ void DocumentStatisticsManager::UpdateDocStat( bool 
bCompleteAsync, bool bFields
     {
         maStatsUpdateIdle.Stop();
         while (IncrementalDocStatCalculate(
-                    std::numeric_limits<long>::max(), bFields)) {}
+                    std::numeric_limits<tools::Long>::max(), bFields)) {}
     }
     else if (IncrementalDocStatCalculate(5000, bFields))
         maStatsUpdateIdle.Start();
diff --git a/sw/source/core/layout/dbg_lay.cxx 
b/sw/source/core/layout/dbg_lay.cxx
index 7816ed9c3c0e..97a514b8c79d 100644
--- a/sw/source/core/layout/dbg_lay.cxx
+++ b/sw/source/core/layout/dbg_lay.cxx
@@ -130,7 +130,7 @@ class SwImplProtocol
     std::unique_ptr<SvFileStream> m_pStream; // output stream
     std::unique_ptr<std::set<sal_uInt16>>
         m_pFrameIds; // which FrameIds shall be logged ( NULL == all)
-    std::vector<long> m_aVars; // variables
+    std::vector<tools::Long> m_aVars; // variables
     OStringBuffer m_aLayer; // indentation of output ("  " per start/end)
     SwFrameType m_nTypes; // which types shall be logged
     sal_uInt16 m_nLineCount; // printed lines
diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx
index 397de1daf5fb..8a62abd8aa54 100644
--- a/sw/source/core/layout/newfrm.cxx
+++ b/sw/source/core/layout/newfrm.cxx
@@ -106,7 +106,7 @@ static SwRectFnCollection aHorizontal = {
     /*.fnXDiff =*/&FirstMinusSecond,
     /*.fnYDiff =*/&FirstMinusSecond,
     /*.fnXInc =*/&SwIncrement,
-    /*.fnYInc =*/&o3tl::saturating_add<long>,
+    /*.fnYInc =*/&o3tl::saturating_add<tools::Long>,
 
     /*.fnSetLeftAndWidth =*/&SwRect::SetLeftAndWidth,
     /*.fnSetTopAndHeight =*/&SwRect::SetTopAndHeight
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 052b51b1b42d..b3c36051b661 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -3172,7 +3172,7 @@ SwTwips SwTabFrame::GrowFrame( SwTwips nDist, bool bTst, 
bool bInfo )
 
         if ( nReal < nDist )
         {
-            tools::Long nTmp = GetUpper()->Grow( nDist - std::max<long>(nReal, 
0), bTst, bInfo );
+            tools::Long nTmp = GetUpper()->Grow( nDist - 
std::max<tools::Long>(nReal, 0), bTst, bInfo );
 
             if ( IsRestrictTableGrowth() )
             {
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 3927f405048c..ae422dc2ea46 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -2150,7 +2150,7 @@ SwTwips SwContentFrame::GrowFrame( SwTwips nDist, bool 
bTst, bool bInfo )
         if( GetUpper() )
         {
             if( bTst || !GetUpper()->IsFooterFrame() )
-                nReal = GetUpper()->Grow( nDist - std::max<long>(nReal, 0),
+                nReal = GetUpper()->Grow( nDist - std::max<tools::Long>(nReal, 
0),
                                           bTst, bInfo );
             else
             {
diff --git a/sw/source/core/table/swnewtable.cxx 
b/sw/source/core/table/swnewtable.cxx
index c0e4cbf9bae2..fdafc10df49c 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -2256,7 +2256,7 @@ void SwTable::ConvertSubtableBox(sal_uInt16 const nRow, 
sal_uInt16 const nBox)
                 else
                 {
                     newSourceRowSpan += pSubTableBox->GetTabLines().size() - 1;
-                    newBoxRowSpan = -(newSourceRowSpan - 
sal::static_int_cast<long>(i));
+                    newBoxRowSpan = -(newSourceRowSpan - 
sal::static_int_cast<tools::Long>(i));
                 }
                 pNewLine->GetTabBoxes()[nInsPos]->setRowSpan(newBoxRowSpan);
                 if (i == pSubTableBox->GetTabLines().size() - 1)
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index c78c9ffdea89..4dda8e1d85fa 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -392,7 +392,7 @@ static void lcl_SortedTabColInsert( SwTabCols &rToFill, 
const SwTableBox *pBox,
             {
                 const SwTwips nWidth = 
rBoxes[i]->GetFrameFormat()->GetFrameSize().GetWidth();
                 nSum += nWidth;
-                const tools::Long nTmp = lcl_MulDiv64<long>(nSum, nAct, nWish);
+                const tools::Long nTmp = lcl_MulDiv64<tools::Long>(nSum, nAct, 
nWish);
 
                 if (rBoxes[i] != pCur)
                 {
@@ -648,7 +648,7 @@ static void lcl_ProcessBoxSet( SwTableBox *pBox, Parm 
&rParm )
             const SwTableBoxes &rBoxes = pLine->GetTabBoxes();
             for ( size_t i = 0; (i < rBoxes.size()) && (rBoxes[i] != pCur); 
++i)
             {
-                nLeft += lcl_MulDiv64<long>(
+                nLeft += lcl_MulDiv64<tools::Long>(
                     rBoxes[i]->GetFrameFormat()->GetFrameSize().GetWidth(),
                     nOldAct, rParm.nOldWish);
             }
@@ -660,7 +660,7 @@ static void lcl_ProcessBoxSet( SwTableBox *pBox, Parm 
&rParm )
         if ( nLeft != rParm.rOld.GetLeft() ) // There are still boxes before 
this.
         {
             // Right edge is left edge plus width.
-            const tools::Long nWidth = lcl_MulDiv64<long>(
+            const tools::Long nWidth = lcl_MulDiv64<tools::Long>(
                 pBox->GetFrameFormat()->GetFrameSize().GetWidth(),
                 nOldAct, rParm.nOldWish);
             const tools::Long nRight = nLeft + nWidth;
@@ -694,7 +694,7 @@ static void lcl_ProcessBoxSet( SwTableBox *pBox, Parm 
&rParm )
             if ( rParm.rOld.Count() )
             {
                 // Calculate the difference to the edge touching the first box.
-                const tools::Long nWidth = lcl_MulDiv64<long>(
+                const tools::Long nWidth = lcl_MulDiv64<tools::Long>(
                     pBox->GetFrameFormat()->GetFrameSize().GetWidth(),
                     nOldAct, rParm.nOldWish);
                 const tools::Long nTmp = nWidth + rParm.rOld.GetLeft();
@@ -1172,8 +1172,8 @@ void SwTable::NewSetTabCols( Parm &rParm, const SwTabCols 
&rNew,
             nOldPos = rOld[i] - rParm.rOld.GetLeft();
             nNewPos = rNew[i] - rParm.rNew.GetLeft();
         }
-        nNewPos = lcl_MulDiv64<long>(nNewPos, rParm.nNewWish, nNewWidth);
-        nOldPos = lcl_MulDiv64<long>(nOldPos, rParm.nOldWish, nOldWidth);
+        nNewPos = lcl_MulDiv64<tools::Long>(nNewPos, rParm.nNewWish, 
nNewWidth);
+        nOldPos = lcl_MulDiv64<tools::Long>(nOldPos, rParm.nOldWish, 
nOldWidth);
         if( nOldPos != nNewPos && nNewPos > 0 && nOldPos > 0 )
         {
             ColChange aChg( static_cast<sal_uInt16>(nOldPos), 
static_cast<sal_uInt16>(nNewPos) );
diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx
index d3ce7116407b..26eaad505161 100644
--- a/sw/source/core/text/inftxt.hxx
+++ b/sw/source/core/text/inftxt.hxx
@@ -347,7 +347,7 @@ class SwTextPaintInfo : public SwTextSizeInfo
     sw::WrongListIterator *m_pWrongList;
     sw::WrongListIterator *m_pGrammarCheckList;
     sw::WrongListIterator *m_pSmartTags;
-    std::vector<long>* pSpaceAdd;
+    std::vector<tools::Long>* pSpaceAdd;
     const SvxBrushItem *pBrushItem; // For the background
     SwTextFly    aTextFly;    // Calculate the FlyFrame
     Point       aPos;       // Paint position
@@ -448,8 +448,8 @@ public:
         { return ( pSpaceAdd && nSpaceIdx < pSpaceAdd->size() )
                    ? (*pSpaceAdd)[nSpaceIdx] : 0; }
 
-    void SetpSpaceAdd( std::vector<long>* pNew ){ pSpaceAdd = pNew; }
-    std::vector<long>* GetpSpaceAdd() const { return pSpaceAdd; }
+    void SetpSpaceAdd( std::vector<tools::Long>* pNew ){ pSpaceAdd = pNew; }
+    std::vector<tools::Long>* GetpSpaceAdd() const { return pSpaceAdd; }
 
     void SetWrongList(sw::WrongListIterator *const pNew) { m_pWrongList = 
pNew; }
     sw::WrongListIterator* GetpWrongList() const { return m_pWrongList; }
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index aae48722464f..fb064af7d3c9 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -64,7 +64,7 @@ namespace {
     tools::Long lcl_CalcOptRepaint( SwTextFormatter &rThis,
                                     SwLineLayout const &rCurr,
                                     TextFrameIndex nOldLineEnd,
-                                    const std::vector<long> &rFlyStarts );
+                                    const std::vector<tools::Long> &rFlyStarts 
);
     //! Determine if we need to build hidden portions
     bool lcl_BuildHiddenPortion(const SwTextSizeInfo& rInf, TextFrameIndex 
&rPos);
 
@@ -1592,7 +1592,7 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex 
const nStartPos)
     // before and after the BuildPortions call
     const bool bOptimizeRepaint = AllowRepaintOpt();
     TextFrameIndex const nOldLineEnd = nStartPos + m_pCurr->GetLen();
-    std::vector<long> flyStarts;
+    std::vector<tools::Long> flyStarts;
 
     // these are the conditions for a fly position comparison
     if ( bOptimizeRepaint && m_pCurr->IsFly() )
@@ -2772,7 +2772,7 @@ namespace {
     tools::Long lcl_CalcOptRepaint( SwTextFormatter &rThis,
                          SwLineLayout const &rCurr,
                          TextFrameIndex const nOldLineEnd,
-                         const std::vector<long> &rFlyStarts )
+                         const std::vector<tools::Long> &rFlyStarts )
     {
         SwTextFormatInfo& txtFormatInfo = rThis.GetInfo();
         if ( txtFormatInfo.GetIdx() < txtFormatInfo.GetReformatStart() )
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 7e9c2c25cbdc..bb3fb103260f 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -308,7 +308,7 @@ void SwLineLayout::InitSpaceAdd()
 
 void SwLineLayout::CreateSpaceAdd( const tools::Long nInit )
 {
-    m_pLLSpaceAdd.reset( new std::vector<long> );
+    m_pLLSpaceAdd.reset( new std::vector<tools::Long> );
     SetLLSpaceAdd( nInit, 0 );
 }
 
diff --git a/sw/source/core/text/porlay.hxx b/sw/source/core/text/porlay.hxx
index ca2c4e0ae22f..255337d583c1 100644
--- a/sw/source/core/text/porlay.hxx
+++ b/sw/source/core/text/porlay.hxx
@@ -79,7 +79,7 @@ class SwLineLayout : public SwTextPortion
 {
 private:
     SwLineLayout *m_pNext;                // The next Line
-    std::unique_ptr<std::vector<long>> m_pLLSpaceAdd;     // Used for 
justified alignment
+    std::unique_ptr<std::vector<tools::Long>> m_pLLSpaceAdd;     // Used for 
justified alignment
     std::unique_ptr<std::deque<sal_uInt16>> m_pKanaComp;  // Used for Kana 
compression
     sal_uInt16 m_nRealHeight;             // The height resulting from line 
spacing and register
     sal_uInt16 m_nTextHeight;             // The max height of all non-FlyCnt 
portions in this Line
@@ -187,7 +187,7 @@ public:
     }
     tools::Long GetLLSpaceAdd( sal_uInt16 nIdx ) { return (*m_pLLSpaceAdd)[ 
nIdx ]; }
     void RemoveFirstLLSpaceAdd() { m_pLLSpaceAdd->erase( 
m_pLLSpaceAdd->begin() ); }
-    std::vector<long>* GetpLLSpaceAdd() const { return m_pLLSpaceAdd.get(); }
+    std::vector<tools::Long>* GetpLLSpaceAdd() const { return 
m_pLLSpaceAdd.get(); }
 
     // Stuff for Kana compression
     void SetKanaComp( std::unique_ptr<std::deque<sal_uInt16>> pNew ){ 
m_pKanaComp = std::move(pNew); }
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index e61c52b295aa..8050303942c2 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -515,7 +515,7 @@ bool SwDoubleLinePortion::ChgSpaceAdd( SwLineLayout* pCurr,
 //            pCurr->SetLLSpaceAdd( nMultiSpace, 0 );
             // #i65711# SetLLSpaceAdd replaces the first value,
             // instead we want to insert a new first value:
-            std::vector<long>* pVec = pCurr->GetpLLSpaceAdd();
+            std::vector<tools::Long>* pVec = pCurr->GetpLLSpaceAdd();
             pVec->insert( pVec->begin(), nMultiSpace );
             bRet = true;
         }
@@ -1411,7 +1411,7 @@ class SwSpaceManipulator
 {
     SwTextPaintInfo& rInfo;
     SwMultiPortion& rMulti;
-    std::vector<long>* pOldSpaceAdd;
+    std::vector<tools::Long>* pOldSpaceAdd;
     sal_uInt16 nOldSpIdx;
     tools::Long nSpaceAdd;
     bool bSpaceChg;
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index b1f9333ba04a..46851c08d7ad 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -273,7 +273,7 @@ SwRect SwContourCache::ContourRect( const SwFormat* pFormat,
 
     Range aRange( std::min( nTmpTop, nTmpBottom ), std::max( nTmpTop, 
nTmpBottom ) );
 
-    std::deque<long>* pTmp = mvItems[0].mxTextRanger->GetTextRanges( aRange );
+    std::deque<tools::Long>* pTmp = mvItems[0].mxTextRanger->GetTextRanges( 
aRange );
 
     const size_t nCount = pTmp->size();
     if( 0 != nCount )
diff --git a/sw/source/filter/html/htmlcss1.cxx 
b/sw/source/filter/html/htmlcss1.cxx
index 69eccc08fd33..c404d77d58b1 100644
--- a/sw/source/filter/html/htmlcss1.cxx
+++ b/sw/source/filter/html/htmlcss1.cxx
@@ -2049,7 +2049,7 @@ void SwHTMLParser::SetVarSize( SvxCSS1PropertyInfo const 
&rPropInfo,
         nWidth = MINFLY;
         break;
     case SVX_CSS1_LTYPE_TWIP:
-        nWidth = std::max<long>(rPropInfo.m_nWidth, MINFLY);
+        nWidth = std::max<tools::Long>(rPropInfo.m_nWidth, MINFLY);
         nPercentWidth = 0;
         break;
     default:
@@ -2063,7 +2063,7 @@ void SwHTMLParser::SetVarSize( SvxCSS1PropertyInfo const 
&rPropInfo,
     case SVX_CSS1_LTYPE_TWIP:
         // Netscape and MS-IE interpreting the height incorrectly as minimum 
height,
         // therefore we are doing the same.
-        nHeight = std::max<long>(rPropInfo.m_nHeight, MINFLY);
+        nHeight = std::max<tools::Long>(rPropInfo.m_nHeight, MINFLY);
         break;
     default:
         ;
diff --git a/sw/source/filter/writer/wrtswtbl.cxx 
b/sw/source/filter/writer/wrtswtbl.cxx
index 3c9c031c16fb..911bed91cc59 100644
--- a/sw/source/filter/writer/wrtswtbl.cxx
+++ b/sw/source/filter/writer/wrtswtbl.cxx
@@ -383,7 +383,7 @@ tools::Long SwWriteTable::GetAbsHeight(tools::Long 
nRawHeight, size_t const nRow
     }
 
     OSL_ENSURE( nRawHeight > 0, "Row Height <= 0. OK?" );
-    return std::max<long>(nRawHeight, 0);
+    return std::max<tools::Long>(nRawHeight, 0);
 }
 
 bool SwWriteTable::ShouldExpandSub(const SwTableBox *pBox, bool 
/*bExpandedBefore*/,
diff --git a/sw/source/filter/ww8/WW8TableInfo.hxx 
b/sw/source/filter/ww8/WW8TableInfo.hxx
index ca2cfb2c9252..ce7dbbb5faa7 100644
--- a/sw/source/filter/ww8/WW8TableInfo.hxx
+++ b/sw/source/filter/ww8/WW8TableInfo.hxx
@@ -255,7 +255,7 @@ public:
 
 class WW8TableCellGrid
 {
-    typedef std::set<long> RowTops_t;
+    typedef std::set<tools::Long> RowTops_t;
     typedef std::map<long, WW8TableCellGridRow::Pointer_t> Rows_t;
 
     RowTops_t m_aRowTops;
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index c535dd054588..544baec382ad 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1246,7 +1246,7 @@ static tools::Long lcl_GetTrueMargin(const SvxLRSpaceItem 
&rLR, const SwNumForma
     const tools::Long nReverseListIndented = GetListFirstLineIndent(rFormat);
     tools::Long nExtraListIndent = nPseudoListBodyIndent + 
nReverseListIndented;
 
-    return std::max<long>(nExtraListIndent, 0);
+    return std::max<tools::Long>(nExtraListIndent, 0);
 }
 
 // #i103711#
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index 55235e71437d..a4d005fb9a64 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -152,7 +152,7 @@ protected:
     virtual ::svt::CellController*  GetController(tools::Long nRow, sal_uInt16 
nCol) override;
     virtual bool                    SaveModified() override;
 
-    std::vector<long>               GetOptimalColWidths() const;
+    std::vector<tools::Long>               GetOptimalColWidths() const;
 
 public:
     SwEntryBrowseBox(const css::uno::Reference<css::awt::XWindow> &rParent);
@@ -3622,7 +3622,7 @@ void SwEntryBrowseBox::Resize()
     SwEntryBrowseBox_Base::Resize();
 
     tools::Long nWidth = GetSizePixel().Width();
-    std::vector<long> aWidths = GetOptimalColWidths();
+    std::vector<tools::Long> aWidths = GetOptimalColWidths();
     tools::Long nNaturalWidth(std::accumulate(aWidths.begin(), aWidths.end(), 
0));
     tools::Long nExcess = ((nWidth - nNaturalWidth) / aWidths.size()) - 1;
 
@@ -3630,9 +3630,9 @@ void SwEntryBrowseBox::Resize()
         SetColumnWidth(i+1, aWidths[i] + nExcess);
 }
 
-std::vector<long> SwEntryBrowseBox::GetOptimalColWidths() const
+std::vector<tools::Long> SwEntryBrowseBox::GetOptimalColWidths() const
 {
-    std::vector<long> aWidths;
+    std::vector<tools::Long> aWidths;
 
     tools::Long nStandardColMinWidth = approximate_digit_width() * 15;
     tools::Long nYesNoWidth = approximate_digit_width() * 5;
@@ -3661,7 +3661,7 @@ Size SwEntryBrowseBox::GetOptimalSize() const
 {
     Size aSize = LogicToPixel(Size(276 , 175), MapMode(MapUnit::MapAppFont));
 
-    std::vector<long> aWidths = GetOptimalColWidths();
+    std::vector<tools::Long> aWidths = GetOptimalColWidths();
 
     tools::Long nWidth(std::accumulate(aWidths.begin(), aWidths.end(), 0));
 
diff --git a/sw/source/uibase/shells/tabsh.cxx 
b/sw/source/uibase/shells/tabsh.cxx
index 594a018828da..ce54bdd02e31 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -873,8 +873,8 @@ void SwTableShell::Execute(SfxRequest &rReq)
                 {
                     tools::Long maxX = 0;
                     tools::Long maxY = 0;
-                    tools::Long minX = std::numeric_limits<long>::max();
-                    tools::Long minY = std::numeric_limits<long>::max();
+                    tools::Long minX = std::numeric_limits<tools::Long>::max();
+                    tools::Long minY = std::numeric_limits<tools::Long>::max();
                     tools::Long nbBoxes = aBoxes.size();
                     for ( tools::Long i = 0; i < nbBoxes; i++ )
                     {
diff --git a/tools/qa/cppunit/test_bigint.cxx b/tools/qa/cppunit/test_bigint.cxx
index ed3ab3cc3b63..efea3e341235 100644
--- a/tools/qa/cppunit/test_bigint.cxx
+++ b/tools/qa/cppunit/test_bigint.cxx
@@ -59,27 +59,27 @@ void BigIntTest::testConstructionFromLongLong()
 #if SAL_TYPES_SIZEOFLONG < SAL_TYPES_SIZEOFLONGLONG
     // positive number just fitting to long
     {
-        BigInt bi(static_cast<sal_Int64>(std::numeric_limits<long>::max()));
+        BigInt 
bi(static_cast<sal_Int64>(std::numeric_limits<tools::Long>::max()));
         CPPUNIT_ASSERT(bi.IsSet());
         CPPUNIT_ASSERT(!bi.IsZero());
         CPPUNIT_ASSERT(!bi.IsNeg());
         CPPUNIT_ASSERT(bi.IsLong());
-        CPPUNIT_ASSERT_EQUAL(std::numeric_limits<long>::max(), 
static_cast<long>(bi));
+        CPPUNIT_ASSERT_EQUAL(std::numeric_limits<tools::Long>::max(), 
static_cast<tools::Long>(bi));
     }
 
     // negative number just fitting to long
     {
-        BigInt bi(static_cast<sal_Int64>(std::numeric_limits<long>::min()));
+        BigInt 
bi(static_cast<sal_Int64>(std::numeric_limits<tools::Long>::min()));
         CPPUNIT_ASSERT(bi.IsSet());
         CPPUNIT_ASSERT(!bi.IsZero());
         CPPUNIT_ASSERT(bi.IsNeg());
         CPPUNIT_ASSERT(bi.IsLong());
-        CPPUNIT_ASSERT_EQUAL(std::numeric_limits<long>::min(), 
static_cast<long>(bi));
+        CPPUNIT_ASSERT_EQUAL(std::numeric_limits<tools::Long>::min(), 
static_cast<tools::Long>(bi));
     }
 
     // positive number not fitting to long
     {
-        BigInt bi(static_cast<sal_Int64>(std::numeric_limits<long>::max())
+        BigInt 
bi(static_cast<sal_Int64>(std::numeric_limits<tools::Long>::max())
                   + static_cast<sal_Int64>(1));
         CPPUNIT_ASSERT(bi.IsSet());
         CPPUNIT_ASSERT(!bi.IsZero());
@@ -89,7 +89,7 @@ void BigIntTest::testConstructionFromLongLong()
 
     // negative number not fitting to long
     {
-        BigInt bi(static_cast<sal_Int64>(std::numeric_limits<long>::min())
+        BigInt 
bi(static_cast<sal_Int64>(std::numeric_limits<tools::Long>::min())
                   - static_cast<sal_Int64>(1));
         CPPUNIT_ASSERT(bi.IsSet());
         CPPUNIT_ASSERT(!bi.IsZero());
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index b5748e560d2c..7dfa5a89eb41 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -102,7 +102,7 @@ static std::unique_ptr<BitmapBuffer> ImplCreateDIB(
     pDIB->mnWidth = rSize.Width();
     pDIB->mnHeight = rSize.Height();
     tools::Long nScanlineBase;
-    bool bFail = o3tl::checked_multiply<long>(pDIB->mnWidth, nBitCount, 
nScanlineBase);
+    bool bFail = o3tl::checked_multiply<tools::Long>(pDIB->mnWidth, nBitCount, 
nScanlineBase);
     if (bFail)
     {
         SAL_WARN("vcl.gdi", "checked multiply failed");
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 7116cf70f7b2..d878527562c2 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -186,7 +186,7 @@ namespace
         pDst->maPalette = pSrc->maPalette;
 
         tools::Long nScanlineBase;
-        const bool bFail = o3tl::checked_multiply<long>(pDst->mnBitCount, 
nWidth, nScanlineBase);
+        const bool bFail = 
o3tl::checked_multiply<tools::Long>(pDst->mnBitCount, nWidth, nScanlineBase);
         if (bFail)
         {
             SAL_WARN("vcl.gdi", "checked multiply failed");
diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index 887f8d187fb1..bfe3b98523b9 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -11,10 +11,11 @@
 
 #include <ostream>
 #include <vector>
+#include <tools/long.hxx>
 
 #if HAVE_MORE_FONTS
 // must be declared before inclusion of test/bootstrapfixture.hxx
-static std::ostream& operator<<(std::ostream& rStream, const 
std::vector<long>& rVec);
+static std::ostream& operator<<(std::ostream& rStream, const 
std::vector<tools::Long>& rVec);
 #endif
 #include <test/bootstrapfixture.hxx>
 
@@ -25,7 +26,7 @@ static std::ostream& operator<<(std::ostream& rStream, const 
std::vector<long>&
 #include <salgdi.hxx>
 
 #if HAVE_MORE_FONTS
-static std::ostream& operator<<(std::ostream& rStream, const 
std::vector<long>& rVec)
+static std::ostream& operator<<(std::ostream& rStream, const 
std::vector<tools::Long>& rVec)
 {
     rStream << "{ ";
     for (size_t i = 0; i < rVec.size() - 1; i++)
@@ -75,9 +76,9 @@ void VclComplexTextTest::testArabic()
     pOutDev->SetFont( aFont );
 
     // absolute character widths AKA text array.
-    std::vector<long> aRefCharWidths {6,  9,  16, 16, 22, 22, 26, 29, 32, 32,
+    std::vector<tools::Long> aRefCharWidths {6,  9,  16, 16, 22, 22, 26, 29, 
32, 32,
                                       36, 40, 49, 53, 56, 63, 63, 66, 72, 72};
-    std::vector<long> aCharWidths(aOneTwoThree.getLength(), 0);
+    std::vector<tools::Long> aCharWidths(aOneTwoThree.getLength(), 0);
     tools::Long nTextWidth = pOutDev->GetTextArray(aOneTwoThree, 
aCharWidths.data());
 
     CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths);
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 303907501e96..61a1e52211c3 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3681,7 +3681,7 @@ public:
 
     virtual void columns_autosize() override
     {
-        std::vector<long> aWidths;
+        std::vector<tools::Long> aWidths;
         m_xTreeView->getPreferredDimensions(aWidths);
         if (aWidths.size() > 2)
         {
@@ -3708,7 +3708,7 @@ public:
 
     virtual void set_column_fixed_widths(const std::vector<int>& rWidths) 
override
     {
-        std::vector<long> aTabPositions;
+        std::vector<tools::Long> aTabPositions;
         aTabPositions.push_back(0);
         for (size_t i = 0; i < rWidths.size(); ++i)
             aTabPositions.push_back(aTabPositions[i] + rWidths[i]);
@@ -5036,7 +5036,7 @@ IMPL_LINK_NOARG(SalInstanceTreeView, DoubleClickHdl, 
SvTreeListBox*, bool)
 
 IMPL_LINK(SalInstanceTreeView, EndDragHdl, HeaderBar*, pHeaderBar, void)
 {
-    std::vector<long> aTabPositions;
+    std::vector<tools::Long> aTabPositions;
     aTabPositions.push_back(0);
     for (int i = 0; i < pHeaderBar->GetItemCount() - 1; ++i)
         aTabPositions.push_back(aTabPositions[i]
diff --git a/vcl/source/bitmap/BitmapFilterStackBlur.cxx 
b/vcl/source/bitmap/BitmapFilterStackBlur.cxx
index 66645077eb0f..9bf4b810ac60 100644
--- a/vcl/source/bitmap/BitmapFilterStackBlur.cxx
+++ b/vcl/source/bitmap/BitmapFilterStackBlur.cxx
@@ -74,12 +74,12 @@ struct BlurArrays
     BlurSharedData maShared;
 
     std::vector<sal_uInt8> maStackBuffer;
-    std::vector<long> maPositionTable;
-    std::vector<long> maWeightTable;
+    std::vector<tools::Long> maPositionTable;
+    std::vector<tools::Long> maWeightTable;
 
-    std::vector<long> mnSumVector;
-    std::vector<long> mnInSumVector;
-    std::vector<long> mnOutSumVector;
+    std::vector<tools::Long> mnSumVector;
+    std::vector<tools::Long> mnInSumVector;
+    std::vector<tools::Long> mnOutSumVector;
 
     BlurArrays(BlurSharedData const& rShared)
         : maShared(rShared)
diff --git a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx 
b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx
index 3d5fe51d1c5d..95c86f038dd9 100644
--- a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx
+++ b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx
@@ -53,8 +53,8 @@ struct ScaleContext
     tools::Long mnDestW;
     bool mbHMirr;
     bool mbVMirr;
-    std::vector<long> maMapIX;
-    std::vector<long> maMapIY;
+    std::vector<tools::Long> maMapIX;
+    std::vector<tools::Long> maMapIY;
     std::vector<BilinearWeightType> maMapFX;
     std::vector<BilinearWeightType> maMapFY;
 
@@ -78,7 +78,7 @@ struct ScaleContext
     }
 
     static void generateMap(tools::Long nSourceLength, tools::Long 
nDestinationLength, bool bMirrored,
-        std::vector<long> & rMapIX, std::vector<BilinearWeightType> & rMapFX)
+        std::vector<tools::Long> & rMapIX, std::vector<BilinearWeightType> & 
rMapFX)
     {
         const double fRevScale = (nDestinationLength > 1) ? 
double(nSourceLength - 1) / (nDestinationLength - 1) : 0.0;
 
diff --git a/vcl/source/bitmap/bitmappaint.cxx 
b/vcl/source/bitmap/bitmappaint.cxx
index f9dff4ee0b26..f1c849bd5787 100644
--- a/vcl/source/bitmap/bitmappaint.cxx
+++ b/vcl/source/bitmap/bitmappaint.cxx
@@ -538,12 +538,12 @@ Bitmap Bitmap::CreateMask(const Color& rTransColor, 
sal_uInt8 nTol) const
         {
             BitmapColor aCol;
             tools::Long nR, nG, nB;
-            const tools::Long nMinR = MinMax<long>(rTransColor.GetRed() - 
nTol, 0, 255);
-            const tools::Long nMaxR = MinMax<long>(rTransColor.GetRed() + 
nTol, 0, 255);
-            const tools::Long nMinG = MinMax<long>(rTransColor.GetGreen() - 
nTol, 0, 255);
-            const tools::Long nMaxG = MinMax<long>(rTransColor.GetGreen() + 
nTol, 0, 255);
-            const tools::Long nMinB = MinMax<long>(rTransColor.GetBlue() - 
nTol, 0, 255);
-            const tools::Long nMaxB = MinMax<long>(rTransColor.GetBlue() + 
nTol, 0, 255);
+            const tools::Long nMinR = MinMax<tools::Long>(rTransColor.GetRed() 
- nTol, 0, 255);
+            const tools::Long nMaxR = MinMax<tools::Long>(rTransColor.GetRed() 
+ nTol, 0, 255);
+            const tools::Long nMinG = 
MinMax<tools::Long>(rTransColor.GetGreen() - nTol, 0, 255);
+            const tools::Long nMaxG = 
MinMax<tools::Long>(rTransColor.GetGreen() + nTol, 0, 255);
+            const tools::Long nMinB = 
MinMax<tools::Long>(rTransColor.GetBlue() - nTol, 0, 255);
+            const tools::Long nMaxB = 
MinMax<tools::Long>(rTransColor.GetBlue() + nTol, 0, 255);
 
             if (pReadAcc->HasPalette())
             {
@@ -632,13 +632,13 @@ vcl::Region Bitmap::CreateRegion(const Color& rColor, 
const tools::Rectangle& rR
         const tools::Long nBottom = aRect.Bottom();
         const BitmapColor aMatch(pReadAcc->GetBestMatchingColor(rColor));
 
-        std::vector<long> aLine;
+        std::vector<tools::Long> aLine;
         tools::Long nYStart(nTop);
         tools::Long nY(nTop);
 
         for (; nY <= nBottom; nY++)
         {
-            std::vector<long> aNewLine;
+            std::vector<tools::Long> aNewLine;
             tools::Long nX(nLeft);
             Scanline pScanlineRead = pReadAcc->GetScanline(nY);
 
@@ -863,12 +863,12 @@ bool Bitmap::Replace(const Color& rSearchColor, const 
Color& rReplaceColor, sal_
 
     if (pAcc)
     {
-        const tools::Long nMinR = MinMax<long>(rSearchColor.GetRed() - nTol, 
0, 255);
-        const tools::Long nMaxR = MinMax<long>(rSearchColor.GetRed() + nTol, 
0, 255);
-        const tools::Long nMinG = MinMax<long>(rSearchColor.GetGreen() - nTol, 
0, 255);
-        const tools::Long nMaxG = MinMax<long>(rSearchColor.GetGreen() + nTol, 
0, 255);
-        const tools::Long nMinB = MinMax<long>(rSearchColor.GetBlue() - nTol, 
0, 255);
-        const tools::Long nMaxB = MinMax<long>(rSearchColor.GetBlue() + nTol, 
0, 255);
+        const tools::Long nMinR = MinMax<tools::Long>(rSearchColor.GetRed() - 
nTol, 0, 255);
+        const tools::Long nMaxR = MinMax<tools::Long>(rSearchColor.GetRed() + 
nTol, 0, 255);
+        const tools::Long nMinG = MinMax<tools::Long>(rSearchColor.GetGreen() 
- nTol, 0, 255);
+        const tools::Long nMaxG = MinMax<tools::Long>(rSearchColor.GetGreen() 
+ nTol, 0, 255);
+        const tools::Long nMinB = MinMax<tools::Long>(rSearchColor.GetBlue() - 
nTol, 0, 255);
+        const tools::Long nMaxB = MinMax<tools::Long>(rSearchColor.GetBlue() + 
nTol, 0, 255);
 
         if (pAcc->HasPalette())
         {
@@ -940,12 +940,12 @@ bool Bitmap::Replace(const Color* pSearchColors, const 
Color* pReplaceColors, sa
                 const Color& rCol = pSearchColors[i];
                 const sal_uInt8 nTol = pTols[i];
 
-                pMinR[i] = MinMax<long>(rCol.GetRed() - nTol, 0, 255);
-                pMaxR[i] = MinMax<long>(rCol.GetRed() + nTol, 0, 255);
-                pMinG[i] = MinMax<long>(rCol.GetGreen() - nTol, 0, 255);
-                pMaxG[i] = MinMax<long>(rCol.GetGreen() + nTol, 0, 255);
-                pMinB[i] = MinMax<long>(rCol.GetBlue() - nTol, 0, 255);
-                pMaxB[i] = MinMax<long>(rCol.GetBlue() + nTol, 0, 255);
+                pMinR[i] = MinMax<tools::Long>(rCol.GetRed() - nTol, 0, 255);
+                pMaxR[i] = MinMax<tools::Long>(rCol.GetRed() + nTol, 0, 255);
+                pMinG[i] = MinMax<tools::Long>(rCol.GetGreen() - nTol, 0, 255);
+                pMaxG[i] = MinMax<tools::Long>(rCol.GetGreen() + nTol, 0, 255);
+                pMinB[i] = MinMax<tools::Long>(rCol.GetBlue() - nTol, 0, 255);
+                pMaxB[i] = MinMax<tools::Long>(rCol.GetBlue() + nTol, 0, 255);
             }
         }
         else
diff --git a/vcl/source/control/imp_listbox.cxx 
b/vcl/source/control/imp_listbox.cxx
index f9ba50513178..2125e0780afa 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -296,7 +296,7 @@ tools::Long ImplEntryList::GetAddedHeight( sal_Int32 
i_nEndIndex, sal_Int32 i_nB
         while( nIndex != LISTBOX_ENTRY_NOTFOUND && nIndex < nStop )
         {
             tools::Long nPosHeight = GetEntryPtr( nIndex 
)->getHeightWithMargin();
-            if (nHeight > ::std::numeric_limits<long>::max() - nPosHeight)
+            if (nHeight > ::std::numeric_limits<tools::Long>::max() - 
nPosHeight)
             {
                 SAL_WARN( "vcl", "ImplEntryList::GetAddedHeight: truncated");
                 break;
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index e03a203ddb60..4455b6651d58 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -1519,7 +1519,7 @@ void TextEngine::FormatDoc()
                 // otherwise remains Empty() for Paperwidth 0 (AutoPageSize)
                 const tools::Long nWidth = mnMaxTextWidth
                     ? mnMaxTextWidth
-                    : std::numeric_limits<long>::max();
+                    : std::numeric_limits<tools::Long>::max();
                 const Range aInvRange( GetInvalidYOffsets( nPara ) );
                 maInvalidRect = tools::Rectangle( Point( 0, nY+aInvRange.Min() 
),
                     Size( nWidth, aInvRange.Len() ) );
@@ -2146,7 +2146,7 @@ bool TextEngine::CreateLines( sal_uInt32 nPara )
         tools::Long nTmpWidth = mpDoc->GetLeftMargin();
         // do not subtract margin; it is included in TmpWidth
         tools::Long nXWidth = std::max(
-            mnMaxTextWidth ? mnMaxTextWidth : 
std::numeric_limits<long>::max(), nTmpWidth);
+            mnMaxTextWidth ? mnMaxTextWidth : 
std::numeric_limits<tools::Long>::max(), nTmpWidth);
 
         // search for Portion that does not fit anymore into line
         TETextPortion* pPortion = nullptr;
diff --git a/vcl/source/gdi/bmpfast.cxx b/vcl/source/gdi/bmpfast.cxx
index e28f4de0c60a..b39ca1fe6a34 100644
--- a/vcl/source/gdi/bmpfast.cxx
+++ b/vcl/source/gdi/bmpfast.cxx
@@ -525,7 +525,7 @@ bool ImplFastCopyScanline( tools::Long nY, BitmapBuffer& 
rDst, ConstScanline aSr
     // special handling of trivial cases
     if( nSrcFormat == nDstFormat )
     {
-        memcpy( ImplGetScanline( rDst, nY ), aSrcScanline, 
std::min<long>(nSrcScanlineSize, rDst.mnScanlineSize));
+        memcpy( ImplGetScanline( rDst, nY ), aSrcScanline, 
std::min<tools::Long>(nSrcScanlineSize, rDst.mnScanlineSize));
         return true;
     }
 
diff --git a/vcl/source/gdi/salmisc.cxx b/vcl/source/gdi/salmisc.cxx
index 434e94865aa3..1bb094291e86 100644
--- a/vcl/source/gdi/salmisc.cxx
+++ b/vcl/source/gdi/salmisc.cxx
@@ -308,7 +308,7 @@ std::unique_ptr<BitmapBuffer> StretchAndConvert(
     pDstBuffer->mnWidth = rTwoRect.mnDestWidth;
     pDstBuffer->mnHeight = rTwoRect.mnDestHeight;
     tools::Long nScanlineBase;
-    bool bFail = o3tl::checked_multiply<long>(pDstBuffer->mnBitCount, 
pDstBuffer->mnWidth, nScanlineBase);
+    bool bFail = o3tl::checked_multiply<tools::Long>(pDstBuffer->mnBitCount, 
pDstBuffer->mnWidth, nScanlineBase);
     if (bFail)
     {
         SAL_WARN("vcl.gdi", "checked multiply failed");
diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx
index 3a581c050a05..2a1b46ae0b72 100644
--- a/vcl/source/outdev/map.cxx
+++ b/vcl/source/outdev/map.cxx
@@ -363,7 +363,7 @@ static tools::Long ImplLogicToPixel( tools::Long n, 
tools::Long nDPI, tools::Lon
 #else
     (void) nThres;
     assert(nMapNum >= 0);
-    assert(nMapNum == 0 || std::abs(n) < std::numeric_limits<long>::max() / 
nMapNum / nDPI); //detect overflows
+    assert(nMapNum == 0 || std::abs(n) < 
std::numeric_limits<tools::Long>::max() / nMapNum / nDPI); //detect overflows
 #endif
     {
         sal_Int64 n64 = n;
diff --git a/vcl/source/treelist/treelistbox.cxx 
b/vcl/source/treelist/treelistbox.cxx
index 7240215049b9..bbafb2a4ba95 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -3033,7 +3033,7 @@ SvLBoxItem* SvTreeListBox::GetItem_Impl( SvTreeListEntry* 
pEntry, tools::Long nX
     return pItemClicked;
 }
 
-tools::Long SvTreeListBox::getPreferredDimensions(std::vector<long> &rWidths) 
const
+tools::Long SvTreeListBox::getPreferredDimensions(std::vector<tools::Long> 
&rWidths) const
 {
     tools::Long nHeight = 0;
     rWidths.clear();
@@ -3064,7 +3064,7 @@ tools::Long 
SvTreeListBox::getPreferredDimensions(std::vector<long> &rWidths) co
 
 Size SvTreeListBox::GetOptimalSize() const
 {
-    std::vector<long> aWidths;
+    std::vector<tools::Long> aWidths;
     Size aRet(0, getPreferredDimensions(aWidths));
     for (tools::Long aWidth : aWidths)
         aRet.AdjustWidth(aWidth );
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index ed6e18a8cba1..5618af225d4c 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -706,8 +706,8 @@ Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize)
     else
         h -= 100;
 
-    return Size(std::max<long>(w, 640 - 15),
-                std::max<long>(h, 480 - 50));
+    return Size(std::max<tools::Long>(w, 640 - 15),
+                std::max<tools::Long>(h, 480 - 50));
 #else

... etc. - the rest is truncated
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to