diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-01-12 20:24:28 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-01-12 20:24:28 +0100 |
commit | 32bd0425cc53bab05f7ab03252b37ccd6abc7dda (patch) | |
tree | 2c92daf8afd33c605525a90e81fee60734cfc327 /extensions | |
parent | c578d1c81274a1c0e5bdbdf5654bb4e186afdf49 (diff) |
More loplugin:cstylecast: extensions
auto-rewrite with <https://gerrit.libreoffice.org/#/c/47798/> "Enable
loplugin:cstylecast for some more cases" plus
solenv/clang-format/reformat-formatted-files
Change-Id: If5cd78704f10a98524a113c67cdc09529f745c74
Diffstat (limited to 'extensions')
37 files changed, 180 insertions, 180 deletions
diff --git a/extensions/source/abpilot/fieldmappingimpl.cxx b/extensions/source/abpilot/fieldmappingimpl.cxx index f78293f047e8..183d68f6596a 100644 --- a/extensions/source/abpilot/fieldmappingimpl.cxx +++ b/extensions/source/abpilot/fieldmappingimpl.cxx @@ -293,7 +293,7 @@ namespace abp aAddressBookSettings.setNodeValue( OUString( "DataSourceName" ), makeAny( _rDataSourceName ) ); aAddressBookSettings.setNodeValue( OUString( "Command" ), makeAny( _rTableName ) ); - aAddressBookSettings.setNodeValue( OUString( "CommandType" ), makeAny( (sal_Int16)CommandType::TABLE ) ); + aAddressBookSettings.setNodeValue( OUString( "CommandType" ), makeAny( sal_Int16(CommandType::TABLE) ) ); // commit the changes done aAddressBookSettings.commit(); diff --git a/extensions/source/bibliography/bibconfig.cxx b/extensions/source/bibliography/bibconfig.cxx index 20e9b0948fc0..cd8f2709187a 100644 --- a/extensions/source/bibliography/bibconfig.cxx +++ b/extensions/source/bibliography/bibconfig.cxx @@ -227,7 +227,7 @@ void BibConfig::ImplCommit() PropertyValue* pNodeValues = aNodeValues.getArray(); sal_Int32 nIndex = 0; - for(sal_Int32 i = 0; i < (sal_Int32)pMappingsArr->size(); i++) + for(sal_Int32 i = 0; i < static_cast<sal_Int32>(pMappingsArr->size()); i++) { const Mapping* pMapping = (*pMappingsArr)[i].get(); OUString sPrefix(cDataSourceHistory); diff --git a/extensions/source/bibliography/bibload.cxx b/extensions/source/bibliography/bibload.cxx index 0f20d8bf4694..a2b4e988a703 100644 --- a/extensions/source/bibliography/bibload.cxx +++ b/extensions/source/bibliography/bibload.cxx @@ -349,9 +349,9 @@ Reference< XNameAccess > const & BibliographyLoader::GetDataColumns() const xResultSetProps->setPropertyValue("CommandType", aCommandType); Any aTableName; aTableName <<= aBibDesc.sTableOrQuery; xResultSetProps->setPropertyValue("Command", aTableName); - Any aResultSetType; aResultSetType <<= (sal_Int32)ResultSetType::SCROLL_INSENSITIVE; + Any aResultSetType; aResultSetType <<= sal_Int32(ResultSetType::SCROLL_INSENSITIVE); xResultSetProps->setPropertyValue("ResultSetType", aResultSetType); - Any aResultSetCurrency; aResultSetCurrency <<= (sal_Int32)ResultSetConcurrency::UPDATABLE; + Any aResultSetCurrency; aResultSetCurrency <<= sal_Int32(ResultSetConcurrency::UPDATABLE); xResultSetProps->setPropertyValue("ResultSetConcurrency", aResultSetCurrency); bool bSuccess = false; @@ -629,7 +629,7 @@ Any BibliographyLoader::getPropertyValue(const OUString& rPropertyName) for(sal_uInt16 i = 0; i <= text::BibliographyDataField::ISBN ; i++) { pArray[i].Name = pConfig->GetDefColumnName(aInternalMapping[i]); - pArray[i].Value <<= (sal_Int16) i; + pArray[i].Value <<= static_cast<sal_Int16>(i); } aRet <<= aSeq; return aRet; diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx index c189ffc3c300..94005c437fef 100644 --- a/extensions/source/bibliography/datman.cxx +++ b/extensions/source/bibliography/datman.cxx @@ -759,13 +759,13 @@ Reference< XForm > BibDataManager::createDatabaseForm(BibDBDescriptor& rDesc) if(aPropertySet.is()) { Any aVal; - aVal <<= (sal_Int32)ResultSetType::SCROLL_INSENSITIVE; + aVal <<= sal_Int32(ResultSetType::SCROLL_INSENSITIVE); aPropertySet->setPropertyValue("ResultSetType",aVal ); - aVal <<= (sal_Int32)ResultSetConcurrency::READ_ONLY; + aVal <<= sal_Int32(ResultSetConcurrency::READ_ONLY); aPropertySet->setPropertyValue("ResultSetConcurrency", aVal); //Caching for Performance - aVal <<= (sal_Int32)50; + aVal <<= sal_Int32(50); aPropertySet->setPropertyValue("FetchSize", aVal); Reference< XConnection > xConnection = getConnection(rDesc.sDataSource); @@ -975,7 +975,7 @@ void BibDataManager::setActiveDataSource(const OUString& rURL) aPropertySet->setPropertyValue("Command", aVal); aPropertySet->setPropertyValue("CommandType", makeAny(CommandType::TABLE)); //Caching for Performance - aVal <<= (sal_Int32)50; + aVal <<= sal_Int32(50); aPropertySet->setPropertyValue("FetchSize", aVal); OUString aString("SELECT * FROM "); // quote the table name which may contain catalog.schema.table @@ -1293,7 +1293,7 @@ Reference< awt::XControlModel > BibDataManager::loadControlModel( uno::Any aAny; //uno::Reference< beans::XPropertySet > xPropSet(xControl, UNO_QUERY); - aAny <<= (sal_Int16)1; + aAny <<= sal_Int16(1); xPropSet->setPropertyValue("BoundColumn", aAny); aAny <<= ListSourceType_VALUELIST; xPropSet->setPropertyValue("ListSourceType", aAny); diff --git a/extensions/source/dbpilots/groupboxwiz.cxx b/extensions/source/dbpilots/groupboxwiz.cxx index 818f782cda7a..606f6fec94d8 100644 --- a/extensions/source/dbpilots/groupboxwiz.cxx +++ b/extensions/source/dbpilots/groupboxwiz.cxx @@ -375,7 +375,7 @@ namespace dbp OOptionValuesPage::OOptionValuesPage( OControlWizard* _pParent ) :OGBWPage(_pParent, "OptionValuesPage", "modules/sabpilot/ui/optionvaluespage.ui") - ,m_nLastSelection((::svt::WizardTypes::WizardState)-1) + ,m_nLastSelection(::svt::WizardTypes::WizardState(-1)) { get(m_pValue, "optionvalue"); get(m_pOptions, "radiobuttons"); @@ -410,15 +410,15 @@ namespace dbp void OOptionValuesPage::implTraveledOptions() { - if ((::svt::WizardTypes::WizardState)-1 != m_nLastSelection) + if (::svt::WizardTypes::WizardState(-1) != m_nLastSelection) { // save the value for the last option - DBG_ASSERT((size_t)m_nLastSelection < m_aUncommittedValues.size(), "OOptionValuesPage::implTraveledOptions: invalid previous selection index!"); + DBG_ASSERT(static_cast<size_t>(m_nLastSelection) < m_aUncommittedValues.size(), "OOptionValuesPage::implTraveledOptions: invalid previous selection index!"); m_aUncommittedValues[m_nLastSelection] = m_pValue->GetText(); } m_nLastSelection = m_pOptions->GetSelectedEntryPos(); - DBG_ASSERT((size_t)m_nLastSelection < m_aUncommittedValues.size(), "OOptionValuesPage::implTraveledOptions: invalid new selection index!"); + DBG_ASSERT(static_cast<size_t>(m_nLastSelection) < m_aUncommittedValues.size(), "OOptionValuesPage::implTraveledOptions: invalid new selection index!"); m_pValue->SetText(m_aUncommittedValues[m_nLastSelection]); } diff --git a/extensions/source/dbpilots/listcombowizard.cxx b/extensions/source/dbpilots/listcombowizard.cxx index 8f4342e2add5..64cf36e0f0a1 100644 --- a/extensions/source/dbpilots/listcombowizard.cxx +++ b/extensions/source/dbpilots/listcombowizard.cxx @@ -177,7 +177,7 @@ namespace dbp if (isListBox()) { // BoundColumn: 1 - getContext().xObjectModel->setPropertyValue("BoundColumn", makeAny((sal_Int16)1)); + getContext().xObjectModel->setPropertyValue("BoundColumn", makeAny(sal_Int16(1))); // build the statement to set as list source OUString sStatement = "SELECT " + diff --git a/extensions/source/logging/csvformatter.cxx b/extensions/source/logging/csvformatter.cxx index d5e439850023..2e98243864a0 100644 --- a/extensions/source/logging/csvformatter.cxx +++ b/extensions/source/logging/csvformatter.cxx @@ -243,13 +243,13 @@ namespace logging char buffer[ 31 ]; const size_t buffer_size = sizeof( buffer ); snprintf( buffer, buffer_size, "%04i-%02i-%02iT%02i:%02i:%02i.%09i", - (int)record.LogTime.Year, - (int)record.LogTime.Month, - (int)record.LogTime.Day, - (int)record.LogTime.Hours, - (int)record.LogTime.Minutes, - (int)record.LogTime.Seconds, - (int)record.LogTime.NanoSeconds ); + static_cast<int>(record.LogTime.Year), + static_cast<int>(record.LogTime.Month), + static_cast<int>(record.LogTime.Day), + static_cast<int>(record.LogTime.Hours), + static_cast<int>(record.LogTime.Minutes), + static_cast<int>(record.LogTime.Seconds), + static_cast<int>(record.LogTime.NanoSeconds) ); aLogEntry.appendAscii( buffer ); aLogEntry.append(comma_char); } diff --git a/extensions/source/logging/filehandler.cxx b/extensions/source/logging/filehandler.cxx index 697953dd2ec3..4599c3efed59 100644 --- a/extensions/source/logging/filehandler.cxx +++ b/extensions/source/logging/filehandler.cxx @@ -188,7 +188,7 @@ namespace logging { SAL_WARN( "extensions.logging", "FileHandler::impl_prepareFile_nothrow: could not open the designated log file:" "\nURL: " << m_sFileURL - << "\nerror code: " << (sal_Int32)res ); + << "\nerror code: " << static_cast<sal_Int32>(res) ); } #endif if ( m_eFileValidity == eValid ) diff --git a/extensions/source/logging/loggerconfig.cxx b/extensions/source/logging/loggerconfig.cxx index 02ddd0e52776..c268ac636607 100644 --- a/extensions/source/logging/loggerconfig.cxx +++ b/extensions/source/logging/loggerconfig.cxx @@ -96,15 +96,15 @@ namespace logging const size_t buffer_size = sizeof( buffer ); snprintf( buffer, buffer_size, "%04i-%02i-%02i", - (int)aDateTime.Year, - (int)aDateTime.Month, - (int)aDateTime.Day ); + static_cast<int>(aDateTime.Year), + static_cast<int>(aDateTime.Month), + static_cast<int>(aDateTime.Day) ); rtl::OUString sDate = rtl::OUString::createFromAscii( buffer ); snprintf( buffer, buffer_size, "%02i-%02i-%02i.%03i", - (int)aDateTime.Hours, - (int)aDateTime.Minutes, - (int)aDateTime.Seconds, + static_cast<int>(aDateTime.Hours), + static_cast<int>(aDateTime.Minutes), + static_cast<int>(aDateTime.Seconds), ::sal::static_int_cast< sal_Int16 >( aDateTime.NanoSeconds / 10000000 ) ); rtl::OUString sTime = rtl::OUString::createFromAscii( buffer ); diff --git a/extensions/source/logging/logrecord.cxx b/extensions/source/logging/logrecord.cxx index d09c5971f63d..26f59e841aa6 100644 --- a/extensions/source/logging/logrecord.cxx +++ b/extensions/source/logging/logrecord.cxx @@ -43,7 +43,7 @@ namespace logging OUString getCurrentThreadID() { oslThreadIdentifier nThreadID( osl::Thread::getCurrentIdentifier() ); - return OUString::number( (sal_Int64)nThreadID ); + return OUString::number( static_cast<sal_Int64>(nThreadID) ); } } diff --git a/extensions/source/logging/plaintextformatter.cxx b/extensions/source/logging/plaintextformatter.cxx index 3ea3ebca8918..6691ee17b060 100644 --- a/extensions/source/logging/plaintextformatter.cxx +++ b/extensions/source/logging/plaintextformatter.cxx @@ -81,7 +81,7 @@ namespace logging { char buffer[ 30 ]; const int buffer_size = sizeof( buffer ); - int used = snprintf( buffer, buffer_size, "%10i", (int)_rRecord.SequenceNumber ); + int used = snprintf( buffer, buffer_size, "%10i", static_cast<int>(_rRecord.SequenceNumber) ); if ( used >= buffer_size || used < 0 ) buffer[ buffer_size - 1 ] = 0; @@ -95,8 +95,8 @@ namespace logging aLogEntry.append( " " ); snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%09i", - (int)_rRecord.LogTime.Year, (int)_rRecord.LogTime.Month, (int)_rRecord.LogTime.Day, - (int)_rRecord.LogTime.Hours, (int)_rRecord.LogTime.Minutes, (int)_rRecord.LogTime.Seconds, (int)_rRecord.LogTime.NanoSeconds ); + static_cast<int>(_rRecord.LogTime.Year), static_cast<int>(_rRecord.LogTime.Month), static_cast<int>(_rRecord.LogTime.Day), + static_cast<int>(_rRecord.LogTime.Hours), static_cast<int>(_rRecord.LogTime.Minutes), static_cast<int>(_rRecord.LogTime.Seconds), static_cast<int>(_rRecord.LogTime.NanoSeconds) ); aLogEntry.appendAscii( buffer ); aLogEntry.append( " " ); diff --git a/extensions/source/propctrlr/browserlistbox.cxx b/extensions/source/propctrlr/browserlistbox.cxx index a68e2aa956ce..07a39b20988a 100644 --- a/extensions/source/propctrlr/browserlistbox.cxx +++ b/extensions/source/propctrlr/browserlistbox.cxx @@ -433,7 +433,7 @@ namespace pcr UpdateVScroll(); - bool bNeedScrollbar = m_aLines.size() > (sal_uInt32)CalcVisibleLines(); + bool bNeedScrollbar = m_aLines.size() > static_cast<sal_uInt32>(CalcVisibleLines()); if ( !bNeedScrollbar ) { if ( m_aVScroll->IsVisible() ) @@ -523,7 +523,7 @@ namespace pcr Size aSize(m_aLinesPlayground->GetOutputSizePixel()); sal_uInt16 nResult = 0; if (0 != m_nRowHeight) - nResult = (sal_uInt16) aSize.Height()/m_nRowHeight; + nResult = static_cast<sal_uInt16>(aSize.Height())/m_nRowHeight; return nResult; } @@ -646,7 +646,7 @@ namespace pcr { if ( linePos->aName == _rEntryName ) { - nRet = (sal_uInt16)( linePos - m_aLines.begin() ); + nRet = static_cast<sal_uInt16>( linePos - m_aLines.begin() ); break; } } @@ -914,7 +914,7 @@ namespace pcr return sal_uInt16( search - m_aLines.begin() ); OSL_FAIL( "OBrowserListBox::impl_getControlPos: invalid control - not part of any of our lines!" ); - return (sal_uInt16)-1; + return sal_uInt16(-1); } @@ -1079,7 +1079,7 @@ namespace pcr rLine.pLine->SetTitle(_rPropertyData.DisplayName); rLine.xHandler = _rPropertyData.xPropertyHandler; - sal_uInt16 nTextWidth = (sal_uInt16)m_aLinesPlayground->GetTextWidth(_rPropertyData.DisplayName); + sal_uInt16 nTextWidth = static_cast<sal_uInt16>(m_aLinesPlayground->GetTextWidth(_rPropertyData.DisplayName)); if (m_nTheNameSize< nTextWidth) m_nTheNameSize = nTextWidth; @@ -1183,9 +1183,9 @@ namespace pcr sal_uInt16 nFocusControlPos = 0; sal_uInt16 nActiveControlPos = impl_getControlPos( m_xActiveControl ); if ( nActiveControlPos < nNewThumbPos ) - nFocusControlPos = (sal_uInt16)nNewThumbPos; + nFocusControlPos = static_cast<sal_uInt16>(nNewThumbPos); else if ( nActiveControlPos >= nNewThumbPos + CalcVisibleLines() ) - nFocusControlPos = (sal_uInt16)nNewThumbPos + CalcVisibleLines() - 1; + nFocusControlPos = static_cast<sal_uInt16>(nNewThumbPos) + CalcVisibleLines() - 1; if ( nFocusControlPos ) { if ( nFocusControlPos < m_aLines.size() ) diff --git a/extensions/source/propctrlr/cellbindinghandler.cxx b/extensions/source/propctrlr/cellbindinghandler.cxx index a419eaa5aa31..e636aa2a44d9 100644 --- a/extensions/source/propctrlr/cellbindinghandler.cxx +++ b/extensions/source/propctrlr/cellbindinghandler.cxx @@ -136,7 +136,7 @@ namespace pcr // ensure that the "transfer selection as" property is reset. Since we can't remember // it at the object itself, but derive it from the binding only, we have to normalize // it now that there *is* no binding anymore. - setPropertyValue( PROPERTY_CELL_EXCHANGE_TYPE, makeAny( (sal_Int16) 0 ) ); + setPropertyValue( PROPERTY_CELL_EXCHANGE_TYPE, makeAny( sal_Int16(0) ) ); } } break; @@ -261,7 +261,7 @@ namespace pcr case PROPERTY_ID_CELL_EXCHANGE_TYPE: { Reference< XValueBinding > xBinding( m_pHelper->getCurrentBinding() ); - aReturn <<= (sal_Int16)( CellBindingHelper::isCellIntegerBinding( xBinding ) ? 1 : 0 ); + aReturn <<= static_cast<sal_Int16>( CellBindingHelper::isCellIntegerBinding( xBinding ) ? 1 : 0 ); } break; diff --git a/extensions/source/propctrlr/cellbindinghelper.cxx b/extensions/source/propctrlr/cellbindinghelper.cxx index 6852d76fe385..32515e063dec 100644 --- a/extensions/source/propctrlr/cellbindinghelper.cxx +++ b/extensions/source/propctrlr/cellbindinghelper.cxx @@ -127,7 +127,7 @@ namespace pcr if ( xSuppForms->getForms() == xFormsCollection ) { // found it - nSheetIndex = (sal_Int16)i; + nSheetIndex = static_cast<sal_Int16>(i); _out_rxSheet.set( xSuppPage, UNO_QUERY_THROW ); break; } @@ -176,7 +176,7 @@ namespace pcr try { Reference< XSpreadsheet > xSheet; - xConverter->setPropertyValue( PROPERTY_REFERENCE_SHEET, makeAny( (sal_Int32)getControlSheetIndex( xSheet ) ) ); + xConverter->setPropertyValue( PROPERTY_REFERENCE_SHEET, makeAny( static_cast<sal_Int32>(getControlSheetIndex( xSheet )) ) ); xConverter->setPropertyValue( _rInputProperty, _rInputValue ); _rOutputValue = xConverter->getPropertyValue( _rOutputProperty ); bSuccess = true; diff --git a/extensions/source/propctrlr/controltype.hxx b/extensions/source/propctrlr/controltype.hxx index b42f550f2a1a..6039e13b28a3 100644 --- a/extensions/source/propctrlr/controltype.hxx +++ b/extensions/source/propctrlr/controltype.hxx @@ -27,9 +27,9 @@ namespace pcr namespace ControlType { - static const sal_Int16 FIXEDLINE = (sal_Int16)100; - static const sal_Int16 FORMATTEDFIELD = (sal_Int16)101; - static const sal_Int16 PROGRESSBAR = (sal_Int16)102; + static const sal_Int16 FIXEDLINE = sal_Int16(100); + static const sal_Int16 FORMATTEDFIELD = sal_Int16(101); + static const sal_Int16 PROGRESSBAR = sal_Int16(102); // need only those which are not already covered as FormComponentType } diff --git a/extensions/source/propctrlr/editpropertyhandler.cxx b/extensions/source/propctrlr/editpropertyhandler.cxx index 18b66c8894fd..643e43870640 100644 --- a/extensions/source/propctrlr/editpropertyhandler.cxx +++ b/extensions/source/propctrlr/editpropertyhandler.cxx @@ -92,7 +92,7 @@ namespace pcr bool bHasHScroll = false; m_xComponent->getPropertyValue( PROPERTY_HSCROLL ) >>= bHasHScroll; - aReturn <<= (sal_Int32)( ( bHasVScroll ? 2 : 0 ) + ( bHasHScroll ? 1 : 0 ) ); + aReturn <<= static_cast<sal_Int32>( ( bHasVScroll ? 2 : 0 ) + ( bHasHScroll ? 1 : 0 ) ); } break; diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx index 9cfd5fc1f08f..3e8b006bb95d 100644 --- a/extensions/source/propctrlr/eventhandler.cxx +++ b/extensions/source/propctrlr/eventhandler.cxx @@ -815,7 +815,7 @@ namespace pcr // the initial selection in the dialog Sequence< OUString > aNames( pEventHolder->getElementNames() ); const OUString* pChosenEvent = std::find( aNames.begin(), aNames.end(), rForEvent.sListenerMethodName ); - sal_uInt16 nInitialSelection = (sal_uInt16)( pChosenEvent - aNames.begin() ); + sal_uInt16 nInitialSelection = static_cast<sal_uInt16>( pChosenEvent - aNames.begin() ); // the dialog SvxAbstractDialogFactory* pFactory = SvxAbstractDialogFactory::Create(); diff --git a/extensions/source/propctrlr/fontdialog.cxx b/extensions/source/propctrlr/fontdialog.cxx index c9b0f0137cb7..8fd7d4dcc548 100644 --- a/extensions/source/propctrlr/fontdialog.cxx +++ b/extensions/source/propctrlr/fontdialog.cxx @@ -131,7 +131,7 @@ namespace pcr sal_Int32 nValue(_nDefault); ::cppu::enum2int(nValue, aValue); - return (sal_Int16)nValue; + return static_cast<sal_Int16>(nValue); } @@ -207,7 +207,7 @@ namespace pcr OUString aFontStyleName = aPropExtractor.getStringFontProperty(PROPERTY_FONT_STYLENAME, aDefaultFont.StyleName); sal_Int16 nFontFamily = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_FAMILY, aDefaultFont.Family); sal_Int16 nFontCharset = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_CHARSET, aDefaultFont.CharSet); - float nFontHeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_HEIGHT, (float)aDefaultFont.Height); + float nFontHeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_HEIGHT, static_cast<float>(aDefaultFont.Height)); float nFontWeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_WEIGHT, aDefaultFont.Weight); css::awt::FontSlant nFontSlant = static_cast<css::awt::FontSlant>(aPropExtractor.getInt16FontProperty(PROPERTY_FONT_SLANT, (sal_Int16)aDefaultFont.Slant)); sal_Int16 nFontLineStyle = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_UNDERLINE, aDefaultFont.Underline); @@ -224,8 +224,8 @@ namespace pcr // build SfxItems with the values SvxFontItem aFontItem((FontFamily)nFontFamily, aFontName, aFontStyleName, PITCH_DONTKNOW, nFontCharset, CFID_FONT); - nFontHeight = (float)OutputDevice::LogicToLogic(Size(0, (sal_Int32)nFontHeight), MapMode(MapUnit::MapPoint), MapMode(MapUnit::MapTwip)).Height(); - SvxFontHeightItem aSvxFontHeightItem((sal_uInt32)nFontHeight,100,CFID_HEIGHT); + nFontHeight = static_cast<float>(OutputDevice::LogicToLogic(Size(0, static_cast<sal_Int32>(nFontHeight)), MapMode(MapUnit::MapPoint), MapMode(MapUnit::MapTwip)).Height()); + SvxFontHeightItem aSvxFontHeightItem(static_cast<sal_uInt32>(nFontHeight),100,CFID_HEIGHT); FontWeight eWeight=vcl::unohelper::ConvertFontWeight(nFontWeight); FontItalic eItalic=vcl::unohelper::ConvertFontSlant(nFontSlant); @@ -315,8 +315,8 @@ namespace pcr lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_NAME , makeAny(rFontItem.GetFamilyName())); lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STYLENAME, makeAny(rFontItem.GetStyleName())); - lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_FAMILY , makeAny((sal_Int16)rFontItem.GetFamily())); - lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_CHARSET , makeAny((sal_Int16)rFontItem.GetCharSet())); + lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_FAMILY , makeAny(static_cast<sal_Int16>(rFontItem.GetFamily()))); + lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_CHARSET , makeAny(static_cast<sal_Int16>(rFontItem.GetCharSet()))); } @@ -328,7 +328,7 @@ namespace pcr const SvxFontHeightItem& rSvxFontHeightItem = static_cast<const SvxFontHeightItem&>(_rSet.Get(CFID_HEIGHT)); - float nHeight = (float)OutputDevice::LogicToLogic(Size(0, rSvxFontHeightItem.GetHeight()), MapMode(MapUnit::MapTwip), MapMode(MapUnit::MapPoint)).Height(); + float nHeight = static_cast<float>(OutputDevice::LogicToLogic(Size(0, rSvxFontHeightItem.GetHeight()), MapMode(MapUnit::MapTwip), MapMode(MapUnit::MapPoint)).Height()); lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_HEIGHT,makeAny(nHeight)); } @@ -368,14 +368,14 @@ namespace pcr const SvxUnderlineItem& rUnderlineItem = static_cast<const SvxUnderlineItem&>(_rSet.Get(CFID_UNDERLINE)); - sal_Int16 nUnderline = (sal_Int16)rUnderlineItem.GetLineStyle(); + sal_Int16 nUnderline = static_cast<sal_Int16>(rUnderlineItem.GetLineStyle()); lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_UNDERLINE,makeAny(nUnderline)); // the text line color is transported in this item, too sal_Int32 nColor = rUnderlineItem.GetColor().GetColor(); Any aUnoColor; - if (COL_AUTO != (sal_uInt32)nColor) + if (COL_AUTO != static_cast<sal_uInt32>(nColor)) aUnoColor <<= nColor; lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTLINECOLOR, aUnoColor ); @@ -390,7 +390,7 @@ namespace pcr const SvxCrossedOutItem& rCrossedOutItem = static_cast<const SvxCrossedOutItem&>(_rSet.Get(CFID_STRIKEOUT)); - sal_Int16 nStrikeout = (sal_Int16)rCrossedOutItem.GetStrikeout(); + sal_Int16 nStrikeout = static_cast<sal_Int16>(rCrossedOutItem.GetStrikeout()); lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STRIKEOUT,makeAny(nStrikeout)); } @@ -418,7 +418,7 @@ namespace pcr sal_Int32 nColor = rColorItem.GetValue().GetColor(); Any aUnoColor; - if (COL_AUTO != (sal_uInt32)nColor) + if (COL_AUTO != static_cast<sal_uInt32>(nColor)) aUnoColor <<= nColor; lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTCOLOR, aUnoColor ); diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index 89c44b73054b..60bbffd76bb3 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -2678,7 +2678,7 @@ namespace pcr pItem = nullptr; if ( SfxItemState::SET == pResult->GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, false, &pItem ) ) { - _out_rNewValue <<= (sal_Int32)( static_cast< const SfxUInt32Item* >( pItem )->GetValue() ); + _out_rNewValue <<= static_cast<sal_Int32>( static_cast< const SfxUInt32Item* >( pItem )->GetValue() ); bChanged = true; } } diff --git a/extensions/source/propctrlr/formmetadata.cxx b/extensions/source/propctrlr/formmetadata.cxx index 0f8e6cc5b235..8a1622c44311 100644 --- a/extensions/source/propctrlr/formmetadata.cxx +++ b/extensions/source/propctrlr/formmetadata.cxx @@ -621,15 +621,15 @@ namespace pcr break; case TypeClass_SHORT: - _out_rValue <<= (sal_Int16)nPos; + _out_rValue <<= static_cast<sal_Int16>(nPos); break; case TypeClass_UNSIGNED_SHORT: - _out_rValue <<= (sal_uInt16)nPos; + _out_rValue <<= static_cast<sal_uInt16>(nPos); break; case TypeClass_UNSIGNED_LONG: - _out_rValue <<= (sal_uInt32)nPos; + _out_rValue <<= static_cast<sal_uInt32>(nPos); break; default: @@ -657,7 +657,7 @@ namespace pcr --nIntValue; std::vector< OUString > aEnumStrings = m_rMetaData.getPropertyEnumRepresentations( m_nPropertyId ); - if ( ( nIntValue >= 0 ) && ( nIntValue < (sal_Int32)aEnumStrings.size() ) ) + if ( ( nIntValue >= 0 ) && ( nIntValue < static_cast<sal_Int32>(aEnumStrings.size()) ) ) { sReturn = aEnumStrings[ nIntValue ]; } diff --git a/extensions/source/propctrlr/genericpropertyhandler.cxx b/extensions/source/propctrlr/genericpropertyhandler.cxx index 3e8bddacbb6c..21bddf5fc736 100644 --- a/extensions/source/propctrlr/genericpropertyhandler.cxx +++ b/extensions/source/propctrlr/genericpropertyhandler.cxx @@ -165,7 +165,7 @@ namespace pcr sal_Int32 index = std::find( aValues.begin(), aValues.end(), nAsInt ) - aValues.begin(); std::vector< OUString > aDescriptions( getDescriptions() ); - if ( ( index >= 0 ) && ( index < (sal_Int32)aDescriptions.size() ) ) + if ( ( index >= 0 ) && ( index < static_cast<sal_Int32>(aDescriptions.size()) ) ) sDescription = aDescriptions[ index ]; else { diff --git a/extensions/source/propctrlr/propcontroller.cxx b/extensions/source/propctrlr/propcontroller.cxx index 7e6c7419aa6e..539e5be292d6 100644 --- a/extensions/source/propctrlr/propcontroller.cxx +++ b/extensions/source/propctrlr/propcontroller.cxx @@ -634,7 +634,7 @@ namespace pcr m_sPageSelection.clear(); const sal_uInt16 nCurrentPage = m_pView->getActivaPage(); - if ( (sal_uInt16)-1 != nCurrentPage ) + if ( sal_uInt16(-1) != nCurrentPage ) { for ( HashString2Int16::const_iterator pageId = m_aPageIds.begin(); pageId != m_aPageIds.end(); @@ -658,7 +658,7 @@ namespace pcr sal_uInt16 OPropertyBrowserController::impl_getPageIdForCategory_nothrow( const OUString& _rCategoryName ) const { - sal_uInt16 nPageId = (sal_uInt16)-1; + sal_uInt16 nPageId = sal_uInt16(-1); HashString2Int16::const_iterator pagePos = m_aPageIds.find( _rCategoryName ); if ( pagePos != m_aPageIds.end() ) nPageId = pagePos->second; @@ -670,7 +670,7 @@ namespace pcr { sal_uInt16 nNewPage = impl_getPageIdForCategory_nothrow( m_sPageSelection ); - if ( haveView() && ( nNewPage != (sal_uInt16)-1 ) ) + if ( haveView() && ( nNewPage != sal_uInt16(-1) ) ) m_pView->activatePage( nNewPage ); // just in case ... @@ -1204,7 +1204,7 @@ namespace pcr << property->second.Name << "'!"); // finally insert this property control sal_uInt16 nTargetPageId = impl_getPageIdForCategory_nothrow( aDescriptor.Category ); - if ( nTargetPageId == (sal_uInt16)-1 ) + if ( nTargetPageId == sal_uInt16(-1) ) { // this category does not yet exist. This is allowed, as an inspector model might be lazy, and not provide // any category information of its own. In this case, we have a fallback ... @@ -1627,7 +1627,7 @@ namespace pcr throw RuntimeException(); sal_uInt16 nPageId = impl_getPageIdForCategory_nothrow( _rCategory ); - OSL_ENSURE( nPageId != (sal_uInt16)-1, "OPropertyBrowserController::showCategory: invalid category!" ); + OSL_ENSURE( nPageId != sal_uInt16(-1), "OPropertyBrowserController::showCategory: invalid category!" ); getPropertyBox().ShowPropertyPage( nPageId, _bShow ); } diff --git a/extensions/source/propctrlr/propertyeditor.cxx b/extensions/source/propctrlr/propertyeditor.cxx index cb266a4780ce..7083df4cea96 100644 --- a/extensions/source/propctrlr/propertyeditor.cxx +++ b/extensions/source/propctrlr/propertyeditor.cxx @@ -80,7 +80,7 @@ namespace pcr sal_uInt16 nCount = m_aTabControl->GetPageCount(); for(long i = nCount-1; i >= 0; --i) { - sal_uInt16 nID = m_aTabControl->GetPageId((sal_uInt16)i); + sal_uInt16 nID = m_aTabControl->GetPageId(static_cast<sal_uInt16>(i)); VclPtr<OBrowserPage> pPage = static_cast<OBrowserPage*>(m_aTabControl->GetTabPage(nID)); if (pPage) { @@ -135,7 +135,7 @@ namespace pcr sal_Int32 nPageMinWidth = 0; for(long i = nCount-1; i >= 0; --i) { - sal_uInt16 nID = m_aTabControl->GetPageId((sal_uInt16)i); + sal_uInt16 nID = m_aTabControl->GetPageId(static_cast<sal_uInt16>(i)); OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl->GetTabPage(nID)); if (pPage) { @@ -516,7 +516,7 @@ namespace pcr // commit the data on the current (to-be-deactivated) tab page // (79404) sal_Int32 nCurrentId = m_aTabControl->GetCurPageId(); - OBrowserPage* pCurrentPage = static_cast<OBrowserPage*>(m_aTabControl->GetTabPage((sal_uInt16)nCurrentId)); + OBrowserPage* pCurrentPage = static_cast<OBrowserPage*>(m_aTabControl->GetTabPage(static_cast<sal_uInt16>(nCurrentId))); if ( !pCurrentPage ) return true; diff --git a/extensions/source/propctrlr/propertyhandler.cxx b/extensions/source/propctrlr/propertyhandler.cxx index 632036c83f54..093ff3268637 100644 --- a/extensions/source/propctrlr/propertyhandler.cxx +++ b/extensions/source/propctrlr/propertyhandler.cxx @@ -385,7 +385,7 @@ namespace pcr { ::utl::OConfigurationTreeRoot aConfigTree( ::utl::OConfigurationTreeRoot::createWithComponentContext( m_xContext, sConfigurationLocation, -1, ::utl::OConfigurationTreeRoot::CM_READONLY ) ); - sal_Int32 nUnitAsInt = (sal_Int32)FUNIT_NONE; + sal_Int32 nUnitAsInt = sal_Int32(FUNIT_NONE); aConfigTree.getNodeValue( sConfigurationProperty ) >>= nUnitAsInt; // if this denotes a valid (and accepted) unit, then use it diff --git a/extensions/source/propctrlr/sqlcommanddesign.cxx b/extensions/source/propctrlr/sqlcommanddesign.cxx index 63c9528754ed..2f22ac22b30f 100644 --- a/extensions/source/propctrlr/sqlcommanddesign.cxx +++ b/extensions/source/propctrlr/sqlcommanddesign.cxx @@ -229,7 +229,7 @@ namespace pcr aArgs[1].Name = PROPERTY_COMMAND; aArgs[1].Value <<= m_xObjectAdapter->getSQLCommand(); aArgs[2].Name = PROPERTY_COMMANDTYPE; - aArgs[2].Value <<= (sal_Int32)CommandType::COMMAND; + aArgs[2].Value <<= sal_Int32(CommandType::COMMAND); aArgs[3].Name = PROPERTY_ESCAPE_PROCESSING; aArgs[3].Value <<= m_xObjectAdapter->getEscapeProcessing(); diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx index 5985f5f507d1..b1c3152b80c9 100644 --- a/extensions/source/propctrlr/standardcontrol.cxx +++ b/extensions/source/propctrlr/standardcontrol.cxx @@ -202,7 +202,7 @@ namespace pcr if ( m_bIsPassword ) { if ( !sText.isEmpty() ) - aPropValue <<= (sal_Int16)sText[0]; + aPropValue <<= static_cast<sal_Int16>(sText[0]); } else aPropValue <<= sText; @@ -235,7 +235,7 @@ namespace pcr if ( n > std::numeric_limits< long >::max() ) return std::numeric_limits< long >::max(); - return (long)n; + return static_cast<long>(n); } @@ -507,7 +507,7 @@ namespace pcr if ( minValue == std::numeric_limits< sal_Int64 >::min() ) aReturn.IsPresent = false; else - aReturn.Value = (double)minValue; + aReturn.Value = static_cast<double>(minValue); return aReturn; } @@ -530,7 +530,7 @@ namespace pcr if ( maxValue == std::numeric_limits< sal_Int64 >::max() ) aReturn.IsPresent = false; else - aReturn.Value = (double)maxValue; + aReturn.Value = static_cast<double>(maxValue); return aReturn; } @@ -615,7 +615,7 @@ namespace pcr double ONumericControl::impl_fieldValueToApiValue_nothrow( sal_Int64 _nFieldValue ) const { - double nApiValue = ImplCalcDoubleValue( (long)_nFieldValue, getTypedControlWindow()->GetDecimalDigits() ); + double nApiValue = ImplCalcDoubleValue( static_cast<long>(_nFieldValue), getTypedControlWindow()->GetDecimalDigits() ); nApiValue *= m_nFieldToUNOValueFactor; return nApiValue; } @@ -654,7 +654,7 @@ namespace pcr css::util::Color nColor = COL_TRANSPARENT; if (_rValue.hasValue()) _rValue >>= nColor; - getTypedControlWindow()->SelectEntry(::Color((ColorData)nColor)); + getTypedControlWindow()->SelectEntry(::Color(static_cast<ColorData>(nColor))); } Any SAL_CALL OColorControl::getValue() @@ -663,7 +663,7 @@ namespace pcr ::Color aRgbCol = getTypedControlWindow()->GetSelectEntryColor(); if (aRgbCol == COL_TRANSPARENT) return aPropValue; - aPropValue <<= (css::util::Color)aRgbCol.GetColor(); + aPropValue <<= static_cast<css::util::Color>(aRgbCol.GetColor()); return aPropValue; } @@ -1167,7 +1167,7 @@ namespace pcr { for (sal_Int32 i=1; i<nCount; ++i) { - aInput=aStr.getToken((sal_uInt16)i, '\n'); + aInput=aStr.getToken(static_cast<sal_uInt16>(i), '\n'); if (!aInput.isEmpty()) { aOutput += ";"; diff --git a/extensions/source/propctrlr/taborder.cxx b/extensions/source/propctrlr/taborder.cxx index 719ca2cc1431..ee69ac994211 100644 --- a/extensions/source/propctrlr/taborder.cxx +++ b/extensions/source/propctrlr/taborder.cxx @@ -368,7 +368,7 @@ namespace pcr long nVisibleSize = GetVScroll()->GetVisibleSize(); long nFirstVisible = GetModel()->GetAbsPos( FirstVisible()); - if ( ( nThumbPos + nVisibleSize + 1 ) < (long)( nLastSelPos + 3 ) ) + if ( ( nThumbPos + nVisibleSize + 1 ) < static_cast<long>( nLastSelPos + 3 ) ) GetVScroll()->DoScrollAction(ScrollType::LineDown); else if((nThumbPos+nVisibleSize+1) >= nFirstVisible) GetVScroll()->DoScrollAction(ScrollType::LineUp); diff --git a/extensions/source/propctrlr/usercontrol.cxx b/extensions/source/propctrlr/usercontrol.cxx index 213d61c6efa1..82c2634a7670 100644 --- a/extensions/source/propctrlr/usercontrol.cxx +++ b/extensions/source/propctrlr/usercontrol.cxx @@ -155,7 +155,7 @@ namespace pcr { Any aPropValue; if ( !getTypedControlWindow()->GetText().isEmpty() ) - aPropValue <<= (sal_Int32)getTypedControlWindow()->GetFormatKey(); + aPropValue <<= static_cast<sal_Int32>(getTypedControlWindow()->GetFormatKey()); return aPropValue; } diff --git a/extensions/source/scanner/grid.cxx b/extensions/source/scanner/grid.cxx index b0cc583aca43..a5b195756830 100644 --- a/extensions/source/scanner/grid.cxx +++ b/extensions/source/scanner/grid.cxx @@ -315,13 +315,13 @@ Point GridWindow::transform( double x, double y ) { Point aRet; - aRet.X() = (long)( ( x - m_fMinX ) * - (double)m_aGridArea.GetWidth() / ( m_fMaxX - m_fMinX ) + aRet.X() = static_cast<long>( ( x - m_fMinX ) * + static_cast<double>(m_aGridArea.GetWidth()) / ( m_fMaxX - m_fMinX ) + m_aGridArea.Left() ); - aRet.Y() = (long)( + aRet.Y() = static_cast<long>( m_aGridArea.Bottom() - ( y - m_fMinY ) * - (double)m_aGridArea.GetHeight() / ( m_fMaxY - m_fMinY ) ); + static_cast<double>(m_aGridArea.GetHeight()) / ( m_fMaxY - m_fMinY ) ); return aRet; } @@ -331,8 +331,8 @@ void GridWindow::transform( const Point& rOriginal, double& x, double& y ) const long nHeight = m_aGridArea.GetHeight(); if (!nWidth || !nHeight) return; - x = ( rOriginal.X() - m_aGridArea.Left() ) * (m_fMaxX - m_fMinX) / (double)nWidth + m_fMinX; - y = ( m_aGridArea.Bottom() - rOriginal.Y() ) * (m_fMaxY - m_fMinY) / (double)nHeight + m_fMinY; + x = ( rOriginal.X() - m_aGridArea.Left() ) * (m_fMaxX - m_fMinX) / static_cast<double>(nWidth) + m_fMinX; + y = ( m_aGridArea.Bottom() - rOriginal.Y() ) * (m_fMaxY - m_fMinY) / static_cast<double>(nHeight) + m_fMinY; } void GridWindow::drawLine(vcl::RenderContext& rRenderContext, double x1, double y1, double x2, double y2 ) @@ -344,8 +344,8 @@ void GridWindow::computeChunk( double fMin, double fMax, double& fChunkOut, doub { // get a nice chunk size like 10, 100, 25 or such fChunkOut = ( fMax - fMin ) / 6.0; - int logchunk = (int)std::log10( fChunkOut ); - int nChunk = (int)( fChunkOut / std::exp( (double)(logchunk-1) * M_LN10 ) ); + int logchunk = static_cast<int>(std::log10( fChunkOut )); + int nChunk = static_cast<int>( fChunkOut / std::exp( static_cast<double>(logchunk-1) * M_LN10 ) ); if( nChunk >= 75 ) nChunk = 100; else if( nChunk >= 35 ) @@ -358,10 +358,10 @@ void GridWindow::computeChunk( double fMin, double fMax, double& fChunkOut, doub nChunk = 10; else nChunk = 5; - fChunkOut = (double) nChunk * exp( (double)(logchunk-1) * M_LN10 ); + fChunkOut = static_cast<double>(nChunk) * exp( static_cast<double>(logchunk-1) * M_LN10 ); // compute whole chunks fitting into fMin - nChunk = (int)( fMin / fChunkOut ); - fMinChunkOut = (double)nChunk * fChunkOut; + nChunk = static_cast<int>( fMin / fChunkOut ); + fMinChunkOut = static_cast<double>(nChunk) * fChunkOut; while( fMinChunkOut < fMin ) fMinChunkOut += fChunkOut; } diff --git a/extensions/source/scanner/sane.cxx b/extensions/source/scanner/sane.cxx index a22cda021bd4..be0d5bd40527 100644 --- a/extensions/source/scanner/sane.cxx +++ b/extensions/source/scanner/sane.cxx @@ -123,7 +123,7 @@ SANE_Status Sane::ControlOption( int nOption, SANE_Action nAction, { SANE_Int nInfo = 0; - SANE_Status nStatus = p_control_option( maHandle, (SANE_Int)nOption, + SANE_Status nStatus = p_control_option( maHandle, static_cast<SANE_Int>(nOption), nAction, pData, &nInfo ); DUMP_STATE( nStatus, "sane_control_option" ); #if OSL_DEBUG_LEVEL > 0 @@ -271,7 +271,7 @@ void Sane::ReloadOptions() fprintf( stderr, "Error: sane driver returned %s while reading number of options !\n", p_strstatus( nStatus ) ); mnOptions = pOptions[ 0 ]; - if( (size_t)pZero->size > sizeof( SANE_Word ) ) + if( static_cast<size_t>(pZero->size) > sizeof( SANE_Word ) ) fprintf( stderr, "driver returned numer of options with larger size tha SANE_Word !!!\n" ); if( mppOptions ) delete [] mppOptions; @@ -384,7 +384,7 @@ bool Sane::GetOptionValue( int n, double& rRet, int nElement ) { bSuccess = true; if( mppOptions[n]->type == SANE_TYPE_INT ) - rRet = (double)pRet[ nElement ]; + rRet = static_cast<double>(pRet[ nElement ]); else rRet = SANE_UNFIX( pRet[nElement] ); } @@ -406,7 +406,7 @@ bool Sane::GetOptionValue( int n, double* pSet ) if( mppOptions[n]->type == SANE_TYPE_FIXED ) pSet[i] = SANE_UNFIX( pFixedSet[i] ); else - pSet[i] = (double) pFixedSet[i]; + pSet[i] = static_cast<double>(pFixedSet[i]); } return true; } @@ -440,7 +440,7 @@ void Sane::SetOptionValue( int n, double fSet, int nElement ) if( nStatus == SANE_STATUS_GOOD ) { pSet[nElement] = mppOptions[n]->type == SANE_TYPE_INT ? - (SANE_Word)fSet : SANE_FIX( fSet ); + static_cast<SANE_Word>(fSet) : SANE_FIX( fSet ); ControlOption( n, SANE_ACTION_SET_VALUE, pSet.get() ); } } @@ -448,7 +448,7 @@ void Sane::SetOptionValue( int n, double fSet, int nElement ) { SANE_Word nSetTo = mppOptions[n]->type == SANE_TYPE_INT ? - (SANE_Word)fSet : SANE_FIX( fSet ); + static_cast<SANE_Word>(fSet) : SANE_FIX( fSet ); ControlOption( n, SANE_ACTION_SET_VALUE, &nSetTo ); } @@ -465,7 +465,7 @@ void Sane::SetOptionValue( int n, double const * pSet ) if( mppOptions[n]->type == SANE_TYPE_FIXED ) pFixedSet[i] = SANE_FIX( pSet[i] ); else - pFixedSet[i] = (SANE_Word)pSet[i]; + pFixedSet[i] = static_cast<SANE_Word>(pSet[i]); } ControlOption( n, SANE_ACTION_SET_VALUE, pFixedSet.get() ); } @@ -494,7 +494,7 @@ static inline sal_uInt8 ReadValue( FILE* fp, int depth ) return 0; } - return (sal_uInt8)( nWord / 256 ); + return static_cast<sal_uInt8>( nWord / 256 ); } sal_uInt8 nByte; size_t items_read = fread( &nByte, 1, 1, fp ); @@ -556,7 +556,7 @@ bool Sane::Start( BitmapTransporter& rBitmap ) GetOptionValue( nOption, fBRx ) && GetOptionUnit( nOption ) == SANE_UNIT_MM ) { - nWidthMM = (int)fabs(fBRx - fTLx); + nWidthMM = static_cast<int>(fabs(fBRx - fTLx)); } } if( ( nOption = GetOptionByName( "tl-y" ) ) != -1 && @@ -568,7 +568,7 @@ bool Sane::Start( BitmapTransporter& rBitmap ) GetOptionValue( nOption, fBRy ) && GetOptionUnit( nOption ) == SANE_UNIT_MM ) { - nHeightMM = (int)fabs(fBRy - fTLy); + nHeightMM = static_cast<int>(fabs(fBRy - fTLy)); } } if( ( nOption = GetOptionByName( "resolution" ) ) != -1 ) @@ -632,11 +632,11 @@ bool Sane::Start( BitmapTransporter& rBitmap ) { aParams.format = (SANE_Frame)5; } - fprintf( stderr, "format: %s\n", ppFormats[ (int)aParams.format ] ); + fprintf( stderr, "format: %s\n", ppFormats[ static_cast<int>(aParams.format) ] ); fprintf( stderr, "last_frame: %s\n", aParams.last_frame ? "TRUE" : "FALSE" ); - fprintf( stderr, "depth: %d\n", (int)aParams.depth ); - fprintf( stderr, "pixels_per_line: %d\n", (int)aParams.pixels_per_line ); - fprintf( stderr, "bytes_per_line: %d\n", (int)aParams.bytes_per_line ); + fprintf( stderr, "depth: %d\n", static_cast<int>(aParams.depth) ); + fprintf( stderr, "pixels_per_line: %d\n", static_cast<int>(aParams.pixels_per_line) ); + fprintf( stderr, "bytes_per_line: %d\n", static_cast<int>(aParams.bytes_per_line) ); #endif if( ! pBuffer ) { @@ -707,7 +707,7 @@ bool Sane::Start( BitmapTransporter& rBitmap ) struct timeval tv; FD_ZERO( &fdset ); - FD_SET( (int)fd, &fdset ); + FD_SET( static_cast<int>(fd), &fdset ); tv.tv_sec = 5; tv.tv_usec = 0; if( select( fd+1, &fdset, nullptr, nullptr, &tv ) == 0 ) @@ -735,16 +735,16 @@ bool Sane::Start( BitmapTransporter& rBitmap ) int nFrameLength = ftell( pFrame ); fseek( pFrame, 0, SEEK_SET ); - sal_uInt32 nWidth = (sal_uInt32) aParams.pixels_per_line; - sal_uInt32 nHeight = (sal_uInt32) (nFrameLength / aParams.bytes_per_line); + sal_uInt32 nWidth = static_cast<sal_uInt32>(aParams.pixels_per_line); + sal_uInt32 nHeight = static_cast<sal_uInt32>(nFrameLength / aParams.bytes_per_line); if( ! bWidthSet ) { if( ! fResl ) fResl = 300; // if all else fails that's a good guess if( ! nWidthMM ) - nWidthMM = (int)(((double)nWidth / fResl) * 25.4); + nWidthMM = static_cast<int>((static_cast<double>(nWidth) / fResl) * 25.4); if( ! nHeightMM ) - nHeightMM = (int)(((double)nHeight / fResl) * 25.4); + nHeightMM = static_cast<int>((static_cast<double>(nHeight) / fResl) * 25.4); SAL_INFO("extensions.scanner", "set dimensions to(" << nWidth << ", " << nHeight << ") Pixel, (" << nWidthMM << ", " << nHeightMM << ") mm, resolution is " << fResl); @@ -915,15 +915,15 @@ int Sane::GetRange( int n, double*& rpDouble ) } else { - fMin = (double)mppOptions[n]->constraint.range->min; - fMax = (double)mppOptions[n]->constraint.range->max; - fQuant = (double)mppOptions[n]->constraint.range->quant; + fMin = static_cast<double>(mppOptions[n]->constraint.range->min); + fMax = static_cast<double>(mppOptions[n]->constraint.range->max); + fQuant = static_cast<double>(mppOptions[n]->constraint.range->quant); } if( fQuant != 0.0 ) { dbg_msg( "quantum range [ %lg ; %lg ; %lg ]\n", fMin, fQuant, fMax ); - nItems = (int)((fMax - fMin)/fQuant)+1; + nItems = static_cast<int>((fMax - fMin)/fQuant)+1; rpDouble = new double[ nItems ]; double fValue = fMin; for( i = 0; i < nItems; i++, fValue += fQuant ) @@ -949,7 +949,7 @@ int Sane::GetRange( int n, double*& rpDouble ) { rpDouble[i] = bIsFixed ? SANE_UNFIX( mppOptions[n]->constraint.word_list[i+1] ) : - (double)mppOptions[n]->constraint.word_list[i+1]; + static_cast<double>(mppOptions[n]->constraint.word_list[i+1]); } dbg_msg( "wordlist [ %lg ... %lg ]\n", rpDouble[ 0 ], rpDouble[ nItems-1 ] ); @@ -971,7 +971,7 @@ OUString Sane::GetOptionUnitName( int n ) { OUString aText; SANE_Unit nUnit = mppOptions[n]->unit; - size_t nUnitAsSize = (size_t)nUnit; + size_t nUnitAsSize = static_cast<size_t>(nUnit); if (nUnitAsSize >= SAL_N_ELEMENTS( ppUnits )) aText = "[unknown units]"; else diff --git a/extensions/source/scanner/sanedlg.cxx b/extensions/source/scanner/sanedlg.cxx index 83bea0e05367..5a35b7f1026b 100644 --- a/extensions/source/scanner/sanedlg.cxx +++ b/extensions/source/scanner/sanedlg.cxx @@ -393,7 +393,7 @@ void SaneDlg::InitFields() { mpReslBox->Enable(); - mpReslBox->SetValue( (long)fRes ); + mpReslBox->SetValue( static_cast<long>(fRes) ); double *pDouble = nullptr; nValue = mrSane.GetRange( nOption, pDouble ); if( nValue > -1 ) @@ -401,33 +401,33 @@ void SaneDlg::InitFields() assert(pDouble); if( nValue ) { - mpReslBox->SetMin( (long)pDouble[0] ); - mpReslBox->SetMax( (long)pDouble[ nValue-1 ] ); + mpReslBox->SetMin( static_cast<long>(pDouble[0]) ); + mpReslBox->SetMax( static_cast<long>(pDouble[ nValue-1 ]) ); for( i=0; i<nValue; i++ ) { - if( i == 0 || i == nValue-1 || ! ( ((int)pDouble[i]) % 20) ) - mpReslBox->InsertValue( (long)pDouble[i] ); + if( i == 0 || i == nValue-1 || ! ( static_cast<int>(pDouble[i]) % 20) ) + mpReslBox->InsertValue( static_cast<long>(pDouble[i]) ); } } else { - mpReslBox->SetMin( (long)pDouble[0] ); - mpReslBox->SetMax( (long)pDouble[1] ); - mpReslBox->InsertValue( (long)pDouble[0] ); + mpReslBox->SetMin( static_cast<long>(pDouble[0]) ); + mpReslBox->SetMax( static_cast<long>(pDouble[1]) ); + mpReslBox->InsertValue( static_cast<long>(pDouble[0]) ); // Can only select 75 and 2400 dpi in Scanner dialogue // scanner allows random setting of dpi resolution, a slider might be useful // support that // workaround: offer at least some more standard dpi resolution between // min and max value int bGot300 = 0; - for ( long nRes = (long) pDouble[0] * 2; nRes < (long) pDouble[1]; nRes = nRes * 2 ) + for ( long nRes = static_cast<long>(pDouble[0]) * 2; nRes < static_cast<long>(pDouble[1]); nRes = nRes * 2 ) { if ( !bGot300 && nRes > 300 ) { nRes = 300; bGot300 = 1; } mpReslBox->InsertValue(nRes); } - mpReslBox->InsertValue( (long)pDouble[1] ); + mpReslBox->InsertValue( static_cast<long>(pDouble[1]) ); } } else @@ -469,18 +469,18 @@ void SaneDlg::InitFields() if( mrSane.GetOptionUnit( nOption ) == SANE_UNIT_MM ) { pField->SetUnit( FUNIT_MM ); - pField->SetValue( (int)fValue, FUNIT_MM ); + pField->SetValue( static_cast<int>(fValue), FUNIT_MM ); } else // SANE_UNIT_PIXEL { - pField->SetValue( (int)fValue, FUNIT_CUSTOM ); + pField->SetValue( static_cast<int>(fValue), FUNIT_CUSTOM ); pField->SetCustomUnitText("Pixel"); } switch( i ) { - case 0: aTopLeft.X() = (int)fValue;break; - case 1: aTopLeft.Y() = (int)fValue;break; - case 2: aBottomRight.X() = (int)fValue;break; - case 3: aBottomRight.Y() = (int)fValue;break; + case 0: aTopLeft.X() = static_cast<int>(fValue);break; + case 1: aTopLeft.Y() = static_cast<int>(fValue);break; + case 2: aBottomRight.X() = static_cast<int>(fValue);break; + case 3: aBottomRight.Y() = static_cast<int>(fValue);break; } } double *pDouble = nullptr; @@ -489,11 +489,11 @@ void SaneDlg::InitFields() { if( pDouble ) { - pField->SetMin( (long)pDouble[0] ); + pField->SetMin( static_cast<long>(pDouble[0]) ); if( nValue ) - pField->SetMax( (long)pDouble[ nValue-1 ] ); + pField->SetMax( static_cast<long>(pDouble[ nValue-1 ]) ); else - pField->SetMax( (long)pDouble[ 1 ] ); + pField->SetMax( static_cast<long>(pDouble[ 1 ]) ); delete [] pDouble; } switch( i ) { @@ -506,10 +506,10 @@ void SaneDlg::InitFields() else { switch( i ) { - case 0: aMinTopLeft.X() = (int)fValue;break; - case 1: aMinTopLeft.Y() = (int)fValue;break; - case 2: aMaxBottomRight.X() = (int)fValue;break; - case 3: aMaxBottomRight.Y() = (int)fValue;break; + case 0: aMinTopLeft.X() = static_cast<int>(fValue);break; + case 1: aMinTopLeft.Y() = static_cast<int>(fValue);break; + case 2: aMaxBottomRight.X() = static_cast<int>(fValue);break; + case 3: aMaxBottomRight.Y() = static_cast<int>(fValue);break; } } pField->Enable(); @@ -636,7 +636,7 @@ IMPL_LINK( SaneDlg, ClickBtnHdl, Button*, pButton, void ) std::unique_ptr<double[]> x(new double[ nElements ]); std::unique_ptr<double[]> y(new double[ nElements ]); for( int i = 0; i < nElements; i++ ) - x[ i ] = (double)i; + x[ i ] = static_cast<double>(i); mrSane.GetOptionValue( mnCurrentOption, y.get() ); ScopedVclPtrInstance< GridDialog > aGrid( x.get(), y.get(), nElements, this ); @@ -659,7 +659,7 @@ IMPL_LINK( SaneDlg, ClickBtnHdl, Button*, pButton, void ) } if( pButton == mpOKButton || pButton == mpScanButton ) { - double fRes = (double)mpReslBox->GetValue(); + double fRes = static_cast<double>(mpReslBox->GetValue()); SetAdjustedNumericalValue( "resolution", fRes ); UpdateScanArea(true); SaveState(); @@ -779,7 +779,7 @@ IMPL_LINK( SaneDlg, ModifyHdl, Edit&, rEdit, void ) } else if( &rEdit == mpReslBox ) { - double fRes = (double)mpReslBox->GetValue(); + double fRes = static_cast<double>(mpReslBox->GetValue()); int nOption = mrSane.GetOptionByName( "resolution" ); if( nOption != -1 ) { @@ -804,7 +804,7 @@ IMPL_LINK( SaneDlg, ModifyHdl, Edit&, rEdit, void ) fRes = pDouble[ 1 ]; } delete[] pDouble; - mpReslBox->SetValue( (sal_uLong)fRes ); + mpReslBox->SetValue( static_cast<sal_uLong>(fRes) ); } } else if( &rEdit == mpNumericEdit ) @@ -874,7 +874,7 @@ void SaneDlg::AcquirePreview() UpdateScanArea( true ); // set small resolution for preview - double fResl = (double)mpReslBox->GetValue(); + double fResl = static_cast<double>(mpReslBox->GetValue()); SetAdjustedNumericalValue( "resolution", 30.0 ); int nOption = mrSane.GetOptionByName( "preview" ); @@ -905,7 +905,7 @@ void SaneDlg::AcquirePreview() } SetAdjustedNumericalValue( "resolution", fResl ); - mpReslBox->SetValue( (sal_uLong)fResl ); + mpReslBox->SetValue( static_cast<sal_uLong>(fResl) ); mpPreview->UpdatePreviewBounds(); mpPreview->Invalidate(); @@ -1299,10 +1299,10 @@ void SaneDlg::UpdateScanArea(bool bSend) if( mrSane.IsOpen() ) { - SetAdjustedNumericalValue( "tl-x", (double)aUL.X() ); - SetAdjustedNumericalValue( "tl-y", (double)aUL.Y() ); - SetAdjustedNumericalValue( "br-x", (double)aBR.X() ); - SetAdjustedNumericalValue( "br-y", (double)aBR.Y() ); + SetAdjustedNumericalValue( "tl-x", static_cast<double>(aUL.X()) ); + SetAdjustedNumericalValue( "tl-y", static_cast<double>(aUL.Y()) ); + SetAdjustedNumericalValue( "br-x", static_cast<double>(aBR.X()) ); + SetAdjustedNumericalValue( "br-y", static_cast<double>(aBR.Y()) ); } } diff --git a/extensions/source/scanner/scanunx.cxx b/extensions/source/scanner/scanunx.cxx index 45015ef127f1..20fdb2b52e70 100644 --- a/extensions/source/scanner/scanunx.cxx +++ b/extensions/source/scanner/scanunx.cxx @@ -248,7 +248,7 @@ sal_Bool ScannerManager::configureScannerAndScan( ScannerContext& scanner_contex SAL_INFO("extensions.scanner", "ScannerManager::configureScanner"); - if( scanner_context.InternalData < 0 || (sal_uLong)scanner_context.InternalData >= rSanes.size() ) + if( scanner_context.InternalData < 0 || static_cast<sal_uLong>(scanner_context.InternalData) >= rSanes.size() ) throw ScannerException( "Scanner does not exist", Reference< XScannerManager >( this ), @@ -284,7 +284,7 @@ void ScannerManager::startScan( const ScannerContext& scanner_context, SAL_INFO("extensions.scanner", "ScannerManager::startScan"); - if( scanner_context.InternalData < 0 || (sal_uLong)scanner_context.InternalData >= rSanes.size() ) + if( scanner_context.InternalData < 0 || static_cast<sal_uLong>(scanner_context.InternalData) >= rSanes.size() ) throw ScannerException( "Scanner does not exist", Reference< XScannerManager >( this ), @@ -309,7 +309,7 @@ ScanError ScannerManager::getError( const ScannerContext& scanner_context ) osl::MutexGuard aGuard( theSaneProtector::get() ); sanevec &rSanes = theSanes::get().m_aSanes; - if( scanner_context.InternalData < 0 || (sal_uLong)scanner_context.InternalData >= rSanes.size() ) + if( scanner_context.InternalData < 0 || static_cast<sal_uLong>(scanner_context.InternalData) >= rSanes.size() ) throw ScannerException( "Scanner does not exist", Reference< XScannerManager >( this ), @@ -327,7 +327,7 @@ Reference< css::awt::XBitmap > ScannerManager::getBitmap( const ScannerContext& osl::MutexGuard aGuard( theSaneProtector::get() ); sanevec &rSanes = theSanes::get().m_aSanes; - if( scanner_context.InternalData < 0 || (sal_uLong)scanner_context.InternalData >= rSanes.size() ) + if( scanner_context.InternalData < 0 || static_cast<sal_uLong>(scanner_context.InternalData) >= rSanes.size() ) throw ScannerException( "Scanner does not exist", Reference< XScannerManager >( this ), diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx index 7bc20f874f89..922b44272744 100644 --- a/extensions/source/update/check/download.cxx +++ b/extensions/source/update/check/download.cxx @@ -96,7 +96,7 @@ static void openFile( OutData& out ) } while( osl_File_E_EXIST == rc ); if( osl_File_E_None == rc ) - out.Handler->downloadStarted(out.File, (sal_Int64) fDownloadSize); + out.Handler->downloadStarted(out.File, static_cast<sal_Int64>(fDownloadSize)); } } @@ -137,7 +137,7 @@ write_function( void *ptr, size_t size, size_t nmemb, void *stream ) if( nullptr != out->FileHandle ) osl_writeFile(out->FileHandle, ptr, size * nmemb, &nBytesWritten); - return (size_t) nBytesWritten; + return static_cast<size_t>(nBytesWritten); } @@ -160,7 +160,7 @@ progress_callback( void *clientp, double dltotal, double dlnow, SAL_UNUSED_PARAM long nCode; curl_easy_getinfo(out->curl, CURLINFO_RESPONSE_CODE, &nCode); if( (nCode != 302) && (nCode != 303) && (dltotal > 0) ) - out->Handler->downloadProgressAt((sal_Int8)fPercent); + out->Handler->downloadProgressAt(static_cast<sal_Int8>(fPercent)); return 0; } @@ -257,7 +257,7 @@ bool curl_run(const OUString& rURL, OutData& out, const OString& aProxyHost, sal { // curl_off_t offset = nOffset; libcurl seems to be compiled with large // file support (and we not) .. - sal_Int64 offset = (sal_Int64) out.Offset; + sal_Int64 offset = static_cast<sal_Int64>(out.Offset); curl_easy_setopt(pCURL, CURLOPT_RESUME_FROM_LARGE, offset); } diff --git a/extensions/source/update/check/updatecheck.cxx b/extensions/source/update/check/updatecheck.cxx index 93fec712db8c..4f4e30e48568 100644 --- a/extensions/source/update/check/updatecheck.cxx +++ b/extensions/source/update/check/updatecheck.cxx @@ -762,7 +762,7 @@ UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues, } else // Calculate initial percent value. { - sal_Int32 nPercent = (sal_Int32) (100 * nFileSize / nDownloadSize); + sal_Int32 nPercent = static_cast<sal_Int32>(100 * nFileSize / nDownloadSize); getUpdateHandler()->setProgress( nPercent ); } } diff --git a/extensions/source/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx index 26967b7e55c9..eb361bf9bdfa 100644 --- a/extensions/source/update/check/updatecheckconfig.cxx +++ b/extensions/source/update/check/updatecheckconfig.cxx @@ -157,7 +157,7 @@ UpdateCheckROModel::getUpdateEntry(UpdateInfo& rInfo) const OUString aUStr = getStringValue( OString(OStringLiteral(RELEASE_NOTE) + OString::number(n)).getStr()); if( !aUStr.isEmpty() ) - rInfo.ReleaseNotes.push_back(ReleaseNote((sal_Int8) n, aUStr)); + rInfo.ReleaseNotes.push_back(ReleaseNote(static_cast<sal_Int8>(n), aUStr)); } } diff --git a/extensions/source/update/check/updatehdl.cxx b/extensions/source/update/check/updatehdl.cxx index ae0e59670aec..d00d2f935f53 100644 --- a/extensions/source/update/check/updatehdl.cxx +++ b/extensions/source/update/check/updatehdl.cxx @@ -122,8 +122,8 @@ void UpdateHandler::enableControls( short nCtrlState ) // enum list and must never be disabled for ( int i=0; i<HELP_BUTTON; i++ ) { - short nCurStateVal = (short)(nCtrlState >> i); - short nOldStateVal = (short)(mnLastCtrlState >> i); + short nCurStateVal = static_cast<short>(nCtrlState >> i); + short nOldStateVal = static_cast<short>(mnLastCtrlState >> i); if ( ( nCurStateVal & 0x01 ) != ( nOldStateVal & 0x01 ) ) { bool bEnableControl = ( ( nCurStateVal & 0x01 ) == 0x01 ); @@ -262,7 +262,7 @@ OUString UpdateHandler::getBubbleText( UpdateState eState ) osl::MutexGuard aGuard( maMutex ); OUString sText; - sal_Int32 nIndex = (sal_Int32) eState; + sal_Int32 nIndex = static_cast<sal_Int32>(eState); loadStrings(); @@ -278,7 +278,7 @@ OUString UpdateHandler::getBubbleTitle( UpdateState eState ) osl::MutexGuard aGuard( maMutex ); OUString sText; - sal_Int32 nIndex = (sal_Int32) eState; + sal_Int32 nIndex = static_cast<sal_Int32>(eState); loadStrings(); @@ -750,7 +750,7 @@ void UpdateHandler::focusControl( DialogControls eID ) OSL_ENSURE( (eID < BUTTON_COUNT), "UpdateHandler::focusControl: id to big!" ); - uno::Reference< awt::XWindow > xWindow( xContainer->getControl( msButtonIDs[(short)eID] ), uno::UNO_QUERY ); + uno::Reference< awt::XWindow > xWindow( xContainer->getControl( msButtonIDs[static_cast<short>(eID)] ), uno::UNO_QUERY ); if ( xWindow.is() ) xWindow->setFocus(); } @@ -984,18 +984,18 @@ void UpdateHandler::showControls( short nControls ) // The buttons from CANCEL_BUTTON to RESUME_BUTTON will be shown or // hidden on demand short nShiftMe; - for ( int i = 0; i <= (int)RESUME_BUTTON; i++ ) + for ( int i = 0; i <= int(RESUME_BUTTON); i++ ) { - nShiftMe = (short)(nControls >> i); - showControl( msButtonIDs[i], (bool)(nShiftMe & 0x01) ); + nShiftMe = static_cast<short>(nControls >> i); + showControl( msButtonIDs[i], static_cast<bool>(nShiftMe & 0x01) ); } - nShiftMe = (short)(nControls >> THROBBER_CTRL); - startThrobber( (bool)(nShiftMe & 0x01) ); + nShiftMe = static_cast<short>(nControls >> THROBBER_CTRL); + startThrobber( static_cast<bool>(nShiftMe & 0x01) ); - nShiftMe = (short)(nControls >> PROGRESS_CTRL); - showControl( CTRL_PROGRESS, (bool)(nShiftMe & 0x01) ); - showControl( TEXT_PERCENT, (bool)(nShiftMe & 0x01) ); + nShiftMe = static_cast<short>(nControls >> PROGRESS_CTRL); + showControl( CTRL_PROGRESS, static_cast<bool>(nShiftMe & 0x01) ); + showControl( TEXT_PERCENT, static_cast<bool>(nShiftMe & 0x01) ); // Status text needs to be smaller, when there are buttons at the right side of the dialog if ( ( nControls & ( (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) ) ) != 0 ) diff --git a/extensions/source/update/check/updateprotocol.cxx b/extensions/source/update/check/updateprotocol.cxx index 93c6508e42f1..43d55c87b31f 100644 --- a/extensions/source/update/check/updateprotocol.cxx +++ b/extensions/source/update/check/updateprotocol.cxx @@ -211,12 +211,12 @@ checkForUpdates( { sal_Int32 pos = xRelNote->getAttribute("pos").toInt32(); - ReleaseNote aRelNote((sal_uInt8) pos, xRelNote->getAttribute("src")); + ReleaseNote aRelNote(static_cast<sal_uInt8>(pos), xRelNote->getAttribute("src")); if( xRelNote->hasAttribute("src2") ) { pos = xRelNote->getAttribute("pos2").toInt32(); - aRelNote.Pos2 = (sal_Int8) pos; + aRelNote.Pos2 = static_cast<sal_Int8>(pos); aRelNote.URL2 = xRelNote->getAttribute("src2"); } |