diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-03 14:09:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-03 15:32:53 +0200 |
commit | c5a0b7af847a71fd50f713934b29305f8ce96c6b (patch) | |
tree | d7c0193bc183250c36e467f830a4327ab94dc24e /oox | |
parent | d19dbcc139d18771e5e20e82a694f1512476e41c (diff) |
loplugin:stringadd improvement for appending numbers
I was wrong, the Concat framework already optimised appending
numbers by stack-allocating small buffers, so include
them in the plugin
Change-Id: I922edbdde273c89abfe21d51c5d25dc01c97db25
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115037
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/chartexport.cxx | 12 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 14 | ||||
-rw-r--r-- | oox/source/export/vmlexport.cxx | 45 |
3 files changed, 32 insertions, 39 deletions
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 2b412d43430a..4a9a1d027bc5 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -807,13 +807,11 @@ void ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 nI } OUString sFullStream = OUStringBuffer() .appendAscii(sFullPath) - .append(nChartCount) - .append( ".xml" ) + .append(OUString::number(nChartCount) + ".xml") .makeStringAndClear(); OUString sRelativeStream = OUStringBuffer() .appendAscii(sRelativePath) - .append(nChartCount) - .append( ".xml" ) + .append(OUString::number(nChartCount) + ".xml" ) .makeStringAndClear(); FSHelperPtr pChart = CreateOutputStream( sFullStream, @@ -1028,13 +1026,11 @@ void ChartExport::exportAdditionalShapes( const Reference< css::chart::XChartDoc } OUString sFullStream = OUStringBuffer() .appendAscii(sFullPath) - .append(nDrawing) - .append(".xml") + .append(OUString::number(nDrawing) + ".xml") .makeStringAndClear(); OUString sRelativeStream = OUStringBuffer() .appendAscii(sRelativePath) - .append(nDrawing) - .append(".xml") + .append(OUString::number(nDrawing) + ".xml") .makeStringAndClear(); sax_fastparser::FSHelperPtr pDrawing = CreateOutputStream( diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 1e94c7bd68ab..bfe44e32b098 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1252,8 +1252,8 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia, Reference< XOutputStream > xOutStream = mpFB->openFragmentStream( OUStringBuffer() .appendAscii( GetComponentDir() ) - .append( "/media/image" ) - .append( static_cast<sal_Int32>(mnImageCounter) ) + .append( "/media/image" + + OUString::number(mnImageCounter) ) .appendAscii( pExtension ) .makeStringAndClear(), sMediaType ); @@ -1339,9 +1339,9 @@ void DrawingML::WriteMediaNonVisualProperties(const css::uno::Reference<css::dra // copy the video stream Reference<XOutputStream> xOutStream = mpFB->openFragmentStream(OUStringBuffer() .appendAscii(GetComponentDir()) - .append("/media/media") - .append(static_cast<sal_Int32>(mnImageCounter)) - .append(aExtension) + .append("/media/media" + + OUString::number(mnImageCounter) + + aExtension) .makeStringAndClear(), aMimeType); @@ -1352,9 +1352,7 @@ void DrawingML::WriteMediaNonVisualProperties(const css::uno::Reference<css::dra // create the relation OUString aPath = OUStringBuffer().appendAscii(GetRelationCompPrefix()) - .append("media/media") - .append(static_cast<sal_Int32>(mnImageCounter++)) - .append(aExtension) + .append("media/media" + OUString::number(mnImageCounter++) + aExtension) .makeStringAndClear(); aVideoFileRelId = mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(eMediaType), aPath); aMediaRelId = mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(Relationship::MEDIA), aPath); diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index 2539c7eac143..77d3e1686d16 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -582,7 +582,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle& sal_Int32 nX = impl_GetPointComponent( pVerticesIt, nPointSize ); sal_Int32 nY = impl_GetPointComponent( pVerticesIt, nPointSize ); if (nX >= 0 && nY >= 0 ) - aPath.append( "m" ).append( nX ).append( "," ).append( nY ); + aPath.append( "m" + OString::number( nX ) + "," + OString::number( nY ) ); break; } case msopathClientEscape: @@ -613,7 +613,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle& { sal_Int32 nX = impl_GetPointComponent( pVerticesIt, nPointSize ); sal_Int32 nY = impl_GetPointComponent( pVerticesIt, nPointSize ); - aPath.append( "l" ).append( nX ).append( "," ).append( nY ); + aPath.append( "l" + OString::number( nX ) + "," + OString::number( nY ) ); } break; case msopathCurveTo: @@ -625,9 +625,9 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle& sal_Int32 nY2 = impl_GetPointComponent( pVerticesIt, nPointSize ); sal_Int32 nX3 = impl_GetPointComponent( pVerticesIt, nPointSize ); sal_Int32 nY3 = impl_GetPointComponent( pVerticesIt, nPointSize ); - aPath.append( "c" ).append( nX1 ).append( "," ).append( nY1 ).append( "," ) - .append( nX2 ).append( "," ).append( nY2 ).append( "," ) - .append( nX3 ).append( "," ).append( nY3 ); + aPath.append( "c" + OString::number( nX1 ) + "," + OString::number( nY1 ) + "," + + OString::number( nX2 ) + "," + OString::number( nY2 ) + "," + + OString::number( nX3 ) + "," + OString::number( nY3 ) ); } break; case msopathClose: @@ -1005,7 +1005,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle& case ESCHER_Prop_Rotation: { // The higher half of the variable contains the angle. - m_ShapeStyle.append(";rotation:").append(double(opt.nPropValue >> 16)); + m_ShapeStyle.append(";rotation:" + OString::number(double(opt.nPropValue >> 16))); bAlreadyWritten[ESCHER_Prop_Rotation] = true; } break; @@ -1130,24 +1130,24 @@ void VMLExport::AddRectangleDimensions( OStringBuffer& rBuffer, const tools::Rec if(m_bInline) { - rBuffer.append( "width:" ).append( double( rRectangle.Right() - rRectangle.Left() ) / 20 ) - .append( "pt;height:" ).append( double( rRectangle.Bottom() - rRectangle.Top() ) / 20 ) - .append( "pt" ); + rBuffer.append( "width:" + OString::number( double( rRectangle.Right() - rRectangle.Left() ) / 20 ) + + "pt;height:" + OString::number( double( rRectangle.Bottom() - rRectangle.Top() ) / 20 ) + + "pt" ); } else if ( mnGroupLevel == 1 ) { - rBuffer.append( "margin-left:" ).append( double( rRectangle.Left() ) / 20 ) - .append( "pt;margin-top:" ).append( double( rRectangle.Top() ) / 20 ) - .append( "pt;width:" ).append( double( rRectangle.Right() - rRectangle.Left() ) / 20 ) - .append( "pt;height:" ).append( double( rRectangle.Bottom() - rRectangle.Top() ) / 20 ) - .append( "pt" ); + rBuffer.append( "margin-left:" + OString::number( double( rRectangle.Left() ) / 20 ) + + "pt;margin-top:" + OString::number( double( rRectangle.Top() ) / 20 ) + + "pt;width:" + OString::number( double( rRectangle.Right() - rRectangle.Left() ) / 20 ) + + "pt;height:" + OString::number( double( rRectangle.Bottom() - rRectangle.Top() ) / 20 ) + + "pt" ); } else { - rBuffer.append( "left:" ).append( rRectangle.Left() ) - .append( ";top:" ).append( rRectangle.Top() ) - .append( ";width:" ).append( rRectangle.Right() - rRectangle.Left() ) - .append( ";height:" ).append( rRectangle.Bottom() - rRectangle.Top() ); + rBuffer.append( "left:" + OString::number( rRectangle.Left() ) + + ";top:" + OString::number( rRectangle.Top() ) + + ";width:" + OString::number( rRectangle.Right() - rRectangle.Left() ) + + ";height:" + OString::number( rRectangle.Bottom() - rRectangle.Top() ) ); } AddFlipXY(); @@ -1400,12 +1400,11 @@ sal_Int32 VMLExport::StartShape() if ( nShapeElement >= 0 && !m_pShapeAttrList->hasAttribute( XML_type ) && bReferToShapeType ) { - OStringBuffer sTypeBuffer( 20 ); + OString sType; if (m_bUseHashMarkForType) - sTypeBuffer.append("#"); - m_pShapeAttrList->add( XML_type, sTypeBuffer - .append( "_x0000_t" ).append( sal_Int32( m_nShapeType ) ) - .makeStringAndClear() ); + sType = "#"; + m_pShapeAttrList->add( XML_type, sType + + "_x0000_t" + OString::number( m_nShapeType ) ); } // start of the shape |