[Libreoffice-commits] core.git: basic/source compilerplugins/clang cui/source editeng/source filter/source lotuswordpro/source sc/source sd/source svl/source svtools/source svx/source sw/source tools/source vbahelper/source vcl/qa vcl/source vcl/unx writerperfect/source

Noel Grandin noel.grandin at collabora.co.uk
Fri Apr 7 12:16:43 UTC 2017


 basic/source/runtime/methods.cxx                   |    4 
 compilerplugins/clang/redundantcast.cxx            |  104 +++++++++------------
 compilerplugins/clang/test/redundantcast.cxx       |    2 
 cui/source/tabpages/chardlg.cxx                    |    4 
 cui/source/tabpages/numpages.cxx                   |    4 
 cui/source/tabpages/page.cxx                       |    4 
 editeng/source/editeng/eertfpar.cxx                |    2 
 editeng/source/items/itemtype.cxx                  |    4 
 filter/source/flash/swfwriter1.cxx                 |    2 
 filter/source/graphicfilter/eps/eps.cxx            |    2 
 filter/source/graphicfilter/ios2met/ios2met.cxx    |    2 
 filter/source/svg/svgwriter.cxx                    |    2 
 lotuswordpro/source/filter/localtime.cxx           |    6 -
 sc/source/core/data/drwlayer.cxx                   |    4 
 sc/source/ui/view/preview.cxx                      |   12 +-
 sd/source/ui/view/drtxtob1.cxx                     |    8 -
 sd/source/ui/view/drviewse.cxx                     |    4 
 sd/source/ui/view/outlnvs2.cxx                     |    4 
 sd/source/ui/view/viewshel.cxx                     |    4 
 svl/source/numbers/zformat.cxx                     |    4 
 svtools/source/brwbox/brwbox1.cxx                  |    4 
 svtools/source/contnr/treelistbox.cxx              |    2 
 svx/source/sidebar/paragraph/ParaPropertyPanel.cxx |    6 -
 sw/source/core/inc/swfont.hxx                      |    8 -
 sw/source/core/text/txtftn.cxx                     |    4 
 sw/source/filter/html/css1atr.cxx                  |    7 -
 sw/source/filter/ww8/ww8atr.cxx                    |    2 
 sw/source/uibase/uiview/viewtab.cxx                |   13 +-
 tools/source/generic/poly.cxx                      |    4 
 vbahelper/source/vbahelper/vbaapplicationbase.cxx  |    2 
 vcl/qa/cppunit/fontmetric.cxx                      |   28 ++---
 vcl/qa/cppunit/graphicfilter/filters-test.cxx      |    3 
 vcl/source/gdi/bitmap4.cxx                         |    4 
 vcl/source/gdi/pngread.cxx                         |    4 
 vcl/source/window/menu.cxx                         |    2 
 vcl/unx/generic/gdi/salbmp.cxx                     |    4 
 vcl/unx/generic/window/salframe.cxx                |    8 -
 writerperfect/source/common/WPXSvInputStream.cxx   |    4 
 38 files changed, 141 insertions(+), 150 deletions(-)

New commits:
commit be8b9b4d29abb951aea0ea195541143d256954dc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Apr 7 09:08:35 2017 +0200

    loplugin:redundantcast find cstyle arithmetic casts
    
    Change-Id: If7c259f0d12a41182f476ddb558f7cb5f76f9577
    Reviewed-on: https://gerrit.libreoffice.org/36253
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index e23536751753..67c0534f6821 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -4834,12 +4834,12 @@ static long GetDayDiff( const Date& rDate )
     long nDiffDays;
     if ( aRefDate > rDate )
     {
-        nDiffDays = (long)(aRefDate - rDate);
+        nDiffDays = aRefDate - rDate;
         nDiffDays *= -1;
     }
     else
     {
-        nDiffDays = (long)(rDate - aRefDate);
+        nDiffDays = rDate - aRefDate;
     }
     nDiffDays += 2; // adjustment VisualBasic: 1.Jan.1900 == 2
     return nDiffDays;
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx
index 72391256b285..a229f95044c7 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -187,6 +187,7 @@ public:
 
 private:
     bool visitBinOp(BinaryOperator const * expr);
+    bool isOkToRemoveArithmeticCast(QualType t1, QualType t2, const Expr* subExpr);
 };
 
 bool RedundantCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) {
@@ -323,67 +324,45 @@ bool RedundantCast::VisitCStyleCastExpr(CStyleCastExpr const * expr) {
     }
     auto t1 = getSubExprAsWritten(expr)->getType();
     auto t2 = expr->getTypeAsWritten();
-    if (loplugin::TypeCheck(t1).Enum() && t1 == t2) {
-        report(
-            DiagnosticsEngine::Warning,
-            "redundant cstyle enum cast from %0 to %1", expr->getExprLoc())
-            << t1 << t2 << expr->getSourceRange();
+    if (t1 != t2) {
         return true;
     }
-    bool bBuiltinType = t1->isSpecificBuiltinType(BuiltinType::Bool)
-                        || t1->isSpecificBuiltinType(BuiltinType::Void)
-                        || t1->isSpecificBuiltinType(BuiltinType::Float)
-                        || t1->isSpecificBuiltinType(BuiltinType::Double)
-                        || t1->isSpecificBuiltinType(BuiltinType::UChar)
-                        || t1->isSpecificBuiltinType(BuiltinType::Char_U)
-                        || t1->isSpecificBuiltinType(BuiltinType::SChar)
-                        || t1->isSpecificBuiltinType(BuiltinType::Char_S)
-                        || t1->isSpecificBuiltinType(BuiltinType::Char16)
-                        || t1->isSpecificBuiltinType(BuiltinType::Char32)
-                        || t1->isSpecificBuiltinType(BuiltinType::WChar_U)
-                        || t1->isSpecificBuiltinType(BuiltinType::WChar_S);
-    if ((bBuiltinType || loplugin::TypeCheck(t1).Typedef()) && t1 == t2)
-    {
-        // Ignore FD_ISSET expanding to "...(SOCKET)(fd)..." in some Microsoft
-        // winsock2.h (TODO: improve heuristic of determining that the whole
-        // expr is part of a single macro body expansion):
-        auto l1 = expr->getLocStart();
-        while (compiler.getSourceManager().isMacroArgExpansion(l1)) {
-            l1 = compiler.getSourceManager().getImmediateMacroCallerLoc(l1);
-        }
-        auto l2 = expr->getExprLoc();
-        while (compiler.getSourceManager().isMacroArgExpansion(l2)) {
-            l2 = compiler.getSourceManager().getImmediateMacroCallerLoc(l2);
-        }
-        auto l3 = expr->getLocEnd();
-        while (compiler.getSourceManager().isMacroArgExpansion(l3)) {
-            l3 = compiler.getSourceManager().getImmediateMacroCallerLoc(l3);
-        }
-        if (compiler.getSourceManager().isMacroBodyExpansion(l1)
-            && compiler.getSourceManager().isMacroBodyExpansion(l2)
-            && compiler.getSourceManager().isMacroBodyExpansion(l3)
-            && ignoreLocation(compiler.getSourceManager().getSpellingLoc(l2)))
-        {
-            return true;
-        }
-        report(
-            DiagnosticsEngine::Warning,
-            "redundant cstyle cast from %0 to %1", expr->getExprLoc())
-            << t1 << t2 << expr->getSourceRange();
+    if (!t1->isBuiltinType() && !loplugin::TypeCheck(t1).Enum() && !loplugin::TypeCheck(t1).Typedef()) {
         return true;
     }
-    return true;
-}
-
-bool RedundantCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const * expr) {
-    if (ignoreLocation(expr)) {
+    if (!isOkToRemoveArithmeticCast(t1, t2, expr->getSubExpr())) {
         return true;
     }
-    auto t1 = getSubExprAsWritten(expr)->getType();
-    auto t2 = expr->getTypeAsWritten();
-    if (t1.getCanonicalType() != t2.getCanonicalType()) {
+    // Ignore FD_ISSET expanding to "...(SOCKET)(fd)..." in some Microsoft
+    // winsock2.h (TODO: improve heuristic of determining that the whole
+    // expr is part of a single macro body expansion):
+    auto l1 = expr->getLocStart();
+    while (compiler.getSourceManager().isMacroArgExpansion(l1)) {
+        l1 = compiler.getSourceManager().getImmediateMacroCallerLoc(l1);
+    }
+    auto l2 = expr->getExprLoc();
+    while (compiler.getSourceManager().isMacroArgExpansion(l2)) {
+        l2 = compiler.getSourceManager().getImmediateMacroCallerLoc(l2);
+    }
+    auto l3 = expr->getLocEnd();
+    while (compiler.getSourceManager().isMacroArgExpansion(l3)) {
+         l3 = compiler.getSourceManager().getImmediateMacroCallerLoc(l3);
+    }
+    if (compiler.getSourceManager().isMacroBodyExpansion(l1)
+        && compiler.getSourceManager().isMacroBodyExpansion(l2)
+        && compiler.getSourceManager().isMacroBodyExpansion(l3)
+        && ignoreLocation(compiler.getSourceManager().getSpellingLoc(l2)))
+    {
         return true;
     }
+    report(
+        DiagnosticsEngine::Warning,
+        "redundant cstyle cast from %0 to %1", expr->getExprLoc())
+        << t1 << t2 << expr->getSourceRange();
+    return true;
+}
+
+bool RedundantCast::isOkToRemoveArithmeticCast(QualType t1, QualType t2, const Expr* subExpr) {
     // Don't warn if the types are arithmetic (in the C++ meaning), and: either
     // at least one is a typedef (and if both are typedefs,they're different),
     // or the sub-expression involves some operation that is likely to change
@@ -395,9 +374,24 @@ bool RedundantCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const * expr) {
         && ((t1 != t2
              && (loplugin::TypeCheck(t1).Typedef()
                  || loplugin::TypeCheck(t2).Typedef()))
-            || isArithmeticOp(expr->getSubExpr())
-            || isa<IntegerLiteral>(expr->getSubExpr()->IgnoreParenImpCasts())))
+            || isArithmeticOp(subExpr)
+            || isa<IntegerLiteral>(subExpr->IgnoreParenImpCasts())))
     {
+        return false;
+    }
+    return true;
+}
+
+bool RedundantCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const * expr) {
+    if (ignoreLocation(expr)) {
+        return true;
+    }
+    auto t1 = getSubExprAsWritten(expr)->getType();
+    auto t2 = expr->getTypeAsWritten();
+    if (t1.getCanonicalType() != t2.getCanonicalType()) {
+        return true;
+    }
+    if (!isOkToRemoveArithmeticCast(t1, t2, expr->getSubExpr())) {
         return true;
     }
     // Don't warn if the types are 'void *' and at least one involves a typedef
diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx
index a7516c1a058f..73b8ef072411 100644
--- a/compilerplugins/clang/test/redundantcast.cxx
+++ b/compilerplugins/clang/test/redundantcast.cxx
@@ -30,7 +30,7 @@ int main() {
     f2(const_cast<char const *>(p2)); // expected-error {{redundant const_cast from 'const char *' to 'const char *' [loplugin:redundantcast]}}
     f2(const_cast<char const * const>(p2)); // expected-error {{redundant const_cast from 'const char *' to 'const char *const' [loplugin:redundantcast]}}
 
-    Enum1 e = (Enum1)Enum1::X; // expected-error {{redundant cstyle enum cast from 'Enum1' to 'Enum1' [loplugin:redundantcast]}}
+    Enum1 e = (Enum1)Enum1::X; // expected-error {{redundant cstyle cast from 'Enum1' to 'Enum1' [loplugin:redundantcast]}}
     (void)e;
 }
 
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index 744b98135ada..b34670d2f681 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -780,14 +780,14 @@ void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp
         else
         {
             pSizeBox->SetRelative(false);
-            pSizeBox->SetValue( (long)CalcToPoint( rItem.GetHeight(), eUnit, 10 ) );
+            pSizeBox->SetValue( CalcToPoint( rItem.GetHeight(), eUnit, 10 ) );
         }
     }
     else if ( eState >= SfxItemState::DEFAULT )
     {
         MapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
         const SvxFontHeightItem& rItem = static_cast<const SvxFontHeightItem&>(rSet.Get( nWhich ));
-        pSizeBox->SetValue( (long)CalcToPoint( rItem.GetHeight(), eUnit, 10 ) );
+        pSizeBox->SetValue( CalcToPoint( rItem.GetHeight(), eUnit, 10 ) );
     }
     else
     {
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index 794e012f230f..dc018430b430 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -1023,8 +1023,8 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, Button*, void)
                 GraphicConverter::Import( *pIn, aGraphic );
 
                 BitmapEx aBitmap = aGraphic.GetBitmapEx();
-                long nPixelX = (long)(aBitmap.GetSizePixel().Width());
-                long nPixelY = (long)(aBitmap.GetSizePixel().Height());
+                long nPixelX = aBitmap.GetSizePixel().Width();
+                long nPixelY = aBitmap.GetSizePixel().Height();
                 double ratio = nPixelY/(double)nPixelX;
                 if(nPixelX > 30)
                 {
diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx
index a06810695c20..ecc8d361d465 100644
--- a/cui/source/tabpages/page.cxx
+++ b/cui/source/tabpages/page.cxx
@@ -420,10 +420,10 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet )
         const SvxLRSpaceItem& rLRSpace = static_cast<const SvxLRSpaceItem&>(*pItem);
         SetMetricValue( *m_pLeftMarginEdit, rLRSpace.GetLeft(), eUnit );
         m_pBspWin->SetLeft(
-            (sal_uInt16)ConvertLong_Impl( (long)rLRSpace.GetLeft(), eUnit ) );
+            (sal_uInt16)ConvertLong_Impl( rLRSpace.GetLeft(), eUnit ) );
         SetMetricValue( *m_pRightMarginEdit, rLRSpace.GetRight(), eUnit );
         m_pBspWin->SetRight(
-            (sal_uInt16)ConvertLong_Impl( (long)rLRSpace.GetRight(), eUnit ) );
+            (sal_uInt16)ConvertLong_Impl( rLRSpace.GetRight(), eUnit ) );
     }
 
     // adjust margins (top/bottom)
diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx
index e6c185273fe2..95e41042008a 100644
--- a/editeng/source/editeng/eertfpar.cxx
+++ b/editeng/source/editeng/eertfpar.cxx
@@ -512,7 +512,7 @@ void EditRTFParser::CalcValue()
     const MapUnit eDestUnit = aEditMapMode.GetMapUnit();
     const MapUnit eSrcUnit  = aRTFMapMode.GetMapUnit();
     if (eDestUnit != eSrcUnit)
-        nTokenValue = OutputDevice::LogicToLogic( (long)nTokenValue, eSrcUnit, eDestUnit );
+        nTokenValue = OutputDevice::LogicToLogic( nTokenValue, eSrcUnit, eDestUnit );
 }
 
 void EditRTFParser::ReadField()
diff --git a/editeng/source/items/itemtype.cxx b/editeng/source/items/itemtype.cxx
index 5673c59cd76f..620cdadd8b7e 100644
--- a/editeng/source/items/itemtype.cxx
+++ b/editeng/source/items/itemtype.cxx
@@ -44,7 +44,7 @@ OUString GetMetricText( long nVal, MapUnit eSrcUnit, MapUnit eDestUnit, const In
         case MapUnit::MapMM:
         case MapUnit::MapCM:
         {
-            nRet = (long)OutputDevice::LogicToLogic( nVal, eSrcUnit, MapUnit::Map100thMM );
+            nRet = OutputDevice::LogicToLogic( nVal, eSrcUnit, MapUnit::Map100thMM );
 
             switch ( eDestUnit )
             {
@@ -76,7 +76,7 @@ OUString GetMetricText( long nVal, MapUnit eSrcUnit, MapUnit eDestUnit, const In
         case MapUnit::MapPoint:
         case MapUnit::MapTwip:
         case MapUnit::MapPixel:
-            return OUString::number( (long)OutputDevice::LogicToLogic(
+            return OUString::number( OutputDevice::LogicToLogic(
                         nVal, eSrcUnit, eDestUnit ));
 
         default:
diff --git a/filter/source/flash/swfwriter1.cxx b/filter/source/flash/swfwriter1.cxx
index b3bdb5dff933..b66cd0ff2234 100644
--- a/filter/source/flash/swfwriter1.cxx
+++ b/filter/source/flash/swfwriter1.cxx
@@ -660,7 +660,7 @@ void Writer::Impl_writeText( const Point& rPos, const OUString& rText, const lon
         if( ( aOldFont.GetStrikeout() != STRIKEOUT_NONE ) || ( aOldFont.GetUnderline() != LINESTYLE_NONE ) )
         {
             tools::Polygon aPoly( 4 );
-            const long  nLineHeight = std::max( (long) FRound( aMetric.GetLineHeight() * 0.05 ), (long) 1 );
+            const long  nLineHeight = std::max<long>( FRound( aMetric.GetLineHeight() * 0.05 ), 1 );
 
             if( aOldFont.GetStrikeout() != STRIKEOUT_NONE )
             {
diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx
index 6bfb2476f3bd..dc9112c74a12 100644
--- a/filter/source/graphicfilter/eps/eps.cxx
+++ b/filter/source/graphicfilter/eps/eps.cxx
@@ -1685,7 +1685,7 @@ void PSWriter::ImplBmp( Bitmap* pBitmap, Bitmap* pMaskBitmap, const Point & rPoi
                     if ( nHeight > 10 )
                         nHeight = 8;
                 }
-                aRect = tools::Rectangle( Point( 0, nHeightOrg - nHeightLeft ), Size( (long)nWidth, (long)nHeight ) );
+                aRect = tools::Rectangle( Point( 0, nHeightOrg - nHeightLeft ), Size( nWidth, nHeight ) );
                 aRegion = vcl::Region( pMaskBitmap->CreateRegion( COL_BLACK, aRect ) );
 
                 if( mnLevel == 1 )
diff --git a/filter/source/graphicfilter/ios2met/ios2met.cxx b/filter/source/graphicfilter/ios2met/ios2met.cxx
index e2ebb601d1d6..565486f4df0e 100644
--- a/filter/source/graphicfilter/ios2met/ios2met.cxx
+++ b/filter/source/graphicfilter/ios2met/ios2met.cxx
@@ -1070,7 +1070,7 @@ void OS2METReader::ReadChrStr(bool bGivenPos, bool bMove, bool bExtra, sal_uInt1
         aDummyPoly.SetPoint( Point( aP0.X(), aP0.Y() - aSize.Height() ), 1);                // BOTTOM LEFT
         aDummyPoly.SetPoint( Point( aP0.X() + aSize.Width(), aP0.Y() ), 2);                 // TOP RIGHT
         aDummyPoly.SetPoint( Point( aP0.X() + aSize.Width(), aP0.Y() - aSize.Height() ), 3);// BOTTOM RIGHT
-        aDummyPoly.Rotate( aP0, (short)aAttr.nChrAng );
+        aDummyPoly.Rotate( aP0, aAttr.nChrAng );
         if ( bMove )
             aAttr.aCurPos = aDummyPoly.GetPoint( 0 );
         aCalcBndRect.Union( tools::Rectangle( aDummyPoly.GetPoint( 0 ), aDummyPoly.GetPoint( 3 ) ) );
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index e271db6cfceb..93329daf02f9 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -2680,7 +2680,7 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const OUString& rText,
         if( rFont.GetStrikeout() != STRIKEOUT_NONE || rFont.GetUnderline() != LINESTYLE_NONE )
         {
             tools::Polygon aPoly( 4 );
-            const long  nLineHeight = std::max( (long) FRound( aMetric.GetLineHeight() * 0.05 ), (long) 1 );
+            const long  nLineHeight = std::max<long>( FRound( aMetric.GetLineHeight() * 0.05 ), 1 );
 
             if( rFont.GetStrikeout() )
             {
diff --git a/lotuswordpro/source/filter/localtime.cxx b/lotuswordpro/source/filter/localtime.cxx
index c243a36c07c0..9bb702b27271 100644
--- a/lotuswordpro/source/filter/localtime.cxx
+++ b/lotuswordpro/source/filter/localtime.cxx
@@ -78,7 +78,7 @@ bool LtgGmTime(long rtime,LtTm& rtm)
     long tmptim;
     long caltim = rtime;
     tmptim = (long)(caltim / FOURYEAR_SEC);
-    caltim -= ((long)tmptim * FOURYEAR_SEC);
+    caltim -= tmptim * FOURYEAR_SEC;
 
     //Determine which year of the interval
 
@@ -121,7 +121,7 @@ bool LtgGmTime(long rtime,LtTm& rtm)
     //Leave caltim with number of elapsed seconds in that day.
 
     rtm.tm_yday = (long)(caltim / DAY_SEC);
-    caltim -= (long)(rtm.tm_yday) * DAY_SEC;
+    caltim -= rtm.tm_yday * DAY_SEC;
 
     //Determine months since January (0 - 11) and day of month (1 - 31)
 
@@ -153,7 +153,7 @@ bool LtgGmTime(long rtime,LtTm& rtm)
     //(0 - 59), and seconds after the minute (0 - 59).
 
     rtm.tm_hour = (long)(caltim / 3600);
-    caltim -= (long)rtm.tm_hour * 3600;
+    caltim -= rtm.tm_hour * 3600;
 
     rtm.tm_min = (long)(caltim / 60);
     rtm.tm_sec = (long)(caltim - (rtm.tm_min) * 60);
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index c4add975c7a7..64e655b0a7f3 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -714,8 +714,8 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
 
         // Calculations and values as in detfunc.cxx
 
-        Size aSize( (long)( TwipsToHmm( pDoc->GetColWidth( nCol1, nTab1) ) ),
-                    (long)( TwipsToHmm( pDoc->GetRowHeight( nRow1, nTab1) ) ) );
+        Size aSize( TwipsToHmm( pDoc->GetColWidth( nCol1, nTab1) ),
+                    TwipsToHmm( pDoc->GetRowHeight( nRow1, nTab1) ) );
         tools::Rectangle aRect( aPos, aSize );
         aRect.Left()    -= 250;
         aRect.Right()   += 250;
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
index 132267515eb6..f8091dcdff64 100644
--- a/sc/source/ui/view/preview.cxx
+++ b/sc/source/ui/view/preview.cxx
@@ -1055,8 +1055,8 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
 
         aButtonUpPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
 
-        long  nWidth = (long) lcl_GetDocPageSize(&pDocShell->GetDocument(), nTab).Width();
-        long  nHeight = (long) lcl_GetDocPageSize(&pDocShell->GetDocument(), nTab).Height();
+        long  nWidth = lcl_GetDocPageSize(&pDocShell->GetDocument(), nTab).Width();
+        long  nHeight = lcl_GetDocPageSize(&pDocShell->GetDocument(), nTab).Height();
 
         if( rMEvt.IsLeft() && GetPointer() == PointerStyle::HSizeBar )
         {
@@ -1309,8 +1309,8 @@ void ScPreview::MouseMove( const MouseEvent& rMEvt )
     long    nTopMargin = 0;
     long    nBottomMargin = 0;
 
-    long    nWidth = (long) lcl_GetDocPageSize(&pDocShell->GetDocument(), nTab).Width();
-    long    nHeight = (long) lcl_GetDocPageSize(&pDocShell->GetDocument(), nTab).Height();
+    long    nWidth = lcl_GetDocPageSize(&pDocShell->GetDocument(), nTab).Width();
+    long    nHeight = lcl_GetDocPageSize(&pDocShell->GetDocument(), nTab).Height();
 
     if ( nPageNo < nTotalPages )
     {
@@ -1563,8 +1563,8 @@ void ScPreview::DragMove( long nDragMovePos, PointerStyle nFlags )
 
 void ScPreview::DrawInvert( long nDragPos, PointerStyle nFlags )
 {
-    long  nHeight = (long) lcl_GetDocPageSize( &pDocShell->GetDocument(), nTab ).Height();
-    long  nWidth = (long) lcl_GetDocPageSize( &pDocShell->GetDocument(), nTab ).Width();
+    long  nHeight = lcl_GetDocPageSize( &pDocShell->GetDocument(), nTab ).Height();
+    long  nWidth = lcl_GetDocPageSize( &pDocShell->GetDocument(), nTab ).Width();
     if( nFlags == PointerStyle::HSizeBar || nFlags == PointerStyle::HSplit )
     {
         tools::Rectangle aRect( nDragPos, -aOffset.Y(), nDragPos + 1,(long)( ( nHeight * HMM_PER_TWIPS ) - aOffset.Y()));
diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx
index 6f88b159c6ac..9a084422fc29 100644
--- a/sd/source/ui/view/drtxtob1.cxx
+++ b/sd/source/ui/view/drtxtob1.cxx
@@ -162,7 +162,7 @@ void TextObjectBar::Execute( SfxRequest &rReq )
                         else
                         {
                             nUpper -= 100;
-                            nUpper = std::max( (long) nUpper, 0L );
+                            nUpper = std::max<long>( nUpper, 0 );
                         }
                         pNewItem->SetUpper( (sal_uInt16) nUpper );
 
@@ -172,7 +172,7 @@ void TextObjectBar::Execute( SfxRequest &rReq )
                         else
                         {
                             nLower -= 100;
-                            nLower = std::max( (long) nLower, 0L );
+                            nLower = std::max<long>( nLower, 0 );
                         }
                         pNewItem->SetLower( (sal_uInt16) nLower );
 
@@ -203,7 +203,7 @@ void TextObjectBar::Execute( SfxRequest &rReq )
                     else
                     {
                         nUpper -= 100;
-                        nUpper = std::max( (long) nUpper, 0L );
+                        nUpper = std::max<long>( nUpper, 0 );
                     }
                     pNewItem->SetUpper( (sal_uInt16) nUpper );
 
@@ -213,7 +213,7 @@ void TextObjectBar::Execute( SfxRequest &rReq )
                     else
                     {
                         nLower -= 100;
-                        nLower = std::max( (long) nLower, 0L );
+                        nLower = std::max<long>( nLower, 0 );
                     }
                     pNewItem->SetLower( (sal_uInt16) nLower );
 
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 0c9eb63b06a7..7cd022d38ea1 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -1136,7 +1136,7 @@ void DrawViewShell::FuSupport(SfxRequest& rReq)
         case SID_ZOOM_IN:  // BASIC
         {
             mbZoomOnPage = false;
-            SetZoom( std::max( (long) ( GetActiveWindow()->GetZoom() / 2 ), (long) GetActiveWindow()->GetMinZoom() ) );
+            SetZoom( std::max<long>( GetActiveWindow()->GetZoom() / 2, GetActiveWindow()->GetMinZoom() ) );
             ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
                                               GetActiveWindow()->GetOutputSizePixel()) );
             mpZoomList->InsertZoomRect(aVisAreaWin);
@@ -1150,7 +1150,7 @@ void DrawViewShell::FuSupport(SfxRequest& rReq)
         case SID_ZOOM_OUT:
         {
             mbZoomOnPage = false;
-            SetZoom( std::min( (long) ( GetActiveWindow()->GetZoom() * 2 ), (long) GetActiveWindow()->GetMaxZoom() ) );
+            SetZoom( std::min<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 fc1ac93e8383..b3df9d061523 100644
--- a/sd/source/ui/view/outlnvs2.cxx
+++ b/sd/source/ui/view/outlnvs2.cxx
@@ -142,7 +142,7 @@ void OutlineViewShell::FuTemporary(SfxRequest &rReq)
 
         case SID_ZOOM_OUT:
         {
-            SetZoom( std::min( (long) ( GetActiveWindow()->GetZoom() * 2 ), (long) GetActiveWindow()->GetMaxZoom() ) );
+            SetZoom( std::min<long>( GetActiveWindow()->GetZoom() * 2, GetActiveWindow()->GetMaxZoom() ) );
             ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
                                              GetActiveWindow()->GetOutputSizePixel()) );
             mpZoomList->InsertZoomRect(aVisAreaWin);
@@ -169,7 +169,7 @@ void OutlineViewShell::FuTemporary(SfxRequest &rReq)
 
         case SID_ZOOM_IN:
         {
-            SetZoom( std::max( (long) ( GetActiveWindow()->GetZoom() / 2 ), (long) GetActiveWindow()->GetMinZoom() ) );
+            SetZoom( std::max<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 97b709768cb4..f54d8df16cd1 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -790,9 +790,9 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi
                         Point aOldMousePos = GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel());
 
                         if( pData->GetDelta() < 0L )
-                            nNewZoom = std::max( (long) pWin->GetMinZoom(), basegfx::zoomtools::zoomOut( nOldZoom ));
+                            nNewZoom = std::max<long>( pWin->GetMinZoom(), basegfx::zoomtools::zoomOut( nOldZoom ));
                         else
-                            nNewZoom = std::min( (long) pWin->GetMaxZoom(), basegfx::zoomtools::zoomIn( nOldZoom ));
+                            nNewZoom = std::min<long>( pWin->GetMaxZoom(), basegfx::zoomtools::zoomIn( nOldZoom ));
 
                         SetZoom( nNewZoom );
                         // Keep mouse at same doc point before zoom
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index ed6a04ad4b90..80841f320f16 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -1205,13 +1205,13 @@ SvNumberformat::SvNumberformat(OUString& rString,
                         // type check
                         if (nIndex == 0)
                         {
-                            eType = (short) NumFor[nIndex].Info().eScannedType;
+                            eType = NumFor[nIndex].Info().eScannedType;
                         }
                         else if (nIndex == 3)
                         {   // #77026# Everything recognized IS text
                             NumFor[nIndex].Info().eScannedType = css::util::NumberFormat::TEXT;
                         }
-                        else if ( (short) NumFor[nIndex].Info().eScannedType != eType)
+                        else if ( NumFor[nIndex].Info().eScannedType != eType)
                         {
                             eType = css::util::NumberFormat::DEFINED;
                         }
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx
index c76a815ed040..9d96fcda4fa9 100644
--- a/svtools/source/brwbox/brwbox1.cxx
+++ b/svtools/source/brwbox/brwbox1.cxx
@@ -992,7 +992,7 @@ long BrowseBox::ScrollRows( long nRows )
     // compute new top row
     long nTmpMin = std::min( (long)(nTopRow + nRows), (long)(nRowCount - 1) );
 
-    long nNewTopRow = std::max( (long)nTmpMin, (long)0 );
+    long nNewTopRow = std::max<long>( nTmpMin, 0 );
 
     if ( nNewTopRow == nTopRow )
         return 0;
@@ -1005,7 +1005,7 @@ long BrowseBox::ScrollRows( long nRows )
     // compute new top row again (nTopRow might have changed!)
     nTmpMin = std::min( (long)(nTopRow + nRows), (long)(nRowCount - 1) );
 
-    nNewTopRow = std::max( (long)nTmpMin, (long)0 );
+    nNewTopRow = std::max<long>( nTmpMin, 0 );
 
     StartScroll();
 
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index 564bbcb5733b..0605f321e442 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -2448,7 +2448,7 @@ void SvTreeListBox::SetSpaceBetweenEntries( short nOffsLogic )
     if( nOffsLogic != nEntryHeightOffs )
     {
         nEntryHeight = nEntryHeight - nEntryHeightOffs;
-        nEntryHeightOffs = (short)nOffsLogic;
+        nEntryHeightOffs = nOffsLogic;
         nEntryHeight = nEntryHeight + nOffsLogic;
         AdjustEntryHeightAndRecalc();
         pImpl->SetEntryHeight( nEntryHeight );
diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
index f56ecb10073a..5ec8863f837d 100644
--- a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
+++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
@@ -275,7 +275,7 @@ void ParaPropertyPanel::StateChangedIndentImpl( sal_uInt16 /*nSID*/, SfxItemStat
         aTxtFirstLineOfst = OutputDevice::LogicToLogic( aTxtFirstLineOfst, MapUnit::Map100thMM, MapUnit::MapTwip );
 
         long nVal = OutputDevice::LogicToLogic( maTxtLeft, MapUnit::MapTwip, MapUnit::Map100thMM );
-        nVal = (long)mpLeftIndent->Normalize( (long)nVal );
+        nVal = (long)mpLeftIndent->Normalize( nVal );
 
         if ( maContext.GetCombinedContext_DI() != CombinedEnumContext(Application::WriterVariants, Context::Text)
              && maContext.GetCombinedContext_DI() != CombinedEnumContext(Application::WriterVariants, Context::Default)
@@ -285,7 +285,7 @@ void ParaPropertyPanel::StateChangedIndentImpl( sal_uInt16 /*nSID*/, SfxItemStat
         }
 
         long nrVal = OutputDevice::LogicToLogic( aTxtRight, MapUnit::MapTwip, MapUnit::Map100thMM );
-        nrVal = (long)mpRightIndent->Normalize( (long)nrVal );
+        nrVal = (long)mpRightIndent->Normalize( nrVal );
 
         switch (maContext.GetCombinedContext_DI())
         {
@@ -316,7 +316,7 @@ void ParaPropertyPanel::StateChangedIndentImpl( sal_uInt16 /*nSID*/, SfxItemStat
         mpRightIndent->SetValue( nrVal, FUNIT_100TH_MM );
 
         long nfVal = OutputDevice::LogicToLogic( aTxtFirstLineOfst, MapUnit::MapTwip, MapUnit::Map100thMM );
-        nfVal = (long)mpFLineIndent->Normalize( (long)nfVal );
+        nfVal = (long)mpFLineIndent->Normalize( nfVal );
         mpFLineIndent->SetValue( nfVal, FUNIT_100TH_MM );
     }
     else if( eState == SfxItemState::DISABLED )
diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx
index faf5a8bc5adb..83ceece5b427 100644
--- a/sw/source/core/inc/swfont.hxx
+++ b/sw/source/core/inc/swfont.hxx
@@ -723,8 +723,8 @@ inline void SwSubFont::SetSize( const Size& rSize )
     else
     {
         Font::SetFontSize( Size(
-            (long) m_aSize.Width() * GetPropr() / 100L,
-            (long) m_aSize.Height() * GetPropr() / 100L ) );
+            m_aSize.Width() * GetPropr() / 100L,
+            m_aSize.Height() * GetPropr() / 100L ) );
     }
     m_pMagic = nullptr;
 }
@@ -752,8 +752,8 @@ inline void SwFont::SetActual( SwFontScript nNew )
 inline void SwSubFont::SetProportion( const sal_uInt8 nNewPropr )
 {
     m_pMagic = nullptr;
-    Font::SetFontSize( Size( (long) m_aSize.Width() * nNewPropr / 100L,
-                         (long) m_aSize.Height() * nNewPropr / 100L ) );
+    Font::SetFontSize( Size( m_aSize.Width() * nNewPropr / 100L,
+                             m_aSize.Height() * nNewPropr / 100L ) );
     SvxFont::SetPropr( nNewPropr );
 }
 
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index 4348d2d1344c..1477ea9d0ef2 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -1286,8 +1286,8 @@ SwFootnoteSave::SwFootnoteSave( const SwTextSizeInfo &rInf,
         if ( ! pOld->GetEscapement() && 50 == pOld->GetPropr() )
         {
             Size aSize = pFnt->GetSize( pFnt->GetActual() );
-            pFnt->SetSize( Size( (long)aSize.Width() / 2,
-                                 (long)aSize.Height() / 2 ),
+            pFnt->SetSize( Size( aSize.Width() / 2,
+                                 aSize.Height() / 2 ),
                            pFnt->GetActual() );
         }
 
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index afbf49ceef17..8f5aa484af96 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -2915,7 +2915,7 @@ static Writer& OutCSS1_SvxLRSpace( Writer& rWrt, const SfxPoolItem& rHt )
     // match that of the current template
 
     // A left margin can exist because of a list nearby
-    long nLeftMargin = (long)rLRItem.GetTextLeft() - rHTMLWrt.m_nLeftMargin;
+    long nLeftMargin = rLRItem.GetTextLeft() - rHTMLWrt.m_nLeftMargin;
     if( rHTMLWrt.m_nDfltLeftMargin != nLeftMargin )
     {
         rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_left, nLeftMargin );
@@ -2928,8 +2928,7 @@ static Writer& OutCSS1_SvxLRSpace( Writer& rWrt, const SfxPoolItem& rHt )
 
     if( rHTMLWrt.m_nDfltRightMargin != rLRItem.GetRight() )
     {
-        rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_right,
-                                 (long)rLRItem.GetRight() );
+        rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_right, rLRItem.GetRight() );
     }
 
     // The LineIndent of the first line might contain the room for numbering
@@ -2980,7 +2979,7 @@ static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
         pULItem->GetUpper() != rHTMLWrt.m_nDfltTopMargin &&
         pULItem->GetLower() != rHTMLWrt.m_nDfltBottomMargin )
     {
-        rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin, (long)pLRItem->GetLeft() );
+        rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin, pLRItem->GetLeft() );
     }
     else
     {
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 30127381c460..92f2affe9db0 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -4300,7 +4300,7 @@ void AttributeOutputBase::ParaLineSpacing( const SvxLineSpacingItem& rSpacing )
             {
                 // gibt es aber nicht in WW - also wie kommt man an
                 // die MaxLineHeight heran?
-                nSpace = (short)rSpacing.GetInterLineSpace();
+                nSpace = rSpacing.GetInterLineSpace();
                 sal_uInt16 nScript =
                     i18n::ScriptType::LATIN;
                 const SwAttrSet *pSet = nullptr;
diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx
index 25ed16527b75..f9ce09be85f2 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -1274,8 +1274,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
 
         case SID_ATTR_LONG_LRSPACE:
         {
-            SvxLongLRSpaceItem aLongLR( (long)aPageLRSpace.GetLeft(),
-                                        (long)aPageLRSpace.GetRight(),
+            SvxLongLRSpaceItem aLongLR( aPageLRSpace.GetLeft(),
+                                        aPageLRSpace.GetRight(),
                                         SID_ATTR_LONG_LRSPACE);
             if(bBrowse)
             {
@@ -1293,9 +1293,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                     SwRect aRect( rSh.GetAnyCurRect( CurRectType::HeaderFooter, pPt));
                     aRect.Pos() -= rSh.GetAnyCurRect( CurRectType::Page, pPt ).Pos();
                     const SvxLRSpaceItem& aLR = pFormat->GetLRSpace();
-                    aLongLR.SetLeft ( (long)aLR.GetLeft() + (long)aRect.Left() );
-                    aLongLR.SetRight( (nPageWidth -
-                                        (long)aRect.Right() + (long)aLR.GetRight()));
+                    aLongLR.SetLeft ( aLR.GetLeft() + aRect.Left() );
+                    aLongLR.SetRight( nPageWidth - aRect.Right() + aLR.GetRight() );
                 }
             }
             else
@@ -1338,8 +1337,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
         {
             const SvxLRSpaceItem aTmpPageLRSpace( rDesc.GetMaster().GetLRSpace() );
             const SvxLongLRSpaceItem aLongLR(
-                (long)aTmpPageLRSpace.GetLeft(),
-                (long)aTmpPageLRSpace.GetRight(),
+                aTmpPageLRSpace.GetLeft(),
+                aTmpPageLRSpace.GetRight(),
                 SID_ATTR_PAGE_LRSPACE );
             rSet.Put( aLongLR );
         }
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 353638ea984d..f239215bba68 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1315,8 +1315,8 @@ void Polygon::Rotate( const Point& rCenter, double fSin, double fCos )
 
         const long nX = rPt.X() - nCenterX;
         const long nY = rPt.Y() - nCenterY;
-        rPt.X() = (long) FRound( fCos * nX + fSin * nY ) + nCenterX;
-        rPt.Y() = -(long) FRound( fSin * nX - fCos * nY ) + nCenterY;
+        rPt.X() = FRound( fCos * nX + fSin * nY ) + nCenterX;
+        rPt.Y() = - FRound( fSin * nX - fCos * nY ) + nCenterY;
     }
 }
 
diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
index 32bb5469e885..3747e7df27d0 100644
--- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx
+++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
@@ -82,7 +82,7 @@ public:
         Date aDateNow( Date::SYSTEM );
         tools::Time aTimeNow( tools::Time::SYSTEM );
          Date aRefDate( 1,1,1900 );
-        long nDiffDays = (long)(aDateNow - aRefDate);
+        long nDiffDays = aDateNow - aRefDate;
         nDiffDays += 2; // Change VisualBasic: 1.Jan.1900 == 2
 
         long nDiffSeconds = aTimeNow.GetHour() * 3600 + aTimeNow.GetMin() * 60 + aTimeNow.GetSec();
diff --git a/vcl/qa/cppunit/fontmetric.cxx b/vcl/qa/cppunit/fontmetric.cxx
index b8c1f4282afc..7fdd531c52b3 100644
--- a/vcl/qa/cppunit/fontmetric.cxx
+++ b/vcl/qa/cppunit/fontmetric.cxx
@@ -55,27 +55,27 @@ void VclFontMetricTest::testSpacings()
     // default constructor should set scalable flag to false
     FontMetric aFontMetric;
 
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetAscent(), 0L );
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetDescent(), 0L );
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetExternalLeading(), 0L );
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetInternalLeading(), 0L );
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetLineHeight(), 0L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetAscent(), 0L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetDescent(), 0L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetExternalLeading(), 0L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetInternalLeading(), 0L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetLineHeight(), 0L );
 
 
     aFontMetric.SetAscent( 100 );
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetAscent(), 100L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetAscent(), 100L );
 
     aFontMetric.SetDescent( 100 );
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetDescent(), 100L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetDescent(), 100L );
 
     aFontMetric.SetExternalLeading( 100L );
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetExternalLeading(), 100L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetExternalLeading(), 100L );
 
     aFontMetric.SetInternalLeading( 100L );
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetInternalLeading(), 100L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetInternalLeading(), 100L );
 
     aFontMetric.SetLineHeight( 100L );
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetLineHeight(), 100L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetLineHeight(), 100L );
 }
 
 void VclFontMetricTest::testSlant()
@@ -83,10 +83,10 @@ void VclFontMetricTest::testSlant()
     // default constructor should set scalable flag to false
     FontMetric aFontMetric;
 
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetSlant(), 0L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetSlant(), 0L );
 
     aFontMetric.SetSlant( 45 );
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetSlant(), 45L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetSlant(), 45L );
 }
 
 void VclFontMetricTest::testBulletOffset()
@@ -94,10 +94,10 @@ void VclFontMetricTest::testBulletOffset()
     // default constructor should set scalable flag to false
     FontMetric aFontMetric;
 
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetBulletOffset(), 0L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetBulletOffset(), 0L );
 
     aFontMetric.SetBulletOffset( 45 );
-    CPPUNIT_ASSERT_EQUAL( (long) aFontMetric.GetBulletOffset(), 45L );
+    CPPUNIT_ASSERT_EQUAL( aFontMetric.GetBulletOffset(), 45L );
 }
 
 void VclFontMetricTest::testEqualityOperator()
diff --git a/vcl/qa/cppunit/graphicfilter/filters-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-test.cxx
index 6c0eedffb1f7..78477d4846e4 100644
--- a/vcl/qa/cppunit/graphicfilter/filters-test.cxx
+++ b/vcl/qa/cppunit/graphicfilter/filters-test.cxx
@@ -70,8 +70,7 @@ void VclFiltersTest::testScaling()
         fprintf( stderr, "scale with type %d\n", int( i ) );
         CPPUNIT_ASSERT( aBitmapEx.Scale( 0.1937046, 0.193154, i ) );
         Size aAfter( aBitmapEx.GetSizePixel() );
-        fprintf( stderr, "size %ld, %ld\n", (long)aAfter.Width(),
-                 aAfter.Height() );
+        fprintf( stderr, "size %ld, %ld\n", aAfter.Width(), aAfter.Height() );
         CPPUNIT_ASSERT( labs (aAfter.Height() - aAfter.Width()) <= 1 );
     }
 }
diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx
index 30c33bcd36b1..3a172718572c 100644
--- a/vcl/source/gdi/bitmap4.cxx
+++ b/vcl/source/gdi/bitmap4.cxx
@@ -1074,8 +1074,8 @@ void Bitmap::ImplBlurContributions( const int aSize, const int aNumberOfContribu
 
     for ( int i = 0; i < aSize; i++ )
     {
-        aLeft = (int)  i - aNumberOfContributions / 2;
-        aRight = (int) i + aNumberOfContributions / 2;
+        aLeft  = i - aNumberOfContributions / 2;
+        aRight = i + aNumberOfContributions / 2;
         aCurrentCount = 0;
         for ( int j = aLeft; j <= aRight; j++ )
         {
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index 15265890345d..aa2aefa5f760 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -1093,8 +1093,8 @@ void PNGReaderImpl::ImplApplyFilter()
                 int nb = *(p3++);
                 int nc = *(p4++);
 
-                int npa = nb - (int)nc;
-                int npb = na - (int)nc;
+                int npa = nb - nc;
+                int npb = na - nc;
                 int npc = npa + npb;
 
                 if( npa < 0 )
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 6f24bfb72229..668ed11b9067 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -1576,7 +1576,7 @@ Size Menu::ImplCalcSize( vcl::Window* pWin )
             pData->aSz.Height() += EXTRAITEMHEIGHT; // little bit more distance
 
             if (!IsMenuBar())
-                aSz.Height() += (long)pData->aSz.Height();
+                aSz.Height() += pData->aSz.Height();
 
             if ( nWidth > nMaxWidth )
                 nMaxWidth = nWidth;
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index 8301e75774df..5517b47c894d 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -781,8 +781,8 @@ bool X11SalBitmap::Create(
                                     depth,
                                     0,
                                     0,
-                                    (long) rSize.Width(),
-                                    (long) rSize.Height()
+                                    rSize.Width(),
+                                    rSize.Height()
                                 );
                 bool bFreePixmap = false;
                 if( bSuccess && (args[0] >>= bFreePixmap) && bFreePixmap )
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index fcbe5c0456c6..f8dfbd385d96 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -1713,13 +1713,13 @@ void X11SalFrame::SetWindowState( const SalFrameState *pState )
 
                 // adjust position so that frame fits onto screen
                 if( aPosSize.Right()+(long)aGeom.nRightDecoration > aScreenSize.Width()-1 )
-                    aPosSize.Move( (long)aScreenSize.Width() - (long)aPosSize.Right() - (long)aGeom.nRightDecoration, 0 );
+                    aPosSize.Move( aScreenSize.Width() - aPosSize.Right() - (long)aGeom.nRightDecoration, 0 );
                 if( aPosSize.Bottom()+(long)aGeom.nBottomDecoration > aScreenSize.Height()-1 )
-                    aPosSize.Move( 0, (long)aScreenSize.Height() - (long)aPosSize.Bottom() - (long)aGeom.nBottomDecoration );
+                    aPosSize.Move( 0, aScreenSize.Height() - aPosSize.Bottom() - (long)aGeom.nBottomDecoration );
                 if( aPosSize.Left() < (long)aGeom.nLeftDecoration )
-                    aPosSize.Move( (long)aGeom.nLeftDecoration - (long)aPosSize.Left(), 0 );
+                    aPosSize.Move( (long)aGeom.nLeftDecoration - aPosSize.Left(), 0 );
                 if( aPosSize.Top() < (long)aGeom.nTopDecoration )
-                    aPosSize.Move( 0, (long)aGeom.nTopDecoration - (long)aPosSize.Top() );
+                    aPosSize.Move( 0, (long)aGeom.nTopDecoration - aPosSize.Top() );
             }
 
             SetPosSize( 0, 0, aPosSize.GetWidth(), aPosSize.GetHeight(), SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT );
diff --git a/writerperfect/source/common/WPXSvInputStream.cxx b/writerperfect/source/common/WPXSvInputStream.cxx
index 4137cd6f5425..c02734f02aeb 100644
--- a/writerperfect/source/common/WPXSvInputStream.cxx
+++ b/writerperfect/source/common/WPXSvInputStream.cxx
@@ -731,7 +731,7 @@ void WPXSvInputStreamImpl::invalidateReadBuffer()
 {
     if (mpReadBuffer)
     {
-        seek((long) tell() + (long)mnReadBufferPos - (long)mnReadBufferLength);
+        seek(tell() + (long)mnReadBufferPos - (long)mnReadBufferLength);
         mpReadBuffer = nullptr;
         mnReadBufferPos = 0;
         mnReadBufferLength = 0;
@@ -910,7 +910,7 @@ int WPXSvInputStream::seek(long offset, librevenge::RVNG_SEEK_TYPE seekType)
 
     if (tmpOffset < mpImpl->tell() && (unsigned long)tmpOffset >= (unsigned long)mpImpl->tell() - mpImpl->mnReadBufferLength)
     {
-        mpImpl->mnReadBufferPos = (unsigned long)(tmpOffset + (long) mpImpl->mnReadBufferLength - (long) mpImpl->tell());
+        mpImpl->mnReadBufferPos = (unsigned long)(tmpOffset + (long) mpImpl->mnReadBufferLength - mpImpl->tell());
         return retVal;
     }
 


More information about the Libreoffice-commits mailing list