diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-04-23 16:07:32 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-04-27 14:07:56 +0200 |
commit | c7c6f0af6c836ebe0968967a1e7c8320b0ac17d6 (patch) | |
tree | 4bc5b2fa623b9765b88bbfe7de10a7590c87d5c8 /xmloff | |
parent | 99482297c7dd497e41fad2e7193759043e305101 (diff) |
loplugin:stringadd convert chained append to +
which can use the more efficient *StringConcat
Also fix a crash in stringview plugin which
started happening while I working on this.
Change-Id: I91a5b9b7707d1594d27d80b73930f5afac8ae608
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114568
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/forms/elementimport.cxx | 22 | ||||
-rw-r--r-- | xmloff/source/forms/layerimport.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/forms/propertyimport.cxx | 24 | ||||
-rw-r--r-- | xmloff/source/style/xmlexppr.cxx | 7 | ||||
-rw-r--r-- | xmloff/source/style/xmlnumfi.cxx | 6 |
5 files changed, 33 insertions, 30 deletions
diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 06d69218e294..8c94cd738c65 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -226,9 +226,9 @@ namespace xmloff for ( const auto& rCheck : m_aValues ) { OSL_ENSURE(m_xInfo->hasPropertyByName(rCheck.Name), - OStringBuffer("OElementImport::implApplySpecificProperties: read a property ("). - append(OUStringToOString(rCheck.Name, RTL_TEXTENCODING_ASCII_US)). - append(") which does not exist on the element!").getStr()); + OStringBuffer("OElementImport::implApplySpecificProperties: read a property (" + + OUStringToOString(rCheck.Name, RTL_TEXTENCODING_ASCII_US) + + ") which does not exist on the element!").getStr()); } } #endif @@ -286,9 +286,9 @@ namespace xmloff catch(const Exception&) { DBG_UNHANDLED_EXCEPTION("xmloff.forms"); - OSL_FAIL(OStringBuffer("OElementImport::implApplySpecificProperties: could not set the property \""). - append(OUStringToOString(rPropValues.Name, RTL_TEXTENCODING_ASCII_US)). - append("\"!").getStr()); + OSL_FAIL(OStringBuffer("OElementImport::implApplySpecificProperties: could not set the property \"" + + OUStringToOString(rPropValues.Name, RTL_TEXTENCODING_ASCII_US) + + "\"!").getStr()); } } } @@ -430,9 +430,9 @@ namespace xmloff catch(const Exception&) { DBG_UNHANDLED_EXCEPTION("xmloff.forms"); - OSL_FAIL(OStringBuffer("OElementImport::EndElement: could not set the property \""). - append(OUStringToOString(rPropValues.Name, RTL_TEXTENCODING_ASCII_US)). - append("\"!").getStr()); + OSL_FAIL(OStringBuffer("OElementImport::EndElement: could not set the property \"" + + OUStringToOString(rPropValues.Name, RTL_TEXTENCODING_ASCII_US) + + "\"!").getStr()); } } } @@ -562,7 +562,9 @@ namespace xmloff Reference< XComponentContext > xContext = m_rFormImport.getGlobalContext().GetComponentContext(); Reference< XInterface > xPure = xContext->getServiceManager()->createInstanceWithContext(m_sServiceName, xContext); OSL_ENSURE(xPure.is(), - OStringBuffer("OElementImport::createElement: service factory gave me no object (service name: ").append(OUStringToOString(m_sServiceName, RTL_TEXTENCODING_ASCII_US)).append(")!").getStr()); + OStringBuffer("OElementImport::createElement: service factory gave me no object (service name: " + + OUStringToOString(m_sServiceName, RTL_TEXTENCODING_ASCII_US) + + ")!").getStr()); xReturn.set(xPure, UNO_QUERY); } else diff --git a/xmloff/source/forms/layerimport.cxx b/xmloff/source/forms/layerimport.cxx index 6039a1e303f0..40845d735a64 100644 --- a/xmloff/source/forms/layerimport.cxx +++ b/xmloff/source/forms/layerimport.cxx @@ -324,7 +324,9 @@ const SvXMLStyleContext* OFormLayerXMLImport_Impl::getStyleElement(const OUStrin const SvXMLStyleContext* pControlStyle = m_xAutoStyles.is() ? m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::TEXT_PARAGRAPH, _rStyleName ) : nullptr; OSL_ENSURE( pControlStyle || !m_xAutoStyles.is(), - OStringBuffer("OFormLayerXMLImport_Impl::getStyleElement: did not find the style named \"").append(OUStringToOString(_rStyleName, RTL_TEXTENCODING_ASCII_US)).append("\"!").getStr() ); + OStringBuffer("OFormLayerXMLImport_Impl::getStyleElement: did not find the style named \"" + + OUStringToOString(_rStyleName, RTL_TEXTENCODING_ASCII_US) + + "\"!").getStr() ); return pControlStyle; } diff --git a/xmloff/source/forms/propertyimport.cxx b/xmloff/source/forms/propertyimport.cxx index ce1293baafea..ded9fa8565b1 100644 --- a/xmloff/source/forms/propertyimport.cxx +++ b/xmloff/source/forms/propertyimport.cxx @@ -100,9 +100,9 @@ Any PropertyConversion::convertString( const css::uno::Type& _rExpectedType, bool bSuccess = ::sax::Converter::convertBool(bValue, _rReadCharacters); OSL_ENSURE(bSuccess, - OStringBuffer("PropertyConversion::convertString: could not convert \""). - append(OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US)). - append("\" into a boolean!").getStr()); + OStringBuffer("PropertyConversion::convertString: could not convert \"" + + OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US) + + "\" into a boolean!").getStr()); aReturn <<= (_bInvertBoolean ? !bValue : bValue); } break; @@ -114,9 +114,9 @@ Any PropertyConversion::convertString( const css::uno::Type& _rExpectedType, bool bSuccess = ::sax::Converter::convertNumber(nValue, _rReadCharacters); OSL_ENSURE(bSuccess, - OStringBuffer("PropertyConversion::convertString: could not convert \""). - append(OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US)). - append("\" into an integer!").getStr()); + OStringBuffer("PropertyConversion::convertString: could not convert \"" + + OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US) + + "\" into an integer!").getStr()); if (TypeClass_SHORT == _rExpectedType.getTypeClass()) aReturn <<= static_cast<sal_Int16>(nValue); else @@ -151,9 +151,9 @@ Any PropertyConversion::convertString( const css::uno::Type& _rExpectedType, bool bSuccess = ::sax::Converter::convertDouble(nValue, _rReadCharacters); OSL_ENSURE(bSuccess, - OStringBuffer("PropertyConversion::convertString: could not convert \""). - append(OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US)). - append("\" into a double!").getStr()); + OStringBuffer(OString::Concat("PropertyConversion::convertString: could not convert \"") + + OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US) + + "\" into a double!").getStr()); aReturn <<= nValue; } break; @@ -177,9 +177,9 @@ Any PropertyConversion::convertString( const css::uno::Type& _rExpectedType, bool bSuccess = ::sax::Converter::convertDouble(nValue, _rReadCharacters); OSL_ENSURE(bSuccess, - OStringBuffer("PropertyConversion::convertString: could not convert \""). - append(OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US)). - append("\" into a double!").getStr()); + OStringBuffer("PropertyConversion::convertString: could not convert \"" + + OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US) + + "\" into a double!").getStr()); // then convert it into the target type switch (nType) diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx index 291c2ee36041..bd3ee809ec1a 100644 --- a/xmloff/source/style/xmlexppr.cxx +++ b/xmloff/source/style/xmlexppr.cxx @@ -1005,7 +1005,7 @@ void SvXMLExportPropertyMapper::_exportXML( sPrefix = pNamespaceMap->GetPrefixByKey( nKey ); } // In any case, the attribute name has to be adapted. - sNameBuffer.append(sPrefix).append(":").append(rAttribName.subView(nColonPos+1)); + sNameBuffer.append(sPrefix + ":" + rAttribName.subView(nColonPos+1)); sAttribName = sNameBuffer.makeStringAndClear(); } @@ -1017,9 +1017,8 @@ void SvXMLExportPropertyMapper::_exportXML( pNamespaceMap = pNewNamespaceMap.get(); } pNewNamespaceMap->Add( sPrefix, sNamespace ); - sNameBuffer.append( GetXMLToken(XML_XMLNS) ).append( ":" ).append( sPrefix ); - rAttrList.AddAttribute( sNameBuffer.makeStringAndClear(), - sNamespace ); + OUString sAttr = GetXMLToken(XML_XMLNS) + ":" + sPrefix; + rAttrList.AddAttribute( sAttr, sNamespace ); } } } diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index 8bfaf4d35464..a62133cfff99 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -1857,7 +1857,7 @@ void SvXMLNumFormatContext::AddCurrency( const OUString& rContent, LanguageType if ( nLang != LANGUAGE_SYSTEM ) { // '-' sign and language code in hex: - aFormatCode.append("-").append(OUString(OUString::number(sal_uInt16(nLang), 16)).toAsciiUpperCase()); + aFormatCode.append("-" + OUString(OUString::number(sal_uInt16(nLang), 16)).toAsciiUpperCase()); } aFormatCode.append( ']' ); // end of "new" currency symbol @@ -1885,7 +1885,7 @@ void SvXMLNumFormatContext::AddNfKeyword( sal_uInt16 nIndex ) if ( !bTruncate && !bHasDateTime ) { // with truncate-on-overflow = false, add "[]" to first time part - aFormatCode.append("[").append(sKeyword).append("]"); + aFormatCode.append("[" + sKeyword + "]"); } else { @@ -2011,7 +2011,7 @@ void SvXMLNumFormatContext::AddCondition( const sal_Int32 nIndex ) sRealCond = sRealCond.replaceAt( nPos, 1, rDecSep ); } } - aConditions.append("[").append(sRealCond).append("]"); + aConditions.append("[" + sRealCond + "]"); } const SvNumberformat* pFormat = pFormatter->GetEntry(l_nKey); |