From 05db2098032f17085b7c3b47d02f617371eeddc0 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 12 Jan 2018 20:18:19 +0100 Subject: More loplugin:cstylecast: reportdesign auto-rewrite with "Enable loplugin:cstylecast for some more cases" plus solenv/clang-format/reformat-formatted-files Change-Id: I690ddd7eeb5fbac979292a382074e9b29c065416 --- reportdesign/inc/RptDef.hxx | 10 +++++----- reportdesign/source/core/api/ReportDefinition.cxx | 2 +- reportdesign/source/core/sdr/formatnormalizer.cxx | 2 +- reportdesign/source/filter/xml/xmlControlProperty.cxx | 14 +++++++------- reportdesign/source/ui/dlg/CondFormat.cxx | 12 ++++++------ reportdesign/source/ui/dlg/Condition.cxx | 4 ++-- reportdesign/source/ui/inc/CondFormat.hxx | 2 +- reportdesign/source/ui/report/FixedTextColor.cxx | 2 +- reportdesign/source/ui/report/ReportController.cxx | 2 +- reportdesign/source/ui/report/ReportSection.cxx | 4 ++-- reportdesign/source/ui/report/ReportWindow.cxx | 10 +++++----- reportdesign/source/ui/report/ScrollHelper.cxx | 6 +++--- reportdesign/source/ui/report/SectionWindow.cxx | 2 +- reportdesign/source/ui/report/StartMarker.cxx | 4 ++-- reportdesign/source/ui/report/ViewsWindow.cxx | 2 +- reportdesign/source/ui/report/dlgedfunc.cxx | 4 ++-- 16 files changed, 41 insertions(+), 41 deletions(-) diff --git a/reportdesign/inc/RptDef.hxx b/reportdesign/inc/RptDef.hxx index ed4fba1721dc..0851df879d06 100644 --- a/reportdesign/inc/RptDef.hxx +++ b/reportdesign/inc/RptDef.hxx @@ -50,12 +50,12 @@ constexpr SdrLayerID RPT_LAYER_HIDDEN (2); -#define OBJ_DLG_FIXEDTEXT ((sal_uInt16) OBJ_MAXI + 1) +#define OBJ_DLG_FIXEDTEXT (sal_uInt16(OBJ_MAXI) + 1) #define OBJ_DLG_IMAGECONTROL OBJ_FM_IMAGECONTROL -#define OBJ_DLG_FORMATTEDFIELD ((sal_uInt16) OBJ_MAXI + 3) -#define OBJ_DLG_HFIXEDLINE ((sal_uInt16) OBJ_MAXI + 4) -#define OBJ_DLG_VFIXEDLINE ((sal_uInt16) OBJ_MAXI + 5) -#define OBJ_DLG_SUBREPORT ((sal_uInt16) OBJ_MAXI + 6) +#define OBJ_DLG_FORMATTEDFIELD (sal_uInt16(OBJ_MAXI) + 3) +#define OBJ_DLG_HFIXEDLINE (sal_uInt16(OBJ_MAXI) + 4) +#define OBJ_DLG_VFIXEDLINE (sal_uInt16(OBJ_MAXI) + 5) +#define OBJ_DLG_SUBREPORT (sal_uInt16(OBJ_MAXI) + 6) // allows the alignment and resizing of controls enum class ControlModification diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 576cfcd7d115..d30dc28d8568 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -216,7 +216,7 @@ void lcl_extractAndStartStatusIndicator( const utl::MediaDescriptor& _rDescripto _rxStatusIndicator = _rDescriptor.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_STATUSINDICATOR(), _rxStatusIndicator ); if ( _rxStatusIndicator.is() ) { - _rxStatusIndicator->start( OUString(), (sal_Int32)1000000 ); + _rxStatusIndicator->start( OUString(), sal_Int32(1000000) ); sal_Int32 nLength = _rCallArgs.getLength(); _rCallArgs.realloc( nLength + 1 ); diff --git a/reportdesign/source/core/sdr/formatnormalizer.cxx b/reportdesign/source/core/sdr/formatnormalizer.cxx index 092c289160a1..8b6276c20dda 100644 --- a/reportdesign/source/core/sdr/formatnormalizer.cxx +++ b/reportdesign/source/core/sdr/formatnormalizer.cxx @@ -132,7 +132,7 @@ namespace rptui try { sal_Int32 nCount( _rxColumns->getCount() ); - _inout_rFields.reserve( _inout_rFields.size() + (size_t)nCount ); + _inout_rFields.reserve( _inout_rFields.size() + static_cast(nCount) ); Reference< XPropertySet > xColumn; FormatNormalizer::Field aField; diff --git a/reportdesign/source/filter/xml/xmlControlProperty.cxx b/reportdesign/source/filter/xml/xmlControlProperty.cxx index 75b7520145ed..7eae2645c985 100644 --- a/reportdesign/source/filter/xml/xmlControlProperty.cxx +++ b/reportdesign/source/filter/xml/xmlControlProperty.cxx @@ -217,7 +217,7 @@ Any OXMLControlProperty::convertString(const css::uno::Type& _rExpectedType, con append(OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US)). append("\" into an integer!").getStr()); if (TypeClass_SHORT == _rExpectedType.getTypeClass()) - aReturn <<= (sal_Int16)nValue; + aReturn <<= static_cast(nValue); else aReturn <<= nValue; break; @@ -271,14 +271,14 @@ Any OXMLControlProperty::convertString(const css::uno::Type& _rExpectedType, con { case TYPE_DATE: { - OSL_ENSURE(((sal_uInt32)nValue) - nValue == 0, + OSL_ENSURE((static_cast(nValue)) - nValue == 0, "OPropertyImport::convertString: a Date value with a fractional part?"); aReturn <<= implGetDate(nValue); } break; case TYPE_TIME: { - OSL_ENSURE(((sal_uInt32)nValue) == 0, + OSL_ENSURE((static_cast(nValue)) == 0, "OPropertyImport::convertString: a tools::Time value with more than a fractional part?"); aReturn <<= implGetTime(nValue); } @@ -318,11 +318,11 @@ css::util::Time OXMLControlProperty::implGetTime(double _nValue) { css::util::Time aTime; sal_uInt64 nIntValue = ::rtl::math::round(_nValue * 86400000000000.0); - aTime.NanoSeconds = (sal_uInt16)( nIntValue % 1000000000 ); + aTime.NanoSeconds = static_cast( nIntValue % 1000000000 ); nIntValue /= 1000000000; - aTime.Seconds = (sal_uInt16)( nIntValue % 60 ); + aTime.Seconds = static_cast( nIntValue % 60 ); nIntValue /= 60; - aTime.Minutes = (sal_uInt16)( nIntValue % 60 ); + aTime.Minutes = static_cast( nIntValue % 60 ); nIntValue /= 60; OSL_ENSURE(nIntValue < 24, "OPropertyImport::implGetTime: more than a day?"); aTime.Hours = static_cast< sal_uInt16 >( nIntValue ); @@ -333,7 +333,7 @@ css::util::Time OXMLControlProperty::implGetTime(double _nValue) css::util::Date OXMLControlProperty::implGetDate(double _nValue) { - Date aToolsDate((sal_uInt32)_nValue); + Date aToolsDate(static_cast(_nValue)); css::util::Date aDate; ::utl::typeConvert(aToolsDate, aDate); return aDate; diff --git a/reportdesign/source/ui/dlg/CondFormat.cxx b/reportdesign/source/ui/dlg/CondFormat.cxx index 6ded562a5f60..8df157068cb4 100644 --- a/reportdesign/source/ui/dlg/CondFormat.cxx +++ b/reportdesign/source/ui/dlg/CondFormat.cxx @@ -190,7 +190,7 @@ namespace rptui try { - if ( _nNewCondIndex > (size_t)m_xCopy->getCount() ) + if ( _nNewCondIndex > static_cast(m_xCopy->getCount()) ) throw IllegalArgumentException(); Reference< XFormatCondition > xCond = m_xCopy->createFormatCondition(); @@ -280,8 +280,8 @@ namespace rptui Condition *pMovedCondition; try { - aMovedCondition = m_xCopy->getByIndex( (sal_Int32)nOldConditionIndex ); - m_xCopy->removeByIndex( (sal_Int32)nOldConditionIndex ); + aMovedCondition = m_xCopy->getByIndex( static_cast(nOldConditionIndex) ); + m_xCopy->removeByIndex( static_cast(nOldConditionIndex) ); Conditions::iterator aRemovePos( m_aConditions.begin() + nOldConditionIndex ); pMovedCondition = aRemovePos->get(); @@ -295,7 +295,7 @@ namespace rptui try { - m_xCopy->insertByIndex( (sal_Int32)nNewConditionIndex, aMovedCondition ); + m_xCopy->insertByIndex( static_cast(nNewConditionIndex), aMovedCondition ); m_aConditions.insert( m_aConditions.begin() + nNewConditionIndex, pMovedCondition ); } catch( const Exception& ) @@ -385,7 +385,7 @@ namespace rptui aArgs[1].Value <<= VCLUnoHelper::GetInterface(this); aArgs[2].Name = PROPERTY_FONTCOLOR; - aArgs[2].Value <<= (sal_uInt32)rColor.GetColor(); + aArgs[2].Value <<= static_cast(rColor.GetColor()); // we use this way to create undo actions m_rController.executeUnChecked(_nCommandId,aArgs); @@ -539,7 +539,7 @@ namespace rptui size_t ConditionalFormattingDialog::impl_getFirstVisibleConditionIndex() const { - return (size_t)m_pCondScroll->GetThumbPos(); + return static_cast(m_pCondScroll->GetThumbPos()); } diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx index 72f86a5d7ddf..d1b890156b94 100644 --- a/reportdesign/source/ui/dlg/Condition.cxx +++ b/reportdesign/source/ui/dlg/Condition.cxx @@ -358,8 +358,8 @@ void Condition::impl_setCondition( const OUString& _rConditionFormula ) } // update UI - m_pConditionType->SelectEntryPos( (sal_uInt16)eType ); - m_pOperationList->SelectEntryPos( (sal_uInt16)eOperation ); + m_pConditionType->SelectEntryPos( static_cast(eType) ); + m_pOperationList->SelectEntryPos( static_cast(eOperation) ); m_pCondLHS->SetText( sLHS ); m_pCondRHS->SetText( sRHS ); diff --git a/reportdesign/source/ui/inc/CondFormat.hxx b/reportdesign/source/ui/inc/CondFormat.hxx index 0118fe54eac1..eecf554f8c46 100644 --- a/reportdesign/source/ui/inc/CondFormat.hxx +++ b/reportdesign/source/ui/inc/CondFormat.hxx @@ -35,7 +35,7 @@ namespace rptui { - #define MAX_CONDITIONS (size_t)3 + #define MAX_CONDITIONS size_t(3) class OReportController; class Condition; diff --git a/reportdesign/source/ui/report/FixedTextColor.cxx b/reportdesign/source/ui/report/FixedTextColor.cxx index 51b1f3cb9f05..0e99b2083eaf 100644 --- a/reportdesign/source/ui/report/FixedTextColor.cxx +++ b/reportdesign/source/ui/report/FixedTextColor.cxx @@ -104,7 +104,7 @@ namespace rptui { bool bIsDark = false; const sal_Int32 nBackColor( xFixedText->getControlBackground() ); - if ((sal_uInt32)nBackColor == COL_TRANSPARENT) + if (static_cast(nBackColor) == COL_TRANSPARENT) { uno::Reference xSection(xFixedText->getParent(), uno::UNO_QUERY_THROW); diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index 835392c3a044..b3200eeb0f93 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -2742,7 +2742,7 @@ uno::Any SAL_CALL OReportController::getViewData() OSectionWindow* pSectionWindow = getDesignView()->getMarkedSection(); if ( pSectionWindow ) { - aViewData.put( "MarkedSection", (sal_Int32)pSectionWindow->getReportSection().getPage()->GetPageNum() ); + aViewData.put( "MarkedSection", static_cast(pSectionWindow->getReportSection().getPage()->GetPageNum()) ); } } diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx index 759b74027a85..99f93cc72455 100644 --- a/reportdesign/source/ui/report/ReportSection.cxx +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -213,7 +213,7 @@ void OReportSection::fill() m_pView->SetDragStripes( true ); m_pView->SetPageVisible(); sal_Int32 nColor = m_xSection->getBackColor(); - if ( nColor == (sal_Int32)COL_TRANSPARENT ) + if ( nColor == static_cast(COL_TRANSPARENT) ) nColor = getStyleProperty(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR); m_pView->SetApplicationDocumentColor(nColor); @@ -468,7 +468,7 @@ void OReportSection::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) if ( _rEvent.Source == m_xSection || PROPERTY_BACKCOLOR == _rEvent.PropertyName ) { sal_Int32 nColor = m_xSection->getBackColor(); - if ( nColor == (sal_Int32)COL_TRANSPARENT ) + if ( nColor == static_cast(COL_TRANSPARENT) ) nColor = getStyleProperty(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR); m_pView->SetApplicationDocumentColor(nColor); Invalidate(InvalidateFlags::NoChildren|InvalidateFlags::NoErase); diff --git a/reportdesign/source/ui/report/ReportWindow.cxx b/reportdesign/source/ui/report/ReportWindow.cxx index e6ddb124219d..eeb793f71b89 100644 --- a/reportdesign/source/ui/report/ReportWindow.cxx +++ b/reportdesign/source/ui/report/ReportWindow.cxx @@ -145,7 +145,7 @@ sal_Int32 OReportWindow::getMaxMarkerWidth() const { Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); aStartWidth *= m_aViewsWindow->GetMapMode().GetScaleX(); - return sal_Int32((long)aStartWidth); + return sal_Int32(static_cast(aStartWidth)); } sal_Int32 OReportWindow::GetTotalWidth() const @@ -173,7 +173,7 @@ void OReportWindow::Resize() Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)*m_pView->getController().getZoomValue(),100); const Point aOffset = LogicToPixel(Point(SECTION_OFFSET, 0), MapMode(MapUnit::MapAppFont)); - Point aStartPoint((long)aStartWidth + aOffset.X(),0); + Point aStartPoint(static_cast(aStartWidth) + aOffset.X(),0); uno::Reference xReportDefinition = getReportView()->getController().getReportDefinition(); const sal_Int32 nPaperWidth = getStyleProperty(xReportDefinition,PROPERTY_PAPERSIZE).Width; sal_Int32 nLeftMargin = getStyleProperty(xReportDefinition,PROPERTY_LEFTMARGIN); @@ -412,14 +412,14 @@ sal_uInt16 OReportWindow::getZoomFactor(SvxZoomType _eType) const break; case SvxZoomType::WHOLEPAGE: { - nZoom = (sal_uInt16)(long)Fraction(aSize.Width()*100,impl_getRealPixelWidth()); + nZoom = static_cast(static_cast(Fraction(aSize.Width()*100,impl_getRealPixelWidth()))); MapMode aMap( MapUnit::Map100thMM ); const Size aHeight = m_aViewsWindow->LogicToPixel(m_aViewsWindow->PixelToLogic(Size(0,GetTotalHeight() + m_aHRuler->GetSizePixel().Height())),aMap); - nZoom = ::std::min(nZoom,(sal_uInt16)(long)Fraction(aSize.Height()*100,aHeight.Height())); + nZoom = ::std::min(nZoom,static_cast(static_cast(Fraction(aSize.Height()*100,aHeight.Height())))); } break; case SvxZoomType::PAGEWIDTH: - nZoom = (sal_uInt16)(long)Fraction(aSize.Width()*100,impl_getRealPixelWidth()); + nZoom = static_cast(static_cast(Fraction(aSize.Width()*100,impl_getRealPixelWidth()))); break; default: break; diff --git a/reportdesign/source/ui/report/ScrollHelper.cxx b/reportdesign/source/ui/report/ScrollHelper.cxx index ce6b589f72c3..ef3864852066 100644 --- a/reportdesign/source/ui/report/ScrollHelper.cxx +++ b/reportdesign/source/ui/report/ScrollHelper.cxx @@ -111,7 +111,7 @@ void OScrollWindowHelper::setTotalSize(sal_Int32 _nWidth ,sal_Int32 _nHeight) // now set the ranges without start marker Fraction aStartWidth(REPORT_STARTMARKER_WIDTH * m_pParent->getController().getZoomValue(),100); - long nWidth = long(_nWidth - (double)aStartWidth); + long nWidth = long(_nWidth - static_cast(aStartWidth)); m_aHScroll->SetRangeMax( nWidth ); m_aVScroll->SetRangeMax( m_aTotalPixelSize.Height() ); @@ -173,8 +173,8 @@ Size OScrollWindowHelper::ResizeScrollBars() // resize scrollbars and set their ranges { Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH*m_pParent->getController().getZoomValue()),100); - const sal_Int32 nNewWidth = aOutPixSz.Width() - aOffset.X() - (long)aStartWidth; - lcl_setScrollBar(nNewWidth,Point( (long)aStartWidth + aOffset.X(), aOutPixSz.Height() ), Size( nNewWidth, nScrSize ), *m_aHScroll.get()); + const sal_Int32 nNewWidth = aOutPixSz.Width() - aOffset.X() - static_cast(aStartWidth); + lcl_setScrollBar(nNewWidth,Point( static_cast(aStartWidth) + aOffset.X(), aOutPixSz.Height() ), Size( nNewWidth, nScrSize ), *m_aHScroll.get()); } { const sal_Int32 nNewHeight = aOutPixSz.Height() - m_aReportWindow->getRulerHeight(); diff --git a/reportdesign/source/ui/report/SectionWindow.cxx b/reportdesign/source/ui/report/SectionWindow.cxx index e1aaf1ad048f..efb7ad9b055c 100644 --- a/reportdesign/source/ui/report/SectionWindow.cxx +++ b/reportdesign/source/ui/report/SectionWindow.cxx @@ -262,7 +262,7 @@ void OSectionWindow::Resize() // set splitter aReportPos.Y() += aSectionSize.Height(); m_aSplitter->SetPosSizePixel(aReportPos,Size(aSectionSize.Width(),m_aSplitter->GetSizePixel().Height())); - aSectionSize.Height() = (long)(1000 * (double)GetMapMode().GetScaleY()); + aSectionSize.Height() = static_cast(1000 * static_cast(GetMapMode().GetScaleY())); m_aSplitter->SetDragRectPixel( tools::Rectangle(Point(nStartWidth,0),aSectionSize)); // set end marker diff --git a/reportdesign/source/ui/report/StartMarker.cxx b/reportdesign/source/ui/report/StartMarker.cxx index 17c58b71e0b5..c3dce09bfdc8 100644 --- a/reportdesign/source/ui/report/StartMarker.cxx +++ b/reportdesign/source/ui/report/StartMarker.cxx @@ -230,8 +230,8 @@ void OStartMarker::Resize() Size aImageSize = m_aImage->GetImage().GetSizePixel(); const MapMode& rMapMode = GetMapMode(); - aImageSize.Width() = long(aImageSize.Width() * (double)rMapMode.GetScaleX()); - aImageSize.Height() = long(aImageSize.Height() * (double)rMapMode.GetScaleY()); + aImageSize.Width() = long(aImageSize.Width() * static_cast(rMapMode.GetScaleX())); + aImageSize.Height() = long(aImageSize.Height() * static_cast(rMapMode.GetScaleY())); long nExtraWidth = long(REPORT_EXTRA_SPACE * rMapMode.GetScaleX()); diff --git a/reportdesign/source/ui/report/ViewsWindow.cxx b/reportdesign/source/ui/report/ViewsWindow.cxx index 40faf078ee5c..04ac6b526c42 100644 --- a/reportdesign/source/ui/report/ViewsWindow.cxx +++ b/reportdesign/source/ui/report/ViewsWindow.cxx @@ -205,7 +205,7 @@ void OViewsWindow::impl_resizeSectionWindow(OSectionWindow& _rSectionWindow,Poin aSectionSize.Height() = nMinHeight; } const StyleSettings& rSettings = GetSettings().GetStyleSettings(); - aSectionSize.Height() += (long)(rSettings.GetSplitSize() * (double)_rSectionWindow.GetMapMode().GetScaleY()); + aSectionSize.Height() += static_cast(rSettings.GetSplitSize() * static_cast(_rSectionWindow.GetMapMode().GetScaleY())); if ( _bSet ) _rSectionWindow.SetPosSizePixel(_rStartPoint,aSectionSize); diff --git a/reportdesign/source/ui/report/dlgedfunc.cxx b/reportdesign/source/ui/report/dlgedfunc.cxx index ad085bfe72da..dd6cd925d460 100644 --- a/reportdesign/source/ui/report/dlgedfunc.cxx +++ b/reportdesign/source/ui/report/dlgedfunc.cxx @@ -77,7 +77,7 @@ void DlgEdFunc::ForceScroll( const Point& rPos ) Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); aStartWidth *= m_pParent->GetMapMode().GetScaleX(); - aOut.Width() -= (long)aStartWidth; + aOut.Width() -= static_cast(aStartWidth); aOut.Height() = m_pParent->GetOutputSizePixel().Height(); Point aPos = pScrollWindow->getThumbPos(); @@ -86,7 +86,7 @@ void DlgEdFunc::ForceScroll( const Point& rPos ) tools::Rectangle aOutRect( aPos, aOut ); aOutRect = m_pParent->PixelToLogic( aOutRect ); tools::Rectangle aWorkArea(Point(), pScrollWindow->getTotalSize()); - aWorkArea.Right() -= (long)aStartWidth; + aWorkArea.Right() -= static_cast(aStartWidth); aWorkArea = pScrollWindow->PixelToLogic( aWorkArea ); if( !aOutRect.IsInside( rPos ) && aWorkArea.IsInside( rPos ) ) { -- cgit