From 5685ee25aad4a4debb47fb5896082be48f521d17 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 14 Sep 2017 13:59:33 +0200 Subject: improve redundantcast loplugin to find c-style casts where the expression is a templated method Change-Id: Ifbd1e2cdc72d906fc95a7ec0f9408c3f6d2a836b Reviewed-on: https://gerrit.libreoffice.org/42275 Tested-by: Jenkins Reviewed-by: Noel Grandin --- compilerplugins/clang/redundantcast.cxx | 3 +++ compilerplugins/clang/test/redundantcast.cxx | 12 ++++++++++++ cui/source/tabpages/chardlg.cxx | 4 ++-- cui/source/tabpages/labdlg.cxx | 2 +- cui/source/tabpages/textattr.cxx | 12 +++++------- dbaccess/source/ui/misc/UITools.cxx | 2 +- editeng/source/editeng/editattr.cxx | 2 +- editeng/source/editeng/editdoc.cxx | 2 +- editeng/source/items/justifyitem.cxx | 8 ++++---- framework/source/services/substitutepathvars.cxx | 4 ++-- sc/source/core/data/attarray.cxx | 4 ++-- sc/source/core/data/column2.cxx | 10 +++++----- sc/source/core/data/patattr.cxx | 2 +- sc/source/core/data/table1.cxx | 2 +- sc/source/core/tool/editutil.cxx | 2 +- sc/source/ui/app/inputhdl.cxx | 2 +- sc/source/ui/docshell/docsh.cxx | 2 +- sc/source/ui/drawfunc/drtxtob.cxx | 2 +- sc/source/ui/miscdlgs/autofmt.cxx | 2 +- sc/source/ui/sidebar/AlignmentPropertyPanel.cxx | 4 ++-- sc/source/ui/view/formatsh.cxx | 8 ++++---- sc/source/ui/view/gridwin.cxx | 4 ++-- sc/source/ui/view/output.cxx | 6 +++--- sc/source/ui/view/output2.cxx | 10 +++++----- sc/source/ui/view/viewdata.cxx | 4 ++-- sd/source/ui/view/drviews2.cxx | 2 +- svtools/source/svhtml/parhtml.cxx | 6 +++--- svx/source/dialog/fntctrl.cxx | 4 ++-- svx/source/items/algitem.cxx | 2 +- svx/source/items/rotmodit.cxx | 2 +- sw/source/core/graphic/ndgrf.cxx | 2 +- sw/source/uibase/shells/drwtxtsh.cxx | 2 +- ucb/source/ucp/webdav-neon/NeonSession.cxx | 8 ++++---- 33 files changed, 78 insertions(+), 65 deletions(-) diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 19393e0c6449..32f7e8bd7fd9 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -294,6 +294,9 @@ bool RedundantCast::VisitCStyleCastExpr(CStyleCastExpr const * expr) { } auto t1 = compat::getSubExprAsWritten(expr)->getType(); auto t2 = expr->getTypeAsWritten(); + if (auto templateType = dyn_cast(t1)) { + t1 = templateType->desugar(); + } if (t1 != t2) { return true; } diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx index 9eda22a04b0f..db1268b8b87b 100644 --- a/compilerplugins/clang/test/redundantcast.cxx +++ b/compilerplugins/clang/test/redundantcast.cxx @@ -290,11 +290,23 @@ void testCStyleCast() { (void)e; } +template +struct EnumItemInterface { + T GetValue() { return static_cast(0); } +}; +class Enum1Item : public EnumItemInterface { +}; +bool testCStyleCastOfTemplateMethodResult(Enum1Item* item) { + return (Enum1)item->GetValue() == Enum1::X; // expected-error {{redundant cstyle cast from 'Enum1' to 'Enum1' [loplugin:redundantcast]}} +} + + int main() { testConstCast(); testStaticCast(); testFunctionalCast(); testCStyleCast(); + testCStyleCastOfTemplateMethodResult(nullptr); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index 8c67cf48f2e3..0703d70ea751 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -1968,7 +1968,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) case SfxItemState::SET: { const SvxCaseMapItem& rItem = static_cast(rSet->Get( nWhich )); - eCaseMap = (SvxCaseMap)rItem.GetValue(); + eCaseMap = rItem.GetValue(); break; } } @@ -2333,7 +2333,7 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet ) SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich ); const SvxCaseMapItem& rItem = *static_cast(pOld); - if ( (SvxCaseMap)rItem.GetValue() == eCaseMap && !bAllowChg ) + if ( rItem.GetValue() == eCaseMap && !bAllowChg ) bChanged = false; } diff --git a/cui/source/tabpages/labdlg.cxx b/cui/source/tabpages/labdlg.cxx index 3634ac82c565..b2cd972394b1 100644 --- a/cui/source/tabpages/labdlg.cxx +++ b/cui/source/tabpages/labdlg.cxx @@ -285,7 +285,7 @@ void SvxCaptionTabPage::Reset( const SfxItemSet* ) SetMetricValue( *m_pMF_ABSTAND, nGap, eUnit ); nGap = static_cast(m_pMF_ABSTAND->GetValue()); - nCaptionType = (SdrCaptionType)static_cast( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONTYPE ) ) ).GetValue(); + nCaptionType = static_cast( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONTYPE ) ) ).GetValue(); bFitLineLen = static_cast( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONFITLINELEN ) ) ).GetValue(); nEscDir = static_cast( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONESCDIR ) ) ).GetValue(); bEscRel = static_cast( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONESCISREL ) ) ).GetValue(); diff --git a/cui/source/tabpages/textattr.cxx b/cui/source/tabpages/textattr.cxx index b7cf03f7b81b..a56710534587 100644 --- a/cui/source/tabpages/textattr.cxx +++ b/cui/source/tabpages/textattr.cxx @@ -235,8 +235,8 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState) { // VertAdjust and HorAdjust are unequivocal, thus - SdrTextVertAdjust eTVA = (SdrTextVertAdjust)static_cast(rAttrs->Get(SDRATTR_TEXT_VERTADJUST)).GetValue(); - SdrTextHorzAdjust eTHA = (SdrTextHorzAdjust)static_cast(rAttrs->Get(SDRATTR_TEXT_HORZADJUST)).GetValue(); + SdrTextVertAdjust eTVA = static_cast(rAttrs->Get(SDRATTR_TEXT_VERTADJUST)).GetValue(); + SdrTextHorzAdjust eTHA = static_cast(rAttrs->Get(SDRATTR_TEXT_HORZADJUST)).GetValue(); RectPoint eRP = RectPoint::LB; m_pTsbFullWidth->EnableTriState( false ); @@ -309,7 +309,7 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) // adjust to border if ( rAttrs->GetItemState( SDRATTR_TEXT_FITTOSIZE ) != SfxItemState::DONTCARE ) { - SdrFitToSizeType eFTS = (SdrFitToSizeType) + SdrFitToSizeType eFTS = static_cast( rAttrs->Get( SDRATTR_TEXT_FITTOSIZE ) ).GetValue(); if( eFTS == SdrFitToSizeType::Autofit || eFTS == SdrFitToSizeType::NONE ) m_pTsbFitToSize->SetState( TRISTATE_FALSE ); @@ -462,8 +462,7 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs) if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::DONTCARE ) { - eOldTVA = (SdrTextVertAdjust) - static_cast( rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ) ).GetValue(); + eOldTVA = static_cast( rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ) ).GetValue(); if( eOldTVA != eTVA ) rAttrs->Put( SdrTextVertAdjustItem( eTVA ) ); } @@ -472,8 +471,7 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs) if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SfxItemState::DONTCARE ) { - eOldTHA = (SdrTextHorzAdjust) - static_cast( rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ) ).GetValue(); + eOldTHA = static_cast( rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ) ).GetValue(); if( eOldTHA != eTHA ) rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) ); } diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index 0970babdf37b..f9dbd8421ad3 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -859,7 +859,7 @@ bool callColumnFormatDialog(vcl::Window* _pParent, // horizontal justify const SvxHorJustifyItem* pHorJustify = pSet->GetItem(SBA_ATTR_ALIGN_HOR_JUSTIFY); - _eJustify = (SvxCellHorJustify)pHorJustify->GetValue(); + _eJustify = pHorJustify->GetValue(); // format key if (_bHasFormat) diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx index c4aa362fd7ee..b7f73341567d 100644 --- a/editeng/source/editeng/editattr.cxx +++ b/editeng/source/editeng/editattr.cxx @@ -473,7 +473,7 @@ EditCharAttribRelief::EditCharAttribRelief( const SvxCharReliefItem& rAttr, sal_ void EditCharAttribRelief::SetFont( SvxFont& rFont, OutputDevice* ) { - rFont.SetRelief( (FontRelief)static_cast(GetItem())->GetValue() ); + rFont.SetRelief( static_cast(GetItem())->GetValue() ); } // class EditCharAttribGrabBag diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 3b974ecdb0ef..2cd69c1c459e 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -2050,7 +2050,7 @@ void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent, S if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_EMPHASISMARK ) == SfxItemState::SET ) ) rFont.SetEmphasisMark( static_cast(rSet.Get( EE_CHAR_EMPHASISMARK )).GetEmphasisMark() ); if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_RELIEF ) == SfxItemState::SET ) ) - rFont.SetRelief( (FontRelief)static_cast(rSet.Get( EE_CHAR_RELIEF )).GetValue() ); + rFont.SetRelief( static_cast(rSet.Get( EE_CHAR_RELIEF )).GetValue() ); // If comparing the entire font, or if checking before each alteration // whether the value changes, remains relatively the same thing. diff --git a/editeng/source/items/justifyitem.cxx b/editeng/source/items/justifyitem.cxx index 70189308800a..1d7d55c63700 100644 --- a/editeng/source/items/justifyitem.cxx +++ b/editeng/source/items/justifyitem.cxx @@ -69,7 +69,7 @@ bool SvxHorJustifyItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const case MID_HORJUST_HORJUST: { table::CellHoriJustify eUno = table::CellHoriJustify_STANDARD; - switch ( (SvxCellHorJustify)GetValue() ) + switch ( GetValue() ) { case SvxCellHorJustify::Standard: eUno = table::CellHoriJustify_STANDARD; break; case SvxCellHorJustify::Left: eUno = table::CellHoriJustify_LEFT; break; @@ -87,7 +87,7 @@ bool SvxHorJustifyItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const // (same value for ParaAdjust and ParaLastLineAdjust) style::ParagraphAdjust nAdjust = style::ParagraphAdjust_LEFT; - switch ( (SvxCellHorJustify)GetValue() ) + switch ( GetValue() ) { // ParagraphAdjust_LEFT is used for STANDARD and REPEAT case SvxCellHorJustify::Standard: @@ -218,7 +218,7 @@ bool SvxVerJustifyItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const case MID_HORJUST_ADJUST: { style::VerticalAlignment eUno = style::VerticalAlignment_TOP; - switch ( (SvxCellVerJustify)GetValue() ) + switch ( GetValue() ) { case SVX_VER_JUSTIFY_TOP: eUno = style::VerticalAlignment_TOP; break; case SVX_VER_JUSTIFY_CENTER: eUno = style::VerticalAlignment_MIDDLE; break; @@ -231,7 +231,7 @@ bool SvxVerJustifyItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const default: { sal_Int32 nUno = table::CellVertJustify2::STANDARD; - switch ( (SvxCellVerJustify)GetValue() ) + switch ( GetValue() ) { case SVX_VER_JUSTIFY_STANDARD: nUno = table::CellVertJustify2::STANDARD; break; case SVX_VER_JUSTIFY_TOP: nUno = table::CellVertJustify2::TOP; break; diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx index c72771c47a0f..44a17f6ac6b7 100644 --- a/framework/source/services/substitutepathvars.cxx +++ b/framework/source/services/substitutepathvars.cxx @@ -359,7 +359,7 @@ OUString SubstitutePathVariables::impl_substituteVariable( const OUString& rText if ( pNTOIIter != m_aPreDefVarMap.end() ) { // Fixed/Predefined variable found - PreDefVariable nIndex = (PreDefVariable)pNTOIIter->second; + PreDefVariable nIndex = pNTOIIter->second; // Determine variable value and length from array/table if ( nIndex == PREDEFVAR_WORK && !bWorkRetrieved ) @@ -592,7 +592,7 @@ OUString const & SubstitutePathVariables::impl_getSubstituteVariableValue( const // Fixed/Predefined variable if ( pNTOIIter != m_aPreDefVarMap.end() ) { - PreDefVariable nIndex = (PreDefVariable)pNTOIIter->second; + PreDefVariable nIndex = pNTOIIter->second; return m_aPreDefVars.m_FixedVar[(sal_Int32)nIndex]; } else diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index c3023fed67a2..802c5ee9fa06 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -1358,7 +1358,7 @@ bool ScAttrArray::HasAttrib_Impl(const ScPatternAttr* pPattern, HasAttrFlags nMa bFound = true; else if (static_cast(pPattern->GetItem( ATTR_LINEBREAK )).GetValue()) bFound = true; - else if ((SvxCellHorJustify)static_cast(pPattern-> + else if (static_cast(pPattern-> GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SvxCellHorJustify::Block) bFound = true; @@ -1382,7 +1382,7 @@ bool ScAttrArray::HasAttrib_Impl(const ScPatternAttr* pPattern, HasAttrFlags nMa if ( nMask & HasAttrFlags::RightOrCenter ) { // called only if the sheet is LTR, so physical=logical alignment can be assumed - SvxCellHorJustify eHorJust = (SvxCellHorJustify) + SvxCellHorJustify eHorJust = static_cast( pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue(); if ( eHorJust == SvxCellHorJustify::Right || eHorJust == SvxCellHorJustify::Center ) bFound = true; diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 4f8183938a3c..7e072524c22e 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -144,9 +144,9 @@ long ScColumn::GetNeededSize( SvxCellHorJustify eHorJust; if (pCondSet && pCondSet->GetItemState(ATTR_HOR_JUSTIFY, true, &pCondItem) == SfxItemState::SET) - eHorJust = (SvxCellHorJustify)static_cast(pCondItem)->GetValue(); + eHorJust = static_cast(pCondItem)->GetValue(); else - eHorJust = (SvxCellHorJustify)static_cast( + eHorJust = static_cast( pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue(); bool bBreak; if ( eHorJust == SvxCellHorJustify::Block ) @@ -212,9 +212,9 @@ long ScColumn::GetNeededSize( { if (pCondSet && pCondSet->GetItemState(ATTR_ROTATE_MODE, true, &pCondItem) == SfxItemState::SET) - eRotMode = (SvxRotateMode)static_cast(pCondItem)->GetValue(); + eRotMode = static_cast(pCondItem)->GetValue(); else - eRotMode = (SvxRotateMode)static_cast( + eRotMode = static_cast( pPattern->GetItem(ATTR_ROTATE_MODE)).GetValue(); if ( nRotate == 18000 ) @@ -814,7 +814,7 @@ void ScColumn::GetOptimalHeight( if (bStdAllowed) { bool bBreak = static_cast(pPattern->GetItem(ATTR_LINEBREAK)).GetValue() || - ((SvxCellHorJustify)static_cast(pPattern-> + (static_cast(pPattern-> GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SvxCellHorJustify::Block); bStdOnly = !bBreak; diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index e61a217a353a..6b4d207cdf53 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -909,7 +909,7 @@ void ScPatternAttr::FillEditParaItems( SfxItemSet* pEditSet ) const const SfxItemSet& rMySet = GetItemSet(); - SvxCellHorJustify eHorJust = (SvxCellHorJustify) + SvxCellHorJustify eHorJust = static_cast(rMySet.Get(ATTR_HOR_JUSTIFY)).GetValue(); SvxAdjust eSvxAdjust; diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index ced6c3474f95..876289faa95b 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1922,7 +1922,7 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d const ScPatternAttr* pPattern = GetPattern( rCol, nRow ); const SfxItemSet* pCondSet = pDocument->GetCondResult( rCol, nRow, nTab ); - SvxCellHorJustify eHorJust = (SvxCellHorJustify)static_cast( + SvxCellHorJustify eHorJust = static_cast( pPattern->GetItem( ATTR_HOR_JUSTIFY, pCondSet )).GetValue(); if ( eHorJust == SvxCellHorJustify::Center ) nMissing /= 2; // distributed into both directions diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx index 383d8227468a..5198a270509e 100644 --- a/sc/source/core/tool/editutil.cxx +++ b/sc/source/core/tool/editutil.cxx @@ -317,7 +317,7 @@ tools::Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, bool bF long nPixDifY; long nTopMargin = (long) ( pMargin->GetTopMargin() * nPPTY ); - SvxCellVerJustify eJust = (SvxCellVerJustify) static_cast(pPattern-> + SvxCellVerJustify eJust = static_cast(pPattern-> GetItem(ATTR_VER_JUSTIFY)).GetValue(); // asian vertical is always edited top-aligned diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 52793a927060..017456c90123 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -2122,7 +2122,7 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bIn mpEditEngine->SetBackgroundColor( aBackCol ); // Adjustment - eAttrAdjust = (SvxCellHorJustify)static_cast(pPattern-> + eAttrAdjust = static_cast(pPattern-> GetItem(ATTR_HOR_JUSTIFY)).GetValue(); if ( eAttrAdjust == SvxCellHorJustify::Repeat && static_cast(pPattern->GetItem(ATTR_LINEBREAK)).GetValue() ) diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 19116b128b5e..febaf62ecfa2 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -2069,7 +2069,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt if ( bFixedWidth ) { - SvxCellHorJustify eHorJust = (SvxCellHorJustify) + SvxCellHorJustify eHorJust = static_cast( aDocument.GetAttr( nCol, nRow, nTab, ATTR_HOR_JUSTIFY ))->GetValue(); lcl_ScDocShell_GetFixedWidthString( aString, aDocument, nTab, nCol, diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index 41821ece63ef..1f0253266364 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -1237,7 +1237,7 @@ void ScDrawTextObjectBar::GetStatePropPanelAttr(SfxItemSet &rSet) //if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState) if(SfxItemState::DONTCARE != eVState) { - SdrTextVertAdjust eTVA = (SdrTextVertAdjust)static_cast(aEditAttr.Get(SDRATTR_TEXT_VERTADJUST)).GetValue(); + SdrTextVertAdjust eTVA = static_cast(aEditAttr.Get(SDRATTR_TEXT_VERTADJUST)).GetValue(); bool bSet = (nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP) || (nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER) || (nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM); diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx index 70bbc0b33b6e..01d71d232062 100644 --- a/sc/source/ui/miscdlgs/autofmt.cxx +++ b/sc/source/ui/miscdlgs/autofmt.cxx @@ -261,7 +261,7 @@ void ScAutoFmtPreview::DrawString(vcl::RenderContext& rRenderContext, size_t nCo // Justification: eJustification = mbRTL ? SvxCellHorJustify::Right : bJustify ? - (SvxCellHorJustify) (static_cast(pCurData->GetItem(nFmtIndex, ATTR_HOR_JUSTIFY))->GetValue()) : + static_cast(pCurData->GetItem(nFmtIndex, ATTR_HOR_JUSTIFY))->GetValue() : SvxCellHorJustify::Standard; if (pCurData->GetIncludeFont()) diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx index 98069a6a7080..da854a62ac10 100644 --- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx +++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx @@ -270,7 +270,7 @@ void AlignmentPropertyPanel::NotifyItemUpdate( if(eState >= SfxItemState::DEFAULT && pState && dynamic_cast( pState) != nullptr ) { const SvxHorJustifyItem* pItem = static_cast(pState); - meHorAlignState = (SvxCellHorJustify)pItem->GetValue(); + meHorAlignState = pItem->GetValue(); } if( meHorAlignState == SvxCellHorJustify::Repeat ) @@ -359,7 +359,7 @@ void AlignmentPropertyPanel::NotifyItemUpdate( if( eState >= SfxItemState::DEFAULT) { const SvxRotateModeItem* pItem = static_cast(pState); - SvxRotateMode eMode = (SvxRotateMode)pItem->GetValue(); + SvxRotateMode eMode = pItem->GetValue(); if(eMode == SVX_ROTATE_MODE_BOTTOM) { mpRefEdgeBottom->SetState(true); diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index e845a5798b44..885f0ed1f50a 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -1347,14 +1347,14 @@ void ScFormatShell::ExecuteAlignment( SfxRequest& rReq ) case SID_H_ALIGNCELL: { - SvxCellHorJustify eJust = (SvxCellHorJustify)static_cast(pItem)->GetValue(); + SvxCellHorJustify eJust = static_cast(pItem)->GetValue(); // #i78476# update alignment of text in cell edit mode pTabViewShell->UpdateInputHandlerCellAdjust( eJust ); pTabViewShell->ApplyAttr( SvxHorJustifyItem( eJust, ATTR_HOR_JUSTIFY ) ); } break; case SID_V_ALIGNCELL: - pTabViewShell->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify)static_cast(pItem)->GetValue(), ATTR_VER_JUSTIFY ) ); + pTabViewShell->ApplyAttr( SvxVerJustifyItem( static_cast(pItem)->GetValue(), ATTR_VER_JUSTIFY ) ); break; default: OSL_FAIL( "ExecuteAlignment: invalid slot" ); @@ -2443,12 +2443,12 @@ void ScFormatShell::GetAlignState( SfxItemSet& rSet ) SvxCellHorJustify eHAlign = SvxCellHorJustify::Standard; bool bHasHAlign = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY ) != SfxItemState::DONTCARE; if( bHasHAlign ) - eHAlign = (SvxCellHorJustify)static_cast(rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue(); + eHAlign = static_cast(rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue(); SvxCellVerJustify eVAlign = SVX_VER_JUSTIFY_STANDARD; bool bHasVAlign = rAttrSet.GetItemState( ATTR_VER_JUSTIFY ) != SfxItemState::DONTCARE; if( bHasVAlign ) - eVAlign = (SvxCellVerJustify)static_cast(rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue(); + eVAlign = static_cast(rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue(); while ( nWhich ) { diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index be4d38060249..b8ce47a144b2 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -5078,9 +5078,9 @@ bool ScGridWindow::GetEditUrl( const Point& rPos, return false; bool bBreak = static_cast(pPattern->GetItem(ATTR_LINEBREAK)).GetValue() || - ((SvxCellHorJustify)static_cast(pPattern-> + (static_cast(pPattern-> GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SvxCellHorJustify::Block); - SvxCellHorJustify eHorJust = (SvxCellHorJustify)static_cast(pPattern-> + SvxCellHorJustify eHorJust = static_cast(pPattern-> GetItem(ATTR_HOR_JUSTIFY)).GetValue(); // EditEngine diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 94e3f55d7b5c..98f8822a338b 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -656,7 +656,7 @@ void ScOutputData::SetCellRotations() // add rotation info to Array information const long nAttrRotate(pPattern->GetRotateVal(pCondSet)); - const SvxRotateMode eRotMode((SvxRotateMode)static_cast(pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue()); + const SvxRotateMode eRotMode(static_cast(pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue()); const double fOrient((bLayoutRTL ? -1.0 : 1.0) * nAttrRotate * F_PI18000); // 1/100th degrees -> [0..2PI] svx::frame::Array& rArray = mrTabInfo.maArray; @@ -678,7 +678,7 @@ static ScRotateDir lcl_GetRotateDir( const ScDocument* pDoc, SCCOL nCol, SCROW n long nAttrRotate = pPattern->GetRotateVal( pCondSet ); if ( nAttrRotate ) { - SvxRotateMode eRotMode = (SvxRotateMode)static_cast( + SvxRotateMode eRotMode = static_cast( pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue(); if ( eRotMode == SVX_ROTATE_MODE_STANDARD ) @@ -1548,7 +1548,7 @@ void ScOutputData::DrawRotatedFrame(vcl::RenderContext& rRenderContext) //! LastPattern etc. long nAttrRotate = pPattern->GetRotateVal( pCondSet ); - SvxRotateMode eRotMode = (SvxRotateMode)static_cast( + SvxRotateMode eRotMode = static_cast( pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue(); if (nAttrRotate) diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index a4aab11ba9bf..b324d40f872f 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -323,9 +323,9 @@ void ScDrawStringsVars::SetPattern( // alignment - eAttrHorJust = (SvxCellHorJustify)static_cast(pPattern->GetItem( ATTR_HOR_JUSTIFY, pCondSet )).GetValue(); + eAttrHorJust = static_cast(pPattern->GetItem( ATTR_HOR_JUSTIFY, pCondSet )).GetValue(); - eAttrVerJust = (SvxCellVerJustify)static_cast(pPattern->GetItem( ATTR_VER_JUSTIFY, pCondSet )).GetValue(); + eAttrVerJust = static_cast(pPattern->GetItem( ATTR_VER_JUSTIFY, pCondSet )).GetValue(); if ( eAttrVerJust == SVX_VER_JUSTIFY_STANDARD ) eAttrVerJust = SVX_VER_JUSTIFY_BOTTOM; @@ -4721,7 +4721,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) long nCellWidth = (long) pRowInfo[0].pCellInfo[nX+1].nWidth; - SvxCellHorJustify eHorJust = (SvxCellHorJustify)static_cast( + SvxCellHorJustify eHorJust = static_cast( pPattern->GetItem(ATTR_HOR_JUSTIFY, pCondSet)).GetValue(); bool bBreak = ( eHorJust == SvxCellHorJustify::Block ) || static_cast(pPattern->GetItem(ATTR_LINEBREAK, pCondSet)).GetValue(); @@ -4769,7 +4769,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) nOutHeight += (long) mpDoc->GetScaledRowHeight( nY+1, nY+nCountY-1, nTab, mnPPTY); } - SvxCellVerJustify eVerJust = (SvxCellVerJustify)static_cast( + SvxCellVerJustify eVerJust = static_cast( pPattern->GetItem(ATTR_VER_JUSTIFY, pCondSet)).GetValue(); // syntax mode is ignored here... @@ -4848,7 +4848,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) GetItem(ATTR_ROTATE_VALUE, pCondSet)).GetValue(); if ( nAttrRotate ) { - eRotMode = (SvxRotateMode)static_cast( + eRotMode = static_cast( pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue(); if ( nAttrRotate == 18000 ) diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 2f3a8f19e052..d978ef826292 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -1050,7 +1050,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich, bEditActive[eWhich] = true; const ScPatternAttr* pPattern = pDoc->GetPattern( nNewX, nNewY, nTabNo ); - SvxCellHorJustify eJust = (SvxCellHorJustify)static_cast( + SvxCellHorJustify eJust = static_cast( pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue(); bool bBreak = ( eJust == SvxCellHorJustify::Block ) || @@ -1256,7 +1256,7 @@ void ScViewData::EditGrowX() // get bGrow... variables the same way as in SetEditEngine const ScPatternAttr* pPattern = pLocalDoc->GetPattern( nEditCol, nEditRow, nTabNo ); - SvxCellHorJustify eJust = (SvxCellHorJustify)static_cast( + SvxCellHorJustify eJust = static_cast( pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue(); bool bGrowCentered = ( eJust == SvxCellHorJustify::Center ); bool bGrowToLeft = ( eJust == SvxCellHorJustify::Right ); // visual left diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 71da780084cf..3b6c3e2d54f1 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -3202,7 +3202,7 @@ void DrawViewShell::GetStatePropPanelAttr(SfxItemSet& rSet) //if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState) if(SfxItemState::DONTCARE != eVState) { - SdrTextVertAdjust eTVA = (SdrTextVertAdjust)static_cast(aAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue(); + SdrTextVertAdjust eTVA = static_cast(aAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue(); bool bSet = (nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP) || (nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER) || (nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM); diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx index 1ec0aa655c5f..1588187afeca 100644 --- a/svtools/source/svhtml/parhtml.cxx +++ b/svtools/source/svhtml/parhtml.cxx @@ -197,19 +197,19 @@ void HTMLOption::GetColor( Color& rColor ) const HTMLInputType HTMLOption::GetInputType() const { DBG_ASSERT( nToken==HtmlOptionId::TYPE, "GetInputType: Option not TYPE" ); - return (HTMLInputType)GetEnum( aInputTypeOptEnums, HTMLInputType::Text ); + return GetEnum( aInputTypeOptEnums, HTMLInputType::Text ); } HTMLTableFrame HTMLOption::GetTableFrame() const { DBG_ASSERT( nToken==HtmlOptionId::FRAME, "GetTableFrame: Option not FRAME" ); - return (HTMLTableFrame)GetEnum( aTableFrameOptEnums ); + return GetEnum( aTableFrameOptEnums ); } HTMLTableRules HTMLOption::GetTableRules() const { DBG_ASSERT( nToken==HtmlOptionId::RULES, "GetTableRules: Option not RULES" ); - return (HTMLTableRules)GetEnum( aTableRulesOptEnums ); + return GetEnum( aTableRulesOptEnums ); } HTMLParser::HTMLParser( SvStream& rIn, bool bReadNewDoc ) : diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx index e5d9225450c8..c78c8f481d47 100644 --- a/svx/source/dialog/fntctrl.cxx +++ b/svx/source/dialog/fntctrl.cxx @@ -1013,7 +1013,7 @@ void SvxFontPrevWindow::SetFromItemSet(const SfxItemSet &rSet, bool bPreviewBack if( GetWhich( rSet, SID_ATTR_CHAR_CASEMAP, nWhich ) ) { const SvxCaseMapItem& rItem = static_cast( rSet.Get( nWhich ) ); - SvxCaseMap eCaseMap = ( SvxCaseMap ) rItem.GetValue(); + SvxCaseMap eCaseMap = rItem.GetValue(); rFont.SetCaseMap( eCaseMap ); rCJKFont.SetCaseMap( eCaseMap ); // #i78474# small caps do not exist in CTL fonts @@ -1255,7 +1255,7 @@ void SvxFontPrevWindow::Init(const SfxItemSet& rSet) if( ISITEMSET ) { const SvxCaseMapItem& rItem = static_cast( rSet.Get( nWhich ) ); - SvxCaseMap eCaseMap = ( SvxCaseMap ) rItem.GetValue(); + SvxCaseMap eCaseMap = rItem.GetValue(); rFont.SetCaseMap( eCaseMap ); rCJKFont.SetCaseMap( eCaseMap ); // #i78474# small caps do not exist in CTL fonts diff --git a/svx/source/items/algitem.cxx b/svx/source/items/algitem.cxx index dee345f04569..3da88e3625b1 100644 --- a/svx/source/items/algitem.cxx +++ b/svx/source/items/algitem.cxx @@ -82,7 +82,7 @@ bool SvxOrientationItem::GetPresentation bool SvxOrientationItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const { table::CellOrientation eUno = table::CellOrientation_STANDARD; - switch ( (SvxCellOrientation)GetValue() ) + switch ( GetValue() ) { case SvxCellOrientation::Standard: eUno = table::CellOrientation_STANDARD; break; case SvxCellOrientation::TopBottom: eUno = table::CellOrientation_TOPBOTTOM; break; diff --git a/svx/source/items/rotmodit.cxx b/svx/source/items/rotmodit.cxx index 0a7b87322860..559f35a9e254 100644 --- a/svx/source/items/rotmodit.cxx +++ b/svx/source/items/rotmodit.cxx @@ -104,7 +104,7 @@ sal_uInt16 SvxRotateModeItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const bool SvxRotateModeItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const { sal_Int32 nUno = table::CellVertJustify2::STANDARD; - switch ( (SvxRotateMode)GetValue() ) + switch ( GetValue() ) { case SVX_ROTATE_MODE_STANDARD: nUno = table::CellVertJustify2::STANDARD; break; case SVX_ROTATE_MODE_TOP: nUno = table::CellVertJustify2::TOP; break; diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index 8501948cdd99..e6dd87bd0616 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -1020,7 +1020,7 @@ GraphicAttr& SwGrfNode::GetGraphicAttr( GraphicAttr& rGA, { const SwAttrSet& rSet = GetSwAttrSet(); - rGA.SetDrawMode( (GraphicDrawMode)rSet.GetDrawModeGrf().GetValue() ); + rGA.SetDrawMode( rSet.GetDrawModeGrf().GetValue() ); const SwMirrorGrf & rMirror = rSet.GetMirrorGrf(); BmpMirrorFlags nMirror = BmpMirrorFlags::NONE; diff --git a/sw/source/uibase/shells/drwtxtsh.cxx b/sw/source/uibase/shells/drwtxtsh.cxx index 96b553b49914..5c81891d0de2 100644 --- a/sw/source/uibase/shells/drwtxtsh.cxx +++ b/sw/source/uibase/shells/drwtxtsh.cxx @@ -855,7 +855,7 @@ void SwDrawTextShell::GetStatePropPanelAttr(SfxItemSet &rSet) //if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState) if(SfxItemState::DONTCARE != eVState) { - SdrTextVertAdjust eTVA = (SdrTextVertAdjust)static_cast(aAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue(); + SdrTextVertAdjust eTVA = static_cast(aAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue(); bool bSet = (nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP) || (nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER) || (nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM); diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx index 5f9addf184f9..1dcc6eb7a090 100644 --- a/ucb/source/ucp/webdav-neon/NeonSession.cxx +++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx @@ -796,15 +796,15 @@ void NeonSession::Init() // set the timeout (in seconds) used when making a connection sal_Int32 nConnectTimeout = officecfg::Inet::Settings::ConnectTimeout::get( rContext ); ne_set_connect_timeout( m_pHttpSession, - (int) ( std::max( nConnectTimeoutMin, - std::min( nConnectTimeout, nConnectTimeoutMax ) ) ) ); + std::max( nConnectTimeoutMin, + std::min( nConnectTimeout, nConnectTimeoutMax ) ) ); // provides a read time out facility as well // set the timeout (in seconds) used when reading from a socket. sal_Int32 nReadTimeout = officecfg::Inet::Settings::ReadTimeout::get( rContext ); ne_set_read_timeout( m_pHttpSession, - (int) ( std::max( nReadTimeoutMin, - std::min( nReadTimeout, nReadTimeoutMax ) ) ) ); + std::max( nReadTimeoutMin, + std::min( nReadTimeout, nReadTimeoutMax ) ) ); } } -- cgit