xmloff/source/core/DomExport.cxx | 12 +-- xmloff/source/core/namespacemap.cxx | 29 ++----- xmloff/source/core/xmlerror.cxx | 43 ++++------- xmloff/source/core/xmluconv.cxx | 6 - xmloff/source/draw/propimp0.cxx | 3 xmloff/source/draw/sdxmlexp.cxx | 9 -- xmloff/source/meta/xmlmetae.cxx | 6 - xmloff/source/style/XMLBitmapRepeatOffsetPropertyHandler.cxx | 3 xmloff/source/style/XMLClipPropertyHandler.cxx | 3 xmloff/source/style/bordrhdl.cxx | 4 - xmloff/source/style/chrhghdl.cxx | 3 xmloff/source/style/fonthdl.cxx | 5 - xmloff/source/style/impastpl.cxx | 40 ++++------ xmloff/source/style/xmlnumfe.cxx | 13 +-- xmloff/source/text/XMLTextListAutoStylePool.cxx | 5 - xmloff/source/text/txtprhdl.cxx | 3 xmloff/source/transform/TransformerBase.cxx | 6 - 17 files changed, 72 insertions(+), 121 deletions(-)
New commits: commit 5988a3cf91e2cb5bf1628b88965e3652932e4eb6 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Mar 30 10:57:25 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Mar 30 13:53:28 2023 +0000 loplugin:stringadd in xmloff when applying my upcoming patch to also consider O[U]StringBuffer Change-Id: Id38d983e59386554c61e9bdcd9333554bbf4665c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149756 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/xmloff/source/core/DomExport.cxx b/xmloff/source/core/DomExport.cxx index 9d26d68b1cee..585c2b4572b4 100644 --- a/xmloff/source/core/DomExport.cxx +++ b/xmloff/source/core/DomExport.cxx @@ -128,7 +128,7 @@ class DomExport: public DomVisitor void pushNamespace(); void addNamespace( const OUString& sPrefix, const OUString& sURI ); OUString qualifiedName( const OUString& sPrefix, const OUString& sURI, - std::u16string_view sLocalName ); + const OUString& sLocalName ); OUString qualifiedName( const Reference<XElement>& ); OUString qualifiedName( const Reference<XAttr>& ); void addAttribute( const Reference<XAttr>& ); @@ -181,17 +181,15 @@ void DomExport::addNamespace( const OUString& sPrefix, const OUString& sURI ) OUString DomExport::qualifiedName( const OUString& sPrefix, const OUString& sURI, - std::u16string_view sLocalName ) + const OUString& sLocalName ) { - OUStringBuffer sBuffer; if( !sPrefix.isEmpty() && !sURI.isEmpty() ) { addNamespace( sPrefix, sURI ); - sBuffer.append( sPrefix ); - sBuffer.append( ':' ); + return sPrefix + ":" + sLocalName; } - sBuffer.append( sLocalName ); - return sBuffer.makeStringAndClear(); + else + return sLocalName; } OUString DomExport::qualifiedName( const Reference<XElement>& xElement ) diff --git a/xmloff/source/core/namespacemap.cxx b/xmloff/source/core/namespacemap.cxx index 84668a612dfe..c64f28087f36 100644 --- a/xmloff/source/core/namespacemap.cxx +++ b/xmloff/source/core/namespacemap.cxx @@ -212,14 +212,10 @@ OUString SvXMLNamespaceMap::GetQNameByKey( sal_uInt16 nKey, { // ...if it's in the xmlns namespace, make the prefix // don't bother caching this, it rarely happens - OUStringBuffer sQName; - sQName.append ( m_sXMLNS ); if (!rLocalName.isEmpty()) // not default namespace - { - sQName.append ( ':' ); - sQName.append ( rLocalName ); - } - return sQName.makeStringAndClear(); + return m_sXMLNS + ":" + rLocalName; + else + return m_sXMLNS; } case XML_NAMESPACE_XML: { @@ -242,21 +238,14 @@ OUString SvXMLNamespaceMap::GetQNameByKey( sal_uInt16 nKey, { // ...if it's in our map, make the prefix const OUString & prefix( (*aIter).second.sPrefix ); - OUStringBuffer sQName(prefix.getLength() + 1 + rLocalName.getLength()); + OUString sQName; if (!prefix.isEmpty()) // not default namespace - { - sQName.append( prefix ); - sQName.append( ':' ); - } - sQName.append ( rLocalName ); - if (bCache) - { - OUString sString(sQName.makeStringAndClear()); - m_aQNameCache.emplace(QNamePair(nKey, rLocalName), sString); - return sString; - } + sQName = prefix + ":" + rLocalName; else - return sQName.makeStringAndClear(); + sQName = rLocalName; + if (bCache) + m_aQNameCache.emplace(QNamePair(nKey, rLocalName), sQName); + return sQName; } else { diff --git a/xmloff/source/core/xmlerror.cxx b/xmloff/source/core/xmlerror.cxx index a3ace36f71d2..9cda2297e0af 100644 --- a/xmloff/source/core/xmlerror.cxx +++ b/xmloff/source/core/xmlerror.cxx @@ -103,14 +103,13 @@ void XMLErrors::AddRecord( // give detailed assertion on this message - OUStringBuffer sMessage; - - sMessage.append( "An error or a warning has occurred during XML import/export!\n" ); + OUStringBuffer sMessage( "An error or a warning has occurred during XML import/export!\n" ); // ID & flags - sMessage.append( "Error-Id: 0x"); - sMessage.append( nId, 16 ); - sMessage.append( "\n Flags: " ); + sMessage.append( + "Error-Id: 0x" + + OUString::number( nId, 16 ) + + "\n Flags: " ); sal_Int32 nFlags = (nId & XMLERROR_MASK_FLAG); sMessage.append( nFlags >> 28, 16 ); if( (nFlags & XMLERROR_FLAG_WARNING) != 0 ) @@ -132,8 +131,8 @@ void XMLErrors::AddRecord( sMessage.append( " OTHER" ); sMessage.append( "\n Number: " ); sal_Int32 nNumber = (nId & XMLERROR_MASK_NUMBER); - sMessage.append( nNumber, 16 ); - sMessage.append( "\n"); + sMessage.append( OUString::number(nNumber, 16) + + "\n" ); // the parameters sMessage.append( "Parameters:\n" ); @@ -141,30 +140,24 @@ void XMLErrors::AddRecord( const OUString* pParams = rParams.getConstArray(); for( sal_Int32 i = 0; i < nLength; i++ ) { - sMessage.append( " " ); - sMessage.append( i ); - sMessage.append( ": " ); - sMessage.append( pParams[i] ); - sMessage.append( "\n" ); + sMessage.append( " " + OUString::number(i) + ": " + pParams[i] + "\n" ); } // the exception message - sMessage.append( "Exception-Message: " ); - sMessage.append( rExceptionMessage ); - sMessage.append( "\n" ); + sMessage.append( "Exception-Message: " + rExceptionMessage + "\n" ); // position (if given) if( (nRow != -1) || (nColumn != -1) ) { - sMessage.append( "Position:\n Public Identifier: " ); - sMessage.append( rPublicId ); - sMessage.append( "\n System Identifier: " ); - sMessage.append( rSystemId ); - sMessage.append( "\n Row, Column: " ); - sMessage.append( nRow ); - sMessage.append( "," ); - sMessage.append( nColumn ); - sMessage.append( "\n" ); + sMessage.append( "Position:\n Public Identifier: " + + rPublicId + + "\n System Identifier: " + + rSystemId + + "\n Row, Column: " + + OUString::number( nRow ) + + "," + + OUString::number( nColumn ) + + "\n" ); } SAL_WARN( "xmloff", sMessage.makeStringAndClear() ); diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index 96bc2f0e4031..7c16b202681f 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -900,9 +900,9 @@ OUString SvXMLUnitConverter::encodeStyleName( if( c > 0x000f ) aBuffer.append( static_cast< sal_Unicode >( aHexTab[ (c >> 4) & 0x0f ] ) ); - aBuffer.append( static_cast< sal_Unicode >( - aHexTab[ c & 0x0f ] ) ); - aBuffer.append( '_' ); + aBuffer.append( + OUStringChar(static_cast< sal_Unicode >( aHexTab[ c & 0x0f ] ) ) + + "_" ); if( pEncoded ) *pEncoded = true; } diff --git a/xmloff/source/draw/propimp0.cxx b/xmloff/source/draw/propimp0.cxx index 961aa406d868..92bb46bdacbc 100644 --- a/xmloff/source/draw/propimp0.cxx +++ b/xmloff/source/draw/propimp0.cxx @@ -217,8 +217,7 @@ bool XMLTextAnimationStepPropertyHdl::exportXML( if( nVal < 0 ) { - aOut.append( static_cast<sal_Int32>(-nVal) ); - aOut.append( "px" ); + aOut.append( OUString::number(static_cast<sal_Int32>(-nVal) ) + "px" ); } else { diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index 0e7fc6160867..bc7d5e6ad35d 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -1428,8 +1428,7 @@ void SdXMLExport::ImpWriteHeaderFooterDecls() sal_Int32 nIndex = 1; for( const auto& rDecl : maHeaderDeclsVector ) { - sBuffer.append( aPrefix ); - sBuffer.append( nIndex ); + sBuffer.append( aPrefix + OUString::number( nIndex ) ); AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear()); SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_HEADER_DECL, true, true); @@ -1445,8 +1444,7 @@ void SdXMLExport::ImpWriteHeaderFooterDecls() sal_Int32 nIndex = 1; for( const auto& rDecl : maFooterDeclsVector ) { - sBuffer.append( aPrefix ); - sBuffer.append( nIndex ); + sBuffer.append( aPrefix + OUString::number( nIndex ) ); AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear()); SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_FOOTER_DECL, false, false); @@ -1463,8 +1461,7 @@ void SdXMLExport::ImpWriteHeaderFooterDecls() sal_Int32 nIndex = 1; for( const auto& rDecl : maDateTimeDeclsVector ) { - sBuffer.append( aPrefix ); - sBuffer.append( nIndex ); + sBuffer.append( aPrefix + OUString::number( nIndex ) ); AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear()); AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SOURCE, rDecl.mbFixed ? XML_FIXED : XML_CURRENT_DATE ); diff --git a/xmloff/source/meta/xmlmetae.cxx b/xmloff/source/meta/xmlmetae.cxx index 90de88dbcc93..395772ab2aca 100644 --- a/xmloff/source/meta/xmlmetae.cxx +++ b/xmloff/source/meta/xmlmetae.cxx @@ -54,9 +54,9 @@ SvXMLMetaExport::GetISODateTimeString( const util::DateTime& rDateTime ) { // return ISO date string "YYYY-MM-DDThh:mm:ss" - OUStringBuffer sTmp; - sTmp.append( static_cast<sal_Int32>(rDateTime.Year) ); - sTmp.append( '-' ); + OUStringBuffer sTmp = + OUString::number( static_cast<sal_Int32>(rDateTime.Year) ) + + "-"; lcl_AddTwoDigits( sTmp, rDateTime.Month ); sTmp.append( '-' ); lcl_AddTwoDigits( sTmp, rDateTime.Day ); diff --git a/xmloff/source/style/XMLBitmapRepeatOffsetPropertyHandler.cxx b/xmloff/source/style/XMLBitmapRepeatOffsetPropertyHandler.cxx index 29e743dfa3f0..c4a9384bfd1e 100644 --- a/xmloff/source/style/XMLBitmapRepeatOffsetPropertyHandler.cxx +++ b/xmloff/source/style/XMLBitmapRepeatOffsetPropertyHandler.cxx @@ -81,8 +81,7 @@ bool XMLBitmapRepeatOffsetPropertyHandler::exportXML( { OUStringBuffer aOut; ::sax::Converter::convertPercent( aOut, nValue ); - aOut.append( ' ' ); - aOut.append( mbX ? msHorizontal : msVertical ); + aOut.append( " " + ( mbX ? msHorizontal : msVertical ) ); rStrExpValue = aOut.makeStringAndClear(); return true; diff --git a/xmloff/source/style/XMLClipPropertyHandler.cxx b/xmloff/source/style/XMLClipPropertyHandler.cxx index 4bfa563d2ade..7a4d01cd99df 100644 --- a/xmloff/source/style/XMLClipPropertyHandler.cxx +++ b/xmloff/source/style/XMLClipPropertyHandler.cxx @@ -114,8 +114,7 @@ bool XMLClipPropertyHandler::exportXML( OUString& rStrExpValue, const uno::Any& if( rValue >>= aCrop ) { - aOut.append( GetXMLToken(XML_RECT) ); - aOut.append( '(' ); + aOut.append( GetXMLToken(XML_RECT) + "(" ); rUnitConverter.convertMeasureToXML( aOut, aCrop.Top ); if( !m_bODF11 ) aOut.append( ',' ); diff --git a/xmloff/source/style/bordrhdl.cxx b/xmloff/source/style/bordrhdl.cxx index 4b3a7b666cd2..d04d3f2f85c9 100644 --- a/xmloff/source/style/bordrhdl.cxx +++ b/xmloff/source/style/bordrhdl.cxx @@ -336,9 +336,7 @@ bool XMLBorderHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, co default: break; } - aOut.append( GetXMLToken( eStyleToken ) ); - - aOut.append( ' ' ); + aOut.append( GetXMLToken( eStyleToken ) + " " ); ::sax::Converter::convertColor( aOut, aBorderLine.Color ); } diff --git a/xmloff/source/style/chrhghdl.cxx b/xmloff/source/style/chrhghdl.cxx index 5417800c6d18..53048812726b 100644 --- a/xmloff/source/style/chrhghdl.cxx +++ b/xmloff/source/style/chrhghdl.cxx @@ -66,8 +66,7 @@ bool XMLCharHeightHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue fSize = ::std::max<float>(fSize, 1.0f); // fdo#49876: 0pt is invalid ::sax::Converter::convertDouble(aOut, static_cast<double>(fSize), true, util::MeasureUnit::POINT, util::MeasureUnit::POINT); - aOut.append( 'p'); - aOut.append( 't'); + aOut.append( "pt" ); } rStrExpValue = aOut.makeStringAndClear(); diff --git a/xmloff/source/style/fonthdl.cxx b/xmloff/source/style/fonthdl.cxx index 3d736a1f1a75..d85f425ae662 100644 --- a/xmloff/source/style/fonthdl.cxx +++ b/xmloff/source/style/fonthdl.cxx @@ -155,10 +155,7 @@ bool XMLFontFamilyNamePropHdl::exportXML( OUString& rStrExpValue, const uno::Any if( nFirst <= nLast ) { if( !sValue.isEmpty() ) - { - sValue.append( ',' ); - sValue.append( ' ' ); - } + sValue.append( ", " ); sal_Int32 nLen = nLast-nFirst+1; std::u16string_view sFamily( aStrFamilyName.subView( nFirst, nLen ) ); bool bQuote = false; diff --git a/xmloff/source/style/impastpl.cxx b/xmloff/source/style/impastpl.cxx index 948c1dde3b8e..14507b4ea69d 100644 --- a/xmloff/source/style/impastpl.cxx +++ b/xmloff/source/style/impastpl.cxx @@ -70,9 +70,7 @@ struct2string(void *data, { assert(type->eTypeClass == typelib_TypeClass_STRUCT); - OUStringBuffer result; - - result.append("{"); + OUStringBuffer result("{"); const typelib_CompoundTypeDescription *compoundType = &reinterpret_cast<const typelib_StructTypeDescription*>(type)->aBase; @@ -81,9 +79,10 @@ struct2string(void *data, { if (i > 0) result.append(":"); - result.append(compoundType->ppMemberNames[i]); - result.append("="); - result.append(data2string(static_cast<char *>(data)+compoundType->pMemberOffsets[i], + result.append( + OUString::unacquired(&compoundType->ppMemberNames[i]) + + "=" + + data2string(static_cast<char *>(data)+compoundType->pMemberOffsets[i], compoundType->ppTypeRefs[i])); } @@ -161,8 +160,7 @@ XMLAutoStylePoolProperties::XMLAutoStylePoolProperties( XMLAutoStyleFamily& rFam if (!rParentName.isEmpty()) { - aStemBuffer.append("-"); - aStemBuffer.append(rParentName); + aStemBuffer.append("-" + rParentName); } // Create a name based on the properties used @@ -173,12 +171,13 @@ XMLAutoStylePoolProperties::XMLAutoStylePoolProperties( XMLAutoStyleFamily& rFam OUString sXMLName(rFamilyData.mxMapper->getPropertySetMapper()->GetEntryXMLName(rState.mnIndex)); if (sXMLName.isEmpty()) continue; - aStemBuffer.append("-"); - aStemBuffer.append(static_cast<sal_Int32>(rFamilyData.mxMapper->getPropertySetMapper()->GetEntryNameSpace(rState.mnIndex))); - aStemBuffer.append(":"); - aStemBuffer.append(sXMLName); - aStemBuffer.append("="); - aStemBuffer.append(any2string(rState.maValue)); + aStemBuffer.append( + "-" + + OUString::number(static_cast<sal_Int32>(rFamilyData.mxMapper->getPropertySetMapper()->GetEntryNameSpace(rState.mnIndex))) + + ":" + + sXMLName + + "=" + + any2string(rState.maValue)); } #if 0 @@ -191,9 +190,8 @@ XMLAutoStylePoolProperties::XMLAutoStylePoolProperties( XMLAutoStyleFamily& rFam // create a name that hasn't been used before. The created name has not // to be added to the array, because it will never tried again - OUStringBuffer aTry( aStemBuffer ); - msName = aTry.makeStringAndClear(); + msName = aStemBuffer; bool bWarned = false; while (rFamilyData.maNameSet.find(msName) != rFamilyData.maNameSet.end()) @@ -202,10 +200,7 @@ XMLAutoStylePoolProperties::XMLAutoStylePoolProperties( XMLAutoStyleFamily& rFam SAL_WARN("xmloff", "Overlapping style name for " << msName); bWarned = true; rFamilyData.mnName++; - aTry.append( aStemBuffer ); - aTry.append( "-" ); - aTry.append( static_cast<sal_Int64>(rFamilyData.mnName) ); - msName = aTry.makeStringAndClear(); + msName = aStemBuffer + "-" + OUString::number( static_cast<sal_Int64>(rFamilyData.mnName) ); } rFamilyData.maNameSet.insert(msName); } @@ -213,13 +208,10 @@ XMLAutoStylePoolProperties::XMLAutoStylePoolProperties( XMLAutoStyleFamily& rFam { // create a name that hasn't been used before. The created name has not // to be added to the array, because it will never tried again - OUStringBuffer sBuffer( 7 ); do { rFamilyData.mnName++; - sBuffer.append( rFamilyData.maStrPrefix ); - sBuffer.append( static_cast<sal_Int64>(rFamilyData.mnName) ); - msName = sBuffer.makeStringAndClear(); + msName = rFamilyData.maStrPrefix + OUString::number( static_cast<sal_Int64>(rFamilyData.mnName) ); } while (rFamilyData.maNameSet.find(msName) != rFamilyData.maNameSet.end() || rFamilyData.maReservedNameSet.find(msName) != rFamilyData.maReservedNameSet.end()); } diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx index 7d44f43342ef..a335f79ae23a 100644 --- a/xmloff/source/style/xmlnumfe.cxx +++ b/xmloff/source/style/xmlnumfe.cxx @@ -274,15 +274,10 @@ SvXMLNumFmtExport::~SvXMLNumFmtExport() static OUString lcl_CreateStyleName( sal_Int32 nKey, sal_Int32 nPart, bool bDefPart, std::u16string_view rPrefix ) { - OUStringBuffer aFmtName(10); - aFmtName.append( rPrefix ); - aFmtName.append( nKey ); - if (!bDefPart) - { - aFmtName.append( 'P' ); - aFmtName.append( nPart ); - } - return aFmtName.makeStringAndClear(); + if (bDefPart) + return rPrefix + OUString::number(nKey); + else + return rPrefix + OUString::number(nKey) + "P" + OUString::number( nPart ); } void SvXMLNumFmtExport::AddCalendarAttr_Impl( const OUString& rCalendar ) diff --git a/xmloff/source/text/XMLTextListAutoStylePool.cxx b/xmloff/source/text/XMLTextListAutoStylePool.cxx index 1e6cfdc368d8..93a1f6794d5a 100644 --- a/xmloff/source/text/XMLTextListAutoStylePool.cxx +++ b/xmloff/source/text/XMLTextListAutoStylePool.cxx @@ -108,13 +108,10 @@ XMLTextListAutoStylePoolEntry_Impl::XMLTextListAutoStylePoolEntry_Impl( // create a name that hasn't been used before. The created name has not // to be added to the array, because it will never tried again - OUStringBuffer sBuffer( 7 ); do { rName++; - sBuffer.append( rPrefix ); - sBuffer.append( static_cast<sal_Int32>(rName) ); - sName = sBuffer.makeStringAndClear(); + sName = rPrefix + OUString::number( static_cast<sal_Int32>(rName) ); } while (rNames.find(sName) != rNames.end()); } diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx index c0259d2f9dc9..56d9642631b5 100644 --- a/xmloff/source/text/txtprhdl.cxx +++ b/xmloff/source/text/txtprhdl.cxx @@ -926,8 +926,7 @@ bool XMLTextEmphasizePropHdl_Impl::exportXML( if( nType != 0 ) { enum XMLTokenEnum ePos = bBelow ? XML_BELOW : XML_ABOVE; - aOut.append( ' ' ); - aOut.append( GetXMLToken(ePos) ); + aOut.append( " " + GetXMLToken(ePos) ); } rStrExpValue = aOut.makeStringAndClear(); } diff --git a/xmloff/source/transform/TransformerBase.cxx b/xmloff/source/transform/TransformerBase.cxx index 87a6ae23836e..e15e81d85d14 100644 --- a/xmloff/source/transform/TransformerBase.cxx +++ b/xmloff/source/transform/TransformerBase.cxx @@ -1050,9 +1050,9 @@ bool XMLTransformerBase::EncodeStyleName( OUString& rName ) const if( c > 0x000f ) aBuffer.append( static_cast< sal_Unicode >( aHexTab[ (c >> 4) & 0x0f ] ) ); - aBuffer.append( static_cast< sal_Unicode >( - aHexTab[ c & 0x0f ] ) ); - aBuffer.append( '_' ); + aBuffer.append( + OUString::number(static_cast< sal_Unicode >( aHexTab[ c & 0x0f ] ) ) + + "_" ); bEncoded = true; } }