diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-14 14:27:57 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-15 14:33:57 +0200 |
commit | f13c6ad5f020a196a0e3aa6f28bda3dc185d465b (patch) | |
tree | f9aaab122974d36c134fb1723ec3c1c8df51eeef /xmloff | |
parent | 9270f74466d0eb841babaa24997f608631c70341 (diff) |
new loplugin:bufferadd
look for OUStringBuffer append sequences that can be turned
into creating an OUString with + operations
Change-Id: Ica840dc096000307b4a105fb4d9ec7588a15ade6
Reviewed-on: https://gerrit.libreoffice.org/80809
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/core/nmspmap.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/style/styleexp.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/text/XMLSectionExport.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/text/txtflde.cxx | 11 | ||||
-rw-r--r-- | xmloff/source/text/txtfldi.cxx | 7 | ||||
-rw-r--r-- | xmloff/source/text/txtftne.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 23 | ||||
-rw-r--r-- | xmloff/source/text/txtvfldi.cxx | 23 | ||||
-rw-r--r-- | xmloff/source/xforms/xformsexport.cxx | 5 |
9 files changed, 24 insertions, 64 deletions
diff --git a/xmloff/source/core/nmspmap.cxx b/xmloff/source/core/nmspmap.cxx index 669d0cc9f727..44e619c0f348 100644 --- a/xmloff/source/core/nmspmap.cxx +++ b/xmloff/source/core/nmspmap.cxx @@ -219,11 +219,7 @@ OUString SvXMLNamespaceMap::GetQNameByKey( sal_uInt16 nKey, case XML_NAMESPACE_XML: { // this namespace is reserved, and needs not to be declared - OUStringBuffer sQName; - sQName.append ( GetXMLToken(XML_XML) ); - sQName.append ( ':' ); - sQName.append ( rLocalName ); - return sQName.makeStringAndClear(); + return GetXMLToken(XML_XML) + ":" + rLocalName; } default: { diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx index 706b5b10a1b9..d5569f633eec 100644 --- a/xmloff/source/style/styleexp.cxx +++ b/xmloff/source/style/styleexp.cxx @@ -220,11 +220,9 @@ bool XMLStyleExport::exportStyle( aAny >>= nOutlineLevel; if( nOutlineLevel > 0 ) { - OUStringBuffer sTmp; - sTmp.append(nOutlineLevel); GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_DEFAULT_OUTLINE_LEVEL, - sTmp.makeStringAndClear() ); + OUString::number(nOutlineLevel) ); } else { diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx index cd34a861b3f3..2ae5b7520bde 100644 --- a/xmloff/source/text/XMLSectionExport.cxx +++ b/xmloff/source/text/XMLSectionExport.cxx @@ -1811,10 +1811,8 @@ void XMLSectionExport::ExportMasterDocHeadingDummies() GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( sStyle ) ); - OUStringBuffer sTmp; - sTmp.append( nLevel + 1 ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_LEVEL, - sTmp.makeStringAndClear() ); + OUString::number( nLevel + 1 ) ); SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, XML_H, true, false ); } diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index b4005a976b9a..a1c04371666f 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -3446,10 +3446,7 @@ OUString XMLTextFieldExport::MakeFootnoteRefName( sal_Int16 nSeqNo) { // generate foot-/endnote ID - OUStringBuffer aBuf; - aBuf.append("ftn"); - aBuf.append(static_cast<sal_Int32>(nSeqNo)); - return aBuf.makeStringAndClear(); + return "ftn" + OUString::number(static_cast<sal_Int32>(nSeqNo)); } OUString XMLTextFieldExport::MakeSequenceRefName( @@ -3457,11 +3454,7 @@ OUString XMLTextFieldExport::MakeSequenceRefName( const OUString& rSeqName) { // generate foot-/endnote ID - OUStringBuffer aBuf; - aBuf.append("ref"); - aBuf.append(rSeqName); - aBuf.append(static_cast<sal_Int32>(nSeqNo)); - return aBuf.makeStringAndClear(); + return "ref" +rSeqName + OUString::number(static_cast<sal_Int32>(nSeqNo)); } diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index 124ebb010d52..cde1edd6daa3 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -2784,11 +2784,6 @@ void XMLDdeFieldDeclImportContext::StartElement( // valid data? if (bNameOK && bCommandApplicationOK && bCommandTopicOK && bCommandItemOK) { - // make service name - OUStringBuffer sBuf; - sBuf.append(sAPI_fieldmaster_prefix); - sBuf.append(sAPI_dde); - // create DDE TextFieldMaster Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(), UNO_QUERY); @@ -2803,7 +2798,7 @@ void XMLDdeFieldDeclImportContext::StartElement( try { Reference<XInterface> xIfc = - xFactory->createInstance(sBuf.makeStringAndClear()); + xFactory->createInstance(OUStringLiteral(sAPI_fieldmaster_prefix) + sAPI_dde); if( xIfc.is() ) { Reference<XPropertySet> xPropSet( xIfc, UNO_QUERY ); diff --git a/xmloff/source/text/txtftne.cxx b/xmloff/source/text/txtftne.cxx index 3ab12bb6d601..c41fad2fe63b 100644 --- a/xmloff/source/text/txtftne.cxx +++ b/xmloff/source/text/txtftne.cxx @@ -166,11 +166,8 @@ void XMLTextParagraphExport::exportTextFootnoteHelper( Any aAny = xPropSet->getPropertyValue(gsReferenceId); sal_Int32 nNumber = 0; aAny >>= nNumber; - OUStringBuffer aBuf; - aBuf.append("ftn"); - aBuf.append(nNumber); GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_ID, - aBuf.makeStringAndClear()); + "ftn" + OUString::number(nNumber)); GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NOTE_CLASS, GetXMLToken( bIsEndnote ? XML_ENDNOTE : XML_FOOTNOTE ) ); diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index af8e721bce65..0238e918535d 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -1086,11 +1086,9 @@ void XMLTextParagraphExport::exportListChange( } else if (bRestartNumberingAtContinuedList) { - OUStringBuffer aBuffer; - aBuffer.append( nRestartValueForContinuedList ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE, - aBuffer.makeStringAndClear() ); + OUString::number(nRestartValueForContinuedList) ); bRestartNumberingAtContinuedList = false; } } @@ -1972,11 +1970,9 @@ void XMLTextParagraphExport::exportParagraph( if( 0 < nOutlineLevel ) { - OUStringBuffer sTmp; - sTmp.append( sal_Int32( nOutlineLevel) ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL, - sTmp.makeStringAndClear() ); + OUString::number( sal_Int32( nOutlineLevel) ) ); if( rPropSetHelper.hasProperty( NUMBERING_IS_NUMBER ) ) { @@ -2051,15 +2047,10 @@ void XMLTextParagraphExport::exportParagraph( xPropSet->getPropertyValue("NumberingStartValue") >>= nStartValue; - OUStringBuffer sTmpStartValue; - - sTmpStartValue.append(nStartValue); - GetExport(). AddAttribute(XML_NAMESPACE_TEXT, XML_START_VALUE, - sTmpStartValue. - makeStringAndClear()); + OUString::number(nStartValue)); } } } @@ -3543,10 +3534,8 @@ void XMLTextParagraphExport::exportCharacterData(const OUString& rText, if( nSpaceChars > 1 ) { - OUStringBuffer sTmp; - sTmp.append( nSpaceChars ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_C, - sTmp.makeStringAndClear() ); + OUString::number(nSpaceChars) ); } SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, @@ -3606,10 +3595,8 @@ void XMLTextParagraphExport::exportCharacterData(const OUString& rText, { if( nSpaceChars > 1 ) { - OUStringBuffer sTmp; - sTmp.append( nSpaceChars ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_C, - sTmp.makeStringAndClear() ); + OUString::number(nSpaceChars) ); } SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, XML_S, diff --git a/xmloff/source/text/txtvfldi.cxx b/xmloff/source/text/txtvfldi.cxx index 24ab366f71e7..5a1f2255035e 100644 --- a/xmloff/source/text/txtvfldi.cxx +++ b/xmloff/source/text/txtvfldi.cxx @@ -827,18 +827,17 @@ bool XMLVariableDeclImportContext::FindFieldMaster( Reference<container::XNameAccess> xFieldMasterNameAccess = xTextFieldsSupp->getTextFieldMasters(); - OUStringBuffer sBuffer; - sBuffer.append(sAPI_fieldmaster_prefix); - sBuffer.append(sAPI_set_expression); - sBuffer.append("."); - sBuffer.append(sName); - OUString sVarServiceName = sBuffer.makeStringAndClear(); - - sBuffer.append(sAPI_fieldmaster_prefix); - sBuffer.append(sAPI_user); - sBuffer.append("."); - sBuffer.append(sName); - OUString sUserServiceName = sBuffer.makeStringAndClear(); + OUString sVarServiceName = + OUStringLiteral(sAPI_fieldmaster_prefix) + + sAPI_set_expression + + "." + + sName; + + OUString sUserServiceName = + OUStringLiteral(sAPI_fieldmaster_prefix) + + sAPI_user + + "." + + sName; if (xFieldMasterNameAccess->hasByName(sVarServiceName)) { // variable field master already in document diff --git a/xmloff/source/xforms/xformsexport.cxx b/xmloff/source/xforms/xformsexport.cxx index 84adcb6f59c8..35b10383f6d4 100644 --- a/xmloff/source/xforms/xformsexport.cxx +++ b/xmloff/source/xforms/xformsexport.cxx @@ -269,11 +269,8 @@ void exportXFormsBinding( SvXMLExport& rExport, if( sName.isEmpty() ) { // if we don't have a name yet, generate one on the fly - OUStringBuffer aBuffer; - aBuffer.append( "bind_" ); sal_Int64 nId = reinterpret_cast<sal_uInt64>( xBinding.get() ); - aBuffer.append( nId , 16 ); - sName = aBuffer.makeStringAndClear(); + sName = "bind_" + OUString::number( nId , 16 ); xBinding->setPropertyValue( "BindingID", makeAny(sName)); } } |