compilerplugins/clang/redundantcast.cxx | 16 ++++++++++++++-- svx/source/customshapes/EnhancedCustomShape2d.cxx | 5 ----- sw/source/ui/vba/vbaparagraphformat.cxx | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-)
New commits: commit ae39b1ef2dcc9ef7784ff002dd10318564931c2b Author: Stephan Bergmann <sberg...@redhat.com> Date: Wed May 16 16:50:20 2018 +0200 Further loplugin:redundantcast improvements for floating-integer conversions The code in svx/source/customshapes/EnhancedCustomShape2d.cxx started out as > aStart.X() = (sal_Int32)( ( (double)( aStart.X() - aCenter.X() ) / fXScale ) ) + aCenter.X(); > aStart.Y() = (sal_Int32)( ( (double)( aStart.Y() - aCenter.Y() ) / fYScale ) ) + aCenter.Y(); > aEnd.X() = (sal_Int32)( ( (double)( aEnd.X() - aCenter.X() ) / fXScale ) ) + aCenter.X(); > aEnd.Y() = (sal_Int32)( ( (double)( aEnd.Y() - aCenter.Y() ) / fYScale ) ) + aCenter.Y(); in afd1cf255d9cb4c78633e668376a09bd309be7ef "INTEGRATION: CWS sj05", then the floating-point scaling factors got gradually removed first with 101559f88022162ede229fe14366d394700816fe "INTEGRATION: CWS bm3" and then completely with d9f21c90bd61d15fd78a8df9115bf2e9ededbd1b "Fixes Circular arrow distortion, Bug #46272". Change-Id: I337d7893e513738c986d0e85efabcbf7bab912e5 Reviewed-on: https://gerrit.libreoffice.org/54434 Reviewed-by: Stephan Bergmann <sberg...@redhat.com> Tested-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 66b81941e579..b6db47495a6d 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -65,6 +65,18 @@ char const * printExprValueKind(ExprValueKind k) { llvm_unreachable("unknown ExprValueKind"); } +enum class AlgebraicType { None, Integer, FloatingPoint }; + +AlgebraicType algebraicType(clang::Type const & type) { + if (type.isIntegralOrEnumerationType()) { + return AlgebraicType::Integer; + } else if (type.isRealFloatingType()) { + return AlgebraicType::FloatingPoint; + } else { + return AlgebraicType::None; + } +} + class RedundantCast: public RecursiveASTVisitor<RedundantCast>, public loplugin::RewritePlugin { @@ -252,8 +264,8 @@ bool RedundantCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) { case CK_IntegralToFloating: if (auto e = dyn_cast<ExplicitCastExpr>(expr->getSubExpr()->IgnoreParenImpCasts())) { if ((isa<CXXStaticCastExpr>(e) || isa<CXXFunctionalCastExpr>(e)) - && (e->getSubExprAsWritten()->getType().getCanonicalType().getTypePtr() - == expr->getType().getCanonicalType().getTypePtr())) + && (algebraicType(*e->getSubExprAsWritten()->getType()) + == algebraicType(*expr->getType()))) { report( DiagnosticsEngine::Warning, diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index b3d1c996a4f2..56fba266c325 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -1790,13 +1790,8 @@ void EnhancedCustomShape2d::CreateSubPath( tools::Rectangle aRect( GetPoint( seqCoordinates[ rSrcPt ], true, true ), GetPoint( seqCoordinates[ rSrcPt + 1 ], true, true ) ); if ( aRect.GetWidth() && aRect.GetHeight() ) { - Point aCenter( aRect.Center() ); Point aStart( GetPoint( seqCoordinates[ static_cast<sal_uInt16>( rSrcPt + nXor ) ], true, true ) ); Point aEnd( GetPoint( seqCoordinates[ static_cast<sal_uInt16>( rSrcPt + ( nXor ^ 1 ) ) ], true, true ) ); - aStart.setX( static_cast<sal_Int32>( static_cast<double>( aStart.X() - aCenter.X() ) ) + aCenter.X() ); - aStart.setY( static_cast<sal_Int32>( static_cast<double>( aStart.Y() - aCenter.Y() ) ) + aCenter.Y() ); - aEnd.setX( static_cast<sal_Int32>( static_cast<double>( aEnd.X() - aCenter.X() ) ) + aCenter.X() ); - aEnd.setY( static_cast<sal_Int32>( static_cast<double>( aEnd.Y() - aCenter.Y() ) ) + aCenter.Y() ); aNewB2DPolygon.append(CreateArc( aRect, aStart, aEnd, bClockwise)); } rSrcPt += 4; diff --git a/sw/source/ui/vba/vbaparagraphformat.cxx b/sw/source/ui/vba/vbaparagraphformat.cxx index 400488882b91..33f16d6f9d55 100644 --- a/sw/source/ui/vba/vbaparagraphformat.cxx +++ b/sw/source/ui/vba/vbaparagraphformat.cxx @@ -341,12 +341,12 @@ style::LineSpacing SwVbaParagraphFormat::getOOoLineSpacing( float _lineSpace, sa aLineSpacing.Mode = style::LineSpacingMode::PROP; aLineSpacing.Height = PERCENT100; } - else if( _lineSpace == sal_Int16( CHARACTER_INDENT_FACTOR * 1.5 ) ) + else if( _lineSpace == CHARACTER_INDENT_FACTOR * 1.5 ) // no rounding issues, == 18 { aLineSpacing.Mode = style::LineSpacingMode::PROP; aLineSpacing.Height = PERCENT150; } - else if( _lineSpace == sal_Int16( CHARACTER_INDENT_FACTOR * 2 ) ) + else if( _lineSpace == CHARACTER_INDENT_FACTOR * 2 ) { aLineSpacing.Mode = style::LineSpacingMode::PROP; aLineSpacing.Height = PERCENT200; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits