From e235da515af0e2a5d5a0cf80773943b65fdb8f7b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 12 Jan 2018 20:10:26 +0100 Subject: More loplugin:cstylecast: writerfilter auto-rewrite with "Enable loplugin:cstylecast for some more cases" plus solenv/clang-format/reformat-formatted-files Change-Id: I94d069b3605b45de958c3541ff93d3ae70955ea3 --- writerfilter/source/dmapper/DomainMapper.cxx | 14 +++++++------- writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 2 +- writerfilter/source/dmapper/DomainMapperTableManager.cxx | 14 +++++++------- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 10 +++++----- writerfilter/source/dmapper/GraphicImport.cxx | 6 +++--- writerfilter/source/dmapper/PropertyMap.cxx | 14 +++++++------- writerfilter/source/dmapper/SettingsTable.cxx | 2 +- writerfilter/source/dmapper/ThemeTable.cxx | 2 +- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 8 ++++---- writerfilter/source/rtftok/rtfsdrimport.cxx | 2 +- 10 files changed, 37 insertions(+), 37 deletions(-) (limited to 'writerfilter') diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index a9c431a1d11b..12ab244f6604 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1301,10 +1301,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) //style sheets cannot have a numbering rule attached StyleSheetPropertyMap* pStyleSheetPropertyMap = dynamic_cast< StyleSheetPropertyMap* >( rContext.get() ); if (pStyleSheetPropertyMap) - pStyleSheetPropertyMap->SetListLevel( (sal_Int16)nIntValue ); + pStyleSheetPropertyMap->SetListLevel( static_cast(nIntValue) ); } else - rContext->Insert( PROP_NUMBERING_LEVEL, uno::makeAny( (sal_Int16)nIntValue )); + rContext->Insert( PROP_NUMBERING_LEVEL, uno::makeAny( static_cast(nIntValue) )); break; case NS_ooxml::LN_CT_NumPr_numId: { @@ -1621,7 +1621,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) nIntValue = fDoubleValue > 100. ? 0 : 1; } else if((aStyleVal >>= nStyleValue) || - (nStyleValue = (sal_Int16)comphelper::getEnumAsINT32(aStyleVal)) >= 0 ) + (nStyleValue = static_cast(comphelper::getEnumAsINT32(aStyleVal))) >= 0 ) { nIntValue = 0x83a == nSprmId ? nStyleValue ? 0 : 4 : @@ -1999,7 +1999,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) uno::Reference< beans::XPropertySet > xLineNumberingPropSet = xLineNumberingProperties->getLineNumberingProperties(); xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_IS_ON ), uno::makeAny(true) ); if( aSettings.nInterval ) - xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_INTERVAL ), uno::makeAny((sal_Int16)aSettings.nInterval) ); + xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_INTERVAL ), uno::makeAny(static_cast(aSettings.nInterval)) ); if( aSettings.nDistance ) xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_DISTANCE ), uno::makeAny(aSettings.nDistance) ); xLineNumberingPropSet->setPropertyValue(getPropertyName( PROP_RESTART_AT_EACH_PAGE ), uno::makeAny(aSettings.bRestartAtEachPage) ); @@ -2074,7 +2074,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) if( pSectHdl->IsEqualWidth() ) { pSectionContext->SetEvenlySpaced( true ); - pSectionContext->SetColumnCount( (sal_Int16) (pSectHdl->GetNum() - 1) ); + pSectionContext->SetColumnCount( static_cast(pSectHdl->GetNum() - 1) ); pSectionContext->SetColumnDistance( pSectHdl->GetSpace() ); pSectionContext->SetSeparatorLine( pSectHdl->IsSeparator() ); } @@ -2082,7 +2082,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) { pSectionContext->SetEvenlySpaced( false ); pSectionContext->SetColumnDistance( pSectHdl->GetSpace() ); - pSectionContext->SetColumnCount( (sal_Int16)(pSectHdl->GetColumns().size() -1)); + pSectionContext->SetColumnCount( static_cast(pSectHdl->GetColumns().size() -1)); std::vector::const_iterator tmpIter = pSectHdl->GetColumns().begin(); for (; tmpIter != pSectHdl->GetColumns().end(); ++tmpIter) { @@ -2094,7 +2094,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) } else if( pSectHdl->GetNum() > 0 ) { - pSectionContext->SetColumnCount( (sal_Int16)pSectHdl->GetNum() - 1 ); + pSectionContext->SetColumnCount( static_cast(pSectHdl->GetNum()) - 1 ); pSectionContext->SetColumnDistance( pSectHdl->GetSpace() ); pSectionContext->SetSeparatorLine( pSectHdl->IsSeparator() ); } diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index a6e6947d9491..1f8564422e63 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -613,7 +613,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo lcl_extractHoriOrient( rFrameProperties, nHoriOrient ); m_aTableProperties->Insert( PROP_HORI_ORIENT, uno::makeAny( sal_Int16(nHoriOrient) ) ); //fill default value - if not available - m_aTableProperties->Insert( PROP_HEADER_ROW_COUNT, uno::makeAny( (sal_Int32)0), false); + m_aTableProperties->Insert( PROP_HEADER_ROW_COUNT, uno::makeAny( sal_Int32(0)), false); // if table is only a single row, and row is set as don't split, set the same value for the whole table. if( m_aRowProperties.size() == 1 && m_aRowProperties[0].get() ) diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index 52151565c0d5..40ca3365232c 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -77,26 +77,26 @@ bool DomainMapperTableManager::attribute(Id nName, Value const & rValue) TablePropertyMapPtr pPropMap(new TablePropertyMap()); pPropMap->Insert(PROP_TBL_LOOK, uno::makeAny(rValue.getInt())); insertTableProps(pPropMap); - m_aTableLook["val"] <<= (sal_Int32)rValue.getInt(); + m_aTableLook["val"] <<= static_cast(rValue.getInt()); } break; case NS_ooxml::LN_CT_TblLook_noVBand: - m_aTableLook["noVBand"] <<= (sal_Int32)rValue.getInt(); + m_aTableLook["noVBand"] <<= static_cast(rValue.getInt()); break; case NS_ooxml::LN_CT_TblLook_noHBand: - m_aTableLook["noHBand"] <<= (sal_Int32)rValue.getInt(); + m_aTableLook["noHBand"] <<= static_cast(rValue.getInt()); break; case NS_ooxml::LN_CT_TblLook_lastColumn: - m_aTableLook["lastColumn"] <<= (sal_Int32)rValue.getInt(); + m_aTableLook["lastColumn"] <<= static_cast(rValue.getInt()); break; case NS_ooxml::LN_CT_TblLook_lastRow: - m_aTableLook["lastRow"] <<= (sal_Int32)rValue.getInt(); + m_aTableLook["lastRow"] <<= static_cast(rValue.getInt()); break; case NS_ooxml::LN_CT_TblLook_firstColumn: - m_aTableLook["firstColumn"] <<= (sal_Int32)rValue.getInt(); + m_aTableLook["firstColumn"] <<= static_cast(rValue.getInt()); break; case NS_ooxml::LN_CT_TblLook_firstRow: - m_aTableLook["firstRow"] <<= (sal_Int32)rValue.getInt(); + m_aTableLook["firstRow"] <<= static_cast(rValue.getInt()); break; default: bRet = false; diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index b16190b830df..4b84edb98b66 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1111,7 +1111,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap ) //handles (2) and part of (6) pToBeSavedProperties.reset( new ParagraphProperties(*pParaContext) ); sal_Int32 nCount = xParaCursor->getString().getLength(); - pToBeSavedProperties->SetDropCapLength(nCount > 0 && nCount < 255 ? (sal_Int8)nCount : 1); + pToBeSavedProperties->SetDropCapLength(nCount > 0 && nCount < 255 ? static_cast(nCount) : 1); } if( rAppendContext.pLastParagraphProperties.get() ) { @@ -1120,10 +1120,10 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap ) //handles (4) and part of (5) //create a DropCap property, add it to the property sequence of finishParagraph sal_Int32 nLines = rAppendContext.pLastParagraphProperties->GetLines(); - aDrop.Lines = nLines > 0 && nLines < SAL_MAX_INT8 ? (sal_Int8)nLines : 2; + aDrop.Lines = nLines > 0 && nLines < SAL_MAX_INT8 ? static_cast(nLines) : 2; aDrop.Count = rAppendContext.pLastParagraphProperties->GetDropCapLength(); sal_Int32 nHSpace = rAppendContext.pLastParagraphProperties->GethSpace(); - aDrop.Distance = nHSpace > 0 && nHSpace < SAL_MAX_INT16 ? (sal_Int16)nHSpace : 0; + aDrop.Distance = nHSpace > 0 && nHSpace < SAL_MAX_INT16 ? static_cast(nHSpace) : 0; //completes (5) if( pParaContext->IsFrameMode() ) pToBeSavedProperties.reset( new ParagraphProperties(*pParaContext) ); @@ -3357,7 +3357,7 @@ static uno::Sequence< beans::PropertyValues > lcl_createTOXLevelHyperlinks( bool aChapterNo[0].Value <<= getPropertyName( PROP_TOKEN_CHAPTER_INFO ); aChapterNo[1].Name = getPropertyName( PROP_CHAPTER_FORMAT ); //todo: is ChapterFormat::Number correct? - aChapterNo[1].Value <<= (sal_Int16)text::ChapterFormat::NUMBER; + aChapterNo[1].Value <<= sal_Int16(text::ChapterFormat::NUMBER); pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 4 : 2) ] = aChapterNo; beans::PropertyValues aChapterSeparator(2); @@ -4405,7 +4405,7 @@ void DomainMapper_Impl::CloseFieldCommand() { sal_Int32 nLevel = sValue.toInt32(); if( !sValue.isEmpty() && nLevel >= 0 && nLevel <= 10 ) - xTC->setPropertyValue(getPropertyName(PROP_LEVEL), uno::makeAny( (sal_Int16)nLevel )); + xTC->setPropertyValue(getPropertyName(PROP_LEVEL), uno::makeAny( static_cast(nLevel) )); } // if( lcl_FindInCommand( pContext->GetCommand(), 'n', sValue )) // \n Suppress page numbers diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 0a81989d392d..3309f8caedd1 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -1146,7 +1146,7 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b { aBorderLine.Color = 0; aBorderLine.InnerLineWidth = 0; - aBorderLine.OuterLineWidth = (sal_Int16)rBorderLine.nLineWidth; + aBorderLine.OuterLineWidth = static_cast(rBorderLine.nLineWidth); aBorderLine.LineDistance = 0; } PropertyIds const aBorderProps[] = @@ -1275,9 +1275,9 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b } xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_ADJUST_CONTRAST ), - uno::makeAny((sal_Int16)m_pImpl->nContrast)); + uno::makeAny(static_cast(m_pImpl->nContrast))); xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_ADJUST_LUMINANCE ), - uno::makeAny((sal_Int16)m_pImpl->nBrightness)); + uno::makeAny(static_cast(m_pImpl->nBrightness))); if(m_pImpl->eColorMode != drawing::ColorMode_STANDARD) { xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_GRAPHIC_COLOR_MODE ), diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 2ecf76bd2793..11c49c99fc09 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -411,17 +411,17 @@ SectionPropertyMap::SectionPropertyMap( bool bIsFirstSection ) // initialize defaults PaperInfo aLetter( PAPER_LETTER ); // page height, 1/100mm - Insert( PROP_HEIGHT, uno::makeAny( (sal_Int32)aLetter.getHeight() ) ); + Insert( PROP_HEIGHT, uno::makeAny( static_cast(aLetter.getHeight()) ) ); // page width, 1/100mm - Insert( PROP_WIDTH, uno::makeAny( (sal_Int32)aLetter.getWidth() ) ); + Insert( PROP_WIDTH, uno::makeAny( static_cast(aLetter.getWidth()) ) ); // page left margin, default 0x708 (1800) twip -> 3175 1/100 mm - Insert( PROP_LEFT_MARGIN, uno::makeAny( (sal_Int32)3175 ) ); + Insert( PROP_LEFT_MARGIN, uno::makeAny( sal_Int32(3175) ) ); // page right margin, default 0x708 (1800) twip -> 3175 1/100 mm - Insert( PROP_RIGHT_MARGIN, uno::makeAny( (sal_Int32)3175 ) ); + Insert( PROP_RIGHT_MARGIN, uno::makeAny( sal_Int32(3175) ) ); // page top margin, default 0x5a0 (1440) twip -> 2540 1/100 mm - Insert( PROP_TOP_MARGIN, uno::makeAny( (sal_Int32)2540 ) ); + Insert( PROP_TOP_MARGIN, uno::makeAny( sal_Int32(2540) ) ); // page bottom margin, default 0x5a0 (1440) twip -> 2540 1/100 mm - Insert( PROP_BOTTOM_MARGIN, uno::makeAny( (sal_Int32)2540 ) ); + Insert( PROP_BOTTOM_MARGIN, uno::makeAny( sal_Int32(2540) ) ); // page style layout Insert( PROP_PAGE_STYLE_LAYOUT, uno::makeAny( style::PageStyleLayout_ALL ) ); uno::Any aFalse( uno::makeAny( false ) ); @@ -1287,7 +1287,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) { double fHeight = 0; if ( pPropHeight->second >>= fHeight ) - nCharWidth = ConversionHelper::convertTwipToMM100( (long)(fHeight * 20.0 + 0.5) ); + nCharWidth = ConversionHelper::convertTwipToMM100( static_cast(fHeight * 20.0 + 0.5) ); } } diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx index c1814ed1b65b..76df6f81ab77 100644 --- a/writerfilter/source/dmapper/SettingsTable.cxx +++ b/writerfilter/source/dmapper/SettingsTable.cxx @@ -325,7 +325,7 @@ void SettingsTable::lcl_attribute(Id nName, Value & val) break; case NS_ooxml::LN_CT_DocProtect_enforcement: // 92039 m_pImpl->m_DocumentProtection.m_bEnforcement = (nIntValue != 0); - m_pImpl->m_bProtectForm &= (bool)nIntValue; + m_pImpl->m_bProtectForm &= static_cast(nIntValue); break; case NS_ooxml::LN_CT_DocProtect_formatting: // 92038 m_pImpl->m_DocumentProtection.m_bFormatting = (nIntValue != 0); diff --git a/writerfilter/source/dmapper/ThemeTable.cxx b/writerfilter/source/dmapper/ThemeTable.cxx index 75860620810a..5f9cfc041450 100644 --- a/writerfilter/source/dmapper/ThemeTable.cxx +++ b/writerfilter/source/dmapper/ThemeTable.cxx @@ -264,7 +264,7 @@ OUString ThemeTable::fromLCIDToScriptTag(LanguageType lang) { // conversion list from: // http://blogs.msdn.com/b/officeinteroperability/archive/2013/04/22/office-open-xml-themes-schemes-and-fonts.aspx - switch ((sal_uInt16)lang) + switch (static_cast(lang)) { case 0x429 : // lidFarsi case 0x401 : // lidArabic diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index b84e2eb81c4d..0474991024e4 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -795,7 +795,7 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference(b)); count = 2; b = 0; } @@ -963,11 +963,11 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference(m_aStates.top().aPicture.nScaleX) * (nXExt - (m_aStates.top().aPicture.nCropL + m_aStates.top().aPicture.nCropR))) / 100L; if (m_aStates.top().aPicture.nScaleY != 100) - nYExt = (((long)m_aStates.top().aPicture.nScaleY) + nYExt = (static_cast(m_aStates.top().aPicture.nScaleY) * (nYExt - (m_aStates.top().aPicture.nCropT + m_aStates.top().aPicture.nCropB))) / 100L; if (m_aStates.top().bInShape) @@ -2317,7 +2317,7 @@ RTFError RTFDocumentImpl::popState() count--; if (!count) { - aBuf.append((char)b); + aBuf.append(static_cast(b)); count = 2; b = 0; } diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 98fd48aa008e..c2037600e7be 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -415,7 +415,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap else if (rProperty.first == "gtextSize") { // RTF size is multiplied by 2^16 - nFontSize = (float)rProperty.second.toUInt32() / RTF_MULTIPLIER; + nFontSize = static_cast(rProperty.second.toUInt32()) / RTF_MULTIPLIER; } else if (rProperty.first == "pib") { -- cgit