diff options
author | Noel <noelgrandin@gmail.com> | 2020-10-01 11:00:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-10-01 12:23:08 +0200 |
commit | 7bd7ff5a8d938e474a8f15e2c6facad632a342bb (patch) | |
tree | 6321afdb483360b1130b0d2a0d995b6f27bbe59b /xmloff/source/style | |
parent | cc2b7c1f930bc05253153f3c8381fb4fb352f3ca (diff) |
loplugin:reducevarscope in xmloff
Change-Id: Ib67311f84a6a7a490afb392e642d74693fde3113
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103747
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff/source/style')
-rw-r--r-- | xmloff/source/style/DrawAspectHdl.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/style/XMLBitmapRepeatOffsetPropertyHandler.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/style/XMLConstantsPropertyHandler.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/style/XMLFillBitmapSizePropertyHandler.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/style/cdouthdl.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/style/chrhghdl.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/style/csmaphdl.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/style/fonthdl.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/style/shadwhdl.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/style/styleexp.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/style/undlihdl.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/style/xmlbahdl.cxx | 10 | ||||
-rw-r--r-- | xmloff/source/style/xmlimppr.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/style/xmlnumfe.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/style/xmlstyle.cxx | 3 |
15 files changed, 24 insertions, 36 deletions
diff --git a/xmloff/source/style/DrawAspectHdl.cxx b/xmloff/source/style/DrawAspectHdl.cxx index 884d89a74625..7eeb374ca559 100644 --- a/xmloff/source/style/DrawAspectHdl.cxx +++ b/xmloff/source/style/DrawAspectHdl.cxx @@ -45,15 +45,12 @@ bool DrawAspectHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, c bool DrawAspectHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const { bool bRet = false; - OUStringBuffer aOut; sal_Int64 nAspect = 0; if( ( rValue >>= nAspect ) && nAspect > 0 ) { // store the aspect as an integer value - aOut.append( nAspect ); - - rStrExpValue = aOut.makeStringAndClear(); + rStrExpValue = OUString::number(nAspect); bRet = true; } diff --git a/xmloff/source/style/XMLBitmapRepeatOffsetPropertyHandler.cxx b/xmloff/source/style/XMLBitmapRepeatOffsetPropertyHandler.cxx index 4528cd8056c2..9b8ad7c63f80 100644 --- a/xmloff/source/style/XMLBitmapRepeatOffsetPropertyHandler.cxx +++ b/xmloff/source/style/XMLBitmapRepeatOffsetPropertyHandler.cxx @@ -76,11 +76,10 @@ bool XMLBitmapRepeatOffsetPropertyHandler::exportXML( const Any& rValue, const SvXMLUnitConverter& ) const { - OUStringBuffer aOut; - sal_Int32 nValue = 0; if( rValue >>= nValue ) { + OUStringBuffer aOut; ::sax::Converter::convertPercent( aOut, nValue ); aOut.append( ' ' ); aOut.append( mbX ? msHorizontal : msVertical ); diff --git a/xmloff/source/style/XMLConstantsPropertyHandler.cxx b/xmloff/source/style/XMLConstantsPropertyHandler.cxx index 73b880deb357..a5467f247354 100644 --- a/xmloff/source/style/XMLConstantsPropertyHandler.cxx +++ b/xmloff/source/style/XMLConstantsPropertyHandler.cxx @@ -49,8 +49,6 @@ bool XMLConstantsPropertyHandler::exportXML( const Any& rValue, const SvXMLUnitConverter& ) const { - OUStringBuffer aOut; - bool bRet = false; sal_Int32 nEnum = 0; @@ -70,6 +68,7 @@ bool XMLConstantsPropertyHandler::exportXML( if( (nEnum >= 0) && (nEnum <= 0xffff) ) { sal_uInt16 nConst = static_cast<sal_uInt16>( nEnum ); + OUStringBuffer aOut; bRet = SvXMLUnitConverter::convertEnum( aOut, nConst, pMap, eDefault ); diff --git a/xmloff/source/style/XMLFillBitmapSizePropertyHandler.cxx b/xmloff/source/style/XMLFillBitmapSizePropertyHandler.cxx index e9bf5926f130..4dded1859c35 100644 --- a/xmloff/source/style/XMLFillBitmapSizePropertyHandler.cxx +++ b/xmloff/source/style/XMLFillBitmapSizePropertyHandler.cxx @@ -65,11 +65,10 @@ bool XMLFillBitmapSizePropertyHandler::exportXML( const Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const { - OUStringBuffer aOut; - sal_Int32 nValue = 0; if( rValue >>= nValue ) { + OUStringBuffer aOut; if( nValue < 0 ) { ::sax::Converter::convertPercent( aOut, -nValue ); diff --git a/xmloff/source/style/cdouthdl.cxx b/xmloff/source/style/cdouthdl.cxx index 74eee9fa6b08..0b484dcf047a 100644 --- a/xmloff/source/style/cdouthdl.cxx +++ b/xmloff/source/style/cdouthdl.cxx @@ -134,10 +134,10 @@ bool XMLCrossedOutTypePropHdl::exportXML( OUString& rStrExpValue, const uno::Any { bool bRet = false; sal_uInt16 nValue = sal_uInt16(); - OUStringBuffer aOut; if (rValue >>= nValue) { + OUStringBuffer aOut; bRet = SvXMLUnitConverter::convertEnum( aOut, nValue, pXML_CrossedoutType_Enum ); if( bRet ) @@ -181,10 +181,10 @@ bool XMLCrossedOutStylePropHdl::exportXML( OUString& rStrExpValue, const uno::An { bool bRet = false; sal_uInt16 nValue = sal_uInt16(); - OUStringBuffer aOut; if( rValue >>= nValue ) { + OUStringBuffer aOut; bRet = SvXMLUnitConverter::convertEnum( aOut, nValue, pXML_CrossedoutStyle_Enum ); if( bRet ) @@ -250,10 +250,10 @@ bool XMLCrossedOutWidthPropHdl::exportXML( OUString& rStrExpValue, const uno::An { bool bRet = false; sal_uInt16 nValue = sal_uInt16(); - OUStringBuffer aOut; if( (rValue >>= nValue) && (awt::FontStrikeout::BOLD == nValue) ) { + OUStringBuffer aOut; bRet = SvXMLUnitConverter::convertEnum( aOut, nValue, pXML_CrossedoutWidth_Enum ); if( bRet ) diff --git a/xmloff/source/style/chrhghdl.cxx b/xmloff/source/style/chrhghdl.cxx index c6f04f34008f..5417800c6d18 100644 --- a/xmloff/source/style/chrhghdl.cxx +++ b/xmloff/source/style/chrhghdl.cxx @@ -135,11 +135,10 @@ bool XMLCharHeightDiffHdl::importXML( const OUString& rStrImpValue, uno::Any& rV bool XMLCharHeightDiffHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const { - OUStringBuffer aOut; - float nRel = 0; if( (rValue >>= nRel) && (nRel != 0) ) { + OUStringBuffer aOut; ::sax::Converter::convertMeasure( aOut, static_cast<sal_Int32>(nRel), util::MeasureUnit::POINT, util::MeasureUnit::POINT ); rStrExpValue = aOut.makeStringAndClear(); diff --git a/xmloff/source/style/csmaphdl.cxx b/xmloff/source/style/csmaphdl.cxx index 97367734bfc7..4e760a6c9e33 100644 --- a/xmloff/source/style/csmaphdl.cxx +++ b/xmloff/source/style/csmaphdl.cxx @@ -58,10 +58,10 @@ bool XMLCaseMapPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValu { bool bRet = false; sal_uInt16 nValue = sal_uInt16(); - OUStringBuffer aOut; if( rValue >>= nValue ) { + OUStringBuffer aOut; bRet = SvXMLUnitConverter::convertEnum( aOut, nValue, pXML_Casemap_Enum ); if( bRet ) diff --git a/xmloff/source/style/fonthdl.cxx b/xmloff/source/style/fonthdl.cxx index e3a8adec7173..128dfa15289c 100644 --- a/xmloff/source/style/fonthdl.cxx +++ b/xmloff/source/style/fonthdl.cxx @@ -239,15 +239,13 @@ bool XMLFontEncodingPropHdl::importXML( const OUString& rStrImpValue, uno::Any& bool XMLFontEncodingPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const { bool bRet = false; - OUStringBuffer aOut; sal_Int16 nSet = sal_Int16(); if( rValue >>= nSet ) { if( static_cast<rtl_TextEncoding>(nSet) == RTL_TEXTENCODING_SYMBOL ) { - aOut.append( GetXMLToken(XML_X_SYMBOL) ); - rStrExpValue = aOut.makeStringAndClear(); + rStrExpValue = GetXMLToken(XML_X_SYMBOL); bRet = true; } } @@ -275,7 +273,6 @@ bool XMLFontPitchPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rVa { bool bRet = false; sal_Int16 nPitch = sal_Int16(); - OUStringBuffer aOut; FontPitch ePitch = PITCH_DONTKNOW; if( rValue >>= nPitch ) @@ -283,6 +280,7 @@ bool XMLFontPitchPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rVa if( PITCH_DONTKNOW != ePitch ) { + OUStringBuffer aOut; bRet = SvXMLUnitConverter::convertEnum( aOut, ePitch, aFontPitchMapping, XML_FIXED ); rStrExpValue = aOut.makeStringAndClear(); } diff --git a/xmloff/source/style/shadwhdl.cxx b/xmloff/source/style/shadwhdl.cxx index 60db10a44f15..2b02a40cb1c8 100644 --- a/xmloff/source/style/shadwhdl.cxx +++ b/xmloff/source/style/shadwhdl.cxx @@ -120,7 +120,6 @@ bool XMLShadowPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue bool XMLShadowPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const { bool bRet = false; - OUStringBuffer aOut; table::ShadowFormat aShadow; if( rValue >>= aShadow ) @@ -150,8 +149,8 @@ bool XMLShadowPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue nX *= aShadow.ShadowWidth; nY *= aShadow.ShadowWidth; + OUStringBuffer aOut; ::sax::Converter::convertColor( aOut, aShadow.Color ); - aOut.append( ' ' ); rUnitConverter.convertMeasureToXML( aOut, nX ); aOut.append( ' ' ); diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx index c87d3e3edff6..734318a0ab13 100644 --- a/xmloff/source/style/styleexp.cxx +++ b/xmloff/source/style/styleexp.cxx @@ -281,7 +281,6 @@ bool XMLStyleExport::exportStyle( Reference< XChapterNumberingSupplier > xCNSupplier (GetExport().GetModel(), UNO_QUERY); - OUString sOutlineName; if (xCNSupplier.is()) { Reference< XIndexReplace > xNumRule @@ -290,6 +289,7 @@ bool XMLStyleExport::exportStyle( Reference< XPropertySet > xNumRulePropSet (xNumRule, UNO_QUERY); + OUString sOutlineName; xNumRulePropSet->getPropertyValue("Name") >>= sOutlineName; bSuppressListStyle = sListName == sOutlineName; diff --git a/xmloff/source/style/undlihdl.cxx b/xmloff/source/style/undlihdl.cxx index 0e610442febb..4d6482c4f4be 100644 --- a/xmloff/source/style/undlihdl.cxx +++ b/xmloff/source/style/undlihdl.cxx @@ -168,12 +168,12 @@ bool XMLUnderlineTypePropHdl::exportXML( OUString& rStrExpValue, const uno::Any& { bool bRet = false; sal_uInt16 nValue = sal_uInt16(); - OUStringBuffer aOut; if( (rValue >>= nValue) && (awt::FontUnderline::DOUBLE == nValue || awt::FontUnderline::DOUBLEWAVE == nValue) ) { + OUStringBuffer aOut; bRet = SvXMLUnitConverter::convertEnum( aOut, nValue, pXML_UnderlineType_Enum ); if( bRet ) @@ -259,10 +259,10 @@ bool XMLUnderlineStylePropHdl::exportXML( OUString& rStrExpValue, const uno::Any { bool bRet = false; sal_uInt16 nValue = sal_uInt16(); - OUStringBuffer aOut; if( rValue >>= nValue ) { + OUStringBuffer aOut; bRet = SvXMLUnitConverter::convertEnum( aOut, nValue, pXML_UnderlineStyle_Enum ); if( bRet ) @@ -349,10 +349,10 @@ bool XMLUnderlineWidthPropHdl::exportXML( OUString& rStrExpValue, const uno::Any { bool bRet = false; sal_uInt16 nValue = sal_uInt16(); - OUStringBuffer aOut; if( (rValue >>= nValue) && (awt::FontUnderline::NONE != nValue) ) { + OUStringBuffer aOut; bRet = SvXMLUnitConverter::convertEnum( aOut, nValue, pXML_UnderlineWidth_Enum ); if( bRet ) diff --git a/xmloff/source/style/xmlbahdl.cxx b/xmloff/source/style/xmlbahdl.cxx index b4016039dff2..0a728467e4ba 100644 --- a/xmloff/source/style/xmlbahdl.cxx +++ b/xmloff/source/style/xmlbahdl.cxx @@ -192,10 +192,10 @@ bool XMLMeasurePropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, co { bool bRet = false; sal_Int32 nValue; - OUStringBuffer aOut; if( lcl_xmloff_getAny( rValue, nValue, nBytes ) ) { + OUStringBuffer aOut; rUnitConverter.convertMeasureToXML( aOut, nValue ); rStrExpValue = aOut.makeStringAndClear(); @@ -304,10 +304,10 @@ bool XMLPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, co { bool bRet = false; sal_Int32 nValue; - OUStringBuffer aOut; if( lcl_xmloff_getAny( rValue, nValue, nBytes ) ) { + OUStringBuffer aOut; ::sax::Converter::convertPercent( aOut, nValue ); rStrExpValue = aOut.makeStringAndClear(); @@ -382,10 +382,10 @@ bool XMLNegPercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, { bool bRet = false; sal_Int32 nValue; - OUStringBuffer aOut; if( lcl_xmloff_getAny( rValue, nValue, nBytes ) ) { + OUStringBuffer aOut; ::sax::Converter::convertPercent( aOut, 100-nValue ); rStrExpValue = aOut.makeStringAndClear(); @@ -412,10 +412,10 @@ bool XMLMeasurePxPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, { bool bRet = false; sal_Int32 nValue; - OUStringBuffer aOut; if( lcl_xmloff_getAny( rValue, nValue, nBytes ) ) { + OUStringBuffer aOut; ::sax::Converter::convertMeasurePx( aOut, nValue ); rStrExpValue = aOut.makeStringAndClear(); @@ -514,9 +514,9 @@ bool XMLHexPropHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const bool bRet = false; sal_uInt32 nRsid = 0; - OUStringBuffer aOut; if( rValue >>= nRsid ) { + OUStringBuffer aOut; SvXMLUnitConverter::convertHex( aOut, nRsid ); rStrExpValue = aOut.makeStringAndClear(); diff --git a/xmloff/source/style/xmlimppr.cxx b/xmloff/source/style/xmlimppr.cxx index cf81dfcd1e1c..a0886b18bd2d 100644 --- a/xmloff/source/style/xmlimppr.cxx +++ b/xmloff/source/style/xmlimppr.cxx @@ -142,12 +142,11 @@ void SvXMLImportPropertyMapper::importXML( const css::uno::Sequence< css::xml::Attribute > unknownAttribs = xAttrList->getUnknownAttributes(); for (const css::xml::Attribute& rAttribute : unknownAttribs) { - OUString aPrefix; int nSepIndex = rAttribute.Name.indexOf(SvXMLImport::aNamespaceSeparator); if (nSepIndex != -1) { // If it's an unknown attribute in a known namespace, ignore it. - aPrefix = rAttribute.Name.copy(0, nSepIndex); + OUString aPrefix = rAttribute.Name.copy(0, nSepIndex); if (rNamespaceMap.GetKeyByPrefix(aPrefix) != USHRT_MAX) continue; } diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx index 077dcb7b475a..e463b1dcd89d 100644 --- a/xmloff/source/style/xmlnumfe.cxx +++ b/xmloff/source/style/xmlnumfe.cxx @@ -1935,7 +1935,6 @@ sal_uInt32 SvXMLNumFmtExport::ForceSystemLanguage( sal_uInt32 nKey ) { SAL_WARN_IF( pFormatter == nullptr, "xmloff.style", "format without formatter?" ); - sal_Int32 nErrorPos; SvNumFormatType nType = pFormat->GetType(); sal_uInt32 nNewKey = pFormatter->GetFormatForLanguageIfBuiltIn( @@ -1948,6 +1947,7 @@ sal_uInt32 SvXMLNumFmtExport::ForceSystemLanguage( sal_uInt32 nKey ) else { OUString aFormatString( pFormat->GetFormatstring() ); + sal_Int32 nErrorPos; pFormatter->PutandConvertEntry( aFormatString, nErrorPos, nType, nNewKey, diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index 2a8e44b21285..fdaf07f47b4d 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -613,14 +613,13 @@ Reference < XAutoStyleFamily > SvXMLStylesContext::GetAutoStyles( XmlStyleFamily if( XmlStyleFamily::TEXT_TEXT == nFamily || XmlStyleFamily::TEXT_PARAGRAPH == nFamily) { bool bPara = XmlStyleFamily::TEXT_PARAGRAPH == nFamily; - OUString sName; if( !bPara && mxTextAutoStyles.is() ) xAutoStyles = mxTextAutoStyles; else if( bPara && mxParaAutoStyles.is() ) xAutoStyles = mxParaAutoStyles; else { - sName = bPara ? OUStringLiteral( u"ParagraphStyles" ): OUStringLiteral( u"CharacterStyles" ); + OUStringLiteral sName = bPara ? OUStringLiteral( u"ParagraphStyles" ): OUStringLiteral( u"CharacterStyles" ); Reference< XAutoStylesSupplier > xAutoStylesSupp( GetImport().GetModel(), UNO_QUERY ); Reference< XAutoStyles > xAutoStyleFamilies = xAutoStylesSupp->getAutoStyles(); if (xAutoStyleFamilies->hasByName(sName)) |